diff --git a/lib/collections/routes.dart b/lib/collections/routes.dart index 0faf432b8..faa63da8c 100644 --- a/lib/collections/routes.dart +++ b/lib/collections/routes.dart @@ -128,8 +128,8 @@ final router = GoRouter( GoRoute( path: "/mini-player", parentNavigatorKey: rootNavigatorKey, - pageBuilder: (context, state) => const SpotubePage( - child: MiniLyricsPage(), + pageBuilder: (context, state) => SpotubePage( + child: MiniLyricsPage(prevSize: state.extra as Size), ), ), GoRoute( diff --git a/lib/components/root/bottom_player.dart b/lib/components/root/bottom_player.dart index 5a09ffa5e..6d2e83196 100644 --- a/lib/components/root/bottom_player.dart +++ b/lib/components/root/bottom_player.dart @@ -92,6 +92,8 @@ class BottomPlayer extends HookConsumerWidget { tooltip: context.l10n.mini_player, icon: const Icon(SpotubeIcons.miniPlayer), onPressed: () async { + final prevSize = + await DesktopTools.window.getSize(); await DesktopTools.window.setMinimumSize( const Size(300, 300), ); @@ -106,7 +108,10 @@ class BottomPlayer extends HookConsumerWidget { await Future.delayed( const Duration(milliseconds: 100), () async { - GoRouter.of(context).go('/mini-player'); + GoRouter.of(context).go( + '/mini-player', + extra: prevSize, + ); }, ); }, diff --git a/lib/pages/lyrics/mini_lyrics.dart b/lib/pages/lyrics/mini_lyrics.dart index e99674c86..ad3a13ef4 100644 --- a/lib/pages/lyrics/mini_lyrics.dart +++ b/lib/pages/lyrics/mini_lyrics.dart @@ -19,13 +19,13 @@ import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; import 'package:spotube/utils/platform.dart'; class MiniLyricsPage extends HookConsumerWidget { - const MiniLyricsPage({Key? key}) : super(key: key); + final Size prevSize; + const MiniLyricsPage({Key? key, required this.prevSize}) : super(key: key); @override Widget build(BuildContext context, ref) { final theme = Theme.of(context); final update = useForceUpdate(); - final prevSize = useRef(null); final wasMaximized = useRef(false); final playlistQueue = ref.watch(ProxyPlaylistNotifier.provider); @@ -35,7 +35,6 @@ class MiniLyricsPage extends HookConsumerWidget { useEffect(() { WidgetsBinding.instance.addPostFrameCallback((_) async { - prevSize.value = await DesktopTools.window.getSize(); wasMaximized.value = await DesktopTools.window.isMaximized(); }); return null; @@ -213,7 +212,7 @@ class MiniLyricsPage extends HookConsumerWidget { if (wasMaximized.value) { await DesktopTools.window.maximize(); } else { - await DesktopTools.window.setSize(prevSize.value!); + await DesktopTools.window.setSize(prevSize); } await DesktopTools.window .setAlignment(Alignment.center);