public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-flutter-frontend 1/9] replace BottomNavigationBar with NavigationBar
Date: Fri, 12 Apr 2024 10:04:50 +0200	[thread overview]
Message-ID: <20240412080458.1066580-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20240412080458.1066580-1-d.csapak@proxmox.com>

it has proper material 3 styling. For the animations to work correctly,
we have to put the bar outside of the part that we replace when we
navigate though

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 lib/pages/main_layout_slim.dart | 57 +++++++++++++++++----------------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/lib/pages/main_layout_slim.dart b/lib/pages/main_layout_slim.dart
index 3da9beb..2a5e646 100644
--- a/lib/pages/main_layout_slim.dart
+++ b/lib/pages/main_layout_slim.dart
@@ -80,21 +80,12 @@ class _MainLayoutSlimState extends State<MainLayoutSlim> {
           stream: pageSelector.stream,
           initialData: pageSelector.value,
           builder: (context, snapshot) {
-            if (snapshot.hasData) {
-              switch (snapshot.data) {
-                case 0:
-                  return const MobileDashboard();
-                case 1:
-                  return const MobileResourceOverview();
-                case 2:
-                  Provider.of<PveAccessManagementBloc>(context)
-                      .events
-                      .add(LoadUsers());
-                  return const MobileAccessManagement();
-                default:
-              }
-            }
-            return Container();
+            return Scaffold(
+              body: getMainContent(snapshot, context),
+              // it cannot be const, but depends only on context
+              // ignore: prefer_const_constructors
+              bottomNavigationBar: PveMobileBottomNavigationbar(),
+            );
           },
         ),
       ),
@@ -108,6 +99,22 @@ class _MainLayoutSlimState extends State<MainLayoutSlim> {
   }
 }
 
+Widget getMainContent(snapshot, context) {
+  if (snapshot.hasData) {
+    switch (snapshot.data) {
+      case 0:
+        return const MobileDashboard();
+      case 1:
+        return const MobileResourceOverview();
+      case 2:
+        Provider.of<PveAccessManagementBloc>(context).events.add(LoadUsers());
+        return const MobileAccessManagement();
+      default:
+    }
+  }
+  return Container();
+}
+
 class PveMobileBottomNavigationbar extends StatelessWidget {
   const PveMobileBottomNavigationbar({super.key});
 
@@ -115,29 +122,28 @@ class PveMobileBottomNavigationbar extends StatelessWidget {
   Widget build(BuildContext context) {
     final pageSelector = Provider.of<BehaviorSubject<int>>(context);
     final light = Theme.of(context).colorScheme.brightness == Brightness.light;
-    return BottomNavigationBar(
-        type: BottomNavigationBarType.fixed,
+    return NavigationBar(
         backgroundColor: light ? Colors.white : ProxmoxColors.greyShade40,
-        items: const [
-          BottomNavigationBarItem(
+        destinations: const <Widget>[
+          NavigationDestination(
             icon: Icon(Icons.dashboard),
             label: "Dashboard",
           ),
-          BottomNavigationBarItem(
+          NavigationDestination(
             icon: Icon(Icons.developer_board),
             label: "Resources",
           ),
-          BottomNavigationBarItem(
+          NavigationDestination(
             icon: Icon(Icons.supervised_user_circle),
             label: "Access",
           ),
-          BottomNavigationBarItem(
+          NavigationDestination(
             icon: Icon(Icons.logout),
             label: "Sites",
           ),
         ],
-        currentIndex: pageSelector.value,
-        onTap: (index) {
+        selectedIndex: pageSelector.value,
+        onDestinationSelected: (int index) {
           if (index == 3) {
             Provider.of<PveAuthenticationBloc>(context, listen: false)
                 .events
@@ -543,7 +549,6 @@ class MobileDashboard extends StatelessWidget {
               ]);
             }),
       ]),
-      bottomNavigationBar: const PveMobileBottomNavigationbar(),
     );
   }
 }
@@ -656,7 +661,6 @@ class MobileResourceOverview extends StatelessWidget {
                 }
               },
             ),
-            bottomNavigationBar: const PveMobileBottomNavigationbar(),
           )),
         );
       },
@@ -1237,7 +1241,6 @@ class MobileAccessManagement extends StatelessWidget {
                     }),
               ]);
             }),
-        bottomNavigationBar: const PveMobileBottomNavigationbar(),
       ),
     );
   }
-- 
2.39.2





  reply	other threads:[~2024-04-12  8:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12  8:04 [pve-devel] [PATCH pve-flutter-frontend 0/9] small improvements Dominik Csapak
2024-04-12  8:04 ` Dominik Csapak [this message]
2024-04-12  8:04 ` [pve-devel] [PATCH pve-flutter-frontend 2/9] resource tab: improve colors for headers Dominik Csapak
2024-04-12  8:04 ` [pve-devel] [PATCH pve-flutter-frontend 3/9] node overview: don't throw permission errors on every update Dominik Csapak
2024-04-12  8:04 ` [pve-devel] [PATCH pve-flutter-frontend 4/9] adapt to material 3 changes for themes Dominik Csapak
2024-04-12  8:04 ` [pve-devel] [PATCH pve-flutter-frontend 5/9] fix clipping for data card widget Dominik Csapak
2024-04-12  8:04 ` [pve-devel] [PATCH pve-flutter-frontend 6/9] set the color of the template indicator to that of the icon Dominik Csapak
2024-04-12  8:04 ` [pve-devel] [PATCH pve-flutter-frontend 7/9] task logs: don't always say 'Last Task: ' Dominik Csapak
2024-04-12  8:04 ` [pve-devel] [PATCH pve-flutter-frontend 8/9] task logs: use separate color for warnings Dominik Csapak
2024-04-12  8:04 ` [pve-devel] [PATCH pve-flutter-frontend 9/9] task log list: make warning icon more distinct Dominik Csapak
2024-04-16 14:15 ` [pve-devel] applied: [PATCH pve-flutter-frontend 0/9] small improvements Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240412080458.1066580-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal