Advertisement
Guest User

Init layout

a guest
Apr 6th, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.96 KB | None | 0 0
  1. func (m *configManager) loadAppView() fyne.CanvasObject {
  2.  
  3.     title := canvas.NewText(m.translator.T("VIEW_APPS_TITLE"), theme.TextColor())
  4.     title.TextSize = 18
  5.  
  6.     appList := widget.NewVBox()
  7.  
  8.     appName := "My application"
  9.  
  10.     for i := 0; i < 2; i++ {
  11.         actionBlock := widget.NewHBox()
  12.  
  13.         openBtn := widget.NewButton(m.translator.T("BTN_OPEN"), nil)
  14.         openBtn.Style = widget.DefaultButton
  15.         openBtn.OnTapped = func() {
  16.             open.Run("https://example.com")
  17.  
  18.         }
  19.         actionBlock.Append(openBtn)
  20.  
  21.         detailsBtn := widget.NewButton(m.translator.T("BTN_DETAILS"), nil)
  22.         detailsBtn.Style = widget.DefaultButton
  23.         detailsBtn.OnTapped = func() {
  24.             open.Run("https://example.com")
  25.  
  26.         }
  27.         actionBlock.Append(detailsBtn)
  28.  
  29.         appImage := canvas.NewImageFromFile("img/app_icon.png")
  30.         appImage.SetMinSize(fyne.NewSize(55, 55))
  31.         appImage.FillMode = canvas.ImageFillContain
  32.  
  33.         appLabel := canvas.NewText(appName, m.ui.Settings().Theme().TextColor())
  34.         appLabel.TextSize = m.ui.Settings().Theme().TextSize() + 2
  35.         appLabel.TextStyle = fyne.TextStyle{
  36.             Bold:      true,
  37.             Italic:    false,
  38.             Monospace: false,
  39.         }
  40.  
  41.         appVendor := canvas.NewText("Vendor", m.ui.Settings().Theme().TextColor())
  42.         appVendor.TextSize = m.ui.Settings().Theme().TextSize() - 2
  43.  
  44.         appBox := widget.NewVBox(appLabel, appVendor)
  45.  
  46.         actionBox := widget.NewVBox(lib.Pd(10, 10), actionBlock, lib.Pd(10, 10))
  47.  
  48.         borderLayout := layout.NewBorderLayout(nil, nil, appImage, actionBox)
  49.  
  50.         appRow := fyne.NewContainerWithLayout(
  51.             borderLayout,
  52.             appImage,
  53.             actionBox,
  54.             appBox,
  55.         )
  56.         appList.Append(appRow)
  57.     }
  58.  
  59.     appView := widget.NewVBox(
  60.         widget.NewHBox(
  61.             lib.Pd(20, 20),
  62.             widget.NewVBox(
  63.                 lib.Pd(20, 20),
  64.                 title,
  65.                 lib.Pd(10, 10),
  66.                 appList,
  67.             ),
  68.         ),
  69.     )
  70.  
  71.     return appView
  72.  
  73. }
  74. //Helper for padding elements
  75. func Pd(width, height int) fyne.CanvasObject {
  76.     rec := canvas.NewRectangle(theme.BackgroundColor())
  77.     rec.SetMinSize(fyne.Size{width, height})
  78.     return rec
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement