Skip to content

Commit

Permalink
fix: window size remains same after exiting mini player (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Aug 26, 2023
1 parent 2a80761 commit fb36003
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/collections/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 6 additions & 1 deletion lib/components/root/bottom_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand All @@ -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,
);
},
);
},
Expand Down
7 changes: 3 additions & 4 deletions lib/pages/lyrics/mini_lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Size?>(null);
final wasMaximized = useRef<bool>(false);

final playlistQueue = ref.watch(ProxyPlaylistNotifier.provider);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit fb36003

Please sign in to comment.