summaryrefslogtreecommitdiff
path: root/lib/routes.dart
blob: a1136c9208021ff07069d1ca1f06817e4b3eb73d (plain)
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
import 'package:flutter/material.dart';
import 'cart.dart';
import 'package:intl/intl.dart';

class Route {
  final String name;
  final String startLocation;
  final String endLocation;

  Route(
      {required this.name,
      required this.startLocation,
      required this.endLocation});
}

class RoutesPage extends StatelessWidget {
  final List<Route> dummyRoutes = [
    Route(
        name: 'Morning Ride - Gate 3 to Abdu-Basha',
        startLocation: 'Abassyia',
        endLocation: 'Abdu-Basha Gate-3'),
    Route(
        name: 'Afternoon Ride - Abdu-Basha to Gate 3',
        startLocation: 'Hadayek Elkoba',
        endLocation: 'Abdu-Basha Gate-6'),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Routes')),
      body: ListView.builder(
        itemCount: dummyRoutes.length,
        itemBuilder: (BuildContext context, int index) {
          final Route route = dummyRoutes[index];
          return GestureDetector(
            onTap: () {
              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),
              ),
            ),
          );
        },
      ),
    );
  }
}