app: add 'about' page
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-05-24 23:27:39 +02:00
parent 654ef05e0b
commit fdabd847c6
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
4 changed files with 108 additions and 1 deletions

92
xkcdreader/about.go Normal file

@ -0,0 +1,92 @@
// Copyright 2022 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
package xkcdreader
import (
// for embedding standard license header
_ "embed"
"log"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
"git.dotya.ml/wanderer/go-xkcdreader/cmd"
)
type project struct {
name string
version string
homepage string
codeHomepage string
author string
license string
}
var authorInfo = "Adam Mirre <a_mirre at utb dot cz>"
var projectURL = "https://git.dotya.ml/wanderer/go-xkcdreader"
//go:embed assets/standard-license-header.txt
var l string
func aboutWindow() {
app := getApp()
w := app.NewWindow("about - " + cmd.GetAppName())
projectInfo := &project{
name: cmd.GetAppName(),
homepage: projectURL,
codeHomepage: projectURL,
version: cmd.GetShortVersion(),
author: authorInfo,
license: "GPL-3.0-or-later",
}
aboutTitle := container.New(
layout.NewHBoxLayout(),
&layout.Spacer{},
&widget.Label{Text: "About", TextStyle: fyne.TextStyle{Bold: true}},
&layout.Spacer{},
)
licenseScroll := container.NewScroll(
&widget.Label{Text: l, TextStyle: fyne.TextStyle{Monospace: true}},
)
licenseScroll.SetMinSize(fyne.Size{Height: 200, Width: 300})
ac := widget.NewAccordion(widget.NewAccordionItem(
projectInfo.license,
licenseScroll,
))
homepageScroll := container.NewHScroll(
&widget.Hyperlink{Text: projectInfo.codeHomepage, TextStyle: fyne.TextStyle{Monospace: true}},
)
homepageScroll.SetMinSize(fyne.Size{Width: 300})
about := container.New(
layout.NewFormLayout(),
&widget.Label{Text: "Name and version"},
&widget.Label{Text: projectInfo.name + " - " + projectInfo.version, TextStyle: fyne.TextStyle{Bold: true}},
&widget.Label{Text: "Author"},
&widget.Label{Text: projectInfo.author, TextStyle: fyne.TextStyle{Bold: true}},
&widget.Label{Text: "Project homepage"},
homepageScroll,
&widget.Label{Text: "License"},
ac,
)
w.SetContent(container.NewVBox(
aboutTitle,
container.NewHBox(
&layout.Spacer{},
about,
&layout.Spacer{},
),
))
w.Resize(fyne.NewSize(600, 420))
log.Println("Show About window")
w.Show()
}

@ -73,6 +73,7 @@ func makeToolbar() *widget.Toolbar {
widget.NewToolbarAction(theme.SettingsIcon(), func() { widget.NewToolbarAction(theme.SettingsIcon(), func() {
log.Println("Display settings") log.Println("Display settings")
}), }),
widget.NewToolbarAction(theme.InfoIcon(), aboutWindow),
) )
return toolbar return toolbar
} }

@ -19,7 +19,7 @@ func TestGreetingText(t *testing.T) {
} }
func TestToolbar(t *testing.T) { func TestToolbar(t *testing.T) {
wantItems := 4 wantItems := 5
gotToolbar := makeToolbar() gotToolbar := makeToolbar()
if len(gotToolbar.Items) != wantItems { if len(gotToolbar.Items) != wantItems {

@ -0,0 +1,14 @@
an offline-capable xkcd webcomic reader written in Go
Copyright (C) 2022 Adam Mirre <a_mirre at utb dot cz>
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.