mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2026-10-23 15:41:14 +00:00
first class theming: settings_notifications_page
This commit is contained in:
parent
207c452cb5
commit
10d4e111db
4 changed files with 49 additions and 66 deletions
|
|
@ -65,7 +65,7 @@ pub fn settings_notifications_page(sniffer: &Sniffer) -> Container<Message, Rend
|
|||
.push(
|
||||
notifications_title_translation(sniffer.language)
|
||||
.font(font)
|
||||
.style(TextStyleTuple(sniffer.style, TextType::Subtitle))
|
||||
.style(TextType::Subtitle)
|
||||
.size(FONT_SIZE_SUBTITLE)
|
||||
.width(Length::Fill)
|
||||
.horizontal_alignment(Horizontal::Center),
|
||||
|
|
@ -101,12 +101,7 @@ pub fn settings_notifications_page(sniffer: &Sniffer) -> Container<Message, Rend
|
|||
)),
|
||||
)
|
||||
.direction(Direction::Vertical(ScrollbarType::properties()))
|
||||
.style(
|
||||
<ScrollbarStyleTuple as Into<iced::theme::Scrollable>>::into(ScrollbarStyleTuple(
|
||||
sniffer.style,
|
||||
ScrollbarType::Standard,
|
||||
)),
|
||||
),
|
||||
.style(ScrollbarType::Standard),
|
||||
);
|
||||
|
||||
content = content.push(volume_notification_col);
|
||||
|
|
@ -148,9 +143,7 @@ fn get_packets_notify(
|
|||
)
|
||||
.size(18)
|
||||
.font(font)
|
||||
.style(<CheckboxStyleTuple as Into<iced::theme::Checkbox>>::into(
|
||||
CheckboxStyleTuple(style, CheckboxType::Standard),
|
||||
));
|
||||
.style(CheckboxType::Standard);
|
||||
|
||||
let mut ret_val = Column::new().spacing(5).push(checkbox);
|
||||
|
||||
|
|
@ -219,9 +212,7 @@ fn get_bytes_notify(
|
|||
)
|
||||
.size(18)
|
||||
.font(font)
|
||||
.style(<CheckboxStyleTuple as Into<iced::theme::Checkbox>>::into(
|
||||
CheckboxStyleTuple(style, CheckboxType::Standard),
|
||||
));
|
||||
.style(CheckboxType::Standard);
|
||||
|
||||
let mut ret_val = Column::new().spacing(5).push(checkbox);
|
||||
|
||||
|
|
@ -281,9 +272,7 @@ fn get_favorite_notify(
|
|||
)
|
||||
.size(18)
|
||||
.font(font)
|
||||
.style(<CheckboxStyleTuple as Into<iced::theme::Checkbox>>::into(
|
||||
CheckboxStyleTuple(style, CheckboxType::Standard),
|
||||
));
|
||||
.style(CheckboxType::Standard);
|
||||
|
||||
let mut ret_val = Column::new().spacing(5).push(checkbox);
|
||||
|
||||
|
|
@ -342,9 +331,7 @@ fn input_group_packets(
|
|||
.padding([0, 0, 0, 10])
|
||||
.font(font)
|
||||
.width(Length::Fixed(100.0))
|
||||
.style(<TextInputStyleTuple as Into<iced::theme::TextInput>>::into(
|
||||
TextInputStyleTuple(style, TextInputType::Standard),
|
||||
)),
|
||||
.style(TextInputType::Standard),
|
||||
)
|
||||
.push(
|
||||
Text::new(per_second_translation(language))
|
||||
|
|
@ -387,9 +374,7 @@ fn input_group_bytes(
|
|||
.padding([0, 0, 0, 10])
|
||||
.font(font)
|
||||
.width(Length::Fixed(100.0))
|
||||
.style(<TextInputStyleTuple as Into<iced::theme::TextInput>>::into(
|
||||
TextInputStyleTuple(style, TextInputType::Standard),
|
||||
)),
|
||||
.style(TextInputType::Standard),
|
||||
)
|
||||
.push(
|
||||
Text::new(info_str)
|
||||
|
|
@ -426,9 +411,7 @@ fn volume_slider(
|
|||
Slider::new(0..=100, volume, Message::ChangeVolume)
|
||||
.step(5)
|
||||
.width(Fixed(200.0))
|
||||
.style(<SliderStyleTuple as Into<iced::theme::Slider>>::into(
|
||||
SliderStyleTuple(style, SliderType::Standard),
|
||||
)),
|
||||
.style(SliderType::Standard),
|
||||
)
|
||||
.push(horizontal_space(Length::Fixed(15.0)))
|
||||
.push(
|
||||
|
|
|
|||
|
|
@ -13,17 +13,17 @@ pub enum CheckboxType {
|
|||
#[derive(Clone)]
|
||||
pub struct CheckboxStyleTuple(pub StyleType, pub CheckboxType);
|
||||
|
||||
impl From<CheckboxStyleTuple> for iced::theme::Checkbox {
|
||||
fn from(tuple: CheckboxStyleTuple) -> Self {
|
||||
iced::theme::Checkbox::Custom(Box::new(tuple))
|
||||
}
|
||||
}
|
||||
// impl From<CheckboxStyleTuple> for iced::theme::Checkbox {
|
||||
// fn from(tuple: CheckboxStyleTuple) -> Self {
|
||||
// iced::theme::Checkbox::Custom(Box::new(tuple))
|
||||
// }
|
||||
// }
|
||||
|
||||
impl iced::widget::checkbox::StyleSheet for CheckboxStyleTuple {
|
||||
type Style = iced::Theme;
|
||||
impl iced::widget::checkbox::StyleSheet for StyleType {
|
||||
type Style = CheckboxType;
|
||||
|
||||
fn active(&self, _: &Self::Style, is_checked: bool) -> Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
let colors = get_colors(*self);
|
||||
Appearance {
|
||||
background: Background::Color(colors.buttons),
|
||||
icon_color: colors.text_body,
|
||||
|
|
@ -35,7 +35,7 @@ impl iced::widget::checkbox::StyleSheet for CheckboxStyleTuple {
|
|||
}
|
||||
|
||||
fn hovered(&self, _: &Self::Style, _is_checked: bool) -> Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
let colors = get_colors(*self);
|
||||
Appearance {
|
||||
background: Background::Color(colors.buttons),
|
||||
icon_color: colors.text_body,
|
||||
|
|
|
|||
|
|
@ -15,17 +15,17 @@ pub enum SliderType {
|
|||
#[derive(Clone)]
|
||||
pub struct SliderStyleTuple(pub StyleType, pub SliderType);
|
||||
|
||||
impl From<SliderStyleTuple> for iced::theme::Slider {
|
||||
fn from(tuple: SliderStyleTuple) -> Self {
|
||||
iced::theme::Slider::Custom(Box::new(tuple))
|
||||
}
|
||||
}
|
||||
// impl From<SliderStyleTuple> for iced::theme::Slider {
|
||||
// fn from(tuple: SliderStyleTuple) -> Self {
|
||||
// iced::theme::Slider::Custom(Box::new(tuple))
|
||||
// }
|
||||
// }
|
||||
|
||||
impl iced::widget::slider::StyleSheet for SliderStyleTuple {
|
||||
type Style = iced::Theme;
|
||||
impl iced::widget::slider::StyleSheet for StyleType {
|
||||
type Style = SliderType;
|
||||
|
||||
fn active(&self, _: &Self::Style) -> Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
let colors = get_colors(*self);
|
||||
Appearance {
|
||||
rail: Rail {
|
||||
colors: (mix_colors(colors.secondary, colors.buttons), colors.buttons),
|
||||
|
|
@ -42,7 +42,7 @@ impl iced::widget::slider::StyleSheet for SliderStyleTuple {
|
|||
}
|
||||
|
||||
fn hovered(&self, _: &Self::Style) -> Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
let colors = get_colors(*self);
|
||||
Appearance {
|
||||
rail: Rail {
|
||||
colors: (colors.secondary, colors.buttons),
|
||||
|
|
@ -59,7 +59,7 @@ impl iced::widget::slider::StyleSheet for SliderStyleTuple {
|
|||
}
|
||||
|
||||
fn dragging(&self, _: &Self::Style) -> Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
let colors = get_colors(*self);
|
||||
Appearance {
|
||||
rail: Rail {
|
||||
colors: (colors.secondary, colors.buttons),
|
||||
|
|
|
|||
|
|
@ -16,28 +16,28 @@ pub enum TextInputType {
|
|||
#[derive(Clone)]
|
||||
pub struct TextInputStyleTuple(pub StyleType, pub TextInputType);
|
||||
|
||||
impl From<TextInputStyleTuple> for iced::theme::TextInput {
|
||||
fn from(tuple: TextInputStyleTuple) -> Self {
|
||||
iced::theme::TextInput::Custom(Box::new(tuple))
|
||||
}
|
||||
}
|
||||
// impl From<TextInputStyleTuple> for iced::theme::TextInput {
|
||||
// fn from(tuple: TextInputStyleTuple) -> Self {
|
||||
// iced::theme::TextInput::Custom(Box::new(tuple))
|
||||
// }
|
||||
// }
|
||||
|
||||
impl iced::widget::text_input::StyleSheet for TextInputStyleTuple {
|
||||
type Style = iced::Theme;
|
||||
impl iced::widget::text_input::StyleSheet for StyleType {
|
||||
type Style = TextInputType;
|
||||
|
||||
fn active(&self, _: &Self::Style) -> iced::widget::text_input::Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
fn active(&self, style: &Self::Style) -> iced::widget::text_input::Appearance {
|
||||
let colors = get_colors(*self);
|
||||
Appearance {
|
||||
background: Background::Color(match self.1 {
|
||||
background: Background::Color(match style {
|
||||
TextInputType::Badge => Color::TRANSPARENT,
|
||||
TextInputType::Standard => colors.buttons,
|
||||
}),
|
||||
border_radius: 0.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: match self.1 {
|
||||
border_color: match style {
|
||||
TextInputType::Badge => Color::TRANSPARENT,
|
||||
TextInputType::Standard => Color {
|
||||
a: get_alpha_round_borders(self.0),
|
||||
a: get_alpha_round_borders(*self),
|
||||
..colors.buttons
|
||||
},
|
||||
},
|
||||
|
|
@ -45,8 +45,8 @@ impl iced::widget::text_input::StyleSheet for TextInputStyleTuple {
|
|||
}
|
||||
}
|
||||
|
||||
fn focused(&self, _: &Self::Style) -> iced::widget::text_input::Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
fn focused(&self, style: &Self::Style) -> iced::widget::text_input::Appearance {
|
||||
let colors = get_colors(*self);
|
||||
Appearance {
|
||||
background: Background::Color(colors.primary),
|
||||
border_radius: 0.0.into(),
|
||||
|
|
@ -57,15 +57,15 @@ impl iced::widget::text_input::StyleSheet for TextInputStyleTuple {
|
|||
}
|
||||
|
||||
fn placeholder_color(&self, _: &Self::Style) -> Color {
|
||||
let color = get_colors(self.0).text_body;
|
||||
let color = get_colors(*self).text_body;
|
||||
Color {
|
||||
a: if color.eq(&Color::BLACK) { 0.7 } else { 0.2 },
|
||||
a: if self.is_nightly() { 0.2 } else { 0.7 },
|
||||
..color
|
||||
}
|
||||
}
|
||||
|
||||
fn value_color(&self, _: &Self::Style) -> Color {
|
||||
get_colors(self.0).text_body
|
||||
get_colors(*self).text_body
|
||||
}
|
||||
|
||||
fn disabled_color(&self, _style: &Self::Style) -> Color {
|
||||
|
|
@ -73,17 +73,17 @@ impl iced::widget::text_input::StyleSheet for TextInputStyleTuple {
|
|||
}
|
||||
|
||||
fn selection_color(&self, _: &Self::Style) -> Color {
|
||||
let color = get_colors(self.0).text_body;
|
||||
let color = get_colors(*self).text_body;
|
||||
Color {
|
||||
a: if color.eq(&Color::BLACK) { 0.4 } else { 0.05 },
|
||||
a: if self.is_nightly() { 0.05 } else { 0.4 },
|
||||
..color
|
||||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, _: &Self::Style) -> iced::widget::text_input::Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
fn hovered(&self, style: &Self::Style) -> iced::widget::text_input::Appearance {
|
||||
let colors = get_colors(*self);
|
||||
Appearance {
|
||||
background: Background::Color(match self.1 {
|
||||
background: Background::Color(match style {
|
||||
TextInputType::Badge => Color::TRANSPARENT,
|
||||
TextInputType::Standard => colors.buttons,
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue