|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | + |
| 3 | +class addbooking extends StatelessWidget { |
| 4 | + late List<Widget> widgetlist; |
| 5 | + |
| 6 | + addbooking(this.date, this.starttime, this.endtime, {Key? key}) |
| 7 | + : super(key: key) { |
| 8 | + widgetlist = [ |
| 9 | + const ListTile( |
| 10 | + title: Center( |
| 11 | + child: Text( |
| 12 | + "Details", |
| 13 | + style: TextStyle( |
| 14 | + color: Colors.blue, |
| 15 | + fontFamily: 'Helvetica', |
| 16 | + fontSize: 22, |
| 17 | + fontWeight: FontWeight.bold), |
| 18 | + ), |
| 19 | + ), |
| 20 | + tileColor: Colors.black, |
| 21 | + ), |
| 22 | + ListTile( |
| 23 | + leading: const Icon( |
| 24 | + Icons.calendar_today_sharp, |
| 25 | + color: Colors.blue, |
| 26 | + size: 22, |
| 27 | + ), |
| 28 | + title: Text( |
| 29 | + "Date: $date", |
| 30 | + style: const TextStyle( |
| 31 | + color: Colors.white, fontFamily: 'Helvetica', fontSize: 15), |
| 32 | + ), |
| 33 | + tileColor: Colors.black, |
| 34 | + ), |
| 35 | + ListTile( |
| 36 | + leading: const Icon( |
| 37 | + Icons.lock_clock, |
| 38 | + color: Colors.blue, |
| 39 | + size: 22, |
| 40 | + ), |
| 41 | + title: Text( |
| 42 | + "Time Slot: $starttime Hours to $endtime Hours", |
| 43 | + style: const TextStyle( |
| 44 | + color: Colors.white, fontFamily: 'Helvetica', fontSize: 15), |
| 45 | + ), |
| 46 | + tileColor: Colors.black, |
| 47 | + ), |
| 48 | + const ListTile( |
| 49 | + title: Center( |
| 50 | + child: Text( |
| 51 | + "Available Carpools", |
| 52 | + style: TextStyle( |
| 53 | + color: Colors.blue, |
| 54 | + fontFamily: 'Helvetica', |
| 55 | + fontSize: 22, |
| 56 | + fontWeight: FontWeight.bold), |
| 57 | + ), |
| 58 | + ), |
| 59 | + tileColor: Colors.black, |
| 60 | + ), |
| 61 | + ]; |
| 62 | + } |
| 63 | + |
| 64 | + final String date; |
| 65 | + final String starttime; |
| 66 | + final String endtime; |
| 67 | + List<String> carpools = [ |
| 68 | + "Ishaan Jalan", |
| 69 | + "Rudransh Dixit", |
| 70 | + "hewwo", |
| 71 | + "manda", |
| 72 | + "ramesh", |
| 73 | + "mukesh", |
| 74 | + "sukesh", |
| 75 | + "nilesh" |
| 76 | + ]; |
| 77 | + |
| 78 | + @override |
| 79 | + Widget build(BuildContext context) { |
| 80 | + avlblcarpools(); |
| 81 | + return Scaffold( |
| 82 | + appBar: AppBar( |
| 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), |
| 90 | + ), |
| 91 | + Text( |
| 92 | + "New Booking Details", |
| 93 | + style: TextStyle(color: Colors.white, fontSize: 14.0), |
| 94 | + ) |
| 95 | + ], |
| 96 | + ), |
| 97 | + leadingWidth: 70, |
| 98 | + leading: FloatingActionButton( |
| 99 | + shape: RoundedRectangleBorder( |
| 100 | + borderRadius: BorderRadius.circular(30), |
| 101 | + ), |
| 102 | + heroTag: "button1", |
| 103 | + onPressed: () { |
| 104 | + Navigator.pop(context); |
| 105 | + }, |
| 106 | + backgroundColor: Colors.black, |
| 107 | + child: Row( |
| 108 | + children: <Widget>[ |
| 109 | + Icon(Icons.arrow_back, color: Colors.white), |
| 110 | + CircleAvatar( |
| 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 | + )), |
| 121 | + ), |
| 122 | + backgroundColor: Colors.black, |
| 123 | + floatingActionButton: FloatingActionButton( |
| 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), |
| 133 | + ), |
| 134 | + title: const Center( |
| 135 | + child: Text( |
| 136 | + 'Confirmation', |
| 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 book this slot?', |
| 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.green), |
| 156 | + ), |
| 157 | + ), |
| 158 | + TextButton( |
| 159 | + onPressed: () { |
| 160 | + Navigator.pop(context); |
| 161 | + }, |
| 162 | + child: const Text( |
| 163 | + 'NO', |
| 164 | + style: TextStyle(color: Colors.red), |
| 165 | + ), |
| 166 | + ), |
| 167 | + ], |
| 168 | + ), |
| 169 | + ), |
| 170 | + ); |
| 171 | + }, |
| 172 | + backgroundColor: Colors.green[700], |
| 173 | + child: const Icon( |
| 174 | + Icons.add, |
| 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 | + ), |
| 184 | + ), |
| 185 | + ); |
| 186 | + } |
| 187 | + |
| 188 | + void avlblcarpools() { |
| 189 | + if (carpools.length != 0) { |
| 190 | + for (int i = 0; i < carpools.length; i++) { |
| 191 | + String name = carpools[i]; |
| 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 { |
| 212 | + widgetlist.add( |
| 213 | + const ListTile( |
| 214 | + title: Center( |
| 215 | + child: Text( |
| 216 | + "Sorry, there are no carpools available in your time slot", |
| 217 | + style: TextStyle( |
| 218 | + color: Colors.white, fontFamily: 'Helvetica', fontSize: 15), |
| 219 | + ), |
| 220 | + ), |
| 221 | + tileColor: Colors.black, |
| 222 | + ), |
| 223 | + ); |
| 224 | + } |
| 225 | + } |
| 226 | +} |
0 commit comments