@@ -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" );
0 commit comments