improv(segmented-button): Express vertical/horizontal variants as a state machine
It's difficult to make iterative developments when there's two nearly-identical types that need to be kept synchronized to any change. Rust gives us traits so we should use them instead of duplicating code. This made it easier to make styling and layout improvements to both instances of the segmented button.
This commit is contained in:
parent
b704eea531
commit
357de5e9be
9 changed files with 633 additions and 726 deletions
|
|
@ -48,15 +48,10 @@ mod horizontal;
|
|||
mod state;
|
||||
mod style;
|
||||
mod vertical;
|
||||
mod widget;
|
||||
|
||||
pub use self::horizontal::{horizontal_segmented_button, HorizontalSegmentedButton};
|
||||
pub use self::horizontal::{horizontal_segmented_button, Horizontal, HorizontalSegmentedButton};
|
||||
pub use self::state::{ButtonContent, Key, SecondaryState, SharedWidgetState, State};
|
||||
pub use self::style::{Appearance, ButtonAppearance, StyleSheet};
|
||||
pub use self::vertical::{vertical_segmented_button, VerticalSegmentedButton};
|
||||
|
||||
/// State that is maintained by each individual widget.
|
||||
#[derive(Default)]
|
||||
struct UniqueWidgetState {
|
||||
/// The ID of the button that is being hovered. Defaults to null.
|
||||
hovered: Key,
|
||||
}
|
||||
pub use self::style::{Appearance, ButtonAppearance, ButtonStatusAppearance, StyleSheet};
|
||||
pub use self::vertical::{vertical_segmented_button, Vertical, VerticalSegmentedButton};
|
||||
pub use self::widget::{SegmentedButton, SegmentedVariant};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue