Skip to content

Commit

Permalink
Removed 'Save' in SettingsBrowser
Browse files Browse the repository at this point in the history
The 'Save' button in the SettingsBrowser was removed. Due to the changed
save behaviour it is not neccessary.
  • Loading branch information
seternate committed May 24, 2024
1 parent 062a700 commit f4a37ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
21 changes: 16 additions & 5 deletions pkg/widget/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func (widget *Form) SetSubmitText(text string) {
widget.Refresh()
}

func (widget *Form) HideSubmit() {
widget.submit.Hide()
widget.Refresh()
}

func (widget *Form) SetCancelText(text string) {
widget.cancel.SetText(text)
widget.Refresh()
Expand Down Expand Up @@ -91,11 +96,17 @@ func (renderer *formRenderer) Layout(size fyne.Size) {
item.Resize(fyne.NewSize(size.Width-2*theme.InnerPadding(), item.MinSize().Height))
lastposition = item.Position().Y + item.Size().Height
}
buttonSize := fyne.NewSize(fyne.Max(renderer.widget.cancel.MinSize().Width, renderer.widget.submit.MinSize().Width), renderer.widget.submit.MinSize().Height)
renderer.widget.submit.Resize(buttonSize)
renderer.widget.submit.Move(fyne.NewPos(size.Width-theme.InnerPadding()-buttonSize.Width, size.Height-theme.InnerPadding()-buttonSize.Height))
renderer.widget.cancel.Resize(buttonSize)
renderer.widget.cancel.Move(fyne.NewPos(renderer.widget.submit.Position().X-theme.InnerPadding()-buttonSize.Width, renderer.widget.submit.Position().Y))
if renderer.widget.submit.Hidden {
buttonSize := fyne.NewSize(renderer.widget.cancel.MinSize().Width, renderer.widget.cancel.MinSize().Height)
renderer.widget.cancel.Resize(buttonSize)
renderer.widget.cancel.Move(fyne.NewPos(size.Width-theme.InnerPadding()-buttonSize.Width, size.Height-theme.InnerPadding()-buttonSize.Height))
} else {
buttonSize := fyne.NewSize(fyne.Max(renderer.widget.cancel.MinSize().Width, renderer.widget.submit.MinSize().Width), renderer.widget.submit.MinSize().Height)
renderer.widget.submit.Resize(buttonSize)
renderer.widget.submit.Move(fyne.NewPos(size.Width-theme.InnerPadding()-buttonSize.Width, size.Height-theme.InnerPadding()-buttonSize.Height))
renderer.widget.cancel.Resize(buttonSize)
renderer.widget.cancel.Move(fyne.NewPos(renderer.widget.submit.Position().X-theme.InnerPadding()-buttonSize.Width, renderer.widget.submit.Position().Y))
}
}

func (renderer *formRenderer) MinSize() fyne.Size {
Expand Down
10 changes: 1 addition & 9 deletions pkg/widget/settingbrowser.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,8 @@ func NewSettingsBrowser(controller *controller.Controller, window fyne.Window) (
}
settingsbrowser.form.AppendItem(NewFormItem("Username", settingsbrowser.username))

settingsbrowser.form.SetSubmitText("Save")
settingsbrowser.form.HideSubmit()
settingsbrowser.form.SetCancelText("Reset")
settingsbrowser.form.OnSubmit = func() {
controller.Settings.SetServerURL(settingsbrowser.serverurl.Text)
controller.Settings.SetGameDirectory(settingsbrowser.gamedirectory.Text)
controller.Settings.SetUsername(settingsbrowser.username.Text)
if controller.Settings.Save() == nil {
controller.Status.Info("Settings successfully saved", 3*time.Second)
}
}
settingsbrowser.form.OnCancel = func() {
settingsbrowser.ResetData()
controller.Status.Info("Settings resetted", 3*time.Second)
Expand Down

0 comments on commit f4a37ec

Please sign in to comment.