From 6fa08163ed9c794482f27d17bf0e0508b474f239 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Mon, 20 Nov 2023 18:20:37 +0200 Subject: Added a simpler drawer for different routes --- lib/main.dart | 102 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 20 deletions(-) (limited to 'lib/main.dart') diff --git a/lib/main.dart b/lib/main.dart index 82a55d8..61dfcf0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'routes.dart'; import 'login.dart'; import 'cart.dart'; +import 'payement_order.dart'; import 'order_history.dart'; void main() { @@ -22,13 +23,14 @@ class MyApp extends StatelessWidget { '/login': (context) => LoginPage(), '/routes': (context) => RoutesPage(), '/order_history': (context) => OrderHistoryPage(), + '/payment': (context) => PaymentOrderTrackingPage(), '/cart': (context) => CartPage( selectedRide: Ride( name: 'Sample Ride', startLocation: 'Sample Start', endLocation: 'Sample End', time: 'Sample Time', - )), // Assuming a sample ride is passed to the CartPage for testing + )), }, ); } @@ -39,28 +41,88 @@ class HomePage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Select Page for Testing'), + title: const Text('Home'), ), - body: Center( - child: DropdownButton( - onChanged: (String? route) { - if (route != null) { - Navigator.pushNamed(context, route); - } - }, - items: [ - '/login', - '/routes', - '/cart', - '/order_history', - ].map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), + drawer: Drawer( + child: ListView( + padding: EdgeInsets.zero, + children: [ + const DrawerHeader( + decoration: BoxDecoration( + color: Colors.blue, + ), + child: Text( + 'Menu', + style: TextStyle( + color: Colors.white, + fontSize: 24, + ), + ), + ), + _buildDrawerItem( + icon: Icons.login, + text: 'Login', + onTap: () { + Navigator.pop(context); + Navigator.pushNamed(context, '/login'); + }, + ), + _buildDrawerItem( + icon: Icons.map, + text: 'Routes', + onTap: () { + Navigator.pop(context); + Navigator.pushNamed(context, '/routes'); + }, + ), + _buildDrawerItem( + icon: Icons.shopping_cart, + text: 'Cart', + onTap: () { + Navigator.pop(context); + Navigator.pushNamed(context, '/cart'); + }, + ), + _buildDrawerItem( + icon: Icons.history, + text: 'Order History', + onTap: () { + Navigator.pop(context); + Navigator.pushNamed(context, '/order_history'); + }, + ), + _buildDrawerItem( + icon: Icons.payment, + text: 'Payment & Order Tracking', + onTap: () { + Navigator.pop(context); + Navigator.pushNamed(context, '/payment'); + }, + ), + ], ), ), + body: const Center( + child: Text( + 'Welcome to Carpool App!', + style: TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + ), + ), + ), + ); + } + + Widget _buildDrawerItem({ + required IconData icon, + required String text, + required VoidCallback onTap, + }) { + return ListTile( + leading: Icon(icon), + title: Text(text), + onTap: onTap, ); } } -- cgit v1.2.3