• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fyne-io / fyne / 18807176232

25 Oct 2025 06:34PM UTC coverage: 61.057% (-0.004%) from 61.061%
18807176232

Pull #5989

github

Jacalz
Fix TODO regarding comparable map key
Pull Request #5989: RFC: Proof of concept for upgrading Go to 1.24

155 of 188 new or added lines in 62 files covered. (82.45%)

27 existing lines in 6 files now uncovered.

25609 of 41943 relevant lines covered (61.06%)

692.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cmd/fyne_demo/tutorials/welcome.go
1
package tutorials
2

3
import (
4
        "image/color"
5
        "net/url"
6
        "strings"
7

8
        "fyne.io/fyne/v2"
9
        "fyne.io/fyne/v2/canvas"
10
        "fyne.io/fyne/v2/cmd/fyne_demo/data"
11
        "fyne.io/fyne/v2/container"
12
        "fyne.io/fyne/v2/layout"
13
        "fyne.io/fyne/v2/theme"
14
        "fyne.io/fyne/v2/widget"
15
)
16

17
func parseURL(urlStr string) *url.URL {
×
18
        link, err := url.Parse(urlStr)
×
19
        if err != nil {
×
20
                fyne.LogError("Could not parse URL", err)
×
21
        }
×
22

23
        return link
×
24
}
25

26
func welcomeScreen(_ fyne.Window) fyne.CanvasObject {
×
27
        logo := canvas.NewImageFromResource(data.FyneLogoTransparent)
×
28
        logo.FillMode = canvas.ImageFillContain
×
29
        if fyne.CurrentDevice().IsMobile() {
×
30
                logo.SetMinSize(fyne.NewSize(192, 192))
×
31
        } else {
×
32
                logo.SetMinSize(fyne.NewSize(256, 256))
×
33
        }
×
34

35
        footer := container.NewHBox(
×
36
                layout.NewSpacer(),
×
37
                widget.NewHyperlink("fyne.io", parseURL("https://fyne.io/")),
×
38
                widget.NewLabel("-"),
×
39
                widget.NewHyperlink("documentation", parseURL("https://docs.fyne.io/")),
×
40
                widget.NewLabel("-"),
×
41
                widget.NewHyperlink("sponsor", parseURL("https://fyne.io/sponsor/")),
×
42
                layout.NewSpacer(),
×
43
        )
×
44

×
45
        authors := widget.NewRichTextFromMarkdown(formatAuthors(string(data.Authors.Content())))
×
46
        content := container.NewVBox(
×
47
                widget.NewLabelWithStyle("\n\nWelcome to the Fyne toolkit demo app", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}),
×
48
                logo,
×
49
                container.NewCenter(authors),
×
50
                widget.NewLabelWithStyle("\nWith great thanks to our many kind sponsors\n", fyne.TextAlignCenter, fyne.TextStyle{Italic: true}))
×
51
        scroll := container.NewScroll(content)
×
52

×
53
        bgColor := withAlpha(theme.Color(theme.ColorNameBackground), 0xe0)
×
54
        shadowColor := withAlpha(theme.Color(theme.ColorNameBackground), 0x33)
×
55

×
56
        underlay := canvas.NewImageFromResource(data.FyneLogo)
×
57
        bg := canvas.NewRectangle(bgColor)
×
58
        underlayer := underLayout{}
×
59
        slideBG := container.New(underlayer, underlay)
×
60
        footerBG := canvas.NewRectangle(shadowColor)
×
61

×
62
        fyne.CurrentApp().Settings().AddListener(func(fyne.Settings) {
×
63
                bgColor = withAlpha(theme.Color(theme.ColorNameBackground), 0xe0)
×
64
                bg.FillColor = bgColor
×
65
                bg.Refresh()
×
66

×
67
                shadowColor = withAlpha(theme.Color(theme.ColorNameBackground), 0x33)
×
68
                footerBG.FillColor = bgColor
×
69
                footer.Refresh()
×
70
        })
×
71

72
        underlay.Resize(fyne.NewSize(1024, 1024))
×
73
        scroll.OnScrolled = func(p fyne.Position) {
×
74
                underlayer.offset = -p.Y / 3
×
75
                underlayer.Layout(slideBG.Objects, slideBG.Size())
×
76
        }
×
77

78
        bgClip := container.NewScroll(slideBG)
×
79
        bgClip.Direction = container.ScrollNone
×
80
        return container.NewStack(container.New(unpad{top: true}, bgClip, bg),
×
81
                container.NewBorder(nil,
×
82
                        container.NewStack(footerBG, footer), nil, nil,
×
83
                        container.New(unpad{top: true, bottom: true}, scroll)))
×
84
}
85

86
func withAlpha(c color.Color, alpha uint8) color.Color {
×
87
        r, g, b, _ := c.RGBA()
×
88
        return color.NRGBA{R: uint8(r >> 8), G: uint8(g >> 8), B: uint8(b >> 8), A: alpha}
×
89
}
×
90

91
type underLayout struct {
92
        offset float32
93
}
94

95
func (u underLayout) Layout(objs []fyne.CanvasObject, size fyne.Size) {
×
96
        under := objs[0]
×
97
        left := size.Width/2 - under.Size().Width/2
×
98
        under.Move(fyne.NewPos(left, u.offset-50))
×
99
}
×
100

101
func (u underLayout) MinSize(_ []fyne.CanvasObject) fyne.Size {
×
102
        return fyne.Size{}
×
103
}
×
104

105
type unpad struct {
106
        top, bottom bool
107
}
108

109
func (u unpad) Layout(objs []fyne.CanvasObject, s fyne.Size) {
×
110
        pad := theme.Padding()
×
111
        var pos fyne.Position
×
112
        if u.top {
×
113
                pos = fyne.NewPos(0, -pad)
×
114
        }
×
115
        size := s
×
116
        if u.top {
×
117
                size = size.AddWidthHeight(0, pad)
×
118
        }
×
119
        if u.bottom {
×
120
                size = size.AddWidthHeight(0, pad)
×
121
        }
×
122
        for _, o := range objs {
×
123
                o.Move(pos)
×
124
                o.Resize(size)
×
125
        }
×
126
}
127

128
func (u unpad) MinSize(_ []fyne.CanvasObject) fyne.Size {
×
129
        return fyne.NewSize(100, 100)
×
130
}
×
131

132
func formatAuthors(lines string) string {
×
133
        markdown := &strings.Builder{}
×
134
        markdown.WriteString("### Authors\n\n")
×
135

×
NEW
136
        for line := range strings.SplitSeq(lines, "\n") {
×
137
                if len(line) == 0 {
×
138
                        continue
×
139
                }
140

141
                markdown.WriteString("* ")
×
142
                markdown.WriteString(line)
×
143
                markdown.WriteByte('\n')
×
144
        }
145

146
        return markdown.String()
×
147
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc