Add sort direction option to config
This commit is contained in:
parent
7c8bcbe998
commit
1b69c3bf5c
1 changed files with 33 additions and 17 deletions
50
src/app.rs
50
src/app.rs
|
|
@ -231,6 +231,7 @@ pub struct App {
|
||||||
config: Config,
|
config: Config,
|
||||||
app_themes: Vec<String>,
|
app_themes: Vec<String>,
|
||||||
sort_by_names: Vec<String>,
|
sort_by_names: Vec<String>,
|
||||||
|
sort_direction: Vec<String>,
|
||||||
context_page: ContextPage,
|
context_page: ContextPage,
|
||||||
dialog_pages: VecDeque<DialogPage>,
|
dialog_pages: VecDeque<DialogPage>,
|
||||||
dialog_text_input: widget::Id,
|
dialog_text_input: widget::Id,
|
||||||
|
|
@ -530,23 +531,37 @@ impl App {
|
||||||
let tab_config = self.config.tab;
|
let tab_config = self.config.tab;
|
||||||
let sort_by_selected = tab_config.sort_name as _;
|
let sort_by_selected = tab_config.sort_name as _;
|
||||||
|
|
||||||
widget::settings::item::builder(fl!("sorting-name"))
|
widget::settings::item::builder(fl!("sorting-name")).control(widget::dropdown(
|
||||||
.description(format!("{}", tab_config.sort_name))
|
&self.sort_by_names,
|
||||||
.control(widget::dropdown(
|
Some(sort_by_selected),
|
||||||
&self.sort_by_names,
|
move |index| {
|
||||||
Some(sort_by_selected),
|
Message::TabConfig(TabConfig {
|
||||||
move |index| {
|
sort_name: match index {
|
||||||
Message::TabConfig(TabConfig {
|
0 => HeadingOptions::Name,
|
||||||
sort_name: match index {
|
1 => HeadingOptions::Modified,
|
||||||
0 => HeadingOptions::Name,
|
2 => HeadingOptions::Size,
|
||||||
1 => HeadingOptions::Modified,
|
_ => HeadingOptions::Name,
|
||||||
2 => HeadingOptions::Size,
|
},
|
||||||
_ => HeadingOptions::Name,
|
..tab_config
|
||||||
},
|
})
|
||||||
..tab_config
|
},
|
||||||
})
|
))
|
||||||
},
|
})
|
||||||
))
|
.add({
|
||||||
|
let tab_config = self.config.tab;
|
||||||
|
// Ascending is true. Descending is false
|
||||||
|
let direction = tab_config.sort_direction.into();
|
||||||
|
|
||||||
|
widget::settings::item::builder(fl!("direction")).control(widget::dropdown(
|
||||||
|
&self.sort_direction,
|
||||||
|
Some(direction),
|
||||||
|
move |index| {
|
||||||
|
Message::TabConfig(TabConfig {
|
||||||
|
sort_direction: index == 1,
|
||||||
|
..tab_config
|
||||||
|
})
|
||||||
|
},
|
||||||
|
))
|
||||||
})
|
})
|
||||||
.into(),
|
.into(),
|
||||||
widget::settings::view_section(fl!("settings-tab"))
|
widget::settings::view_section(fl!("settings-tab"))
|
||||||
|
|
@ -637,6 +652,7 @@ impl Application for App {
|
||||||
config: flags.config,
|
config: flags.config,
|
||||||
app_themes,
|
app_themes,
|
||||||
sort_by_names: HeadingOptions::names(),
|
sort_by_names: HeadingOptions::names(),
|
||||||
|
sort_direction: vec![fl!("descending"), fl!("ascending")],
|
||||||
context_page: ContextPage::Settings,
|
context_page: ContextPage::Settings,
|
||||||
dialog_pages: VecDeque::new(),
|
dialog_pages: VecDeque::new(),
|
||||||
dialog_text_input: widget::Id::unique(),
|
dialog_text_input: widget::Id::unique(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue