UI changes in sidemenu.

This commit is contained in:
bala 2025-11-30 02:25:45 +05:30
parent fe49bdf9af
commit 064e753fb9
3 changed files with 90 additions and 46 deletions

View File

@ -1,3 +1,7 @@
import 'package:flutter/material.dart';
ValueNotifier<String> selectedRoute = ValueNotifier<String>("/dashboard");
class AppRoutePaths { class AppRoutePaths {
///Auth ///Auth
static const auth = '/auth'; static const auth = '/auth';

View File

@ -22,7 +22,7 @@ class SideMenu extends ConsumerWidget {
children: [ children: [
// Header // Header
DrawerHeader( DrawerHeader(
decoration: BoxDecoration(color: Color(0xFF00BFFF)), decoration: const BoxDecoration(color: Color(0xFF00BFFF)),
child: SizedBox( child: SizedBox(
width: double.infinity, width: double.infinity,
child: Row( child: Row(
@ -112,8 +112,10 @@ class SideMenu extends ConsumerWidget {
// Section title widget // Section title widget
Widget _sectionHeader(String title) { Widget _sectionHeader(String title) {
return Container( return Container(
padding: EdgeInsets.symmetric(vertical: 8), padding: const EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration(color: Color.fromARGB(255, 225, 236, 255)), decoration: const BoxDecoration(
color: Color.fromARGB(255, 225, 236, 255),
),
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: Text( child: Text(
@ -130,43 +132,65 @@ class SideMenu extends ConsumerWidget {
); );
} }
// Menu item widget // Menu item widget with persistent left indicator
Widget _menuItem( Widget _menuItem(
BuildContext context, BuildContext context,
String emoji, String emoji,
String title, String title,
String route, String route,
) { ) {
final bool isSelected = selected == route; return ValueListenableBuilder(
valueListenable: selectedRoute,
builder: (_, current, __) {
final bool isSelected = current == route;
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3), padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
child: InkWell( child: InkWell(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
onTap: () { onTap: () async {
Navigator.pop(context); // close drawer Navigator.pop(context);
if (isSelected) return; // avoid duplicate navigation selectedRoute.value = route; // indicator ALWAYS updates
onItemSelected(route);
if (ModalRoute.of(context)?.settings.name != route) {
Navigator.pushReplacementNamed(context, route); Navigator.pushReplacementNamed(context, route);
}
}, },
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected ? const Color(0x143B81F9) : Colors.transparent, color: isSelected
? const Color(0x143B81F9)
: Colors.transparent,
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
child: Row( child: Row(
children: [ children: [
Container(
width: 4,
height: 48,
decoration: BoxDecoration(
color: isSelected
? const Color(0xFF3B81F9)
: Colors.transparent,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10),
bottomLeft: Radius.circular(10),
),
),
),
const SizedBox(width: 8),
Text(emoji, style: const TextStyle(fontSize: 18)), Text(emoji, style: const TextStyle(fontSize: 18)),
const SizedBox(width: 10), const SizedBox(width: 10),
Text( Text(
title, title,
style: TextStyle( style: TextStyle(
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal, fontWeight: isSelected
color: isSelected ? const Color(0xFF3B81F9) : Colors.black87, ? FontWeight.w600
: FontWeight.normal,
color: isSelected
? const Color(0xFF3B81F9)
: Colors.black87,
fontSize: 16, fontSize: 16,
), ),
), ),
@ -175,6 +199,7 @@ class SideMenu extends ConsumerWidget {
), ),
), ),
); );
},
);
} }
} }

View File

@ -141,15 +141,29 @@ class _AccountScreenState extends ConsumerState<AccountScreen> {
_row("Subscription", "growth_monthly"), _row("Subscription", "growth_monthly"),
_row("Period", "24 Nov 2025 - 24 Dec 2025"), _row("Period", "24 Nov 2025 - 24 Dec 2025"),
const SizedBox(height: 20), const SizedBox(height: 20),
OutlinedButton( ElevatedButton(
onPressed: () {}, onPressed: () {},
style: OutlinedButton.styleFrom( style: ElevatedButton.styleFrom(
foregroundColor: Colors.red, backgroundColor: const Color(
side: const BorderSide(color: Colors.red), 0xFFFF4C4C,
padding: const EdgeInsets.symmetric(vertical: 14), ), // override global primary color
foregroundColor: Colors.white, // text color
elevation: 6,
shadowColor: Colors.black.withValues(alpha: 0.2),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
), ),
padding: const EdgeInsets.symmetric(vertical: 14),
textStyle: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: const Text("Cancel Subscription"), child: const Text("Cancel Subscription"),
), ),
),
], ],
), ),
); );
@ -233,9 +247,10 @@ class _AccountScreenState extends ConsumerState<AccountScreen> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(title, Text(
style: title,
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 16), const SizedBox(height: 16),
child, child,
], ],