Single column search bar, part of #550
This commit is contained in:
parent
665fdebce9
commit
ad8be058ef
2 changed files with 83 additions and 23 deletions
48
src/app.rs
48
src/app.rs
|
|
@ -3601,21 +3601,32 @@ impl Application for App {
|
|||
}
|
||||
|
||||
if let Some(term) = self.search_get() {
|
||||
elements.push(
|
||||
widget::text_input::search_input("", term)
|
||||
.width(Length::Fixed(240.0))
|
||||
.id(self.search_id.clone())
|
||||
.on_clear(Message::SearchClear)
|
||||
.on_input(Message::SearchInput)
|
||||
.into(),
|
||||
)
|
||||
if self.core.is_condensed() {
|
||||
elements.push(
|
||||
//TODO: selected state is not appearing different
|
||||
widget::button::icon(widget::icon::from_name("system-search-symbolic"))
|
||||
.on_press(Message::SearchClear)
|
||||
.padding(8)
|
||||
.selected(true)
|
||||
.into(),
|
||||
);
|
||||
} else {
|
||||
elements.push(
|
||||
widget::text_input::search_input("", term)
|
||||
.width(Length::Fixed(240.0))
|
||||
.id(self.search_id.clone())
|
||||
.on_clear(Message::SearchClear)
|
||||
.on_input(Message::SearchInput)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
elements.push(
|
||||
widget::button::icon(widget::icon::from_name("system-search-symbolic"))
|
||||
.padding(8)
|
||||
.on_press(Message::SearchActivate)
|
||||
.padding(8)
|
||||
.into(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
elements
|
||||
|
|
@ -3627,7 +3638,22 @@ impl Application for App {
|
|||
space_xxs, space_s, ..
|
||||
} = theme::active().cosmic().spacing;
|
||||
|
||||
let mut tab_column = widget::column::with_capacity(3);
|
||||
let mut tab_column = widget::column::with_capacity(4);
|
||||
|
||||
if self.core.is_condensed() {
|
||||
if let Some(term) = self.search_get() {
|
||||
tab_column = tab_column.push(
|
||||
widget::container(
|
||||
widget::text_input::search_input("", term)
|
||||
.width(Length::Fill)
|
||||
.id(self.search_id.clone())
|
||||
.on_clear(Message::SearchClear)
|
||||
.on_input(Message::SearchInput),
|
||||
)
|
||||
.padding(space_xxs),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if self.tab_model.iter().count() > 1 {
|
||||
tab_column = tab_column.push(
|
||||
|
|
|
|||
|
|
@ -896,21 +896,32 @@ impl Application for App {
|
|||
let mut elements = Vec::with_capacity(3);
|
||||
|
||||
if let Some(term) = self.search_get() {
|
||||
elements.push(
|
||||
widget::text_input::search_input("", term)
|
||||
.width(Length::Fixed(240.0))
|
||||
.id(self.search_id.clone())
|
||||
.on_clear(Message::SearchClear)
|
||||
.on_input(Message::SearchInput)
|
||||
.into(),
|
||||
)
|
||||
if self.core.is_condensed() {
|
||||
elements.push(
|
||||
//TODO: selected state is not appearing different
|
||||
widget::button::icon(widget::icon::from_name("system-search-symbolic"))
|
||||
.on_press(Message::SearchClear)
|
||||
.padding(8)
|
||||
.selected(true)
|
||||
.into(),
|
||||
);
|
||||
} else {
|
||||
elements.push(
|
||||
widget::text_input::search_input("", term)
|
||||
.width(Length::Fixed(240.0))
|
||||
.id(self.search_id.clone())
|
||||
.on_clear(Message::SearchClear)
|
||||
.on_input(Message::SearchInput)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
elements.push(
|
||||
widget::button::icon(widget::icon::from_name("system-search-symbolic"))
|
||||
.on_press(Message::SearchActivate)
|
||||
.padding(8)
|
||||
.into(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if self.flags.kind.save() {
|
||||
|
|
@ -1458,9 +1469,32 @@ impl Application for App {
|
|||
|
||||
/// Creates a view after each update.
|
||||
fn view(&self) -> Element<Message> {
|
||||
self.tab
|
||||
.view(&self.key_binds)
|
||||
.map(move |message| Message::TabMessage(message))
|
||||
let cosmic_theme::Spacing { space_xxs, .. } = theme::active().cosmic().spacing;
|
||||
|
||||
let mut col = widget::column::with_capacity(2);
|
||||
|
||||
if self.core.is_condensed() {
|
||||
if let Some(term) = self.search_get() {
|
||||
col = col.push(
|
||||
widget::container(
|
||||
widget::text_input::search_input("", term)
|
||||
.width(Length::Fill)
|
||||
.id(self.search_id.clone())
|
||||
.on_clear(Message::SearchClear)
|
||||
.on_input(Message::SearchInput),
|
||||
)
|
||||
.padding(space_xxs),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
col = col.push(
|
||||
self.tab
|
||||
.view(&self.key_binds)
|
||||
.map(move |message| Message::TabMessage(message)),
|
||||
);
|
||||
|
||||
col.into()
|
||||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue