Skip to content

Commit 2796041

Browse files
committed
feat: refactored scanner into files
1 parent fc9b357 commit 2796041

8 files changed

Lines changed: 1060 additions & 819 deletions

File tree

src/gui/app.rs

Lines changed: 196 additions & 118 deletions
Large diffs are not rendered by default.

src/gui/theme.rs

Lines changed: 108 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
use iced::widget::{button, container};
22
use iced::{Background, Border, Color, Theme};
33

4-
pub const BG_COLOR: Color = Color::from_rgb(0.08, 0.08, 0.10);
5-
pub const SURFACE_COLOR: Color = Color::from_rgb(0.10, 0.10, 0.16);
6-
pub const CARD_COLOR: Color = Color::from_rgb(0.15, 0.15, 0.22);
7-
pub const BORDER_COLOR: Color = Color::from_rgb(0.25, 0.25, 0.30);
8-
pub const ACCENT_COLOR: Color = Color::from_rgb(0.3, 0.7, 1.0);
9-
pub const ACCENT_COLOR_MUTED: Color = Color::from_rgb(0.15, 0.35, 0.5);
10-
pub const ACCENT_MUTED: Color = Color::from_rgb(0.2, 0.5, 0.8);
11-
pub const SUCCESS_COLOR: Color = Color::from_rgb(0.2, 0.8, 0.4);
12-
pub const WARNING_COLOR: Color = Color::from_rgb(1.0, 0.8, 0.2);
13-
pub const ERROR_COLOR: Color = Color::from_rgb(1.0, 0.3, 0.3);
14-
pub const ERROR_COLOR_MUTED: Color = Color::from_rgb(0.8, 0.4, 0.4);
15-
pub const TEXT_PRIMARY: Color = Color::from_rgb(0.95, 0.95, 0.95);
16-
pub const TEXT_SECONDARY: Color = Color::from_rgb(0.7, 0.7, 0.7);
4+
pub const BG_COLOR: Color = Color::from_rgb(0.06, 0.06, 0.08);
5+
pub const SURFACE_COLOR: Color = Color::from_rgb(0.09, 0.10, 0.14);
6+
pub const CARD_COLOR: Color = Color::from_rgb(0.12, 0.13, 0.18);
7+
pub const BORDER_COLOR: Color = Color::from_rgb(0.20, 0.22, 0.28);
8+
pub const BORDER_HIGHLIGHT: Color = Color::from_rgb(0.30, 0.35, 0.45);
9+
10+
pub const ACCENT_COLOR: Color = Color::from_rgb(0.25, 0.75, 1.0);
11+
pub const ACCENT_COLOR_MUTED: Color = Color::from_rgb(0.18, 0.40, 0.58);
12+
pub const ACCENT_HOVER: Color = Color::from_rgb(0.30, 0.82, 1.0);
13+
14+
pub const WARNING_COLOR: Color = Color::from_rgb(1.0, 0.75, 0.15);
15+
pub const ERROR_COLOR: Color = Color::from_rgb(1.0, 0.35, 0.40);
16+
pub const ERROR_COLOR_MUTED: Color = Color::from_rgb(0.65, 0.25, 0.30);
17+
18+
pub const TEXT_PRIMARY: Color = Color::from_rgb(0.96, 0.97, 0.98);
19+
pub const TEXT_SECONDARY: Color = Color::from_rgb(0.65, 0.68, 0.72);
1720

1821
pub const DANGER_CRITICAL: Color = ERROR_COLOR;
1922
pub const DANGER_CRITICAL_MUTED: Color = ERROR_COLOR_MUTED;
20-
pub const DANGER_HIGH: Color = WARNING_COLOR;
21-
pub const DANGER_MEDIUM: Color = Color::from_rgb(1.0, 1.0, 0.3);
22-
pub const DANGER_LOW: Color = SUCCESS_COLOR;
23+
pub const DANGER_HIGH: Color = Color::from_rgb(1.0, 0.60, 0.20);
24+
pub const DANGER_MEDIUM: Color = WARNING_COLOR;
25+
pub const DANGER_LOW: Color = Color::from_rgb(0.40, 0.90, 0.60);
2326

