Skip to content

Commit c098ac3

Browse files
committed
added user class and a database class and did required changes in LoginForm. COmmented(landing page)
1 parent 7c2a3cb commit c098ac3

File tree

3 files changed

+100
-37
lines changed

3 files changed

+100
-37
lines changed

lib/home.dart

Lines changed: 84 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class Homepage extends State<Home> {
3434
late BookingRecord? curBookingRecord;
3535
late int curIntervalIndex;
3636

37+
List<Widget> widgetlist = [];
38+
3739
bool didOpenDialog = false;
3840

3941
Future<void> OpenDialog() async {
@@ -117,21 +119,43 @@ class Homepage extends State<Home> {
117119
}
118120

119121
void bookings() {
122+
String dt;
123+
var newFormat = DateFormat("yyyy-MM-dd");
124+
dt = newFormat.format(LoginForm.u.present!);
120125
setState(() {
121126
if (curBookingRecord != null) {
122127
if (curBookingRecord!.intervals.isNotEmpty) {
123128
print(0);
124-
presentwidget = Container(
125-
child: ListView.builder(
126-
padding: const EdgeInsets.all(10),
127-
itemCount: curBookingRecord!.intervals.length,
128-
itemBuilder: (BuildContext context, int index) {
129-
//print(LoginForm.u.present);
130-
String starttime = curBookingRecord!.intervals[index].start.toString() + ":00";
131-
String endtime = curBookingRecord!.intervals[index].end.toString() + ":00";
132-
133-
return Container(
134-
margin: const EdgeInsets.all(10),
129+
widgetlist = [
130+
const SizedBox(
131+
height: 10,
132+
),
133+
Center(
134+
child: RichText(
135+
text: TextSpan(
136+
children: [
137+
const WidgetSpan(
138+
child: Icon(Icons.lock_clock, size: 22, color: Colors.blue),
139+
),
140+
TextSpan(
141+
text: " $dt",
142+
style: TextStyle(color: Colors.white, fontSize: 15),
143+
),
144+
],
145+
),
146+
)
147+
),
148+
const SizedBox(
149+
height: 15,
150+
),
151+
];
152+
153+
for(int i=0; i<curBookingRecord!.intervals.length ; i++){
154+
String starttime = curBookingRecord!.intervals[i].start.toString() + ":00";
155+
String endtime = curBookingRecord!.intervals[i].end.toString() + ":00";
156+
widgetlist.add(
157+
Container(
158+
margin: const EdgeInsets.all(5),
135159
child: Card(
136160
shape: RoundedRectangleBorder(
137161
borderRadius: BorderRadius.circular(12),
@@ -145,37 +169,71 @@ class Homepage extends State<Home> {
145169
"Booking Time: $starttime to $endtime",
146170
style: const TextStyle(color: Colors.white),
147171
),
148-
tileColor: Colors.teal,
172+
tileColor: Colors.blue,
149173
shape: RoundedRectangleBorder(
150174
borderRadius: BorderRadius.circular(12),
151175
),
152176
trailing: IconButton(
153177
onPressed: () {
154-
curIntervalIndex = index;
178+
curIntervalIndex = i;
155179
OpenDialog().then((value) => bookings());
156180
},
157181
icon: const Icon(
158182
Icons.more_vert,
159183
color: Colors.white,
160184
))),
161185
),
162-
);
163-
},
164-
),
165-
);
166-
} else {
186+
)
187+
);
188+
}
189+
presentwidget = Scrollbar(
190+
child: ListView(
191+
scrollDirection: Axis.vertical,
192+
shrinkWrap: true,
193+
children: widgetlist,
194+
));
195+
}
196+
} else {
167197
print(1);
168-
presentwidget = Container(
169-
child: const Center(
170-
child: Text(
171-
"You have no bookings available for the selected date.",
172-
style: TextStyle(color: Colors.white, fontFamily: 'Helvetica'),
198+
widgetlist = [
199+
const SizedBox(
200+
height: 10,
173201
),
202+
Center(
203+
child: RichText(
204+
text: TextSpan(
205+
children: [
206+
const WidgetSpan(
207+
child: Icon(Icons.lock_clock, size: 22, color: Colors.blue),
208+
),
209+
TextSpan(
210+
text: " $dt",
211+
style: TextStyle(color: Colors.white, fontSize: 15),
212+
),
213+
],
214+
),
215+
)
216+
),
217+
const SizedBox(
218+
height: 220,
219+
),
220+
const Center(
221+
child: Text(
222+
"You have no bookings available for the selected date.",
223+
style: TextStyle(color: Colors.white, fontFamily: 'Helvetica'),
224+
),
225+
),
226+
];
227+
228+
presentwidget = Scrollbar(
229+
child: ListView(
230+
scrollDirection: Axis.vertical,
231+
shrinkWrap: true,
232+
children: widgetlist,
174233
));
175234
}
176-
}
177-
});
178-
}
235+
});
236+
}
179237

180238
void setbookings() async {
181239
print("setbookings called");

lib/landing.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Landing extends State<TabNavigator>{
106106
},
107107
children: [
108108
Home(),
109-
newBookings(),
109+
Booking(),
110110
],
111111
),
112112
backgroundColor: Colors.black,

lib/newbooking.dart

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
import 'package:flutter/material.dart';
22
import 'package:carpool/LoginForm.dart';
3+
import 'package:carpool/user.dart';
34

5+
class Booking extends StatefulWidget{
46

5-
class newBookings extends StatelessWidget {
6-
newBookings({Key? key}) : super(key: key);
7+
static newBookings newpage = newBookings();
78

9+
@override
10+
newBookings createState() {
11+
newpage = new newBookings();
12+
return newpage;
13+
}
14+
15+
}
16+
17+
class newBookings extends State<Booking>{
18+
19+
late String date;
820
@override
921
Widget build(BuildContext context) {
1022
return Scaffold(
1123
backgroundColor: Colors.black,
1224
);
1325
}
14-
_showCalendar(BuildContext context) async {
15-
LoginForm.u.selected = await showDatePicker(
16-
context: context,
17-
initialDate: DateTime.now(),
18-
firstDate: DateTime(1960),
19-
lastDate: DateTime(2060),
20-
);
21-
}
26+
2227

2328
}

0 commit comments

Comments
 (0)