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() {
|
if let Some(term) = self.search_get() {
|
||||||
elements.push(
|
if self.core.is_condensed() {
|
||||||
widget::text_input::search_input("", term)
|
elements.push(
|
||||||
.width(Length::Fixed(240.0))
|
//TODO: selected state is not appearing different
|
||||||
.id(self.search_id.clone())
|
widget::button::icon(widget::icon::from_name("system-search-symbolic"))
|
||||||
.on_clear(Message::SearchClear)
|
.on_press(Message::SearchClear)
|
||||||
.on_input(Message::SearchInput)
|
.padding(8)
|
||||||
.into(),
|
.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 {
|
} else {
|
||||||
elements.push(
|
elements.push(
|
||||||
widget::button::icon(widget::icon::from_name("system-search-symbolic"))
|
widget::button::icon(widget::icon::from_name("system-search-symbolic"))
|
||||||
.padding(8)
|
|
||||||
.on_press(Message::SearchActivate)
|
.on_press(Message::SearchActivate)
|
||||||
|
.padding(8)
|
||||||
.into(),
|
.into(),
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
elements
|
elements
|
||||||
|
|
@ -3627,7 +3638,22 @@ impl Application for App {
|
||||||
space_xxs, space_s, ..
|
space_xxs, space_s, ..
|
||||||
} = theme::active().cosmic().spacing;
|
} = 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 {
|
if self.tab_model.iter().count() > 1 {
|
||||||
tab_column = tab_column.push(
|
tab_column = tab_column.push(
|
||||||
|
|
|
||||||
|
|
@ -896,21 +896,32 @@ impl Application for App {
|
||||||
let mut elements = Vec::with_capacity(3);
|
let mut elements = Vec::with_capacity(3);
|
||||||
|
|
||||||
if let Some(term) = self.search_get() {
|
if let Some(term) = self.search_get() {
|
||||||
elements.push(
|
if self.core.is_condensed() {
|
||||||
widget::text_input::search_input("", term)
|
elements.push(
|
||||||
.width(Length::Fixed(240.0))
|
//TODO: selected state is not appearing different
|
||||||
.id(self.search_id.clone())
|
widget::button::icon(widget::icon::from_name("system-search-symbolic"))
|
||||||
.on_clear(Message::SearchClear)
|
.on_press(Message::SearchClear)
|
||||||
.on_input(Message::SearchInput)
|
.padding(8)
|
||||||
.into(),
|
.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 {
|
} else {
|
||||||
elements.push(
|
elements.push(
|
||||||
widget::button::icon(widget::icon::from_name("system-search-symbolic"))
|
widget::button::icon(widget::icon::from_name("system-search-symbolic"))
|
||||||
.on_press(Message::SearchActivate)
|
.on_press(Message::SearchActivate)
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.into(),
|
.into(),
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.flags.kind.save() {
|
if self.flags.kind.save() {
|
||||||
|
|
@ -1458,9 +1469,32 @@ impl Application for App {
|
||||||
|
|
||||||
/// Creates a view after each update.
|
/// Creates a view after each update.
|
||||||
fn view(&self) -> Element<Message> {
|
fn view(&self) -> Element<Message> {
|
||||||
self.tab
|
let cosmic_theme::Spacing { space_xxs, .. } = theme::active().cosmic().spacing;
|
||||||
.view(&self.key_binds)
|
|
||||||
.map(move |message| Message::TabMessage(message))
|
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> {
|
fn subscription(&self) -> Subscription<Message> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue