summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoromagdy7 <omar.professional8777@gmail.com>2023-11-20 14:17:52 +0200
committeromagdy7 <omar.professional8777@gmail.com>2023-11-20 14:17:52 +0200
commitb25419f76f1b325319d7d303d69eca6de77b8fb0 (patch)
tree86fd013007a7d61bd28e875dfa5a7789cd091d13 /lib
parent868ac401d5e0a45d6b66bea813dda4241d93dbcc (diff)
downloadcarpool-b25419f76f1b325319d7d303d69eca6de77b8fb0.tar.xz
carpool-b25419f76f1b325319d7d303d69eca6de77b8fb0.zip
Modified the routes UI and added a simple cart page
Diffstat (limited to 'lib')
-rw-r--r--lib/cart.dart95
-rw-r--r--lib/main.dart43
-rw-r--r--lib/routes.dart68
3 files changed, 193 insertions, 13 deletions
diff --git a/lib/cart.dart b/lib/cart.dart
new file mode 100644
index 0000000..b3d5b0b
--- /dev/null
+++ b/lib/cart.dart
@@ -0,0 +1,95 @@
+import 'package:flutter/material.dart';
+
+// Define a Ride class to represent the selected ride
+class Ride {
+ final String name;
+ final String startLocation;
+ final String endLocation;
+ final String time;
+
+ Ride({
+ required this.name,
+ required this.startLocation,
+ required this.endLocation,
+ required this.time,
+ });
+}
+
+class CartPage extends StatelessWidget {
+ final Ride selectedRide;
+
+ CartPage({required this.selectedRide});
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: const Text('Cart'),
+ ),
+ body: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Card(
+ elevation: 5,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: <Widget>[
+ const Text(
+ 'Selected Ride:',
+ style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
+ ),
+ const SizedBox(height: 12),
+ ListTile(
+ leading: const Icon(Icons.directions_car, color: Colors.blue),
+ title: Text(selectedRide.name),
+ subtitle: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const SizedBox(height: 8),
+ Row(
+ children: [
+ const Icon(Icons.location_on, color: Colors.blue),
+ const SizedBox(width: 4),
+ Text(selectedRide.startLocation),
+ ],
+ ),
+ const SizedBox(height: 4),
+ Row(
+ children: [
+ const Icon(Icons.arrow_forward, color: Colors.blue),
+ const SizedBox(width: 4),
+ Text(selectedRide.endLocation),
+ ],
+ ),
+ const SizedBox(height: 4),
+ Row(
+ children: [
+ const Icon(Icons.access_time, color: Colors.blue),
+ const SizedBox(width: 4),
+ Text(selectedRide.time),
+ ],
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(height: 20),
+ ElevatedButton(
+ onPressed: () {
+ // Implement payment or confirmation logic here
+ // For now, just print a message
+ print('Processing payment/confirmation...');
+ },
+ child: const Text('Proceed to Payment/Confirm'),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/main.dart b/lib/main.dart
index dc8ba74..4aea560 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
-import 'routes.dart';
-import 'login.dart';
+import 'routes.dart'; // Import your RoutesPage file
+import 'login.dart'; // Import your LoginPage file
+import 'cart.dart'; // Import your CartPage file
void main() {
runApp(MyApp());
@@ -15,11 +16,47 @@ class MyApp extends StatelessWidget {
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
- initialRoute: '/routes', // Set the initial route to the login page
+ home: HomePage(), // Set the home page to a custom HomePage widget
routes: {
'/login': (context) => LoginPage(),
'/routes': (context) => RoutesPage(),
+ '/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
},
);
}
}
+
+class HomePage extends StatelessWidget {
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: Text('Select Page for Testing'),
+ ),
+ body: Center(
+ child: DropdownButton<String>(
+ onChanged: (String? route) {
+ if (route != null) {
+ Navigator.pushNamed(context, route);
+ }
+ },
+ items: <String>[
+ '/login',
+ '/routes',
+ '/cart',
+ ].map<DropdownMenuItem<String>>((String value) {
+ return DropdownMenuItem<String>(
+ value: value,
+ child: Text(value),
+ );
+ }).toList(),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/routes.dart b/lib/routes.dart
index 8898922..a1136c9 100644
--- a/lib/routes.dart
+++ b/lib/routes.dart
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
+import 'cart.dart';
+import 'package:intl/intl.dart';
class Route {
final String name;
@@ -15,12 +17,12 @@ class RoutesPage extends StatelessWidget {
final List<Route> dummyRoutes = [
Route(
name: 'Morning Ride - Gate 3 to Abdu-Basha',
- startLocation: 'Gate 3',
- endLocation: 'Abdu-Basha'),
+ startLocation: 'Abassyia',
+ endLocation: 'Abdu-Basha Gate-3'),
Route(
name: 'Afternoon Ride - Abdu-Basha to Gate 3',
- startLocation: 'Abdu-Basha',
- endLocation: 'Gate 3'),
+ startLocation: 'Hadayek Elkoba',
+ endLocation: 'Abdu-Basha Gate-6'),
];
@override
@@ -31,14 +33,60 @@ class RoutesPage extends StatelessWidget {
itemCount: dummyRoutes.length,
itemBuilder: (BuildContext context, int index) {
final Route route = dummyRoutes[index];
- return ListTile(
- title: Text(route.name),
- subtitle:
- Text('From: ${route.startLocation} - To: ${route.endLocation}'),
+ return GestureDetector(
onTap: () {
- // Handle route selection here, if needed
- print('Selected route: ${route.name}');
+ DateTime now = DateTime.now();
+ String formattedDateTime =
+ DateFormat('EEEE dd/MM/yyyy hh:mm a').format(now);
+ Ride selectedRide = Ride(
+ name: route.name,
+ startLocation: route.startLocation,
+ endLocation: route.endLocation,
+ time: formattedDateTime, // Get current time
+ );
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => CartPage(selectedRide: selectedRide),
+ ),
+ );
},
+ child: Card(
+ elevation: 3,
+ margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: ListTile(
+ title: Text(
+ route.name,
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ fontSize: 16,
+ ),
+ ),
+ subtitle: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ children: [
+ Icon(Icons.location_on, color: Colors.blue),
+ SizedBox(width: 4),
+ Flexible(child: Text(route.startLocation)),
+ ],
+ ),
+ Row(
+ children: [
+ Icon(Icons.arrow_forward, color: Colors.blue),
+ SizedBox(width: 4),
+ Flexible(child: Text(route.endLocation)),
+ ],
+ ),
+ ],
+ ),
+ leading: Icon(Icons.directions_car),
+ ),
+ ),
);
},
),