@@ -117,7 +117,8 @@ class _CalendarScreenState extends State<CalendarScreen> {
117117 vertical: 16.0 ,
118118 horizontal: 8.0 ,
119119 ),
120- child: BlocBuilder <MonthlySchedulesBloc , MonthlySchedulesState >(
120+ child:
121+ BlocBuilder <MonthlySchedulesBloc , MonthlySchedulesState >(
121122 builder: (context, state) {
122123 if (state.status == MonthlySchedulesStatus .error) {
123124 return Text (AppLocalizations .of (context)! .error);
@@ -229,14 +230,26 @@ class _CalendarScreenState extends State<CalendarScreen> {
229230 BlocBuilder <MonthlySchedulesBloc , MonthlySchedulesState >(
230231 builder: (context, state) {
231232 if (state.schedules[_selectedDate]? .isEmpty ?? true ) {
232- if (state.status == MonthlySchedulesStatus .loading) {
233+ if (state.status ==
234+ MonthlySchedulesStatus .loading) {
233235 return const CircularProgressIndicator ();
234236 }
235237
236- if (state.status != MonthlySchedulesStatus .success) {
238+ if (state.status !=
239+ MonthlySchedulesStatus .success) {
237240 return const SizedBox ();
238241 }
239242
243+ final now = DateTime .now ();
244+ final today =
245+ DateTime (now.year, now.month, now.day);
246+ final selected = DateTime (
247+ _selectedDate.year,
248+ _selectedDate.month,
249+ _selectedDate.day,
250+ );
251+ final isPastSelectedDay = selected.isBefore (today);
252+
240253 return Padding (
241254 padding: const EdgeInsets .all (39.0 ),
242255 child: Column (
@@ -248,44 +261,50 @@ class _CalendarScreenState extends State<CalendarScreen> {
248261 color: theme.colorScheme.outlineVariant,
249262 ),
250263 ),
251- ElevatedButton (
252- onPressed: () {
253- showModalBottomSheet (
254- context: context,
255- isScrollControlled: true ,
256- backgroundColor: Colors .transparent,
257- builder: (context) =>
258- const ScheduleCreateScreen (),
259- );
260- },
261- style: ElevatedButton .styleFrom (
262- backgroundColor: theme.colorScheme.surface,
263- side: BorderSide (
264- width: 0.5 ,
265- color: theme.colorScheme.outlineVariant,
266- ),
267- padding: const EdgeInsets .symmetric (
268- vertical: 4.0 ,
269- horizontal: 12.0 ,
264+ if (! isPastSelectedDay)
265+ ElevatedButton (
266+ onPressed: () {
267+ showModalBottomSheet (
268+ context: context,
269+ isScrollControlled: true ,
270+ backgroundColor: Colors .transparent,
271+ builder: (context) =>
272+ ScheduleCreateScreen (
273+ initialDate: _selectedDate,
274+ ),
275+ );
276+ },
277+ style: ElevatedButton .styleFrom (
278+ backgroundColor:
279+ theme.colorScheme.surface,
280+ side: BorderSide (
281+ width: 0.5 ,
282+ color:
283+ theme.colorScheme.outlineVariant,
284+ ),
285+ padding: const EdgeInsets .symmetric (
286+ vertical: 4.0 ,
287+ horizontal: 12.0 ,
288+ ),
270289 ),
271- ),
272- child : Text (
273- AppLocalizations . of (context) !
274- .addAppointment,
275- style : textTheme.bodyMedium ? . copyWith (
276- color :
277- theme.colorScheme.onSurfaceVariant ,
290+ child : Text (
291+ AppLocalizations . of (context) !
292+ .addAppointment,
293+ style : textTheme.bodyMedium ? . copyWith (
294+ color : theme
295+ .colorScheme.onSurfaceVariant,
296+ ) ,
278297 ),
279298 ),
280- ),
281299 ],
282300 ),
283301 );
284302 }
285303
286304 return Expanded (
287305 child: ListView .builder (
288- itemCount: state.schedules[_selectedDate]? .length ?? 0 ,
306+ itemCount:
307+ state.schedules[_selectedDate]? .length ?? 0 ,
289308 itemBuilder: (context, index) {
290309 final schedule =
291310 state.schedules[_selectedDate]! [index];
0 commit comments