Added ability to disable highlighting of weekend days in DatePickerPopup. (#4151)
I added a handfull of lines to allow for the red highlight on weekends in `DatePickerPopup` to be disabled. I tried to follow the rules, but I've never done any kind of PR before, and I'm also not sure if this is at all the kind of thing that is wanted at the moment. If it is not, I'm happy to just have this removed. Just a tiny little addition I would find useful. --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
parent
861a1b6225
commit
365d035b20
|
|
@ -17,6 +17,7 @@ pub struct DatePickerButton<'a> {
|
|||
calendar_week: bool,
|
||||
show_icon: bool,
|
||||
format: String,
|
||||
highlight_weekends: bool,
|
||||
}
|
||||
|
||||
impl<'a> DatePickerButton<'a> {
|
||||
|
|
@ -30,6 +31,7 @@ impl<'a> DatePickerButton<'a> {
|
|||
calendar_week: true,
|
||||
show_icon: true,
|
||||
format: "%Y-%m-%d".to_owned(),
|
||||
highlight_weekends: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +85,13 @@ impl<'a> DatePickerButton<'a> {
|
|||
self.format = format.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Highlight weekend days. (Default: true)
|
||||
#[inline]
|
||||
pub fn highlight_weekends(mut self, highlight_weekends: bool) -> Self {
|
||||
self.highlight_weekends = highlight_weekends;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Widget for DatePickerButton<'a> {
|
||||
|
|
@ -148,6 +157,7 @@ impl<'a> Widget for DatePickerButton<'a> {
|
|||
arrows: self.arrows,
|
||||
calendar: self.calendar,
|
||||
calendar_week: self.calendar_week,
|
||||
highlight_weekends: self.highlight_weekends,
|
||||
}
|
||||
.draw(ui)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ pub(crate) struct DatePickerPopup<'a> {
|
|||
pub arrows: bool,
|
||||
pub calendar: bool,
|
||||
pub calendar_week: bool,
|
||||
pub highlight_weekends: bool,
|
||||
}
|
||||
|
||||
impl<'a> DatePickerPopup<'a> {
|
||||
|
|
@ -304,8 +305,9 @@ impl<'a> DatePickerPopup<'a> {
|
|||
&& popup_state.day == day.day()
|
||||
{
|
||||
ui.visuals().selection.bg_fill
|
||||
} else if day.weekday() == Weekday::Sat
|
||||
|| day.weekday() == Weekday::Sun
|
||||
} else if (day.weekday() == Weekday::Sat
|
||||
|| day.weekday() == Weekday::Sun)
|
||||
&& self.highlight_weekends
|
||||
{
|
||||
if ui.visuals().dark_mode {
|
||||
Color32::DARK_RED
|
||||
|
|
|
|||
Loading…
Reference in New Issue