11import 'package:flutter/material.dart' ;
22
3- class BookingDetails extends StatelessWidget {
3+ class BookingDetails extends StatelessWidget {
44 late List <Widget > widgetlist;
55
6- BookingDetails (this .date, this .starttime, this .endtime, {Key ? key}) : super (key: key){
6+ BookingDetails (this .date, this .starttime, this .endtime, {Key ? key})
7+ : super (key: key) {
78 widgetlist = [
89 const ListTile (
910 title: Center (
1011 child: Text (
1112 "Details" ,
12- style: TextStyle (color: Colors .blue, fontFamily: 'Helvetica' , fontSize: 22 , fontWeight: FontWeight .bold),
13+ style: TextStyle (
14+ color: Colors .blue,
15+ fontFamily: 'Helvetica' ,
16+ fontSize: 22 ,
17+ fontWeight: FontWeight .bold),
1318 ),
1419 ),
1520 tileColor: Colors .black,
@@ -22,7 +27,8 @@ class BookingDetails extends StatelessWidget{
2227 ),
2328 title: Text (
2429 "Date: $date " ,
25- style: const TextStyle (color: Colors .white, fontFamily: 'Helvetica' , fontSize: 15 ),
30+ style: const TextStyle (
31+ color: Colors .white, fontFamily: 'Helvetica' , fontSize: 15 ),
2632 ),
2733 tileColor: Colors .black,
2834 ),
@@ -34,172 +40,187 @@ class BookingDetails extends StatelessWidget{
3440 ),
3541 title: Text (
3642 "Time Slot: $starttime Hours to $endtime Hours" ,
37- style: const TextStyle (color: Colors .white, fontFamily: 'Helvetica' , fontSize: 15 ),
43+ style: const TextStyle (
44+ color: Colors .white, fontFamily: 'Helvetica' , fontSize: 15 ),
3845 ),
3946 tileColor: Colors .black,
4047 ),
4148 const ListTile (
4249 title: Center (
4350 child: Text (
4451 "Available Carpools" ,
45- style: TextStyle (color: Colors .blue, fontFamily: 'Helvetica' , fontSize: 22 , fontWeight: FontWeight .bold),
52+ style: TextStyle (
53+ color: Colors .blue,
54+ fontFamily: 'Helvetica' ,
55+ fontSize: 22 ,
56+ fontWeight: FontWeight .bold),
4657 ),
4758 ),
4859 tileColor: Colors .black,
4960 ),
5061 ];
51- }
62+ }
5263
5364 final String date;
5465 final String starttime;
5566 final String endtime;
56- List <String > carpools = ["Ishaan Jalan" , "Rudransh Dixit" , "hewwo" , "manda" , "ramesh" , "mukesh" , "sukesh" , "nilesh" ];
57-
67+ List <String > carpools = [
68+ "Ishaan Jalan" ,
69+ "Rudransh Dixit" ,
70+ "hewwo" ,
71+ "manda" ,
72+ "ramesh" ,
73+ "mukesh" ,
74+ "sukesh" ,
75+ "nilesh"
76+ ];
5877
5978 @override
6079 Widget build (BuildContext context) {
6180 avlblcarpools ();
6281 return Scaffold (
6382 appBar: AppBar (
64- title: Column (
65- mainAxisAlignment: MainAxisAlignment .center,
66- crossAxisAlignment: CrossAxisAlignment .start,
67-
68- children: const [
69- Text (
70- "ShareCab" ,
71- style: TextStyle (color: Colors .white, fontSize: 16.0 ),
72- ),
73- Text (
74- "Booking Details" ,
75- style: TextStyle (color: Colors .white, fontSize: 14.0 ),
76- )
77- ],
83+ title: Column (
84+ mainAxisAlignment: MainAxisAlignment .center,
85+ crossAxisAlignment: CrossAxisAlignment .start,
86+ children: const [
87+ Text (
88+ "ShareCab" ,
89+ style: TextStyle (color: Colors .white, fontSize: 16.0 ),
7890 ),
79- leadingWidth: 70 ,
80- leading: FloatingActionButton (
91+ Text (
92+ "Booking Details" ,
93+ style: TextStyle (color: Colors .white, fontSize: 14.0 ),
94+ )
95+ ],
96+ ),
97+ leadingWidth: 70 ,
98+ leading: FloatingActionButton (
8199 shape: RoundedRectangleBorder (
82100 borderRadius: BorderRadius .circular (30 ),
83101 ),
84102 heroTag: "button1" ,
85- onPressed: (){
103+ onPressed: () {
86104 Navigator .pop (context);
87105 },
88106 backgroundColor: Colors .black,
89- child: Row (
107+ child: Row (
90108 children: < Widget > [
91- Icon (Icons .arrow_back,
92- color: Colors .white),
109+ Icon (Icons .arrow_back, color: Colors .white),
93110 CircleAvatar (
94- backgroundImage: AssetImage ('assets/logo.png' ),
95- backgroundColor: Colors .black,
96- ),
97- ],)),
98- backgroundColor : Colors .black ,
99- shape : const Border (
100- bottom : BorderSide (
101- color : Color ( 0xFF424242 ),
102- )
103- ),
111+ backgroundImage: AssetImage ('assets/logo.png' ),
112+ backgroundColor: Colors .black,
113+ ),
114+ ],
115+ )) ,
116+ backgroundColor : Colors .black,
117+ shape : const Border (
118+ bottom : BorderSide (
119+ color : Color ( 0xFF424242 ),
120+ ) ),
104121 ),
105122 backgroundColor: Colors .black,
106123 floatingActionButton: FloatingActionButton (
107- heroTag: "button2" ,
108- onPressed: (){
109- Navigator .push (context, MaterialPageRoute (builder: (context) => AlertDialog (
110- backgroundColor: Color (0xFF212121 ),
111- shape: RoundedRectangleBorder (
112- borderRadius: BorderRadius .circular (14 ),
113- ),
114- title: const Center (
115- child: Text (
116- 'Cancel Booking' ,
117- style: TextStyle (color: Colors .white, fontSize: 18 ),
118- ),
119- ),// To display the title it is optional
120- content: const Text (
121- 'Are you sure you want to cancel the booking?' ,
122- style: TextStyle (color: Colors .white),
123- ), // Message which will be pop up on the screen
124- // Action widget which will provide the user to acknowledge the choice
125- actions: [
126- TextButton ( // FlatButton widget is used to make a text to work like a button
127- onPressed: () {
128- Navigator .pop (context);
129- Navigator .pop (context);
130- }, // function used to perform after pressing the button
131- child: const Text (
132- 'YES' ,
133- style: TextStyle (color: Colors .red),
124+ heroTag: "button2" ,
125+ onPressed: () {
126+ Navigator .push (
127+ context,
128+ MaterialPageRoute (
129+ builder: (context) => AlertDialog (
130+ backgroundColor: Color (0xFF212121 ),
131+ shape: RoundedRectangleBorder (
132+ borderRadius: BorderRadius .circular (14 ),
134133 ),
135- ),
136- TextButton (
137- onPressed: () {
138- Navigator .pop (context);
139- },
140- child: const Text (
134+ title: const Center (
135+ child: Text (
136+ 'Cancel Booking' ,
137+ style: TextStyle (color: Colors .white, fontSize: 18 ),
138+ ),
139+ ), // To display the title it is optional
140+ content: const Text (
141+ 'Are you sure you want to cancel the booking?' ,
142+ style: TextStyle (color: Colors .white),
143+ ), // Message which will be pop up on the screen
144+ // Action widget which will provide the user to acknowledge the choice
145+ actions: [
146+ TextButton (
147+ // FlatButton widget is used to make a text to work like a button
148+ onPressed: () {
149+ //DB deletion strategy same as home.dart
150+ Navigator .pop (context);
151+ Navigator .pop (context);
152+ }, // function used to perform after pressing the button
153+ child: const Text (
154+ 'YES' ,
155+ style: TextStyle (color: Colors .red),
156+ ),
157+ ),
158+ TextButton (
159+ onPressed: () {
160+ Navigator .pop (context);
161+ },
162+ child: const Text (
141163 'NO' ,
142164 style: TextStyle (color: Colors .green),
165+ ),
143166 ),
167+ ],
168+ ),
144169 ),
145- ],
146- ),
147- ),
148170 );
149- },
150- backgroundColor: Colors .red,
151- child: const Icon (
152- Icons .delete,
153- color: Colors .white,
154- )
171+ },
172+ backgroundColor: Colors .red,
173+ child: const Icon (
174+ Icons .delete,
175+ color: Colors .white,
176+ )),
177+ body: Scrollbar (
178+ child: ListView (
179+ scrollDirection: Axis .vertical,
180+ shrinkWrap: true ,
181+ padding: EdgeInsets .all (5 ),
182+ children: widgetlist,
183+ ),
155184 ),
156- body: Scrollbar (
157- child: ListView (
158- scrollDirection: Axis .vertical,
159- shrinkWrap: true ,
160- padding: EdgeInsets .all (5 ),
161- children: widgetlist,
162- ),
163- ),
164185 );
165186 }
166187
167- void avlblcarpools (){
168- if (carpools.length!= 0 ){
169- for (int i= 0 ; i< carpools.length; i++ ){
170-
188+ void avlblcarpools () {
189+ if (carpools.length != 0 ) {
190+ for (int i = 0 ; i < carpools.length; i++ ) {
171191 String name = carpools[i];
172- widgetlist.add (
173- ListTile (
174- leading: const Icon (
175- Icons .person,
176- color: Colors .blue,
177- size: 22 ,
178- ),
179- title: Text (
180- name,
181- style: const TextStyle (color : Colors .white, fontFamily : 'Helvetica' , fontSize : 15 ),
182- ),
183- tileColor : Colors .black ,
184- shape : RoundedRectangleBorder (
185- borderRadius : BorderRadius . circular ( 12 ),
186- ),
187- ),
188- );
189- }
190- }
191- else {
192+ widgetlist.add (
193+ ListTile (
194+ leading: const Icon (
195+ Icons .person,
196+ color: Colors .blue,
197+ size: 22 ,
198+ ),
199+ title: Text (
200+ name,
201+ style: const TextStyle (
202+ color : Colors .white, fontFamily : 'Helvetica' , fontSize : 15 ),
203+ ) ,
204+ tileColor : Colors .black,
205+ shape : RoundedRectangleBorder (
206+ borderRadius : BorderRadius . circular ( 12 ),
207+ ),
208+ ),
209+ );
210+ }
211+ } else {
192212 widgetlist.add (
193- const ListTile (
194- title: Center (
213+ const ListTile (
214+ title: Center (
195215 child: Text (
196- "Sorry, there are no carpools available in your time slot" ,
197- style: TextStyle (color: Colors .white, fontFamily: 'Helvetica' , fontSize: 15 ),
216+ "Sorry, there are no carpools available in your time slot" ,
217+ style: TextStyle (
218+ color: Colors .white, fontFamily: 'Helvetica' , fontSize: 15 ),
219+ ),
198220 ),
221+ tileColor: Colors .black,
199222 ),
200- tileColor: Colors .black,
201- ),
202223 );
203224 }
204225 }
205- }
226+ }
0 commit comments