diff --git a/cmd/calendar_demo/main.go b/cmd/calendar_demo/main.go index fb22d8d9..99311d53 100644 --- a/cmd/calendar_demo/main.go +++ b/cmd/calendar_demo/main.go @@ -23,7 +23,7 @@ func main() { // Defines which date you would like the calendar to start startingDate := time.Now() - calendar := xwidget.NewCalendar(startingDate, xwidget.CalendarSingle, d.onChanged) + calendar := xwidget.NewCalendar(startingDate, d.onChanged) selection := widget.NewRadioGroup([]string{"Single", "Multi", "Range"}, func(s string) { calendar.ClearSelection() diff --git a/widget/calendar.go b/widget/calendar.go index 8fbe4591..c3ff3685 100644 --- a/widget/calendar.go +++ b/widget/calendar.go @@ -432,10 +432,10 @@ func (c *Calendar) CreateRenderer() fyne.WidgetRenderer { } // NewCalendar creates a calendar instance -func NewCalendar(cT time.Time, selectionMode int, onChanged func([]time.Time)) *Calendar { +func NewCalendar(cT time.Time, onChanged func([]time.Time)) *Calendar { c := &Calendar{ currentTime: cT, - SelectionMode: selectionMode, + SelectionMode: CalendarSingle, OnChanged: onChanged, } diff --git a/widget/calendar_test.go b/widget/calendar_test.go index b3b932e3..146129c3 100644 --- a/widget/calendar_test.go +++ b/widget/calendar_test.go @@ -14,7 +14,7 @@ import ( func TestNewCalendar(t *testing.T) { now := time.Now() - c := NewCalendar(now, CalendarSingle, nil) + c := NewCalendar(now, nil) assert.Equal(t, now.Day(), c.currentTime.Day()) assert.Equal(t, int(now.Month()), int(c.currentTime.Month())) assert.Equal(t, now.Year(), c.currentTime.Year()) @@ -25,7 +25,7 @@ func TestNewCalendar(t *testing.T) { func TestNewCalendar_ButtonDate(t *testing.T) { date := time.Now() - c := NewCalendar(date, CalendarSingle, nil) + c := NewCalendar(date, nil) _ = test.WidgetRenderer(c) // and render endNextMonth := date.AddDate(0, 1, 0).AddDate(0, 0, -(date.Day() - 1)) @@ -39,7 +39,7 @@ func TestNewCalendar_ButtonDate(t *testing.T) { func TestNewCalendar_Next(t *testing.T) { date := time.Now() - c := NewCalendar(date, CalendarSingle, nil) + c := NewCalendar(date, nil) _ = test.WidgetRenderer(c) // and render assert.Equal(t, date.Format("January 2006"), c.monthLabel.Text) @@ -51,7 +51,7 @@ func TestNewCalendar_Next(t *testing.T) { func TestNewCalendar_Previous(t *testing.T) { date := time.Now() - c := NewCalendar(date, CalendarSingle, nil) + c := NewCalendar(date, nil) _ = test.WidgetRenderer(c) // and render assert.Equal(t, date.Format("January 2006"), c.monthLabel.Text) @@ -86,7 +86,7 @@ func TestNewCalendar_Resize(t *testing.T) { func TestNewCalendar_Single(t *testing.T) { date := time.Date(2023, time.June, 22, 13, 48, 45, 0, time.UTC) - c := NewCalendar(date, CalendarSingle, nil) + c := NewCalendar(date, nil) _ = test.WidgetRenderer(c) // and render btn := getDateButton(c.dates, 14) @@ -108,7 +108,8 @@ func TestNewCalendar_Single(t *testing.T) { func TestNewCalendar_Multi(t *testing.T) { date := time.Date(2023, time.June, 22, 13, 48, 45, 0, time.UTC) - c := NewCalendar(date, CalendarMulti, nil) + c := NewCalendar(date, nil) + c.SelectionMode = CalendarMulti _ = test.WidgetRenderer(c) // and render test.Tap(getDateButton(c.dates, 4)) @@ -150,7 +151,8 @@ func TestNewCalendar_Multi(t *testing.T) { func TestNewCalendar_Range(t *testing.T) { date := time.Date(2023, time.June, 22, 13, 48, 45, 0, time.UTC) - c := NewCalendar(date, CalendarRange, nil) + c := NewCalendar(date, nil) + c.SelectionMode = CalendarRange _ = test.WidgetRenderer(c) // and render test.Tap(getDateButton(c.dates, 5))