Skip to content

Commit

Permalink
Added Setting Page (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
vikkio88 authored May 21, 2023
1 parent 9eef4b7 commit 05a45c6
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func NewApp() App {
c.List: func() *fyne.Container { return ui.GetPasswordListView(&ctx) },
c.Details: func() *fyne.Container { return ui.GetPasswordDetailsView(&ctx) },
c.AddUpdate: func() *fyne.Container { return ui.GetPasswordAddUpdateView(&ctx) },
c.Settings: func() *fyne.Container { return ui.GetSettingsView(&ctx) },
c.About: func() *fyne.Container { return ui.GetAboutView(&ctx) },
},
}
Expand Down
4 changes: 4 additions & 0 deletions context/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const (
list string = "LIST"
details string = "DETAILS"
addUpdate string = "ADDUPDATE"
settings string = "SETTINGS"
about string = "ABOUT"
quit string = "QUIT"

Expand All @@ -24,6 +25,7 @@ const (
List
Details
AddUpdate
Settings
About
Quit
)
Expand All @@ -35,6 +37,7 @@ func getMapping() map[AppRoute]string {
List: list,
Details: details,
AddUpdate: addUpdate,
Settings: settings,
About: about,
Quit: quit,
}
Expand All @@ -47,6 +50,7 @@ func getReverseMapping() map[string]AppRoute {
list: List,
details: Details,
addUpdate: AddUpdate,
settings: Settings,
about: About,
quit: Quit,
}
Expand Down
15 changes: 3 additions & 12 deletions ui/password_list_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,9 @@ func GetPasswordListView(ctx *c.AppContext) *fyne.Container {
}
}

removeAllBtn := widget.NewButtonWithIcon("", theme.DeleteIcon(), func() {
dialog.ShowConfirm("Confirmation", "Are you sure you want to remove all the saved password?",
func(b bool) {
if !b {
return
}
settingsBtn := widget.NewButtonWithIcon("", theme.SettingsIcon(), func() {
ctx.NavigateTo(c.Settings)

ctx.Db.Drop()
ctx.NavigateTo(c.Setup)
},
ctx.GetWindow(),
)
})
aboutPageBtn := widget.NewButtonWithIcon("", theme.InfoIcon(), func() {
ctx.NavigateTo(c.About)
Expand All @@ -73,8 +64,8 @@ func GetPasswordListView(ctx *c.AppContext) *fyne.Container {
nil,
nil,
container.NewHBox(
settingsBtn,
aboutPageBtn,
removeAllBtn,
),
addNewBtn,
),
Expand Down
63 changes: 63 additions & 0 deletions ui/settings_view.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package ui

import (
c "muscurdig/context"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)

func GetSettingsView(ctx *c.AppContext) *fyne.Container {
deleteAllBtn := widget.NewButtonWithIcon("", theme.DeleteIcon(), func() {
dialog.ShowConfirm("Confirmation", "Are you sure you want to remove all the saved password?",
func(b bool) {
if !b {
return
}

ctx.Db.Drop()
ctx.NavigateTo(c.Setup)
},
ctx.GetWindow(),
)
})

exportPassBtn := widget.NewButtonWithIcon("", theme.DownloadIcon(), func() {
dialog.ShowInformation("Coming soon!", "This featute is coming soon", ctx.GetWindow())
})

importPassBtn := widget.NewButtonWithIcon("", theme.UploadIcon(), func() {
dialog.ShowInformation("Coming soon!", "This featute is coming soon", ctx.GetWindow())
})

return container.NewMax(
container.NewBorder(
centered(h1("Settings")),
leftAligned(
backButton(ctx, c.List),
),
nil,
nil,
container.NewCenter(
container.NewVBox(
container.NewGridWithColumns(2,
widget.NewLabel("Delete all data"),
deleteAllBtn,
),
container.NewGridWithColumns(2,
widget.NewLabel("Export data"),
exportPassBtn,
),
container.NewGridWithColumns(2,
widget.NewLabel("Import data"),
importPassBtn,
),
),
),
),
)

}

0 comments on commit 05a45c6

Please sign in to comment.