Skip to content

Commit

Permalink
fix time picker year chooser updating structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoreilly committed Jul 22, 2024
1 parent dbe78bd commit 89033f6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/timepicker.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,19 @@ func (dp *DatePicker) Init() {
w.Styler(arrowStyle)
})
tree.AddChild(w, func(w *Chooser) {
yr := dp.Time.Year()
var yrs []ChooserItem
// we go 100 in each direction from the current year
for i := yr - 100; i <= yr+100; i++ {
yrs = append(yrs, ChooserItem{Value: i})
}
w.SetItems(yrs...)
w.Updater(func() {
yr := dp.Time.Year()
var yrs []ChooserItem
// we go 100 in each direction from the current year
for i := yr - 100; i <= yr+100; i++ {
yrs = append(yrs, ChooserItem{Value: i})
}
w.SetItems(yrs...)
w.SetCurrentValue(yr)
})
w.OnChange(func(e events.Event) {
// we are centered at current year with 100 in each direction
nyr := w.CurrentIndex + yr - 100
nyr := w.CurrentIndex + dp.Time.Year() - 100
// set our year
dp.setTime(dp.Time.AddDate(nyr-dp.Time.Year(), 0, 0))
})
Expand Down

0 comments on commit 89033f6

Please sign in to comment.