Skip to content

Commit

Permalink
rebase pr and clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sirmorrison committed Jul 21, 2021
1 parent c2c6e6d commit e2a12c1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
24 changes: 12 additions & 12 deletions ui/page/settings_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ func NewSettingsPage(l *load.Load) *SettingsPage {
walletInfo: l.WL.Info,
wal: l.WL.Wallet,

isDarkModeOn: common.theme.Switch(),
spendUnconfirmed: common.theme.Switch(),
startupPassword: common.theme.Switch(),
beepNewBlocks: common.theme.Switch(),
connectToPeer: common.theme.Switch(),
userAgent: common.theme.Switch(),
isDarkModeOn: l.Theme.Switch(),
spendUnconfirmed: l.Theme.Switch(),
startupPassword: l.Theme.Switch(),
beepNewBlocks: l.Theme.Switch(),
connectToPeer: l.Theme.Switch(),
userAgent: l.Theme.Switch(),
chevronRightIcon: chevronRightIcon,

errorReceiver: make(chan error),
Expand Down Expand Up @@ -329,7 +329,7 @@ func (pg *SettingsPage) subSection(gtx layout.Context, title string, body layout
})
}

func (pg *settingsPage) subSectionSwitch(gtx layout.Context, title string, option *decredmaterial.Switch) layout.Dimensions {
func (pg *SettingsPage) subSectionSwitch(gtx layout.Context, title string, option *decredmaterial.Switch) layout.Dimensions {
return pg.subSection(gtx, title, option.Layout)
}

Expand Down Expand Up @@ -377,7 +377,7 @@ func (pg *SettingsPage) Handle() {

if pg.isDarkModeOn.Changed() {
pg.wal.SaveConfigValueForKey("isDarkModeOn", pg.isDarkModeOn.IsChecked())
common.refreshTheme()
pg.RefreshTheme()
}

if pg.spendUnconfirmed.Changed() {
Expand Down Expand Up @@ -545,26 +545,26 @@ func (pg *SettingsPage) updateSettingOptions() {
pg.startupPassword.SetChecked(false)
pg.isStartupPassword = false
if isPassword {
pg.startupPassword.SetChecked(true)
pg.startupPassword.SetChecked(isPassword)
pg.isStartupPassword = true
}

isDarkModeOn := pg.wal.ReadBoolConfigValueForKey("isDarkModeOn")
pg.isDarkModeOn.SetChecked(false)
if isDarkModeOn {
pg.isDarkModeOn.SetChecked(true)
pg.isDarkModeOn.SetChecked(isDarkModeOn)
}

isSpendUnconfirmed := pg.wal.ReadBoolConfigValueForKey(dcrlibwallet.SpendUnconfirmedConfigKey)
pg.spendUnconfirmed.SetChecked(false)
if isSpendUnconfirmed {
pg.spendUnconfirmed.SetChecked(true)
pg.spendUnconfirmed.SetChecked(isSpendUnconfirmed)
}

beep := pg.wal.ReadBoolConfigValueForKey(dcrlibwallet.BeepNewBlocksConfigKey)
pg.beepNewBlocks.SetChecked(false)
if beep {
pg.beepNewBlocks.SetChecked(true)
pg.beepNewBlocks.SetChecked(beep)
}

pg.peerAddr = pg.wal.ReadStringConfigValueForKey(dcrlibwallet.SpvPersistentPeerAddressesConfigKey)
Expand Down
29 changes: 14 additions & 15 deletions ui/page/wallet_settings_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ type WalletSettingsPage struct {

changePass, rescan, deleteWallet *widget.Clickable

notificationW *widget.Bool
notification *decredmaterial.Switch

chevronRightIcon *widget.Icon
backButton decredmaterial.IconButton
}

func NewWalletSettingsPage(l *load.Load, wal *dcrlibwallet.Wallet) *WalletSettingsPage {
pg := &WalletSettingsPage{
Load: l,
wallet: wal,
notificationW: new(widget.Bool),
changePass: new(widget.Clickable),
rescan: new(widget.Clickable),
deleteWallet: new(widget.Clickable),
Load: l,
wallet: wal,
notification: l.Theme.Switch(),
changePass: new(widget.Clickable),
rescan: new(widget.Clickable),
deleteWallet: new(widget.Clickable),

chevronRightIcon: l.Icons.ChevronRight,
}
Expand All @@ -50,9 +50,9 @@ func (pg *WalletSettingsPage) OnResume() {
func (pg *WalletSettingsPage) Layout(gtx layout.Context) layout.Dimensions {

beep := pg.wallet.ReadBoolConfigValueForKey(dcrlibwallet.BeepNewBlocksConfigKey, false)
pg.notificationW.Value = beep
pg.notification.SetChecked(beep)
if beep {
pg.notificationW.Value = true
pg.notification.SetChecked(true)
}

body := func(gtx C) D {
Expand All @@ -72,7 +72,7 @@ func (pg *WalletSettingsPage) Layout(gtx layout.Context) layout.Dimensions {
}
return layout.Dimensions{}
}),
layout.Rigid(pg.notification()),
layout.Rigid(pg.notificationSection()),
layout.Rigid(pg.debug()),
layout.Rigid(pg.dangerZone()),
)
Expand All @@ -98,14 +98,14 @@ func (pg *WalletSettingsPage) changePassphrase() layout.Widget {
}
}

func (pg *WalletSettingsPage) notification() layout.Widget {
func (pg *WalletSettingsPage) notificationSection() layout.Widget {
return func(gtx C) D {
return pg.pageSections(gtx, values.String(values.StrNotifications), nil, func(gtx C) D {
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
layout.Rigid(pg.bottomSectionLabel(values.String(values.StrBeepForNewBlocks))),
layout.Flexed(1, func(gtx C) D {
return layout.E.Layout(gtx, func(gtx C) D {
return pg.Theme.Switch(pg.notificationW).Layout(gtx)
return pg.notification.Layout(gtx)
})
}),
)
Expand Down Expand Up @@ -245,8 +245,8 @@ func (pg *WalletSettingsPage) Handle() {
break
}

if pg.notificationW.Changed() {
pg.wallet.SetBoolConfigValueForKey(dcrlibwallet.BeepNewBlocksConfigKey, pg.notificationW.Value)
if pg.notification.Changed() {
pg.wallet.SetBoolConfigValueForKey(dcrlibwallet.BeepNewBlocksConfigKey, pg.notification.IsChecked())
}

for pg.deleteWallet.Clicked() {
Expand All @@ -255,7 +255,6 @@ func (pg *WalletSettingsPage) Handle() {
Body("Make sure to have the seed phrase backed up before removing the wallet").
NegativeButton(values.String(values.StrCancel), func() {}).
PositiveButton(values.String(values.StrRemove), func() {

modal.NewPasswordModal(pg.Load).
Title(values.String(values.StrConfirmToRemove)).
NegativeButton(values.String(values.StrCancel), func() {}).
Expand Down

0 comments on commit e2a12c1

Please sign in to comment.