Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func (m *configManager) loadAppView() fyne.CanvasObject {
- title := canvas.NewText(m.translator.T("VIEW_APPS_TITLE"), theme.TextColor())
- title.TextSize = 18
- appList := widget.NewVBox()
- appName := "My application"
- for i := 0; i < 2; i++ {
- actionBlock := widget.NewHBox()
- openBtn := widget.NewButton(m.translator.T("BTN_OPEN"), nil)
- openBtn.Style = widget.DefaultButton
- openBtn.OnTapped = func() {
- open.Run("https://example.com")
- }
- actionBlock.Append(openBtn)
- detailsBtn := widget.NewButton(m.translator.T("BTN_DETAILS"), nil)
- detailsBtn.Style = widget.DefaultButton
- detailsBtn.OnTapped = func() {
- open.Run("https://example.com")
- }
- actionBlock.Append(detailsBtn)
- appImage := canvas.NewImageFromFile("img/app_icon.png")
- appImage.SetMinSize(fyne.NewSize(55, 55))
- appImage.FillMode = canvas.ImageFillContain
- appLabel := canvas.NewText(appName, m.ui.Settings().Theme().TextColor())
- appLabel.TextSize = m.ui.Settings().Theme().TextSize() + 2
- appLabel.TextStyle = fyne.TextStyle{
- Bold: true,
- Italic: false,
- Monospace: false,
- }
- appVendor := canvas.NewText("Vendor", m.ui.Settings().Theme().TextColor())
- appVendor.TextSize = m.ui.Settings().Theme().TextSize() - 2
- appBox := widget.NewVBox(appLabel, appVendor)
- actionBox := widget.NewVBox(lib.Pd(10, 10), actionBlock, lib.Pd(10, 10))
- borderLayout := layout.NewBorderLayout(nil, nil, appImage, actionBox)
- appRow := fyne.NewContainerWithLayout(
- borderLayout,
- appImage,
- actionBox,
- appBox,
- )
- appList.Append(appRow)
- }
- appView := widget.NewVBox(
- widget.NewHBox(
- lib.Pd(20, 20),
- widget.NewVBox(
- lib.Pd(20, 20),
- title,
- lib.Pd(10, 10),
- appList,
- ),
- ),
- )
- return appView
- }
- //Helper for padding elements
- func Pd(width, height int) fyne.CanvasObject {
- rec := canvas.NewRectangle(theme.BackgroundColor())
- rec.SetMinSize(fyne.Size{width, height})
- return rec
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement