Skip to content

Commit

Permalink
Reduce code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
hovatterz committed Jan 3, 2021
1 parent f644396 commit 589251a
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions _demo/page.go
Expand Up @@ -487,8 +487,7 @@ func dragAndDropPage(res *uiResources, dnd *widget.DragAndDrop, drag *dragConten
func textInputPage(res *uiResources) *page {
c := newPageContentContainer()

t := widget.NewTextInput(
widget.TextInputOpts.Placeholder("Enter text here"),
tOpts := []widget.TextInputOpt{
widget.TextInputOpts.WidgetOpts(widget.WidgetOpts.LayoutData(widget.RowLayoutData{
Stretch: true,
})),
Expand All @@ -504,27 +503,18 @@ func textInputPage(res *uiResources) *page {
widget.TextInputOpts.CaretOpts(
widget.CaretOpts.Size(res.textInput.face, 2),
),
}

t := widget.NewTextInput(append(
tOpts,
widget.TextInputOpts.Placeholder("Enter text here"))...,
)
c.AddChild(t)

tSecure := widget.NewTextInput(
widget.TextInputOpts.Placeholder("Enter password here"),
widget.TextInputOpts.WidgetOpts(widget.WidgetOpts.LayoutData(widget.RowLayoutData{
Stretch: true,
})),
widget.TextInputOpts.Image(res.textInput.image),
widget.TextInputOpts.Color(res.textInput.color),
widget.TextInputOpts.Padding(widget.Insets{
Left: 13,
Right: 13,
Top: 7,
Bottom: 7,
}),
widget.TextInputOpts.Face(res.textInput.face),
widget.TextInputOpts.CaretOpts(
widget.CaretOpts.Size(res.textInput.face, 2),
),
widget.TextInputOpts.Secure(true),
tSecure := widget.NewTextInput(append(
tOpts,
widget.TextInputOpts.Placeholder("Enter secure text here"),
widget.TextInputOpts.Secure(true))...,
)
c.AddChild(tSecure)

Expand Down

0 comments on commit 589251a

Please sign in to comment.