refactor!(widget): rename view_switcher to tab_bar to match Figma docs
This commit is contained in:
parent
bfc84c4759
commit
ff9438c5ba
5 changed files with 14 additions and 16 deletions
|
|
@ -11,7 +11,7 @@ use iced_core::{border::Radius, Background};
|
||||||
pub enum SegmentedButton {
|
pub enum SegmentedButton {
|
||||||
/// A tabbed widget for switching between views in an interface.
|
/// A tabbed widget for switching between views in an interface.
|
||||||
#[default]
|
#[default]
|
||||||
ViewSwitcher,
|
TabBar,
|
||||||
/// A widget for multiple choice selection.
|
/// A widget for multiple choice selection.
|
||||||
Control,
|
Control,
|
||||||
/// Or implement any custom theme of your liking.
|
/// Or implement any custom theme of your liking.
|
||||||
|
|
@ -24,9 +24,9 @@ impl StyleSheet for Theme {
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
fn horizontal(&self, style: &Self::Style) -> Appearance {
|
fn horizontal(&self, style: &Self::Style) -> Appearance {
|
||||||
match style {
|
match style {
|
||||||
SegmentedButton::ViewSwitcher => {
|
SegmentedButton::TabBar => {
|
||||||
let cosmic = self.cosmic();
|
let cosmic = self.cosmic();
|
||||||
let active = horizontal::view_switcher_active(cosmic);
|
let active = horizontal::tab_bar_active(cosmic);
|
||||||
Appearance {
|
Appearance {
|
||||||
border_radius: cosmic.corner_radii.radius_0.into(),
|
border_radius: cosmic.corner_radii.radius_0.into(),
|
||||||
inactive: ItemStatusAppearance {
|
inactive: ItemStatusAppearance {
|
||||||
|
|
@ -95,8 +95,8 @@ impl StyleSheet for Theme {
|
||||||
let rad_m = cosmic.corner_radii.radius_m;
|
let rad_m = cosmic.corner_radii.radius_m;
|
||||||
let rad_0 = cosmic.corner_radii.radius_0;
|
let rad_0 = cosmic.corner_radii.radius_0;
|
||||||
match style {
|
match style {
|
||||||
SegmentedButton::ViewSwitcher => {
|
SegmentedButton::TabBar => {
|
||||||
let active = vertical::view_switcher_active(cosmic);
|
let active = vertical::tab_bar_active(cosmic);
|
||||||
Appearance {
|
Appearance {
|
||||||
border_radius: cosmic.corner_radii.radius_0.into(),
|
border_radius: cosmic.corner_radii.radius_0.into(),
|
||||||
inactive: ItemStatusAppearance {
|
inactive: ItemStatusAppearance {
|
||||||
|
|
@ -170,7 +170,7 @@ mod horizontal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_switcher_active(cosmic: &cosmic_theme::Theme) -> ItemStatusAppearance {
|
pub fn tab_bar_active(cosmic: &cosmic_theme::Theme) -> ItemStatusAppearance {
|
||||||
let mut neutral_5 = cosmic.palette.neutral_5;
|
let mut neutral_5 = cosmic.palette.neutral_5;
|
||||||
neutral_5.alpha = 0.2;
|
neutral_5.alpha = 0.2;
|
||||||
let rad_s = cosmic.corner_radii.radius_s;
|
let rad_s = cosmic.corner_radii.radius_s;
|
||||||
|
|
@ -246,7 +246,7 @@ mod vertical {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_switcher_active(cosmic: &cosmic_theme::Theme) -> ItemStatusAppearance {
|
pub fn tab_bar_active(cosmic: &cosmic_theme::Theme) -> ItemStatusAppearance {
|
||||||
let mut neutral_5 = cosmic.palette.neutral_5;
|
let mut neutral_5 = cosmic.palette.neutral_5;
|
||||||
neutral_5.alpha = 0.2;
|
neutral_5.alpha = 0.2;
|
||||||
ItemStatusAppearance {
|
ItemStatusAppearance {
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,8 @@ pub mod settings;
|
||||||
pub mod spin_button;
|
pub mod spin_button;
|
||||||
pub use spin_button::{spin_button, SpinButton};
|
pub use spin_button::{spin_button, SpinButton};
|
||||||
|
|
||||||
|
pub mod tab_bar;
|
||||||
|
|
||||||
pub mod text;
|
pub mod text;
|
||||||
pub use text::{text, Text};
|
pub use text::{text, Text};
|
||||||
|
|
||||||
|
|
@ -206,9 +208,5 @@ pub mod tooltip {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod view_switcher;
|
|
||||||
pub use view_switcher::horizontal as horiontal_view_switcher;
|
|
||||||
pub use view_switcher::vertical as vertical_view_switcher;
|
|
||||||
|
|
||||||
pub mod warning;
|
pub mod warning;
|
||||||
pub use warning::*;
|
pub use warning::*;
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ where
|
||||||
.button_spacing(space_xxs)
|
.button_spacing(space_xxs)
|
||||||
.spacing(space_xxs)
|
.spacing(space_xxs)
|
||||||
.on_activate(on_activate)
|
.on_activate(on_activate)
|
||||||
.style(crate::theme::SegmentedButton::ViewSwitcher)
|
.style(crate::theme::SegmentedButton::TabBar)
|
||||||
.apply(scrollable)
|
.apply(scrollable)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
.apply(container)
|
.apply(container)
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ where
|
||||||
/ num as f32;
|
/ num as f32;
|
||||||
}
|
}
|
||||||
|
|
||||||
let segmented_selection = matches!(self.style, crate::theme::SegmentedButton::Control);
|
let segmetned_control = matches!(self.style, crate::theme::SegmentedButton::Control);
|
||||||
|
|
||||||
Box::new(
|
Box::new(
|
||||||
self.model
|
self.model
|
||||||
|
|
@ -91,7 +91,7 @@ where
|
||||||
let button_bounds = ItemBounds::Button(key, layout_bounds);
|
let button_bounds = ItemBounds::Button(key, layout_bounds);
|
||||||
let mut divider = None;
|
let mut divider = None;
|
||||||
|
|
||||||
if self.dividers && segmented_selection && nth + 1 < num {
|
if self.dividers && segmetned_control && nth + 1 < num {
|
||||||
divider = Some(ItemBounds::Divider(Rectangle {
|
divider = Some(ItemBounds::Divider(Rectangle {
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
..bounds
|
..bounds
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ where
|
||||||
segmented_button::horizontal(model)
|
segmented_button::horizontal(model)
|
||||||
.button_height(44)
|
.button_height(44)
|
||||||
.button_padding([space_s, space_xs, space_s, space_xs])
|
.button_padding([space_s, space_xs, space_s, space_xs])
|
||||||
.style(crate::theme::SegmentedButton::ViewSwitcher)
|
.style(crate::theme::SegmentedButton::TabBar)
|
||||||
.font_active(Some(crate::font::FONT_SEMIBOLD))
|
.font_active(Some(crate::font::FONT_SEMIBOLD))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,6 +49,6 @@ where
|
||||||
SegmentedButton::new(model)
|
SegmentedButton::new(model)
|
||||||
.button_height(44)
|
.button_height(44)
|
||||||
.button_padding([space_s, space_xs, space_s, space_xs])
|
.button_padding([space_s, space_xs, space_s, space_xs])
|
||||||
.style(crate::theme::SegmentedButton::ViewSwitcher)
|
.style(crate::theme::SegmentedButton::TabBar)
|
||||||
.font_active(Some(crate::font::FONT_SEMIBOLD))
|
.font_active(Some(crate::font::FONT_SEMIBOLD))
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue