Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor so functions show up in order on docs #184

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/cupertino/cupertino_alert/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use iced::widget::{column, container, Text};
use iced::{alignment, executor, font, Application, Command, Element, Length, Settings, Theme};
use iced_aw::native::cupertino::cupertino_alert::{CupertinoAlert, CupertinoDialogAction};
use iced_aw::native::cupertino::cupertino_button::CupertinoButton;
use iced_aw::native::cupertino::cupertino_colours::system_red;
use iced_aw::native::cupertino::cupertino_colors::system_red;

pub fn main() -> iced::Result {
Alert::run(Settings {
Expand Down Expand Up @@ -97,7 +97,7 @@ impl Application for Alert {

let cancel_button: CupertinoButton<Message, _> = CupertinoButton::new()
.on_pressed(Some(Message::CancelEvent))
.colour(Some(system_red(1.0)))
.color(Some(system_red(1.0)))
.body(Text::new(ALLOW)
.size(24)
.width(Length::Fixed(100.0))
Expand Down
30 changes: 15 additions & 15 deletions src/native/badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ where
}
}

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

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

Expand All @@ -95,24 +95,24 @@ where
self
}

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

/// Sets the vertical alignment of the content of the [`Badge`].
/// Sets the style of the [`Badge`].
#[must_use]
pub fn align_y(mut self, alignment: Alignment) -> Self {
self.vertical_alignment = alignment;
pub fn style(mut self, style: <Renderer::Theme as StyleSheet>::Style) -> Self {
self.style = style;
self
}

/// Sets the style of the [`Badge`].
/// Sets the width of the [`Badge`].
#[must_use]
pub fn style(mut self, style: <Renderer::Theme as StyleSheet>::Style) -> Self {
self.style = style;
pub fn width(mut self, width: Length) -> Self {
self.width = width;
self
}
}
Expand Down
51 changes: 26 additions & 25 deletions src/native/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! *This API requires the following crate features to be activated: card*

use crate::graphics::icons::{Icon, ICON_FONT};

use iced_widget::{
core::{
self,
Expand All @@ -17,7 +19,6 @@ use iced_widget::{
text::LineHeight,
};

use crate::graphics::icons::{Icon, ICON_FONT};
pub use crate::style::card::{Appearance, StyleSheet};

/// The default padding of a [`Card`].
Expand Down Expand Up @@ -95,8 +96,8 @@ where
Card {
width: Length::Fill,
height: Length::Shrink,
max_width: 4_294_967_295.0,
max_height: 4_294_967_295.0,
max_width: u32::MAX as f32,
max_height: u32::MAX as f32,
padding_head: DEFAULT_PADDING,
padding_body: DEFAULT_PADDING,
padding_foot: DEFAULT_PADDING,
Expand All @@ -119,10 +120,10 @@ where
self
}

/// Sets the width of the [`Card`].
/// Sets the size of the close icon of the [`Card`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn close_size(mut self, size: f32) -> Self {
self.close_size = Some(size);
self
}

Expand All @@ -133,17 +134,27 @@ where
self
}

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

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

/// Sets the maximum height of the [`Card`].
/// Sets the message that will be produced when the close icon of the
/// [`Card`] is pressed.
///
/// Setting this enables the drawing of a close icon on the [`Card`].
#[must_use]
pub fn max_height(mut self, height: f32) -> Self {
self.max_height = height;
pub fn on_close(mut self, msg: Message) -> Self {
self.on_close = Some(msg);
self
}

Expand Down Expand Up @@ -180,27 +191,17 @@ where
self
}

/// Sets the size of the close icon of the [`Card`].
#[must_use]
pub fn close_size(mut self, size: f32) -> Self {
self.close_size = Some(size);
self
}

/// Sets the message that will be produced when the close icon of the
/// [`Card`] is pressed.
///
/// Setting this enables the drawing of a close icon on the [`Card`].
/// Sets the style of the [`Card`].
#[must_use]
pub fn on_close(mut self, msg: Message) -> Self {
self.on_close = Some(msg);
pub fn style(mut self, style: <Renderer::Theme as StyleSheet>::Style) -> Self {
self.style = style;
self
}

/// Sets the style of the [`Card`].
/// Sets the width of the [`Card`].
#[must_use]
pub fn style(mut self, style: <Renderer::Theme as StyleSheet>::Style) -> Self {
self.style = style;
pub fn width(mut self, width: Length) -> Self {
self.width = width;
self
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/native/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
//!
//! *This API requires the following crate features to be activated: `color_picker`*

use super::overlay::color_picker::{
self, ColorBarDragged, ColorPickerOverlay, ColorPickerOverlayButtons,
};

use iced_widget::{
button,
core::{
Expand All @@ -20,10 +24,6 @@ use iced_widget::{

pub use crate::style::color_picker::{Appearance, StyleSheet};

use super::overlay::color_picker::{
self, ColorBarDragged, ColorPickerOverlay, ColorPickerOverlayButtons,
};

//TODO: Remove ignore when Null is updated. Temp fix for Test runs
/// An input element for picking colors.
///
Expand Down
56 changes: 26 additions & 30 deletions src/native/cupertino/cupertino_alert.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![allow(clippy::todo)]

use crate::graphics::SF_UI_ROUNDED;
use crate::native::cupertino::cupertino_colors::secondary_system_fill;

use iced_widget::{
core::{
self,
Expand All @@ -16,14 +19,8 @@ use iced_widget::{
style::application,
text, Text,
};

use std::ops::Range;

// INTERNAL //
use crate::graphics::SF_UI_ROUNDED;
use crate::native::cupertino::cupertino_colours::secondary_system_fill;
//

/**
* `CupertinoDialogAction`
*
Expand Down Expand Up @@ -189,24 +186,17 @@ where
self
}

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

/// Sets `is_hidden` for the [`CupertinoAlert`].
/// Sets the `actions` of the [`CupertinoAlert`].
#[must_use]
pub fn is_hidden(mut self, is_hidden: bool) -> Self {
self.is_hidden = is_hidden;
pub fn actions(mut self, actions: Vec<CupertinoDialogAction<'a, Message, Renderer>>) -> Self {
self.actions = actions;
self
}

/// Sets the `title` of the [`CupertinoAlert`].
/// Sets the `backdrop` of the [`CupertinoAlert`].
#[must_use]
pub fn title(mut self, title: String) -> Self {
self.title = title;
pub fn backdrop(mut self, backdrop: Option<Message>) -> Self {
self.backdrop = backdrop;
self
}

Expand All @@ -217,17 +207,17 @@ where
self
}

/// Sets the `actions` of the [`CupertinoAlert`].
/// Sets the `height` of the [`CupertinoAlert`].
#[must_use]
pub fn actions(mut self, actions: Vec<CupertinoDialogAction<'a, Message, Renderer>>) -> Self {
self.actions = actions;
pub fn height(mut self, height: Length) -> Self {
self.height = height;
self
}

/// Sets the `backdrop` of the [`CupertinoAlert`].
/// Sets `is_hidden` for the [`CupertinoAlert`].
#[must_use]
pub fn backdrop(mut self, backdrop: Option<Message>) -> Self {
self.backdrop = backdrop;
pub fn is_hidden(mut self, is_hidden: bool) -> Self {
self.is_hidden = is_hidden;
self
}

Expand All @@ -238,10 +228,16 @@ where
self
}

// Internal //
fn _text_with_font<T>(element: T) -> Element<'a, Message, Renderer>
/// Sets the `title` of the [`CupertinoAlert`].
#[must_use]
pub fn title(mut self, title: String) -> Self {
self.title = title;
self
}

fn text_with_font<E>(element: E) -> Element<'a, Message, Renderer>
where
T: Into<Text<'a, Renderer>>,
E: Into<Text<'a, Renderer>>,
{
let as_text_element = element.into().font(SF_UI_ROUNDED);

Expand Down Expand Up @@ -482,7 +478,7 @@ where
});

let title: Element<'a, Message, Renderer> =
CupertinoAlert::<'a, Message, Renderer>::_text_with_font(
CupertinoAlert::<'a, Message, Renderer>::text_with_font(
Text::new(self.title.clone()).horizontal_alignment(Horizontal::Center),
);

Expand All @@ -497,7 +493,7 @@ where
);

let content: Element<'a, Message, Renderer> =
CupertinoAlert::<'a, Message, Renderer>::_text_with_font(
CupertinoAlert::<'a, Message, Renderer>::text_with_font(
Text::new(self.content.clone()).horizontal_alignment(Horizontal::Center),
);

Expand Down
42 changes: 20 additions & 22 deletions src/native/cupertino/cupertino_button.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use crate::graphics::SF_UI_ROUNDED;
use crate::native::cupertino::cupertino_colors::{secondary_system_fill, system_blue};

use iced_widget::{
core::{
self, event,
Expand All @@ -13,11 +16,6 @@ use iced_widget::{
text, Text,
};

// INTERNAL //
use crate::graphics::SF_UI_ROUNDED;
use crate::native::cupertino::cupertino_colours::{secondary_system_fill, system_blue};
//

/**
* `CupertinoButton`
*
Expand Down Expand Up @@ -78,20 +76,6 @@ where
Self::default()
}

/// Sets the `on_pressed` callback of the [`CupertinoButton`].
#[must_use]
pub fn on_pressed(mut self, on_pressed: Option<Message>) -> Self {
self.on_pressed = on_pressed;
self
}

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

/// Sets the `body` of the [`CupertinoButton`].
#[must_use]
pub fn body<T>(mut self, body: T) -> Self
Expand All @@ -105,10 +89,24 @@ where
self
}

/// Sets the `colour` of the [`CupertinoButton`].
/// Sets the `color` of the [`CupertinoButton`].
#[must_use]
pub fn color(mut self, color: Option<Color>) -> Self {
self.colour = color;
self
}

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

/// Sets the `on_pressed` callback of the [`CupertinoButton`].
#[must_use]
pub fn colour(mut self, colour: Option<Color>) -> Self {
self.colour = colour;
pub fn on_pressed(mut self, on_pressed: Option<Message>) -> Self {
self.on_pressed = on_pressed;
self
}
}
Expand Down
Loading