mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Add [WillPopScope] on tablet mode
This commit is contained in:
		@@ -72,6 +72,15 @@ abstract class MainController extends State<MainRoute> {
 | 
			
		||||
  void popUntilMainRoute() => Navigator.of(context).popUntil((settings) =>
 | 
			
		||||
      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
 | 
			
		||||
  void openNotificationsPage() => pushPage(PageInfo(
 | 
			
		||||
      type: PageType.NOTIFICATIONS_PAGE, child: NotificationsScreen()));
 | 
			
		||||
 
 | 
			
		||||
@@ -21,14 +21,6 @@ class _MainRouteState extends MainController {
 | 
			
		||||
  PageInfo get defaultPage =>
 | 
			
		||||
      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
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return Container(
 | 
			
		||||
@@ -36,7 +28,7 @@ class _MainRouteState extends MainController {
 | 
			
		||||
      child: SafeArea(
 | 
			
		||||
        // Avoid OS areas
 | 
			
		||||
        child: WillPopScope(
 | 
			
		||||
          onWillPop: _willPop,
 | 
			
		||||
          onWillPop: willPop,
 | 
			
		||||
          child: Scaffold(
 | 
			
		||||
            appBar: currentPage.hideNavBar
 | 
			
		||||
                ? null
 | 
			
		||||
 
 | 
			
		||||
@@ -32,9 +32,12 @@ class _TabletRouteState extends MainController {
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return Scaffold(
 | 
			
		||||
      appBar: _buildAppBar(),
 | 
			
		||||
      body: _buildBody(),
 | 
			
		||||
    return WillPopScope(
 | 
			
		||||
      onWillPop: willPop,
 | 
			
		||||
      child: Scaffold(
 | 
			
		||||
        appBar: _buildAppBar(),
 | 
			
		||||
        body: _buildBody(),
 | 
			
		||||
      ),
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user