From 58d2fc7041157a942a866a58c0198eee2719b789 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 1 Dec 2022 12:59:07 -0500 Subject: [PATCH] Add spinner --- CHANGELOG.md | 1 + .../LoadingIndicator/LoadingIndicator.bs | 26 ++++++++++++++++++ .../LoadingIndicator/LoadingIndicator.xml | 16 ++++------- src/components/VideoRowCell/VideoRowCell.xml | 2 -- src/images/spinner.png | Bin 0 -> 18760 bytes 5 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 src/components/LoadingIndicator/LoadingIndicator.bs create mode 100644 src/images/spinner.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d79d5fa..146fcf03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for web request body parsing - Error dialog for video load fail - SponsorBlock sections and category info +- Loading spinner ### Fixed - Bug where playing and exiting a video too quickly would cause the video to play in the background. diff --git a/src/components/LoadingIndicator/LoadingIndicator.bs b/src/components/LoadingIndicator/LoadingIndicator.bs new file mode 100644 index 00000000..c859b2b6 --- /dev/null +++ b/src/components/LoadingIndicator/LoadingIndicator.bs @@ -0,0 +1,26 @@ +function Init() + m.busySpinner = m.top.findNode("busySpinner") + m.busyspinner.poster.width = 150 + m.busyspinner.poster.height = 150 + m.busyspinner.poster.observeField("loadStatus", "PositionSpinner") + m.busySpinner.poster.uri = "pkg:/images/spinner.png" + m.top.observeField("visible", "OnVisibleChange") +end function + +function PositionSpinner() + if m.busyspinner.poster.loadStatus = "ready" + centerx = (1280 - m.busyspinner.poster.width) / 2 + centery = (720 - m.busyspinner.poster.height) / 2 + m.busyspinner.translation = [centerx, centery] + m.busyspinner.visible = true + end if +end function + +function OnVisibleChange() + m.busyspinner.visible = m.top.visible + if m.busyspinner.visible + m.busyspinner.control = "start" + else + m.busyspinner.control = "stop" + end if +end function diff --git a/src/components/LoadingIndicator/LoadingIndicator.xml b/src/components/LoadingIndicator/LoadingIndicator.xml index f1312ac0..ca45c737 100644 --- a/src/components/LoadingIndicator/LoadingIndicator.xml +++ b/src/components/LoadingIndicator/LoadingIndicator.xml @@ -6,17 +6,11 @@ width="1280" height="720" color="#000000" - opacity="0.5" - > -