Skip to content

Commit

Permalink
Update fyne API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
xypwn committed Dec 20, 2024
1 parent dd0191e commit 3440f40
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions internal/gui/downloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func NewDownloads(dls *logic.Downloads, mobile bool, cfgClient *data.Client[*log
sel.SetSelectedIndex(0)

var clearFiltersButton *widget.Button
content := container.NewMax()
content := container.NewStack()
{
clearFiltersButton = widget.NewButtonWithIcon(
"Clear Filters",
Expand Down Expand Up @@ -391,7 +391,7 @@ func NewDownloads(dls *logic.Downloads, mobile bool, cfgClient *data.Client[*log
),
)

placeholder := container.NewMax()
placeholder := container.NewStack()

var lock sync.Mutex
init := true
Expand Down
8 changes: 5 additions & 3 deletions internal/gui/episode.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func NewEpisode(
nil,
),
placeholderImage: canvas.NewImageFromResource(theme.FileImageIcon()),
thumbnailImageCnt: container.NewMax(),
thumbnailImageCnt: container.NewStack(),
thumbnailProgress: widget.NewProgressBarInfinite(),
thumbnailOverlay: canvas.NewRectangle(color.RGBA{16, 16, 16, 160}),
thumbnailText: canvas.NewText("", color.RGBA{255, 255, 255, 255}),
Expand All @@ -117,7 +117,9 @@ func NewEpisode(

res.placeholderImage.FillMode = canvas.ImageFillContain

res.thumbnailProgress.Start()
res.thumbnailProgress.Hide()
res.progressInfinite.Start()
res.progressInfinite.Hide()
res.progressDiscrete.Hide()
res.progressDiscrete.TextFormatter = func() string { return "" }
Expand All @@ -130,14 +132,14 @@ func NewEpisode(
res.thumbnailSize = fyne.NewSize(192, 108)
res.placeholderImage.SetMinSize(res.thumbnailSize)

thumbnail := container.NewMax(
thumbnail := container.NewStack(
res.placeholderImage,
res.thumbnailImageCnt,
res.thumbnailOverlay,
res.thumbnailText,
container.NewBorder(
nil,
container.NewMax(
container.NewStack(
res.thumbnailProgress,
res.progressInfinite,
res.progressDiscrete,
Expand Down
6 changes: 3 additions & 3 deletions internal/gui/episodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func NewEpisodesPanel(

cleanupEpisodesFn := func() {}

episodes := container.NewMax()
episodes := container.NewStack()

seasonLists := make(map[sp.Language]*widget.List)
var selectedSeason atomic.Int32
Expand Down Expand Up @@ -185,7 +185,7 @@ func NewEpisodesPanel(
languageOpts[i] = v.String()
}

seasonsCnt := container.NewMax()
seasonsCnt := container.NewStack()

type searchQuery struct {
Language sp.Language
Expand Down Expand Up @@ -249,7 +249,7 @@ func NewEpisodesPanel(
split.SetOffset(0.1)
}

mainCnt := container.NewMax(split)
mainCnt := container.NewStack(split)

var clearSearchButton *widget.Button
var cleanupSearchResultsFns []func()
Expand Down
11 changes: 6 additions & 5 deletions internal/gui/loadable.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ func NewLoadable(
asyncFn func(ctx context.Context) (fyne.CanvasObject, error),
setClipboard func(string),
) *Loadable {
progress := widget.NewProgressBarInfinite()
progress.Start()
res := &Loadable{
loader: container.NewBorder(
widget.NewProgressBarInfinite(),
progress,
nil,
nil,
nil,
),
retryBtn: widget.NewButtonWithIcon("Retry", theme.ViewRefreshIcon(), func() {}),
errText: widget.NewLabel(""),
copyBtn: widget.NewButtonWithIcon("Copy", theme.ContentCopyIcon(), func() {}),
content: container.NewMax(),
content: container.NewStack(),
}
res.ExtendBaseWidget(res)

Expand All @@ -53,8 +55,7 @@ func NewLoadable(
}
res.copyBtn.Importance = widget.LowImportance

var task *asynctask.AsyncTask[struct{}, struct{}, fyne.CanvasObject]
task = asynctask.New(
task := asynctask.New(
ctx,
func(ctx context.Context, _ struct{}, _ func(struct{})) (fyne.CanvasObject, error) {
return asyncFn(ctx)
Expand Down Expand Up @@ -95,7 +96,7 @@ func NewLoadable(
nil,
)

res.obj = container.NewMax(res.loader, res.retry, res.content)
res.obj = container.NewStack(res.loader, res.retry, res.content)

res.loader.Show()
res.retry.Hide()
Expand Down

0 comments on commit 3440f40

Please sign in to comment.