Skip to content

Commit

Permalink
fixed formating and linting!
Browse files Browse the repository at this point in the history
bq-wrongway committed Oct 23, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 67e88cc commit d16d12e
Showing 4 changed files with 18 additions and 15 deletions.
11 changes: 5 additions & 6 deletions examples/segmented_button/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use iced::widget::container;
use iced::widget::{column, row, text};
use iced::{Element, Length, Sandbox, Settings};
use iced::widget::{column, row, text};

use iced_aw::native::segmented_button;
use segmented_button::SegmentedButton;
@@ -43,23 +43,22 @@ impl Sandbox for Example {
fn view(&self) -> Element<Message> {
// let selected_radio = Some(Choice::A);

// i added a row just to demonstrate that anything can be used as a child,
//in this case instead of A B C you might add icons
// i added a row just to demonstrate that anything can be used as a child,
//in this case instead of A B C you might add icons
let a = SegmentedButton::new(
row!(text("HEAVY "), "A"),
Choice::A,
self.selected_radio,
Message::RadioSelected,
);



let b = SegmentedButton::new(
row!(text("MEDIUM "), "B"),
Choice::B,
self.selected_radio,
Message::RadioSelected,
);

let c = SegmentedButton::new(
row!(text("LIGHT "), "C"),
Choice::C,
4 changes: 2 additions & 2 deletions src/native/mod.rs
Original file line number Diff line number Diff line change
@@ -126,9 +126,9 @@ pub mod context_menu;
pub type ContextMenu<'a, Overlay, Message, Renderer> =
context_menu::ContextMenu<'a, Overlay, Message, Renderer>;


#[cfg(feature = "segmented_button")]
pub mod segmented_button;
#[cfg(feature = "segmented_button")]
/// A badge for color highlighting small information.
pub type SegmentedButton<'a, Message, Renderer> = segmented_button::SegmentedButton<'a, Message, Renderer>;
pub type SegmentedButton<'a, Message, Renderer> =
segmented_button::SegmentedButton<'a, Message, Renderer>;
16 changes: 10 additions & 6 deletions src/native/segmented_button.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Create choices using segnmented_button buttons.
//! Create choices using `segnmented_button` buttons.
use iced_widget::core::{
event,
event,
layout::{Limits, Node},
mouse::{self, Cursor},
renderer, touch,
@@ -11,9 +11,7 @@ use iced_widget::core::{

pub use crate::style::segmented_button::StyleSheet;



/// A segmented_button for color highlighting small information.
/// A `segnmented_button` for color highlighting small information.
///
/// # Example
/// ```ignore
@@ -79,36 +77,42 @@ where
}

/// Sets the padding of the [`SegmentedButton`](SegmentedButton).
#[must_use]
pub fn padding(mut self, units: Padding) -> Self {
self.padding = units;
self
}

/// Sets the width of the [`SegmentedButton`](SegmentedButton).
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
self
}

/// Sets the height of the [`SegmentedButton`](SegmentedButton).
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
self
}

/// Sets the horizontal alignment of the content of the [`SegmentedButton`](SegmentedButton).
#[must_use]
pub fn align_x(mut self, alignment: Alignment) -> Self {
self.horizontal_alignment = alignment;
self
}

/// Sets the vertical alignment of the content of the [`SegmentedButton`](SegmentedButton).
#[must_use]
pub fn align_y(mut self, alignment: Alignment) -> Self {
self.vertical_alignment = alignment;
self
}

/// Sets the style of the [`SegmentedButton`](SegmentedButton).
#[must_use]
pub fn style(mut self, style: <Renderer::Theme as StyleSheet>::Style) -> Self {
self.style = style;
self
@@ -138,7 +142,7 @@ where
}

fn layout(&self, renderer: &Renderer, limits: &Limits) -> Node {
let padding = self.padding.into();
let padding = self.padding;
let limits = limits
.loose()
.width(self.width)
2 changes: 1 addition & 1 deletion src/style/segmented_button.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Use a segmented_button as an alternative to radio button.
//! Use a `segmented_button` as an alternative to radio button.
use iced_widget::{
core::{Background, Color},

0 comments on commit d16d12e

Please sign in to comment.