Skip to content

Commit

Permalink
fix: unable to submit preferences (fyne bug) (#26)
Browse files Browse the repository at this point in the history
* refactor: rename SetOnClose to SetOnClosed

* fix: disable validation
  • Loading branch information
tomsquest authored Sep 24, 2024
1 parent 2395fa8 commit 101d2f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions ui/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type Settings interface {
Show()
SetOnSubmit(callback func())
SetOnClose(callback func())
SetOnClosed(callback func())
}

// type validation
Expand Down Expand Up @@ -49,7 +49,7 @@ func (s *settings) SetOnSubmit(callback func()) {
(*s.form).Refresh()
}

func (s *settings) SetOnClose(callback func()) {
func (s *settings) SetOnClosed(callback func()) {
(*s.win).SetOnClosed(callback)
}

Expand Down Expand Up @@ -91,10 +91,13 @@ func makeForm() *widget.Form {
return form
}

func newIntegerFormItem(bind binding.Int, entryText string, hintText string, validator fyne.StringValidator) *widget.FormItem {
func newIntegerFormItem(bind binding.Int, entryText string, hintText string, _ fyne.StringValidator) *widget.FormItem {
value, _ := bind.Get()
entry := newIntegerEntryWithData(binding.IntToString(bind))
entry.Validator = validator

// Validation disabled until https://github.com/fyne-io/fyne/issues/3961 is fixed (Fyne 2.5.1)
//entry.Validator = validator

formItem := widget.NewFormItem(entryText, entry)
formItem.HintText = fmt.Sprintf(hintText, value)
return formItem
Expand Down
2 changes: 1 addition & 1 deletion ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func MakeClassicLayout(myPomodoro *pomodoro.Pomodoro) fyne.CanvasObject {
timer.Text = formatDuration(myPomodoro.RemainingTime)
timer.Refresh()
})
settings.SetOnClose(func() {
settings.SetOnClosed(func() {
settingsButton.Enable()
})

Expand Down

0 comments on commit 101d2f0

Please sign in to comment.