fix:shop_add
This commit is contained in:
parent
9ef38652d2
commit
967c11f012
212
lib/main.dart
212
lib/main.dart
@ -21,72 +21,22 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({super.key});
|
||||
|
||||
// REUSABLE HEADER WIDGET — USED IN BOTH HOME PAGE & SHOP PAGE
|
||||
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final String title;
|
||||
|
||||
const CustomAppBar({
|
||||
super.key,
|
||||
required this.title,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;
|
||||
|
||||
void _decrementCounter() {
|
||||
setState(() {
|
||||
_counter--;
|
||||
});
|
||||
}
|
||||
|
||||
static const String logoUrl =
|
||||
'https://nest-frontend-v6.vercel.app/assets/imgs/theme/logo.svg';
|
||||
|
||||
// Track expanded top-level items for styling (e.g., "Shop")
|
||||
Set<String> _expandedTopItems = {'Shop'};
|
||||
|
||||
// Reusable widget for sub-menu items with hover/tap effect
|
||||
Widget _buildSubItem(String title, {VoidCallback? onTap}) {
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
hoverColor: Colors.green[50],
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||
child: Text(title),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Reusable styled title for ExpansionTile (NO arrow inside!)
|
||||
Widget _buildTopItem(String title) {
|
||||
final bool isActive = _expandedTopItems.contains(title);
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: isActive ? Colors.green[50] : null,
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: isActive ? Colors.green[700] : null,
|
||||
fontWeight: isActive ? FontWeight.bold : null,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Size get preferredSize => const Size.fromHeight(60);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
return AppBar(
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
leading: Builder(
|
||||
builder: (context) {
|
||||
@ -99,14 +49,34 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
);
|
||||
},
|
||||
),
|
||||
title: const Text(
|
||||
title: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 40,
|
||||
child: SvgPicture.network(
|
||||
'https://nest-frontend-v6.vercel.app/assets/imgs/theme/logo.svg',
|
||||
placeholderBuilder: (context) => const CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Nest',
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Text(
|
||||
'MART & GROCERY',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
Stack(
|
||||
children: [
|
||||
@ -161,8 +131,67 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
// REUSABLE DRAWER WIDGET
|
||||
class AppDrawer extends StatefulWidget {
|
||||
const AppDrawer({super.key});
|
||||
|
||||
@override
|
||||
State<AppDrawer> createState() => _AppDrawerState();
|
||||
}
|
||||
|
||||
class _AppDrawerState extends State<AppDrawer> {
|
||||
Set<String> _expandedTopItems = {'Shop'};
|
||||
|
||||
Widget _buildSubItem(String title, {VoidCallback? onTap}) {
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
hoverColor: Colors.green[50],
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||
child: Text(title),
|
||||
),
|
||||
drawer: Drawer(
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTopItem(String title) {
|
||||
final bool isActive = _expandedTopItems.contains(title);
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: isActive ? Colors.green[50] : null,
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: isActive ? Colors.green[700] : null,
|
||||
fontWeight: isActive ? FontWeight.bold : null,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static const String logoUrl =
|
||||
'https://nest-frontend-v6.vercel.app/assets/imgs/theme/logo.svg';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
@ -238,7 +267,18 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
});
|
||||
},
|
||||
children: [
|
||||
_buildSubItem('Shop Grid - Right Sidebar'),
|
||||
_buildSubItem(
|
||||
'Shop Grid - Right Sidebar',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ShopGridRightSidebarPage(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
_buildSubItem('Shop Grid - Left Sidebar'),
|
||||
_buildSubItem('Shop List - Right Sidebar'),
|
||||
_buildSubItem('Shop - Wide'),
|
||||
@ -513,20 +553,52 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// NEW PAGE: Shop Grid - Right Sidebar
|
||||
class ShopGridRightSidebarPage extends StatelessWidget {
|
||||
const ShopGridRightSidebarPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const CustomAppBar(title: 'Shop Grid - Right Sidebar'),
|
||||
drawer: const AppDrawer(), // ✅ Drawer attached → hamburger works!
|
||||
body: const Center(
|
||||
child: Text(
|
||||
'Hello',
|
||||
style: TextStyle(fontSize: 24),
|
||||
),
|
||||
body: Center(
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
// MAIN HOME PAGE
|
||||
class MyHomePage extends StatelessWidget {
|
||||
const MyHomePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const CustomAppBar(title: 'Home'),
|
||||
drawer: const AppDrawer(), // ✅ Same drawer
|
||||
body: const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text('Hello'),
|
||||
Text('Hello'),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: const TextStyle(fontSize: 48),
|
||||
'0',
|
||||
style: TextStyle(fontSize: 48),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user