mirror of
https://github.com/Apologieze/Benri.git
synced 2026-01-18 17:17:21 +01:00
loading episode popup
This commit is contained in:
@@ -26,7 +26,7 @@ func CreateConfig(app fyne.Preferences) {
|
||||
SkipOpening: app.Bool(SkipOpeningKey),
|
||||
SkipEnding: app.Bool(SkipEndingKey),
|
||||
TrayIcon: app.Bool(TrayIconKey),
|
||||
DiscordPresence: app.Bool(DiscordPresence),
|
||||
DiscordPresence: app.BoolWithFallback(DiscordPresence, true),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"AnimeGUI/src/anilist"
|
||||
"AnimeGUI/src/config"
|
||||
"AnimeGUI/src/richPresence"
|
||||
"AnimeGUI/src/ui"
|
||||
"AnimeGUI/verniy"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -99,6 +100,13 @@ type AllAnimeIdData struct {
|
||||
}
|
||||
|
||||
func OnPlayButtonClick(animeName string, animeData *verniy.MediaList, savingWatch bool) error {
|
||||
succes := false
|
||||
ui.ShowLoadingVideoPopUp()
|
||||
defer func() {
|
||||
if !succes {
|
||||
ui.CloseLoadingPopup(0)
|
||||
}
|
||||
}()
|
||||
|
||||
if mpvPresent == false {
|
||||
log.Error("MPV is not yet dl")
|
||||
@@ -172,6 +180,8 @@ func OnPlayButtonClick(animeName string, animeData *verniy.MediaList, savingWatc
|
||||
}
|
||||
}
|
||||
playingAnimeLoop(playingAnime, animeData, savingWatch)
|
||||
ui.ChangeLoadingStep(2)
|
||||
succes = true
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -246,6 +256,7 @@ func playingAnimeLoop(playingAnime curd.Anime, animeData *verniy.MediaList, savi
|
||||
}
|
||||
}
|
||||
|
||||
ui.CloseLoadingPopup(1)
|
||||
presenceAnime := richPresence.PresenceAnime{Name: playingAnime.Title.English, Ep: playingAnime.Ep.Number + 1, ImageLink: *animeData.Media.CoverImage.Large, PlaybackTime: 0, Duration: playingAnime.Ep.Duration, TotalEp: playingAnime.TotalEpisodes}
|
||||
var pauseCounter int
|
||||
for {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"AnimeGUI/src/anilist"
|
||||
"AnimeGUI/src/config"
|
||||
"AnimeGUI/src/richPresence"
|
||||
"AnimeGUI/src/ui"
|
||||
"AnimeGUI/verniy"
|
||||
"fmt"
|
||||
"fyne.io/fyne/v2"
|
||||
@@ -357,6 +358,7 @@ func initMainApp() {
|
||||
|
||||
initSettingDialog()
|
||||
initPlayMorePopUp()
|
||||
ui.InitLoadingVideoPopUp(window)
|
||||
|
||||
window.SetContent(fynetooltip.AddWindowToolTipLayer(container.NewBorder(nil, nil, nil, imageContainer, leftSide), window.Canvas()))
|
||||
window.Canvas().Focus(input)
|
||||
|
||||
46
src/ui/loadingVideoPopUp.go
Normal file
46
src/ui/loadingVideoPopUp.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/charmbracelet/log"
|
||||
"time"
|
||||
)
|
||||
|
||||
var loadingVideoPopup *dialog.CustomDialog
|
||||
var step int
|
||||
|
||||
func InitLoadingVideoPopUp(window fyne.Window) {
|
||||
content := container.NewVBox(widget.NewLabel("Loading episode"))
|
||||
loadingVideoPopup = dialog.NewCustomWithoutButtons("Loading episode", content, window)
|
||||
loadingVideoPopup.Resize(fyne.NewSize(400, 400))
|
||||
|
||||
}
|
||||
|
||||
func ChangeLoadingStep(value int) {
|
||||
step = value
|
||||
}
|
||||
|
||||
func ShowLoadingVideoPopUp() {
|
||||
step = 1
|
||||
if loadingVideoPopup == nil {
|
||||
log.Error("Couldn't open loading popup")
|
||||
return
|
||||
}
|
||||
fmt.Println("popup")
|
||||
loadingVideoPopup.Show()
|
||||
}
|
||||
|
||||
func CloseLoadingPopup(duration time.Duration) {
|
||||
if loadingVideoPopup == nil {
|
||||
log.Error("Couldn't close loading popup")
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(time.Second * duration)
|
||||
loadingVideoPopup.Hide()
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user