From adb14c22c7c6c1176bcc6c25d8af99ffb0abf1ec Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sun, 8 Oct 2023 02:39:34 +0530 Subject: [PATCH] Update Dashboard NavigationRail --- lib/providers/ui_providers.dart | 5 +- lib/screens/dashboard.dart | 135 +++++++++++++++++++------------- 2 files changed, 85 insertions(+), 55 deletions(-) diff --git a/lib/providers/ui_providers.dart b/lib/providers/ui_providers.dart index a9732df8..581d0029 100644 --- a/lib/providers/ui_providers.dart +++ b/lib/providers/ui_providers.dart @@ -1,11 +1,12 @@ import 'package:apidash/consts.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -final navRailIndexStateProvider = StateProvider((ref) => 0); +final navRailIndexStateProvider = StateProvider((ref) => 0); final activeIdStateProvider = StateProvider((ref) => null); final activeIdEditStateProvider = StateProvider((ref) => null); final sentRequestIdStateProvider = StateProvider((ref) => null); final codePaneVisibleStateProvider = StateProvider((ref) => false); final saveDataStateProvider = StateProvider((ref) => false); final clearDataStateProvider = StateProvider((ref) => false); -final codegenLanguageStateProvider = StateProvider((ref) => CodegenLanguage.dartHttp); \ No newline at end of file +final codegenLanguageStateProvider = + StateProvider((ref) => CodegenLanguage.dartHttp); diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index a32696c0..250aefad 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -21,60 +21,61 @@ class _DashboardState extends ConsumerState { body: SafeArea( child: Row( children: [ - NavigationRail( - selectedIndex: railIdx, - groupAlignment: -1.0, - onDestinationSelected: (int index) { - setState(() { - ref - .read(navRailIndexStateProvider.notifier) - .update((state) => index); - }); - }, - labelType: NavigationRailLabelType.all, - leading: SizedBox(height: kIsMacOS ? 24.0 : 8.0), - trailing: Expanded( - child: Align( - alignment: Alignment.bottomCenter, - child: Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: TextButton( - style: (railIdx == null) - ? TextButton.styleFrom( - backgroundColor: Theme.of(context) - .colorScheme - .secondaryContainer, - ) - : null, - onPressed: (railIdx == null) - ? null - : () { - ref - .read(navRailIndexStateProvider.notifier) - .update((state) => null); - }, - child: Icon( - (railIdx == null) - ? Icons.settings - : Icons.settings_outlined, - color: Theme.of(context).colorScheme.onSurfaceVariant, - ), + Column( + children: [ + SizedBox( + height: kIsMacOS ? 32.0 : 16.0, + width: 64, + ), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + isSelected: railIdx == 0, + onPressed: () { + ref + .read(navRailIndexStateProvider.notifier) + .update((state) => 0); + }, + icon: const Icon(Icons.auto_awesome_mosaic_outlined), + selectedIcon: const Icon(Icons.auto_awesome_mosaic), ), + Text( + 'Requests', + style: Theme.of(context).textTheme.labelSmall, + ), + ], + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: bottomButton(context, railIdx, 1, Icons.help, + Icons.help_outline), + ), + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: bottomButton(context, railIdx, 2, Icons.settings, + Icons.settings_outlined), + ), + ], ), ), - ), - destinations: const [ - NavigationRailDestination( - icon: Icon(Icons.home_outlined), - selectedIcon: Icon(Icons.home), - label: Text('Home'), - ), - NavigationRailDestination( - icon: Icon(Icons.auto_awesome_mosaic_outlined), - selectedIcon: Icon(Icons.auto_awesome_mosaic), - label: Text('Requests'), - ), ], + // destinations: const [ + // // NavigationRailDestination( + // // icon: Icon(Icons.home_outlined), + // // selectedIcon: Icon(Icons.home), + // // label: Text('Home'), + // // ), + // NavigationRailDestination( + // icon: Icon(Icons.auto_awesome_mosaic_outlined), + // selectedIcon: Icon(Icons.auto_awesome_mosaic), + // label: Text('Requests'), + // ), + // ], ), VerticalDivider( thickness: 1, @@ -84,11 +85,11 @@ class _DashboardState extends ConsumerState { Expanded( child: IndexedStack( alignment: AlignmentDirectional.topCenter, - index: railIdx == null ? 0 : railIdx + 1, + index: railIdx, children: const [ - SettingsPage(), - IntroPage(), HomePage(), + IntroPage(), + SettingsPage(), ], ), ) @@ -97,4 +98,32 @@ class _DashboardState extends ConsumerState { ), ); } + + TextButton bottomButton( + BuildContext context, + int railIdx, + int buttonIdx, + IconData selectedIcon, + IconData icon, + ) { + bool isSelected = railIdx == buttonIdx; + return TextButton( + style: isSelected + ? TextButton.styleFrom( + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, + ) + : null, + onPressed: isSelected + ? null + : () { + ref + .read(navRailIndexStateProvider.notifier) + .update((state) => buttonIdx); + }, + child: Icon( + isSelected ? selectedIcon : icon, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ); + } }