1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
import 'package:flutter/material.dart';
import 'routes.dart';
import 'login.dart';
import 'cart.dart';
import 'payement_order.dart';
import 'order_history.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Carpool App',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: HomePage(), // Set the home page to a custom HomePage widget
routes: {
'/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',
)),
},
);
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Home'),
),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
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,
);
}
}
|