Skip to content

Commit

Permalink
fix: tracks page grey screen
Browse files Browse the repository at this point in the history
due to animation controller not being reinitialized properly
  • Loading branch information
MSOB7YY committed Jan 8, 2024
1 parent 1889ca8 commit 6dc31fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion lib/ui/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin

@override
void dispose() {
_shimmerList.clear();
_recentlyAddedFull.clear();
_recentlyAdded.clear();
_randomTracks.clear();
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/pages/tracks_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _TracksPageState extends State<TracksPage> with TickerProviderStateMixin {
final _animationKey = 'tracks_page';
final turnsTween = Tween<double>(begin: 0.0, end: 1.0);
late final animation = AnimationController(vsync: this, duration: Duration.zero);
AnimationController get animation2 => RefreshLibraryIconController.getController(_animationKey);
AnimationController get animation2 => RefreshLibraryIconController.getController(_animationKey, this);

final _minTrigger = 20;

Expand All @@ -43,9 +43,9 @@ class _TracksPageState extends State<TracksPage> with TickerProviderStateMixin {

@override
void dispose() {
super.dispose();
animation.dispose();
RefreshLibraryIconController.dispose(_animationKey);
super.dispose();
}

@override
Expand Down
15 changes: 9 additions & 6 deletions lib/ui/widgets/settings/indexer_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -839,18 +839,21 @@ Future<void> showRefreshPromptDialog(bool didModifyFolder) async {
class RefreshLibraryIconController {
static final _controllers = <String, AnimationController>{};

static AnimationController getController(String key) => _controllers[key]!;
static AnimationController getController(String key, TickerProvider vsync) => _controllers[key] ?? init(key, vsync);

static void init(String key, TickerProvider vsync) {
_controllers[key] ??= AnimationController(
static AnimationController init(String key, TickerProvider vsync) {
_controllers[key]?.dispose();
final c = AnimationController(
duration: const Duration(milliseconds: 1200),
vsync: vsync,
);
_controllers[key] = c;
return c;
}

static void dispose(String key) {
_controllers[key]?.dispose();
_controllers.remove(key);
final c = _controllers.remove(key);
c?.dispose();
}

static void repeat() {
Expand Down Expand Up @@ -906,7 +909,7 @@ class _RefreshLibraryIconState extends State<_RefreshLibraryIcon> with TickerPro
@override
Widget build(BuildContext context) {
return RotationTransition(
turns: turnsTween.animate(RefreshLibraryIconController.getController(widget.widgetKey)),
turns: turnsTween.animate(RefreshLibraryIconController.getController(widget.widgetKey, this)),
child: Icon(
Broken.refresh_2,
color: context.defaultIconColor(),
Expand Down

0 comments on commit 6dc31fb

Please sign in to comment.