mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 14:59:22 +00:00
Add [WillPopScope] on tablet mode
This commit is contained in:
parent
f3eda1c89d
commit
620ad0d5cf
@ -72,6 +72,15 @@ abstract class MainController extends State<MainRoute> {
|
|||||||
void popUntilMainRoute() => Navigator.of(context).popUntil((settings) =>
|
void popUntilMainRoute() => Navigator.of(context).popUntil((settings) =>
|
||||||
ModalRoute.of(context).isCurrent || !ModalRoute.of(context).isActive);
|
ModalRoute.of(context).isCurrent || !ModalRoute.of(context).isActive);
|
||||||
|
|
||||||
|
/// Go to the previous page (use for [WillPop] widget)
|
||||||
|
@protected
|
||||||
|
Future<bool> willPop() async {
|
||||||
|
if (numberOfPages == 1) return true;
|
||||||
|
|
||||||
|
popPage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// Open notifications page
|
/// Open notifications page
|
||||||
void openNotificationsPage() => pushPage(PageInfo(
|
void openNotificationsPage() => pushPage(PageInfo(
|
||||||
type: PageType.NOTIFICATIONS_PAGE, child: NotificationsScreen()));
|
type: PageType.NOTIFICATIONS_PAGE, child: NotificationsScreen()));
|
||||||
|
@ -21,14 +21,6 @@ class _MainRouteState extends MainController {
|
|||||||
PageInfo get defaultPage =>
|
PageInfo get defaultPage =>
|
||||||
PageInfo(type: PageType.NOTIFICATIONS_PAGE, child: NotificationsScreen());
|
PageInfo(type: PageType.NOTIFICATIONS_PAGE, child: NotificationsScreen());
|
||||||
|
|
||||||
/// Allows to go to previous tab
|
|
||||||
Future<bool> _willPop() async {
|
|
||||||
if (numberOfPages == 1) return true;
|
|
||||||
|
|
||||||
popPage();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@ -36,7 +28,7 @@ class _MainRouteState extends MainController {
|
|||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
// Avoid OS areas
|
// Avoid OS areas
|
||||||
child: WillPopScope(
|
child: WillPopScope(
|
||||||
onWillPop: _willPop,
|
onWillPop: willPop,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: currentPage.hideNavBar
|
appBar: currentPage.hideNavBar
|
||||||
? null
|
? null
|
||||||
|
@ -32,9 +32,12 @@ class _TabletRouteState extends MainController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
|
onWillPop: willPop,
|
||||||
|
child: Scaffold(
|
||||||
appBar: _buildAppBar(),
|
appBar: _buildAppBar(),
|
||||||
body: _buildBody(),
|
body: _buildBody(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user