fix(entry): entry bg alpha typo & border radius fixes

This commit is contained in:
Ashley Wulber 2023-03-02 16:51:32 -05:00 committed by Ashley Wulber
parent ff78cfe1ca
commit b510b89b98
3 changed files with 30 additions and 12 deletions

View file

@ -176,7 +176,7 @@ impl Window {
}
#[allow(dead_code)]
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Debug)]
pub enum Message {
Bluetooth(bluetooth::Message),
Close,

View file

@ -1,7 +1,7 @@
use apply::Apply;
use cosmic::{
cosmic_theme,
iced::widget::{checkbox, pick_list, progress_bar, radio, row, slider, text},
iced::widget::{checkbox, pick_list, progress_bar, radio, row, slider, text, text_input},
iced::{Alignment, Length},
theme::{self, Button as ButtonTheme, Theme},
widget::{
@ -11,6 +11,7 @@ use cosmic::{
Element,
};
use fraction::{Decimal, ToPrimitive};
use once_cell::sync::Lazy;
use super::{Page, Window};
@ -28,8 +29,9 @@ pub enum MultiOption {
OptionD,
OptionE,
}
static INPUT_ID: Lazy<text_input::Id> = Lazy::new(text_input::Id::unique);
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Debug)]
pub enum Message {
ButtonPressed,
CheckboxToggled(bool),
@ -46,6 +48,7 @@ pub enum Message {
ToggleWarning,
TogglerToggled(bool),
ViewSwitcher(segmented_button::Entity),
InputChanged(String),
}
pub enum Output {
@ -67,6 +70,7 @@ pub struct State {
pub spin_button: spin_button::Model<i32>,
pub toggler_value: bool,
pub view_switcher: segmented_button::SingleSelectModel,
pub entry_value: String,
}
impl Default for State {
@ -104,6 +108,7 @@ impl Default for State {
.insert(|b| b.text("Segmented Button").data(DemoView::TabB))
.insert(|b| b.text("Tab C").data(DemoView::TabC))
.build(),
entry_value: String::new(),
}
}
}
@ -136,6 +141,9 @@ impl State {
cosmic::settings::set_default_icon_theme(theme);
}
}
Message::InputChanged(s) => {
self.entry_value = s;
}
}
None
@ -390,6 +398,16 @@ impl State {
.padding(8)
.width(Length::Fill)
.into(),
text_input(
"Type to search apps or type “?” for more options...",
&self.entry_value,
Message::InputChanged,
)
// .on_submit(Message::Activate(None))
.padding(8)
.size(20)
.id(INPUT_ID.clone())
.into(),
])
.into()
}

View file

@ -988,17 +988,17 @@ impl text_input::StyleSheet for Theme {
fn active(&self, style: &Self::Style) -> text_input::Appearance {
let palette = self.cosmic();
let mut bg = palette.palette.neutral_7;
bg.alpha = 0.75;
bg.alpha = 0.25;
match style {
TextInput::Default => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 2.0,
border_radius: 8.0,
border_width: 1.0,
border_color: self.current_container().component.divider.into(),
},
TextInput::Search => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 0.0,
border_radius: 24.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
@ -1008,18 +1008,18 @@ impl text_input::StyleSheet for Theme {
fn hovered(&self, style: &Self::Style) -> text_input::Appearance {
let palette = self.cosmic();
let mut bg = palette.palette.neutral_7;
bg.alpha = 0.75;
bg.alpha = 0.25;
match style {
TextInput::Default => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 2.0,
border_radius: 8.0,
border_width: 1.0,
border_color: palette.accent.base.into(),
},
TextInput::Search => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 0.0,
border_radius: 24.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
@ -1029,18 +1029,18 @@ impl text_input::StyleSheet for Theme {
fn focused(&self, style: &Self::Style) -> text_input::Appearance {
let palette = self.cosmic();
let mut bg = palette.palette.neutral_7;
bg.alpha = 0.75;
bg.alpha = 0.25;
match style {
TextInput::Default => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 2.0,
border_radius: 8.0,
border_width: 1.0,
border_color: palette.accent.base.into(),
},
TextInput::Search => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 0.0,
border_radius: 24.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},