add cover and details to album page

This commit is contained in:
Drew Weymouth
2023-01-03 18:01:19 -08:00
parent 4912e6d180
commit a9c854b86b
8 changed files with 87 additions and 23 deletions
+39
View File
@@ -0,0 +1,39 @@
package layouts
import (
"fyne.io/fyne/v2"
)
var _ fyne.Layout = (*CenterPadLayout)(nil)
type CenterPadLayout struct {
PadLeftRight float32
PadTopBottom float32
}
// only supports one object
func (c *CenterPadLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {
if len(objects) == 0 {
return fyne.NewSize(0, 0)
}
return fyne.Size{
Width: objects[0].MinSize().Width + c.PadLeftRight*2,
Height: objects[0].MinSize().Height + c.PadTopBottom*2,
}
}
func (c *CenterPadLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {
if len(objects) == 0 {
return
}
objSize := objects[0].MinSize()
xOffs := (size.Width - objSize.Width) / 2
yOffs := (size.Height - objSize.Height) / 2
for _, child := range objects {
if !child.Visible() {
continue
}
child.Move(fyne.NewPos(xOffs, yOffs))
child.Resize(child.MinSize())
}
}