feat(calendar): add first day of week parameter
This commit is contained in:
parent
d4a87bd394
commit
b7aed0e4d6
1 changed files with 4 additions and 1 deletions
|
|
@ -15,12 +15,14 @@ pub fn calendar<M>(
|
||||||
on_select: impl Fn(NaiveDate) -> M + 'static,
|
on_select: impl Fn(NaiveDate) -> M + 'static,
|
||||||
on_prev: impl Fn() -> M + 'static,
|
on_prev: impl Fn() -> M + 'static,
|
||||||
on_next: impl Fn() -> M + 'static,
|
on_next: impl Fn() -> M + 'static,
|
||||||
|
first_day_of_week: Weekday
|
||||||
) -> Calendar<M> {
|
) -> Calendar<M> {
|
||||||
Calendar {
|
Calendar {
|
||||||
model,
|
model,
|
||||||
on_select: Box::new(on_select),
|
on_select: Box::new(on_select),
|
||||||
on_prev: Box::new(on_prev),
|
on_prev: Box::new(on_prev),
|
||||||
on_next: Box::new(on_next),
|
on_next: Box::new(on_next),
|
||||||
|
first_day_of_week
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,6 +107,7 @@ pub struct Calendar<'a, M> {
|
||||||
on_select: Box<dyn Fn(NaiveDate) -> M>,
|
on_select: Box<dyn Fn(NaiveDate) -> M>,
|
||||||
on_prev: Box<dyn Fn() -> M>,
|
on_prev: Box<dyn Fn() -> M>,
|
||||||
on_next: Box<dyn Fn() -> M>,
|
on_next: Box<dyn Fn() -> M>,
|
||||||
|
first_day_of_week: Weekday
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message> From<Calendar<'a, Message>> for crate::Element<'a, Message>
|
impl<'a, Message> From<Calendar<'a, Message>> for crate::Element<'a, Message>
|
||||||
|
|
@ -130,7 +133,7 @@ where
|
||||||
let mut calendar_grid: Grid<'_, Message> =
|
let mut calendar_grid: Grid<'_, Message> =
|
||||||
grid().padding([0, 12].into()).width(Length::Fill);
|
grid().padding([0, 12].into()).width(Length::Fill);
|
||||||
|
|
||||||
let mut first_day_of_week = Weekday::Sun; // TODO: Configurable
|
let mut first_day_of_week = this.first_day_of_week;
|
||||||
for _ in 0..7 {
|
for _ in 0..7 {
|
||||||
calendar_grid = calendar_grid.push(
|
calendar_grid = calendar_grid.push(
|
||||||
text(first_day_of_week.to_string())
|
text(first_day_of_week.to_string())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue