fyne-widgets/examples/profilebtn/main.go

47 lines
1.1 KiB
Go
Raw Normal View History

2021-12-24 00:00:44 +00:00
package main
import (
"bytes"
"image"
"image/color"
2021-12-24 00:00:44 +00:00
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
2021-12-24 13:02:59 +00:00
"fyne.io/fyne/v2/dialog"
2021-12-24 00:00:44 +00:00
"git.martyn.berlin/martyn/fyne-widgets/pkg/profilebtn"
)
2021-12-24 13:02:59 +00:00
var w fyne.Window
func Pressed() {
i := dialog.NewInformation("You clicked!", "You clicked the button", w)
i.Show()
}
2021-12-24 00:00:44 +00:00
func main() {
a := app.New()
2021-12-24 13:02:59 +00:00
w = a.NewWindow("ProfileBtn")
2021-12-24 00:00:44 +00:00
b := profilebtn.NewProfileBtn()
2021-12-24 13:02:59 +00:00
i, _, err := image.Decode(bytes.NewReader(resourceProfilepicdoesnotexistJpg.StaticContent))
2021-12-24 00:00:44 +00:00
if err != nil {
panic(err)
}
b.SetProfileImage(i)
b.OutlineWidth = 5
2021-12-25 11:49:34 +00:00
b.Disable()
b.OutlineColor = color.RGBA{0x1a, 0x23, 0xce, 0xff}
b2 := profilebtn.NewProfileBtn()
b2.SetProfileResource(resourceProfilepicdoesnotexistJpg)
b2.OutlineWidth = 3
b3 := profilebtn.NewProfileBtn()
b3.OutlineColor = color.RGBA{0x4f, 0, 0xfc, 0xff}
2021-12-24 13:02:59 +00:00
b3.OnTapped = Pressed
2021-12-24 12:40:19 +00:00
b3.SetMinSize(fyne.NewSize(40, 40))
b3.Refresh()
w.SetContent(container.NewBorder(container.NewHBox(b2, b3), nil, nil, nil, b))
2021-12-24 00:00:44 +00:00
w.Resize(fyne.NewSize(640, 480))
w.ShowAndRun()
}