summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/cart.dart95
-rw-r--r--lib/main.dart43
-rw-r--r--lib/routes.dart68
-rw-r--r--pubspec.lock8
-rw-r--r--pubspec.yaml1
5 files changed, 202 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),
+ ),
+ ),
);
},
),
diff --git a/pubspec.lock b/pubspec.lock
index 8890429..2e10497 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -75,6 +75,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ intl:
+ dependency: "direct main"
+ description:
+ name: intl
+ sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.18.1"
lints:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 1c9dcb5..dc78338 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -35,6 +35,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
+ intl: ^0.18.1
dev_dependencies:
flutter_test: