wip: refactor

This commit is contained in:
2024-12-17 18:51:06 +07:00
parent 377f169420
commit 0682612d42
27 changed files with 486 additions and 259 deletions

View File

@@ -11,6 +11,7 @@ pub enum IconName {
ArrowLeft,
ArrowRight,
ArrowUp,
ArrowUpCircle,
Asterisk,
Bell,
BookOpen,
@@ -73,6 +74,7 @@ pub enum IconName {
ThumbsDown,
ThumbsUp,
TriangleAlert,
Upload,
WindowClose,
WindowMaximize,
WindowMinimize,
@@ -87,6 +89,7 @@ impl IconName {
IconName::ArrowLeft => "icons/arrow-left.svg",
IconName::ArrowRight => "icons/arrow-right.svg",
IconName::ArrowUp => "icons/arrow-up.svg",
IconName::ArrowUpCircle => "icons/arrow-up-circle.svg",
IconName::Asterisk => "icons/asterisk.svg",
IconName::Bell => "icons/bell.svg",
IconName::BookOpen => "icons/book-open.svg",
@@ -149,6 +152,7 @@ impl IconName {
IconName::ThumbsDown => "icons/thumbs-down.svg",
IconName::ThumbsUp => "icons/thumbs-up.svg",
IconName::TriangleAlert => "icons/triangle-alert.svg",
IconName::Upload => "icons/upload.svg",
IconName::WindowClose => "icons/window-close.svg",
IconName::WindowMaximize => "icons/window-maximize.svg",
IconName::WindowMinimize => "icons/window-minimize.svg",

View File

@@ -178,6 +178,7 @@ pub struct TextInput {
pub(super) appearance: bool,
pub(super) cleanable: bool,
pub(super) size: Size,
pub(super) text_size: Size,
pub(super) rows: usize,
pattern: Option<regex::Regex>,
validate: Validate,
@@ -215,6 +216,7 @@ impl TextInput {
prefix: None,
suffix: None,
size: Size::Medium,
text_size: Size::Medium,
pattern: None,
validate: None,
rows: 2,
@@ -333,6 +335,12 @@ impl TextInput {
cx.notify();
}
/// Set the Input size
pub fn text_size(mut self, size: Size) -> Self {
self.text_size = size;
self
}
/// Set the appearance of the input field.
pub fn appearance(mut self, appearance: bool) -> Self {
self.appearance = appearance;
@@ -1204,6 +1212,7 @@ impl Render for TextInput {
.line_height(LINE_HEIGHT)
.input_py(self.size)
.input_h(self.size)
.input_text_size(self.text_size)
.cursor_text()
.when(self.multi_line, |this| {
this.on_action(cx.listener(Self::up))

View File

@@ -215,17 +215,22 @@ pub trait Sizable: Sized {
/// Or a `Pixels` to set a custom size: `px(30.)`
fn with_size(self, size: impl Into<Size>) -> Self;
/// Set to Size::Small
fn small(self) -> Self {
self.with_size(Size::Small)
}
/// Set to Size::XSmall
fn xsmall(self) -> Self {
self.with_size(Size::XSmall)
}
/// Set to Size::Small
fn small(self) -> Self {
self.with_size(Size::Small)
}
/// Set to Size::Medium
fn medium(self) -> Self {
self.with_size(Size::Medium)
}
/// Set to Size::Large
fn large(self) -> Self {
self.with_size(Size::Large)
}

View File

@@ -527,8 +527,8 @@ impl From<ThemeColor> for Theme {
} else {
"FreeMono".into()
},
radius: 4.0,
shadow: true,
radius: 5.0,
shadow: false,
scrollbar_show: ScrollbarShow::default(),
colors,
}