Add button to toggle view
This commit is contained in:
parent
40ee305eb2
commit
6acac60526
2 changed files with 18 additions and 0 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -482,6 +482,16 @@ impl Application for App {
|
|||
let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing;
|
||||
|
||||
let active = self.tab_model.active();
|
||||
let current_view = if let Some(tab) = self.tab_model.data::<Tab>(active) {
|
||||
tab.view
|
||||
} else {
|
||||
tab::View::Grid
|
||||
};
|
||||
let (view, view_icon) = match current_view {
|
||||
tab::View::Grid => (tab::View::List, "view-list-symbolic"),
|
||||
tab::View::List => (tab::View::Grid, "view-grid-symbolic"),
|
||||
};
|
||||
|
||||
vec![row![
|
||||
widget::button(widget::icon::from_name("list-add-symbolic").size(16).icon())
|
||||
.on_press(Message::TabNew)
|
||||
|
|
@ -494,6 +504,10 @@ impl Application for App {
|
|||
widget::button(widget::icon::from_name("go-up-symbolic").size(16).icon())
|
||||
.on_press(Message::TabMessage(active, tab::Message::Parent))
|
||||
.padding(space_xxs)
|
||||
.style(style::Button::Icon),
|
||||
widget::button(widget::icon::from_name(view_icon).size(16).icon())
|
||||
.on_press(Message::TabMessage(active, tab::Message::View(view)))
|
||||
.padding(space_xxs)
|
||||
.style(style::Button::Icon)
|
||||
]
|
||||
.align_items(Alignment::Center)
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ pub enum Message {
|
|||
Click(Option<usize>),
|
||||
Home,
|
||||
Parent,
|
||||
View(View),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
@ -397,6 +398,9 @@ impl Tab {
|
|||
cd = Some(parent.to_owned());
|
||||
}
|
||||
}
|
||||
Message::View(view) => {
|
||||
self.view = view;
|
||||
}
|
||||
}
|
||||
if let Some(path) = cd {
|
||||
self.path = path;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue