calendar: Fixed cross year name and multi month linkage click issues (#1241)
<img width="864" height="298" alt="image" src="https://github.com/user-attachments/assets/7f0a34d7-e000-4756-b1ae-0e6511679660" />
This commit is contained in:
parent
da85754b96
commit
feabb748ec
1 changed files with 10 additions and 3 deletions
|
|
@ -474,6 +474,11 @@ impl CalendarState {
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn year_name(&self, offset_month: usize) -> SharedString {
|
||||||
|
let (year, _) = self.offset_year_month(offset_month);
|
||||||
|
year.to_string().into()
|
||||||
|
}
|
||||||
|
|
||||||
fn set_view_mode(&mut self, mode: ViewMode, _: &mut Window, cx: &mut Context<Self>) {
|
fn set_view_mode(&mut self, mode: ViewMode, _: &mut Window, cx: &mut Context<Self>) {
|
||||||
self.view_mode = mode;
|
self.view_mode = mode;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
|
@ -534,7 +539,7 @@ impl Calendar {
|
||||||
let (_, month) = state.offset_year_month(offset_month);
|
let (_, month) = state.offset_year_month(offset_month);
|
||||||
let day = d.day();
|
let day = d.day();
|
||||||
let is_current_month = d.month() == month;
|
let is_current_month = d.month() == month;
|
||||||
let is_active = state.date.is_active(d) && is_current_month;
|
let is_active = state.date.is_active(d);
|
||||||
let is_in_range = state.date.is_in_range(d);
|
let is_in_range = state.date.is_in_range(d);
|
||||||
|
|
||||||
let date = *d;
|
let date = *d;
|
||||||
|
|
@ -544,8 +549,10 @@ impl Calendar {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |disabled| disabled.matched(&date));
|
.map_or(false, |disabled| disabled.matched(&date));
|
||||||
|
|
||||||
|
let date_id: SharedString = format!("{}_{}", date.format("%Y-%m-%d"), offset_month).into();
|
||||||
|
|
||||||
self.item_button(
|
self.item_button(
|
||||||
d.ordinal() as usize,
|
date_id,
|
||||||
day.to_string(),
|
day.to_string(),
|
||||||
is_active,
|
is_active,
|
||||||
is_in_range,
|
is_in_range,
|
||||||
|
|
@ -681,7 +688,7 @@ impl Calendar {
|
||||||
_ => this.gap_3(),
|
_ => this.gap_3(),
|
||||||
})
|
})
|
||||||
.child(state.month_name(n))
|
.child(state.month_name(n))
|
||||||
.child(current_year.to_string())
|
.child(state.year_name(n))
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue