Skip to content

Commit

Permalink
file date filter prototyping
Browse files Browse the repository at this point in the history
  • Loading branch information
B0ney committed Nov 8, 2023
1 parent cbf89f8 commit 45f264d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ impl Application for XMODITS {
}
View::Filters => column![
self.custom_filters.view_file_size().map(Message::CustomFilter),
self.custom_filters.view_file_date().map(Message::CustomFilter),
self.custom_filters.view_file_name().map(Message::CustomFilter),
bottom_left_buttons,
]
Expand Down
7 changes: 7 additions & 0 deletions src/screen/config/custom_filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
mod file_name;
mod file_size;
mod file_date;
mod regex;

use data::config::filters::{Filter, Name, Size};
Expand Down Expand Up @@ -35,6 +36,7 @@ impl Filters {
pub enum Message {
FileSize(file_size::Message),
FileName(file_name::Message),
FileDate(file_date::Message),
}

#[derive(Default, Debug)]
Expand All @@ -48,6 +50,7 @@ impl CustomFilters {
match msg {
Message::FileSize(filesize) => file_size::update(&mut self.filesize, filesize),
Message::FileName(filename) => file_name::update(&mut self.filename, filename),
Message::FileDate(filedate) => file_date::update(filedate),
}
}
pub fn view_file_size(&self) -> Element<Message> {
Expand All @@ -57,5 +60,9 @@ impl CustomFilters {
pub fn view_file_name(&self) -> Element<Message> {
file_name::view(&self.filename).map(Message::FileName)
}

pub fn view_file_date(&self) -> Element<Message> {
file_date::view().map(Message::FileDate)
}
}

42 changes: 42 additions & 0 deletions src/screen/config/custom_filters/file_date.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use std::fmt::Display;

use crate::theme::TextInputStyle;
use crate::widget::helpers::control;
use crate::widget::Element;
use data::config::filters::{size::Modifier, Size};
use iced::widget::{button, checkbox, column, horizontal_rule, pick_list, row, slider, text, text_input};

#[derive(Debug, Clone, Copy)]
pub enum Message {
DatePicker,
}

pub fn update(msg: Message) {}

pub fn view<'a>() -> Element<'a, Message> {
// IDEA: buttons could have a tooltip showing the date&time in more detail
// TODO: buttons must bring up date and time picker, should be an overlay
control(
"File Date",
column![
pick_list(["Created", "Modified"].as_slice(), Some("Created"), |_| {
Message::DatePicker
}),
horizontal_rule(1),
row![
row!["From:", button("2005-12-12").on_press(Message::DatePicker)]
.align_items(iced::Alignment::Center)
.spacing(4),
row!["To:", button("2009-12-12").on_press(Message::DatePicker)]
.align_items(iced::Alignment::Center)
.spacing(4)
]
.align_items(iced::Alignment::Center)

.spacing(4),

]
.spacing(4),
)
.into()
}

0 comments on commit 45f264d

Please sign in to comment.