2427
pub fn container_style(_theme: &Theme) -> container::Style {
2528
container::Style {
@@ -34,62 +37,111 @@ pub fn card_style(_theme: &Theme) -> container::Style {
3437
background: Some(CARD_COLOR.into()),
3538
border: iced::Border {
3639
color: BORDER_COLOR,
37-
width: 1.0,
38-
radius: 8.0.into(),
40+
width: 1.5,
41+
radius: 12.0.into(),
42+
},
43+
shadow: iced::Shadow {
44+
color: Color::from_rgba(0.0, 0.0, 0.0, 0.3),
45+
offset: iced::Vector::new(0.0, 4.0),
46+
blur_radius: 12.0,
3947
},
4048
..Default::default()
4149
}
4250
}
4351

44-
pub fn button_style(_theme: &Theme, _status: button::Status) -> button::Style {
52+
pub fn button_style(_theme: &Theme, status: button::Status) -> button::Style {
53+
let (bg_color, border_color) = match status {
54+
button::Status::Hovered => (Color::from_rgb(0.12, 0.14, 0.20), BORDER_HIGHLIGHT),
55+
button::Status::Pressed => (Color::from_rgb(0.08, 0.09, 0.13), ACCENT_COLOR),
56+
_ => (SURFACE_COLOR, BORDER_COLOR),
57+
};
58+
4559
button::Style {
46-
background: Some(SURFACE_COLOR.into()),
60+
background: Some(bg_color.into()),
4761
text_color: TEXT_PRIMARY,
4862
border: iced::Border {
49-
color: BORDER_COLOR,
50-
width: 1.0,
51-
radius: 5.0.into(),
63+
color: border_color,
64+
width: 1.5,
65+
radius: 8.0.into(),
5266
},
53-
..button::secondary(_theme, _status)
67+
shadow: iced::Shadow {
68+
color: Color::from_rgba(0.0, 0.0, 0.0, 0.2),
69+
offset: iced::Vector::new(0.0, 2.0),
70+
blur_radius: 4.0,
71+
},
72+
..button::secondary(_theme, status)
5473
}
5574
}
5675

57-
pub fn primary_button_style(_theme: &Theme, _status: button::Status) -> button::Style {
76+
pub fn primary_button_style(_theme: &Theme, status: button::Status) -> button::Style {
77+
let (bg_color, shadow_offset) = match status {
78+
button::Status::Hovered => (ACCENT_HOVER, 3.0),
79+
button::Status::Pressed => (ACCENT_COLOR_MUTED, 1.0),
80+
_ => (ACCENT_COLOR, 2.0),
81+
};
82+
5883
button::Style {
59-
background: Some(ACCENT_COLOR_MUTED.into()),
60-
text_color: TEXT_PRIMARY,
84+
background: Some(bg_color.into()),
85+
text_color: Color::WHITE,
6186
border: iced::Border {
62-
color: ACCENT_MUTED,
63-
width: 2.0,
64-
radius: 6.0.into(),
87+
color: Color::from_rgba(0.0, 0.0, 0.0, 0.0),
88+
width: 0.0,
89+
radius: 10.0.into(),
6590
},
66-
..button::primary(_theme, _status)
91+
shadow: iced::Shadow {
92+
color: Color::from_rgba(0.1, 0.4, 0.7, 0.4),
93+
offset: iced::Vector::new(0.0, shadow_offset),
94+
blur_radius: 8.0,
95+
},
96+
..button::primary(_theme, status)
6797
}
6898
}
6999

70-
pub fn cancel_button_style(_theme: &Theme, _status: button::Status) -> button::Style {
100+
pub fn cancel_button_style(_theme: &Theme, status: button::Status) -> button::Style {
101+
let (bg_color, shadow_offset) = match status {
102+
button::Status::Hovered => (Color::from_rgb(1.0, 0.40, 0.45), 3.0),
103+
button::Status::Pressed => (DANGER_CRITICAL_MUTED, 1.0),
104+
_ => (ERROR_COLOR, 2.0),
105+
};
106+
71107
button::Style {
72-
background: Some(DANGER_CRITICAL_MUTED.into()),
73-
text_color: TEXT_PRIMARY,
108+
background: Some(bg_color.into()),
109+
text_color: Color::WHITE,
74110
border: iced::Border {
75-
color: Color::from_rgb(1.0, 0.3, 0.3),
76-
width: 2.0,
77-
radius: 6.0.into(),
111+
color: Color::from_rgba(0.0, 0.0, 0.0, 0.0),
112+
width: 0.0,
113+
radius: 10.0.into(),
78114
},
79-
..button::primary(_theme, _status)
115+
shadow: iced::Shadow {
116+
color: Color::from_rgba(0.8, 0.2, 0.2, 0.4),
117+
offset: iced::Vector::new(0.0, shadow_offset),
118+
blur_radius: 8.0,
119+
},
120+
..button::primary(_theme, status)
80121
}
81122
}
82123

83-
pub fn result_button_style(_theme: &Theme, _status: button::Status) -> button::Style {
124+
pub fn result_button_style(_theme: &Theme, status: button::Status) -> button::Style {
125+
let (bg_color, border_width) = match status {
126+
button::Status::Hovered => (Color::from_rgb(0.14, 0.15, 0.21), 1.5),
127+
button::Status::Pressed => (Color::from_rgb(0.10, 0.11, 0.16), 1.5),
128+
_ => (SURFACE_COLOR, 1.0),
129+
};
130+
84131
button::Style {
85-
background: Some(SURFACE_COLOR.into()),
132+
background: Some(bg_color.into()),
86133
text_color: TEXT_PRIMARY,
87134
border: iced::Border {
88-
color: Color::from_rgb(0.3, 0.3, 0.4),
89-
width: 1.0,
90-
radius: 5.0.into(),
135+
color: BORDER_COLOR,
136+
width: border_width,
137+
radius: 8.0.into(),
138+
},
139+
shadow: iced::Shadow {
140+
color: Color::from_rgba(0.0, 0.0, 0.0, 0.15),
141+
offset: iced::Vector::new(0.0, 2.0),
142+
blur_radius: 6.0,
91143
},
92-
..button::secondary(_theme, _status)
144+
..button::secondary(_theme, status)
93145
}
94146
}
95147

@@ -137,3 +189,15 @@ pub fn danger_color(score: u8) -> Color {
137189
_ => DANGER_LOW,
138190
}
139191
}
192+
193+
pub fn progress_bar_style(_theme: &Theme) -> iced::widget::progress_bar::Style {
194+
iced::widget::progress_bar::Style {
195+
background: Background::Color(SURFACE_COLOR),
196+
bar: Background::Color(ACCENT_COLOR),
197+
border: Border {
198+
radius: 8.0.into(),
199+
width: 0.0,
200+
color: Color::TRANSPARENT,
201+
},
202+
}
203+
}

src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(clippy::collapsible_else_if)]
2-
31
mod config;
42
mod detection;
53
mod errors;
@@ -8,6 +6,7 @@ mod parser;
86
mod scanner;
97
mod types;
108
mod utils;
9+
1110
#[cfg(all(feature = "cli", not(feature = "gui")))]
1211
use colored::Colorize;
1312

@@ -29,7 +28,7 @@ use std::path::{Path, PathBuf};
2928
use walkdir::WalkDir;
3029

3130
#[cfg(all(feature = "cli", not(feature = "gui")))]
32-
use crate::scanner::CollapseScanner;
31+
use crate::scanner::scan::CollapseScanner;
3332
#[cfg(all(feature = "cli", not(feature = "gui")))]
3433
use crate::types::{DetectionMode, FindingType, ScanResult, ScannerOptions};
3534

0 commit comments

Comments
 (0)