Skip to content

Commit

Permalink
fix(android): pressing back button in any other tab other than home e…
Browse files Browse the repository at this point in the history
…xits the app
  • Loading branch information
KRTirtho committed Feb 18, 2024
1 parent 8612345 commit c3289a0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 37 deletions.
2 changes: 0 additions & 2 deletions lib/pages/home/home.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:gap/gap.dart';
Expand Down
73 changes: 41 additions & 32 deletions lib/pages/root/root_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,38 +162,47 @@ class RootApp extends HookConsumerWidget {
}
}

return Scaffold(
body: Sidebar(
selectedIndex: rootPaths[location],
onSelectedIndexChanged: onSelectIndexChanged,
child: child,
),
extendBody: true,
drawerScrimColor: Colors.transparent,
endDrawer: DesktopTools.platform.isDesktop
? Container(
constraints: const BoxConstraints(maxWidth: 800),
decoration: BoxDecoration(
boxShadow: theme.brightness == Brightness.light
? null
: kElevationToShadow[8],
),
margin: const EdgeInsets.only(
top: 40,
bottom: 100,
),
child: const PlayerQueue(floating: true),
)
: null,
bottomNavigationBar: Column(
mainAxisSize: MainAxisSize.min,
children: [
BottomPlayer(),
SpotubeNavigationBar(
selectedIndex: rootPaths[location],
onSelectedIndexChanged: onSelectIndexChanged,
),
],
return WillPopScope(
onWillPop: () async {
if (rootPaths[location] != 0) {
onSelectIndexChanged(0);
return false;
}
return true;
},
child: Scaffold(
body: Sidebar(
selectedIndex: rootPaths[location],
onSelectedIndexChanged: onSelectIndexChanged,
child: child,
),
extendBody: true,
drawerScrimColor: Colors.transparent,
endDrawer: DesktopTools.platform.isDesktop
? Container(
constraints: const BoxConstraints(maxWidth: 800),
decoration: BoxDecoration(
boxShadow: theme.brightness == Brightness.light
? null
: kElevationToShadow[8],
),
margin: const EdgeInsets.only(
top: 40,
bottom: 100,
),
child: const PlayerQueue(floating: true),
)
: null,
bottomNavigationBar: Column(
mainAxisSize: MainAxisSize.min,
children: [
BottomPlayer(),
SpotubeNavigationBar(
selectedIndex: rootPaths[location],
onSelectedIndexChanged: onSelectIndexChanged,
),
],
),
),
);
}
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1014,10 +1014,10 @@ packages:
dependency: "direct main"
description:
name: go_router
sha256: "3b40e751eaaa855179b416974d59d29669e750d2e50fcdb2b37f1cb0ca8c803a"
sha256: c5fa45fa502ee880839e3b2152d987c44abae26d064a2376d4aad434cf0f7b15
url: "https://pub.dev"
source: hosted
version: "13.0.1"
version: "12.1.3"
google_fonts:
dependency: "direct main"
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies:
flutter_svg: ^1.1.6
form_validator: ^2.1.1
fuzzywuzzy: ^1.1.6
go_router: ^13.0.1
go_router: 12.1.3 # Stuck on this https:/flutter/flutter/issues/140869
google_fonts: ^6.1.0
hive: ^2.2.3
hive_flutter: ^1.1.0
Expand Down

0 comments on commit c3289a0

Please sign in to comment.