Skip to content

Commit

Permalink
remove hardcoded dimensions from all pages (decred#173)
Browse files Browse the repository at this point in the history
* add uniform padding to all pages

* remove hard-coded dimensions and text sizes
  • Loading branch information
oshorefueled authored Jul 1, 2020
1 parent 8794290 commit 788eac4
Show file tree
Hide file tree
Showing 14 changed files with 272 additions and 269 deletions.
20 changes: 9 additions & 11 deletions ui/accounts_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ui
import (
"gioui.org/layout"
"gioui.org/text"
"gioui.org/unit"
"gioui.org/widget"
"github.com/raedahgroup/godcr/ui/values"

"github.com/raedahgroup/godcr/ui/decredmaterial"
"github.com/raedahgroup/godcr/wallet"
Expand Down Expand Up @@ -44,12 +44,12 @@ func (win *Window) WalletAccountPage(common pageCommon) layout.Widget {
}
page.accountName.IsRequired = true
page.accountNameW.SingleLine = true
page.create.TextSize = unit.Dp(11)
page.create.TextSize = values.TextSize12
page.errorLabel.Color = common.theme.Color.Danger

page.create.Background = common.theme.Color.Hint
page.backButton.Color = common.theme.Color.Hint
page.backButton.Size = unit.Dp(32)
page.backButton.Size = values.MarginPadding30

return func() {
page.Layout(common)
Expand Down Expand Up @@ -88,19 +88,19 @@ func (page *walletAccountPage) createAccount(common pageCommon) {
layout.W.Layout(common.gtx, func() {
page.backButton.Layout(common.gtx, &page.backButtonW)
})
layout.Inset{Left: unit.Dp(44)}.Layout(common.gtx, func() {
layout.Inset{Left: values.MarginPadding45}.Layout(common.gtx, func() {
common.theme.H5("Create Wallet Acount").Layout(gtx)
})
},
func() {
layout.Flex{}.Layout(gtx,
layout.Rigid(func() {
layout.Inset{Top: unit.Dp(8)}.Layout(gtx, func() {
layout.Inset{Top: values.MarginPadding10}.Layout(gtx, func() {
common.theme.Body1("Are about changing an Account in").Layout(gtx)
})
}),
layout.Rigid(func() {
layout.Inset{Left: unit.Dp(5)}.Layout(gtx, func() {
layout.Inset{Left: values.MarginPadding5}.Layout(gtx, func() {
txt := common.theme.H5(common.info.Wallets[*common.selectedWallet].Name)
txt.Color = common.theme.Color.Danger
txt.Layout(gtx)
Expand All @@ -115,17 +115,15 @@ func (page *walletAccountPage) createAccount(common pageCommon) {
page.accountName.Layout(gtx, &page.accountNameW)
},
func() {
layout.Inset{Top: unit.Dp(20)}.Layout(gtx, func() {
layout.Inset{Top: values.MarginPadding20}.Layout(gtx, func() {
page.create.Layout(gtx, &page.createW)
})
},
}

common.Layout(gtx, func() {
layout.UniformInset(unit.Dp(20)).Layout(gtx, func() {
page.container.Layout(gtx, len(wdgs), func(i int) {
layout.UniformInset(unit.Dp(3)).Layout(gtx, wdgs[i])
})
page.container.Layout(gtx, len(wdgs), func(i int) {
layout.UniformInset(values.MarginPadding5).Layout(gtx, wdgs[i])
})
})

Expand Down
23 changes: 11 additions & 12 deletions ui/change_passphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"image/color"
"strings"

"github.com/raedahgroup/godcr/ui/values"

"gioui.org/layout"
"gioui.org/unit"
"gioui.org/widget"

"github.com/raedahgroup/dcrlibwallet"
Expand Down Expand Up @@ -43,13 +44,13 @@ func (win *Window) WalletPassphrasePage(common pageCommon) layout.Widget {
page.newPassW.SingleLine = true
page.confPass.IsRequired = true
page.confPassW.SingleLine = true
page.savePassword.TextSize = unit.Dp(11)
page.savePassword.TextSize = values.TextSize12
page.savePassword.Background = common.theme.Color.Hint
page.passwordBar = common.theme.ProgressBar(0)
page.errorLabel.Color = common.theme.Color.Danger

page.backButton.Color = common.theme.Color.Hint
page.backButton.Size = unit.Dp(32)
page.backButton.Size = values.MarginPadding30

return func() {
page.Layout(common)
Expand All @@ -65,19 +66,19 @@ func (page *walletPassphrasePage) Layout(common pageCommon) {
layout.W.Layout(common.gtx, func() {
page.backButton.Layout(common.gtx, &page.backButtonW)
})
layout.Inset{Left: unit.Dp(44)}.Layout(common.gtx, func() {
layout.Inset{Left: values.MarginPadding45}.Layout(common.gtx, func() {
common.theme.H5("Change Wallet Password").Layout(gtx)
})
},
func() {
layout.Flex{}.Layout(gtx,
layout.Rigid(func() {
layout.Inset{Top: unit.Dp(8)}.Layout(gtx, func() {
layout.Inset{Top: values.MarginPadding10}.Layout(gtx, func() {
common.theme.Body1("Are about changing the passphrase for").Layout(gtx)
})
}),
layout.Rigid(func() {
layout.Inset{Left: unit.Dp(5)}.Layout(gtx, func() {
layout.Inset{Left: values.MarginPadding5}.Layout(gtx, func() {
txt := common.theme.H5(common.info.Wallets[*common.selectedWallet].Name)
txt.Color = common.theme.Color.Danger
txt.Layout(gtx)
Expand All @@ -101,23 +102,21 @@ func (page *walletPassphrasePage) Layout(common pageCommon) {
page.confPass.Layout(gtx, &page.confPassW)
},
func() {
layout.Inset{Top: unit.Dp(20)}.Layout(gtx, func() {
layout.Inset{Top: values.MarginPadding20}.Layout(gtx, func() {
page.savePassword.Layout(gtx, &page.savePasswordW)
})
},
}

common.Layout(gtx, func() {
layout.UniformInset(unit.Dp(20)).Layout(gtx, func() {
page.container.Layout(gtx, len(wdgs), func(i int) {
layout.UniformInset(unit.Dp(3)).Layout(gtx, wdgs[i])
})
page.container.Layout(gtx, len(wdgs), func(i int) {
layout.UniformInset(values.MarginPadding5).Layout(gtx, wdgs[i])
})
})
}

func (page *walletPassphrasePage) passwordStrength(common pageCommon) {
layout.Inset{Top: unit.Dp(10)}.Layout(common.gtx, func() {
layout.Inset{Top: values.MarginPadding10}.Layout(common.gtx, func() {
common.gtx.Constraints.Height.Max = 20
page.passwordBar.Layout(common.gtx)
})
Expand Down
26 changes: 14 additions & 12 deletions ui/create_restore_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"image/color"
"strings"

"github.com/raedahgroup/godcr/ui/values"

"gioui.org/io/key"

"github.com/raedahgroup/dcrlibwallet"
Expand All @@ -13,7 +15,6 @@ import (

"gioui.org/layout"
"gioui.org/text"
"gioui.org/unit"
"gioui.org/widget"
"github.com/raedahgroup/godcr/ui/decredmaterial"
"golang.org/x/exp/shiny/materialdesign/icons"
Expand Down Expand Up @@ -181,7 +182,7 @@ func (win *Window) CreateRestorePage(common pageCommon) layout.Widget {
func (pg *createRestore) layout(common pageCommon) {
pg.theme.Surface(pg.gtx, func() {
toMax(pg.gtx)
pd := unit.Dp(15)
pd := values.MarginPadding15
layout.Flex{Axis: layout.Vertical, Spacing: layout.SpaceBetween}.Layout(pg.gtx,
layout.Flexed(1, func() {
layout.Inset{Top: pd, Left: pd, Right: pd}.Layout(pg.gtx, func() {
Expand Down Expand Up @@ -223,12 +224,12 @@ func (pg *createRestore) layout(common pageCommon) {
}
layout.Flex{Axis: layout.Horizontal}.Layout(pg.gtx,
layout.Rigid(func() {
layout.UniformInset(unit.Dp(5)).Layout(pg.gtx, func() {
layout.UniformInset(values.MarginPadding5).Layout(pg.gtx, func() {
pg.addWallet.Layout(pg.gtx, pg.addWalletWidget)
})
}),
layout.Rigid(func() {
layout.UniformInset(unit.Dp(5)).Layout(pg.gtx, func() {
layout.UniformInset(values.MarginPadding5).Layout(pg.gtx, func() {
pg.hidePasswordModal.Color = common.theme.Color.Primary
pg.hidePasswordModal.Layout(pg.gtx, pg.hidePasswordModalWidget)
})
Expand All @@ -254,12 +255,12 @@ func (pg *createRestore) layout(common pageCommon) {

layout.Flex{Axis: layout.Horizontal}.Layout(pg.gtx,
layout.Rigid(func() {
layout.UniformInset(unit.Dp(5)).Layout(pg.gtx, func() {
layout.UniformInset(values.MarginPadding5).Layout(pg.gtx, func() {
pg.resetSeedFields.Layout(pg.gtx, pg.resetSeedFieldsWidget)
})
}),
layout.Rigid(func() {
layout.UniformInset(unit.Dp(5)).Layout(pg.gtx, func() {
layout.UniformInset(values.MarginPadding5).Layout(pg.gtx, func() {
pg.hidePasswordModal.Background = common.theme.Color.Primary
pg.hidePasswordModal.Color = color.RGBA{255, 255, 255, 255}
pg.hidePasswordModal.Layout(pg.gtx, pg.hidePasswordModalWidget)
Expand Down Expand Up @@ -298,7 +299,7 @@ func (pg *createRestore) mainContent() layout.Widget {
})
}),
layout.Rigid(func() {
btnPadding := unit.Dp(10)
btnPadding := values.MarginPadding10
layout.Flex{Axis: layout.Vertical}.Layout(pg.gtx,
layout.Rigid(func() {
layout.Inset{Top: btnPadding, Bottom: btnPadding}.Layout(pg.gtx, func() {
Expand Down Expand Up @@ -335,7 +336,7 @@ func (pg *createRestore) restore() layout.Widget {
txt.Layout(pg.gtx)
}),
layout.Rigid(func() {
layout.Inset{Top: unit.Dp(10), Bottom: unit.Dp(10)}.Layout(pg.gtx, func() {
layout.Inset{Top: values.MarginPadding10, Bottom: values.MarginPadding10}.Layout(pg.gtx, func() {
layout.Center.Layout(pg.gtx, func() {
pg.errLabel.Layout(pg.gtx)
})
Expand All @@ -358,7 +359,8 @@ func (pg *createRestore) restore() layout.Widget {
layout.Center.Layout(pg.gtx, func() {
layout.Flex{Alignment: layout.Middle}.Layout(pg.gtx,
layout.Rigid(func() {
layout.Inset{Top: unit.Dp(15), Bottom: unit.Dp(15), Right: unit.Dp(10)}.Layout(pg.gtx, func() {
layout.Inset{Top: values.MarginPadding15, Bottom: values.MarginPadding15,
Right: values.MarginPadding10}.Layout(pg.gtx, func() {
pg.showPasswordModal.Layout(pg.gtx, pg.showPasswordModalWidget)
})
}),
Expand Down Expand Up @@ -396,14 +398,14 @@ func (pg *createRestore) inputsGroup(l *layout.List, len int, startIndex int) {
layout.Rigid(func() {
layout.Flex{Axis: layout.Horizontal, Alignment: layout.Baseline}.Layout(pg.gtx,
layout.Rigid(func() {
layout.Inset{Left: unit.Dp(20), Bottom: unit.Dp(20)}.Layout(pg.gtx, func() {
layout.Inset{Left: values.MarginPadding20, Bottom: values.MarginPadding20}.Layout(pg.gtx, func() {
pg.seedEditors[i+startIndex].Layout(pg.gtx, &pg.seedEditorWidgets.editors[i+startIndex])
})
}),
)
}),
layout.Rigid(func() {
layout.Inset{Top: unit.Dp(2), Left: unit.Dp(20)}.Layout(pg.gtx, func() {
layout.Inset{Top: values.MarginPadding5, Left: values.MarginPadding20}.Layout(pg.gtx, func() {
pg.autoComplete(i, startIndex)
})
}),
Expand All @@ -417,7 +419,7 @@ func (pg *createRestore) autoComplete(index, startIndex int) {
}

pg.autoCompleteList.Layout(pg.gtx, len(pg.suggestions), func(i int) {
layout.Inset{Right: unit.Dp(4)}.Layout(pg.gtx, func() {
layout.Inset{Right: values.MarginPadding5}.Layout(pg.gtx, func() {
pg.seedSuggestions[i].skin.Layout(pg.gtx, pg.seedSuggestions[i].button)
})
})
Expand Down
Loading

0 comments on commit 788eac4

Please sign in to comment.