Added text color and font options for native radio and checkbox (#831)

* text color and font options to radio

* code formatting

* code formatting

* code formatting

* Added text_color for native checkbox

* Removed clone as color has Copy

* Fix code formatting with `cargo fmt`

Co-authored-by: Héctor Ramón <hector@lich.io>
This commit is contained in:
zdevwu 2021-05-17 14:22:55 +01:00 committed by GitHub
parent 0ce6a2db21
commit 40d21d2365
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 8 deletions

View file

@ -8,8 +8,8 @@ use crate::row;
use crate::text;
use crate::touch;
use crate::{
Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length,
Point, Rectangle, Row, Text, VerticalAlignment, Widget,
Align, Clipboard, Color, Element, Hasher, HorizontalAlignment, Layout,
Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget,
};
/// A box that can be checked.
@ -39,6 +39,7 @@ pub struct Checkbox<Message, Renderer: self::Renderer + text::Renderer> {
spacing: u16,
text_size: Option<u16>,
font: Renderer::Font,
text_color: Option<Color>,
style: Renderer::Style,
}
@ -66,6 +67,7 @@ impl<Message, Renderer: self::Renderer + text::Renderer>
spacing: Renderer::DEFAULT_SPACING,
text_size: None,
font: Renderer::Font::default(),
text_color: None,
style: Renderer::Style::default(),
}
}
@ -102,6 +104,12 @@ impl<Message, Renderer: self::Renderer + text::Renderer>
self
}
/// Sets the text color of the [`Checkbox`] button.
pub fn text_color(mut self, color: Color) -> Self {
self.text_color = Some(color);
self
}
/// Sets the style of the [`Checkbox`].
pub fn style(mut self, style: impl Into<Renderer::Style>) -> Self {
self.style = style.into();
@ -193,7 +201,7 @@ where
&self.label,
self.text_size.unwrap_or(renderer.default_size()),
self.font,
None,
self.text_color,
HorizontalAlignment::Left,
VerticalAlignment::Center,
);