From 0fa6693c6caeaac24cda127135d0a710322e17f8 Mon Sep 17 00:00:00 2001 From: mohammad Date: Sun, 30 Jun 2024 23:04:28 +0300 Subject: [PATCH 1/6] fix bugs on create password --- .../bloc/smart_door_bloc/smart_door_bloc.dart | 24 +++--- .../smart_door/create_temporary_password.dart | 74 +++++++++---------- .../smart_door/temporary_password_page.dart | 2 +- lib/utils/resource_manager/color_manager.dart | 1 + 4 files changed, 50 insertions(+), 51 deletions(-) diff --git a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart index 0259855..18d7b9f 100644 --- a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart +++ b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart @@ -147,6 +147,7 @@ class SmartDoorBloc extends Bloc { final TimeOfDay? timePicked = await showTimePicker( context: event.context, initialTime: TimeOfDay.now(), + ); if (timePicked != null) { final selectedDateTime = DateTime( @@ -156,23 +157,28 @@ class SmartDoorBloc extends Bloc { timePicked.hour, timePicked.minute, ); + // Convert selectedDateTime to a timestamp without seconds and milliseconds + final selectedTimestamp = DateTime( + selectedDateTime.year, + selectedDateTime.month, + selectedDateTime.day, + selectedDateTime.hour, + selectedDateTime.minute, + ).millisecondsSinceEpoch ~/ 1000; // Divide by 1000 to remove milliseconds if (event.isEffective) { if (expirationTimeTimeStamp != null && - selectedDateTime.millisecondsSinceEpoch > - expirationTimeTimeStamp!) { + selectedTimestamp > expirationTimeTimeStamp!) { CustomSnackBar.displaySnackBar('Effective Time cannot be later than Expiration Time.'); } else { - effectiveTime = selectedDateTime.toString(); - effectiveTimeTimeStamp = selectedDateTime.millisecondsSinceEpoch; + effectiveTime = selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds + effectiveTimeTimeStamp = selectedTimestamp; } } else { - if (effectiveTimeTimeStamp != null && - selectedDateTime.millisecondsSinceEpoch < - effectiveTimeTimeStamp!) { + if (effectiveTimeTimeStamp != null && selectedTimestamp < effectiveTimeTimeStamp!) { CustomSnackBar.displaySnackBar('Expiration Time cannot be earlier than Effective Time.'); } else { - expirationTime = selectedDateTime.toString(); - expirationTimeTimeStamp = selectedDateTime.millisecondsSinceEpoch; + expirationTime = selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds + expirationTimeTimeStamp = selectedTimestamp; } } emit(TimeSelectedState()); diff --git a/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart b/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart index fd2af90..d3628cf 100644 --- a/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart +++ b/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart @@ -146,11 +146,10 @@ class CreateTemporaryPassword extends StatelessWidget { child: TextFormField( controller: BlocProvider.of(context).passwordNameController, - decoration: const InputDecoration( - labelText: 'Enter The Name'), + decoration: const InputDecoration(hintText: 'Enter The Name'), )), ), - const Divider(color:Color(0xffEBEBEB),), + const Divider(color:ColorsManager.graysColor,), ListTile( contentPadding: EdgeInsets.zero, leading: const BodyMedium( @@ -169,7 +168,7 @@ class CreateTemporaryPassword extends StatelessWidget { ), )), ), - const Divider(color:Color(0xffEBEBEB),), + const Divider(color:ColorsManager.graysColor,), ListTile( contentPadding: EdgeInsets.zero, leading: const BodyMedium( @@ -183,9 +182,6 @@ class CreateTemporaryPassword extends StatelessWidget { child: InkWell( onTap: () { BlocProvider.of(context)..add(SelectTimeEvent(context: context, isEffective: false)); - // BlocProvider.of(context) - // .selectTime(context, - // isEffective: false); }, child: Text( BlocProvider.of(context) @@ -239,60 +235,56 @@ class CreateTemporaryPassword extends StatelessWidget { onTap: () { BlocProvider.of(context).add(const SetStartEndTimeEvent(val: true)); }, - child: BodyMedium(text: 'Start',fontColor:BlocProvider.of(context).isStartEndTime==false? Colors.black:Colors.blue,fontSize: 18,), + child: BodyMedium(text: 'Start', + fontColor: BlocProvider.of(context).isStartEndTime==false? + Colors.black:Colors.blue,fontSize: 18,), ), - InkWell( onTap: () { BlocProvider.of(context).add(const SetStartEndTimeEvent(val: false)); - - }, - child: BodyMedium(text: 'End',fontColor:BlocProvider.of(context).isStartEndTime? Colors.black:Colors.blue,fontSize: 18,), + }, + child:BodyMedium(text: 'End', + fontColor:BlocProvider.of(context).isStartEndTime? + Colors.black:Colors.blue,fontSize: 18,), ) ], ), ), - const Divider(color:Color(0xffEBEBEB),), + const Divider(color:ColorsManager.graysColor,), Container( - height: 80, - child: - Container( - height: 90, - child:BlocProvider.of(context).isStartEndTime? TimePickerSpinner( - time: - BlocProvider.of(context).startTime, + height: 110, + child:BlocProvider.of(context).isStartEndTime? + TimePickerSpinner( + time: BlocProvider.of(context).startTime, + is24HourMode: false, + itemHeight: 40, + normalTextStyle: const TextStyle( + color: Colors.grey, + fontSize: 24, + ), + highlightedTextStyle: const TextStyle( + fontSize: 30, color: Colors.blue), + onTimeChange: (time) { + BlocProvider.of(context).add(ChangeTimeEvent(val: time, isStartEndTime: BlocProvider.of(context).isStartEndTime)); + }, + ): Container( + child: TimePickerSpinner( + time: BlocProvider.of(context).endTime, is24HourMode: false, itemHeight: 40, normalTextStyle: const TextStyle( + color: Colors.grey, fontSize: 24, ), highlightedTextStyle: const TextStyle( fontSize: 30, color: Colors.blue), onTimeChange: (time) { - - // BlocProvider.of(context).changeTime(time, BlocProvider.of(context).isStartEndTime); BlocProvider.of(context).add(ChangeTimeEvent(val: time, isStartEndTime: BlocProvider.of(context).isStartEndTime)); - }, - ): Container( - child: TimePickerSpinner( - time: BlocProvider.of(context).endTime, - is24HourMode: false, - itemHeight: 40, - normalTextStyle: const TextStyle( - fontSize: 24, - ), - highlightedTextStyle: const TextStyle( - fontSize: 30, color: Colors.blue), - onTimeChange: (time) { - BlocProvider.of(context).add(ChangeTimeEvent(val: time, isStartEndTime: BlocProvider.of(context).isStartEndTime)); - - // BlocProvider.of(context).changeTime(time, BlocProvider.of(context).isStartEndTime); - }, - ), + }, ), - ) + ), ), - const Divider(color:Color(0xffEBEBEB),), + const Divider(color:ColorsManager.graysColor,), const SizedBox(height: 20), SelectWeekDays( width: MediaQuery.of(context).size.width / 1, diff --git a/lib/features/devices/view/widgets/smart_door/temporary_password_page.dart b/lib/features/devices/view/widgets/smart_door/temporary_password_page.dart index ae9ad6b..3b9718f 100644 --- a/lib/features/devices/view/widgets/smart_door/temporary_password_page.dart +++ b/lib/features/devices/view/widgets/smart_door/temporary_password_page.dart @@ -96,7 +96,7 @@ class TemporaryPasswordPage extends StatelessWidget { ), ), - const Divider( ), + const Divider(color:ColorsManager.graysColor,), ListTile( contentPadding: EdgeInsets.zero, leading: SvgPicture.asset( diff --git a/lib/utils/resource_manager/color_manager.dart b/lib/utils/resource_manager/color_manager.dart index 7815e27..3e16f78 100644 --- a/lib/utils/resource_manager/color_manager.dart +++ b/lib/utils/resource_manager/color_manager.dart @@ -22,4 +22,5 @@ abstract class ColorsManager { static const Color blackColor = Color(0xFF000000); static const Color lightGreen = Color(0xFF00FF0A); static const Color grayColor = Color(0xFF999999); + static const Color graysColor = Color(0xffEBEBEB); } From 53c33187f4b37585f0cdcbda05d1ed6764363c29 Mon Sep 17 00:00:00 2001 From: mohammad Date: Sun, 30 Jun 2024 23:15:01 +0300 Subject: [PATCH 2/6] fix bugs on create password --- .../bloc/smart_door_bloc/smart_door_bloc.dart | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart index 18d7b9f..6ea1507 100644 --- a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart +++ b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart @@ -12,6 +12,7 @@ import 'package:syncrow_app/features/devices/model/create_temporary_password_mod import 'package:syncrow_app/features/devices/model/temporary_password_model.dart'; import 'package:syncrow_app/services/api/devices_api.dart'; import 'package:syncrow_app/utils/helpers/snack_bar.dart'; +import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; class SmartDoorBloc extends Bloc { final String deviceId; @@ -144,10 +145,30 @@ class SmartDoorBloc extends Bloc { lastDate: DateTime(2101), ); if (picked != null) { - final TimeOfDay? timePicked = await showTimePicker( + final TimeOfDay? timePicked = + await showTimePicker( context: event.context, - initialTime: TimeOfDay.now(), + initialTime: TimeOfDay(hour: 10, minute: 47), + builder: (context, child) { + return Theme( + data: ThemeData.light().copyWith( + colorScheme: ColorScheme.light( + // change the border color + primary: ColorsManager.primaryColor, + // change the text color + onSurface: Colors.black, + ), + // button colors + buttonTheme: ButtonThemeData( + colorScheme: ColorScheme.light( + primary: Colors.green, + ), + ), + ), + child: child!, + ); + }, ); if (timePicked != null) { final selectedDateTime = DateTime( From baae756acc2fe42dbeb61d4bb78722f8f5e6f873 Mon Sep 17 00:00:00 2001 From: mohammad Date: Sun, 30 Jun 2024 23:19:00 +0300 Subject: [PATCH 3/6] fix bugs on create password --- .../bloc/smart_door_bloc/smart_door_bloc.dart | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart index 6ea1507..e5f7391 100644 --- a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart +++ b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart @@ -146,21 +146,17 @@ class SmartDoorBloc extends Bloc { ); if (picked != null) { final TimeOfDay? timePicked = - await showTimePicker( + await showTimePicker( context: event.context, - initialTime: TimeOfDay(hour: 10, minute: 47), + initialTime: TimeOfDay.now(), builder: (context, child) { return Theme( - data: ThemeData.light().copyWith( - colorScheme: ColorScheme.light( - // change the border color + colorScheme: const ColorScheme.light( primary: ColorsManager.primaryColor, - // change the text color onSurface: Colors.black, ), - // button colors - buttonTheme: ButtonThemeData( + buttonTheme: const ButtonThemeData( colorScheme: ColorScheme.light( primary: Colors.green, ), From 675c98443a1e54fa534c0d29adb6cddf7c1109c9 Mon Sep 17 00:00:00 2001 From: mohammad Date: Sun, 30 Jun 2024 23:52:12 +0300 Subject: [PATCH 4/6] fix bugs on create password --- .../smart_door/create_temporary_password.dart | 114 +++++++++++------- lib/utils/resource_manager/color_manager.dart | 1 + 2 files changed, 70 insertions(+), 45 deletions(-) diff --git a/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart b/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart index d3628cf..d0ab14d 100644 --- a/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart +++ b/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart @@ -135,58 +135,81 @@ class CreateTemporaryPassword extends StatelessWidget { padding: const EdgeInsets.all(20), child: Column( children: [ - ListTile( - contentPadding: EdgeInsets.zero, - leading: const BodyMedium( - text: 'Password Name', - fontWeight: FontWeight.normal, - ), - trailing: SizedBox( - width: MediaQuery.of(context).size.width / 2, - child: TextFormField( - controller: - BlocProvider.of(context).passwordNameController, - decoration: const InputDecoration(hintText: 'Enter The Name'), - )), - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + + children: [ + Expanded( + child: Container( + child: const BodyMedium( + text: 'Password Name', + fontWeight: FontWeight.normal, + ), + ), + ) , + SizedBox( + width: MediaQuery.of(context).size.width / 2.6, + child: TextFormField( + controller: + BlocProvider.of(context).passwordNameController, + decoration: const InputDecoration(hintText: 'Enter The Name',hintStyle: + TextStyle(fontSize: 14,color: ColorsManager.textGray)), + )),], + ), const Divider(color:ColorsManager.graysColor,), + Padding( + padding: const EdgeInsets.all(10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + + children: [ + const Expanded( + child: BodyMedium( + text: 'Effective Time', + fontWeight: FontWeight.normal, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: InkWell( + onTap: () { + BlocProvider.of(context)..add(SelectTimeEvent(context: context, isEffective: true)); + }, + child: Text( + BlocProvider.of(context).effectiveTime,style: TextStyle(fontSize: 14,color:BlocProvider.of(context) + .expirationTime!='Select Time'?ColorsManager.blackColor:ColorsManager.textGray),), + )), + ], + ), + ), const Divider(color:ColorsManager.graysColor,), - ListTile( - contentPadding: EdgeInsets.zero, - leading: const BodyMedium( - text: 'Effective Time', - fontWeight: FontWeight.normal, - ), - trailing: SizedBox( - width: MediaQuery.of(context).size.width / 2, - child: InkWell( - onTap: () { - BlocProvider.of(context)..add(SelectTimeEvent(context: context, isEffective: true)); - // .selectTime(context, isEffective: true); - }, - child: Text( - BlocProvider.of(context).effectiveTime + Padding( + padding: const EdgeInsets.all(10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Expanded( + child: BodyMedium( + text: 'Expiration Time', + fontWeight: FontWeight.normal, ), - )), - ), - const Divider(color:ColorsManager.graysColor,), - ListTile( - contentPadding: EdgeInsets.zero, - leading: const BodyMedium( - text: 'Expiration Time', - fontWeight: FontWeight.normal, - ), - trailing: SizedBox( - width: MediaQuery.of(context).size.width / 2, - child: SizedBox( - width: MediaQuery.of(context).size.width / 2, + ), + SizedBox( + width: MediaQuery.of(context).size.width / 4, child: InkWell( onTap: () { BlocProvider.of(context)..add(SelectTimeEvent(context: context, isEffective: false)); }, child: Text( - BlocProvider.of(context) - .expirationTime), - )), + BlocProvider.of(context) + .expirationTime,style: TextStyle(fontSize: 14,color: + + + BlocProvider.of(context) + .expirationTime!='Select Time'?ColorsManager.blackColor:ColorsManager.textGray),), + ), + ), + ], + ), ), ], @@ -260,6 +283,7 @@ class CreateTemporaryPassword extends StatelessWidget { itemHeight: 40, normalTextStyle: const TextStyle( color: Colors.grey, + fontSize: 24, ), highlightedTextStyle: const TextStyle( diff --git a/lib/utils/resource_manager/color_manager.dart b/lib/utils/resource_manager/color_manager.dart index 3e16f78..6c0ea6b 100644 --- a/lib/utils/resource_manager/color_manager.dart +++ b/lib/utils/resource_manager/color_manager.dart @@ -23,4 +23,5 @@ abstract class ColorsManager { static const Color lightGreen = Color(0xFF00FF0A); static const Color grayColor = Color(0xFF999999); static const Color graysColor = Color(0xffEBEBEB); + static const Color textGray = Color(0xffD5D5D5); } From 0695c0306e4938e40be2ffd6b21df63ea2cc0df0 Mon Sep 17 00:00:00 2001 From: mohammad Date: Mon, 1 Jul 2024 00:32:51 +0300 Subject: [PATCH 5/6] fix bugs on create password --- .../smart_door/create_temporary_password.dart | 16 +++---- .../view/widgets/smart_door/door_dialog.dart | 43 +++++++++++++------ 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart b/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart index d0ab14d..d7bedc3 100644 --- a/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart +++ b/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart @@ -152,8 +152,7 @@ class CreateTemporaryPassword extends StatelessWidget { child: TextFormField( controller: BlocProvider.of(context).passwordNameController, - decoration: const InputDecoration(hintText: 'Enter The Name',hintStyle: - TextStyle(fontSize: 14,color: ColorsManager.textGray)), + decoration: const InputDecoration(hintText: 'Enter The Name',hintStyle: TextStyle(fontSize: 14,color: ColorsManager.textGray)), )),], ), const Divider(color:ColorsManager.graysColor,), Padding( @@ -169,14 +168,13 @@ class CreateTemporaryPassword extends StatelessWidget { ), ), SizedBox( - width: MediaQuery.of(context).size.width / 4, + width: MediaQuery.of(context).size.width / 3.5, child: InkWell( onTap: () { BlocProvider.of(context)..add(SelectTimeEvent(context: context, isEffective: true)); }, child: Text( - BlocProvider.of(context).effectiveTime,style: TextStyle(fontSize: 14,color:BlocProvider.of(context) - .expirationTime!='Select Time'?ColorsManager.blackColor:ColorsManager.textGray),), + BlocProvider.of(context).effectiveTime,style: TextStyle(fontSize: 14,color: ColorsManager.textGray),), )), ], ), @@ -194,18 +192,14 @@ class CreateTemporaryPassword extends StatelessWidget { ), ), SizedBox( - width: MediaQuery.of(context).size.width / 4, + width: MediaQuery.of(context).size.width / 3.5, child: InkWell( onTap: () { BlocProvider.of(context)..add(SelectTimeEvent(context: context, isEffective: false)); }, child: Text( BlocProvider.of(context) - .expirationTime,style: TextStyle(fontSize: 14,color: - - - BlocProvider.of(context) - .expirationTime!='Select Time'?ColorsManager.blackColor:ColorsManager.textGray),), + .expirationTime,style: TextStyle(fontSize: 14,color: ColorsManager.textGray),), ), ), ], diff --git a/lib/features/devices/view/widgets/smart_door/door_dialog.dart b/lib/features/devices/view/widgets/smart_door/door_dialog.dart index 022a20e..867cbd1 100644 --- a/lib/features/devices/view/widgets/smart_door/door_dialog.dart +++ b/lib/features/devices/view/widgets/smart_door/door_dialog.dart @@ -32,10 +32,15 @@ class DoorDialogState extends State { @override Widget build(BuildContext context) { final DateTime effectiveDateTime = - DateTime.fromMillisecondsSinceEpoch(widget.value.effectiveTime); + DateTime.fromMillisecondsSinceEpoch(widget.value.effectiveTime * 1000, isUtc: true); + String formattedDateEffectiveTime = DateFormat('yyyy-MM-dd').format(effectiveDateTime); + String formattedTimeEffectiveTime = DateFormat('HH:mm:ss').format(effectiveDateTime); + final DateTime expiredDateTime = - DateTime.fromMillisecondsSinceEpoch(widget.value.invalidTime); - final DateFormat formatter = DateFormat('HH:mm'); + DateTime.fromMillisecondsSinceEpoch(widget.value.invalidTime * 1000, isUtc: true); + String formattedDateExpiredDateTime = DateFormat('yyyy-MM-dd').format(expiredDateTime); + String formattedTimeExpiredDateTime = DateFormat('HH:mm:ss').format(expiredDateTime); + return Dialog( child: Container( decoration: BoxDecoration( @@ -73,15 +78,32 @@ class DoorDialogState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text('Effective Time :'), - Text(formatter.format(effectiveDateTime)), + const Text('Effective Date:'), + Text(formattedDateEffectiveTime), ], ), + SizedBox(height: 8), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text('Expired Time :'), - Text(formatter.format(expiredDateTime)), + const Text('Effective Time:'), + Text(formattedTimeEffectiveTime), + ], + ), + SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text('Expired Date:'), + Text(formattedDateExpiredDateTime), + ], + ), + SizedBox(height: 8), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text('Expired Time:'), + Text(formattedTimeExpiredDateTime), ], ), ], @@ -102,8 +124,7 @@ class DoorDialogState extends State { child: Center( child: BodyMedium( text: 'Cancel', - style: context.bodyMedium - .copyWith(color: ColorsManager.greyColor), + style: context.bodyMedium.copyWith(color: ColorsManager.greyColor), ), ), ), @@ -115,13 +136,11 @@ class DoorDialogState extends State { InkWell( onTap: () { Navigator.pop(context, 'delete'); - }, child: Center( child: BodyMedium( text: 'Delete Password', - style: context.bodyMedium.copyWith( - color: ColorsManager.primaryColorWithOpacity), + style: context.bodyMedium.copyWith(color: ColorsManager.primaryColorWithOpacity), ), ), ), From b3bfe9deccf8173ba596e6aca0786f6b6e24c128 Mon Sep 17 00:00:00 2001 From: Abdullah Alassaf Date: Mon, 1 Jul 2024 01:08:20 +0300 Subject: [PATCH 6/6] Design enhancments --- .../bloc/smart_door_bloc/smart_door_bloc.dart | 82 +-- .../smart_door_bloc/smart_door_state.dart | 31 +- .../smart_door/create_temporary_password.dart | 598 ++++++++++-------- 3 files changed, 386 insertions(+), 325 deletions(-) diff --git a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart index e5f7391..37c3bf4 100644 --- a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart +++ b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart @@ -31,8 +31,7 @@ class SmartDoorBloc extends Bloc { on(selectTime); on(deletePassword); } - void _fetchSmartDoorStatus( - InitialEvent event, Emitter emit) async { + void _fetchSmartDoorStatus(InitialEvent event, Emitter emit) async { try { emit(LoadingInitialState()); var response = await DevicesAPI.getDeviceStatus(deviceId); @@ -48,24 +47,20 @@ class SmartDoorBloc extends Bloc { } } - void getTemporaryPasswords( - InitialPasswordsPage event, Emitter emit) async { + void getTemporaryPasswords(InitialPasswordsPage event, Emitter emit) async { try { emit(LoadingInitialState()); pageType = event.type!; var response = await DevicesAPI.getTemporaryPasswords(deviceId, pageType); if (response is List) { - temporaryPasswords = - response.map((item) => TemporaryPassword.fromJson(item)).toList(); + temporaryPasswords = response.map((item) => TemporaryPassword.fromJson(item)).toList(); } else if (response is Map && response.containsKey('data')) { - temporaryPasswords = (response['data'] as List) - .map((item) => TemporaryPassword.fromJson(item)) - .toList(); + temporaryPasswords = + (response['data'] as List).map((item) => TemporaryPassword.fromJson(item)).toList(); } else { throw Exception("Unexpected response format"); } - emit(TemporaryPasswordsLoadedState( - temporaryPassword: temporaryPasswords!)); + emit(TemporaryPasswordsLoadedState(temporaryPassword: temporaryPasswords!)); } catch (e) { emit(FailedState(errorMessage: e.toString())); } @@ -92,7 +87,7 @@ class SmartDoorBloc extends Bloc { } else { endTime = event.val; } - emit(changeTimeState()); + emit(ChangeTimeState()); } bool toggleRepeat(ToggleRepeatEvent event, Emitter emit) { @@ -102,7 +97,6 @@ class SmartDoorBloc extends Bloc { return repeat; } - bool setStartEndTime(SetStartEndTimeEvent event, Emitter emit) { emit(LoadingInitialState()); isStartEndTime = event.val; @@ -114,10 +108,7 @@ class SmartDoorBloc extends Bloc { emit(LoadingNewSate(smartDoorModel: deviceStatus)); try { final response = await DevicesAPI.controlDevice( - DeviceControlModel( - deviceId: deviceId, - code: 'normal_open_switch', - value: !event.value), + DeviceControlModel(deviceId: deviceId, code: 'normal_open_switch', value: !event.value), deviceId); if (response['success'] ?? false) { @@ -138,6 +129,7 @@ class SmartDoorBloc extends Bloc { } Future selectTime(SelectTimeEvent event, Emitter emit) async { + emit(ChangeTimeState()); final DateTime? picked = await showDatePicker( context: event.context, initialDate: DateTime.now(), @@ -145,8 +137,7 @@ class SmartDoorBloc extends Bloc { lastDate: DateTime(2101), ); if (picked != null) { - final TimeOfDay? timePicked = - await showTimePicker( + final TimeOfDay? timePicked = await showTimePicker( context: event.context, initialTime: TimeOfDay.now(), builder: (context, child) { @@ -176,25 +167,28 @@ class SmartDoorBloc extends Bloc { ); // Convert selectedDateTime to a timestamp without seconds and milliseconds final selectedTimestamp = DateTime( - selectedDateTime.year, - selectedDateTime.month, - selectedDateTime.day, - selectedDateTime.hour, - selectedDateTime.minute, - ).millisecondsSinceEpoch ~/ 1000; // Divide by 1000 to remove milliseconds + selectedDateTime.year, + selectedDateTime.month, + selectedDateTime.day, + selectedDateTime.hour, + selectedDateTime.minute, + ).millisecondsSinceEpoch ~/ + 1000; // Divide by 1000 to remove milliseconds if (event.isEffective) { - if (expirationTimeTimeStamp != null && - selectedTimestamp > expirationTimeTimeStamp!) { + if (expirationTimeTimeStamp != null && selectedTimestamp > expirationTimeTimeStamp!) { CustomSnackBar.displaySnackBar('Effective Time cannot be later than Expiration Time.'); } else { - effectiveTime = selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds + effectiveTime = + selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds effectiveTimeTimeStamp = selectedTimestamp; } } else { if (effectiveTimeTimeStamp != null && selectedTimestamp < effectiveTimeTimeStamp!) { - CustomSnackBar.displaySnackBar('Expiration Time cannot be earlier than Effective Time.'); + CustomSnackBar.displaySnackBar( + 'Expiration Time cannot be earlier than Effective Time.'); } else { - expirationTime = selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds + expirationTime = + selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds expirationTimeTimeStamp = selectedTimestamp; } } @@ -206,8 +200,8 @@ class SmartDoorBloc extends Bloc { Future savePassword(SavePasswordEvent event, Emitter emit) async { if (_validateInputs()) return; try { - emit(LoadingSaveState()); - var res = await DevicesAPI.createPassword( + emit(LoadingSaveState()); + var res = await DevicesAPI.createPassword( pageType: pageType, deviceId: deviceId, effectiveTime: effectiveTimeTimeStamp.toString(), @@ -223,20 +217,18 @@ class SmartDoorBloc extends Bloc { ), ], ); - Navigator.of(event.context).pop(true); - CustomSnackBar.displaySnackBar('Save Successfully'); - emit(SaveState()); - - } catch (_) { - } + Navigator.of(event.context).pop(true); + CustomSnackBar.displaySnackBar('Save Successfully'); + emit(SaveState()); + } catch (_) {} } Future deletePassword(DeletePasswordEvent event, Emitter emit) async { try { emit(LoadingInitialState()); - var response = await DevicesAPI.deletePassword( - deviceId: deviceId, passwordId: event.passwordId) - .then((value) async { + var response = + await DevicesAPI.deletePassword(deviceId: deviceId, passwordId: event.passwordId) + .then((value) async { add(InitialPasswordsPage(type: pageType)); }); } catch (e) { @@ -245,7 +237,7 @@ class SmartDoorBloc extends Bloc { } bool _validateInputs() { - if (passwordController.text.length<7) { + if (passwordController.text.length < 7) { CustomSnackBar.displaySnackBar('Password less than 7'); return true; } @@ -265,16 +257,13 @@ class SmartDoorBloc extends Bloc { CustomSnackBar.displaySnackBar('Select expiration time'); return true; } - if (repeat == true && - (endTime == null || startTime == null || selectedDay == null)) { + if (repeat == true && (endTime == null || startTime == null || selectedDay == null)) { CustomSnackBar.displaySnackBar('Start Time and End time and the days required '); return true; } return false; } - - List days = [ DayInWeek("S", dayKey: 'Sun'), DayInWeek("M", dayKey: 'Mon'), @@ -289,5 +278,4 @@ class SmartDoorBloc extends Bloc { if (dateTime == null) return ''; return DateFormat('HH:mm').format(dateTime); } - } diff --git a/lib/features/devices/bloc/smart_door_bloc/smart_door_state.dart b/lib/features/devices/bloc/smart_door_bloc/smart_door_state.dart index 473a768..29b1d94 100644 --- a/lib/features/devices/bloc/smart_door_bloc/smart_door_state.dart +++ b/lib/features/devices/bloc/smart_door_bloc/smart_door_state.dart @@ -38,16 +38,25 @@ class FailedState extends SmartDoorState { List get props => [errorMessage]; } -class GeneratePasswordState extends SmartDoorState{} -class TimeSelectedState extends SmartDoorState{} -class IsRepeatState extends SmartDoorState{} -class IsStartEndState extends SmartDoorState{} -class changeStartTimeState extends SmartDoorState{} -class changeEndTimeState extends SmartDoorState{} -class changeTimeState extends SmartDoorState{} -class SaveState extends SmartDoorState{} -class LoadingSaveState extends SmartDoorState{} -class TemporaryPasswordsLoadedState extends SmartDoorState{ - final List temporaryPassword; +class GeneratePasswordState extends SmartDoorState {} + +class TimeSelectedState extends SmartDoorState {} + +class IsRepeatState extends SmartDoorState {} + +class IsStartEndState extends SmartDoorState {} + +class ChangeStartTimeState extends SmartDoorState {} + +class ChangeEndTimeState extends SmartDoorState {} + +class ChangeTimeState extends SmartDoorState {} + +class SaveState extends SmartDoorState {} + +class LoadingSaveState extends SmartDoorState {} + +class TemporaryPasswordsLoadedState extends SmartDoorState { + final List temporaryPassword; const TemporaryPasswordsLoadedState({required this.temporaryPassword}); } diff --git a/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart b/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart index d7bedc3..1d7e110 100644 --- a/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart +++ b/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart @@ -19,13 +19,12 @@ class CreateTemporaryPassword extends StatelessWidget { final String? deviceId; final String? type; - const CreateTemporaryPassword({super.key,this.deviceId, this.type}); + const CreateTemporaryPassword({super.key, this.deviceId, this.type}); @override Widget build(BuildContext context) { return BlocProvider( create: (BuildContext context) => SmartDoorBloc(deviceId: deviceId!), - child: BlocConsumer( - listener: (context, state) { + child: BlocConsumer(listener: (context, state) { if (state is FailedState) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -34,301 +33,366 @@ class CreateTemporaryPassword extends StatelessWidget { ), ); } - }, - builder: (context, state) { + }, builder: (context, state) { return DefaultScaffold( appBar: AppBar( backgroundColor: Colors.transparent, centerTitle: true, title: const BodyLarge( - text: 'Create Password' , + text: 'Create Password', fontColor: ColorsManager.primaryColor, fontWeight: FontsManager.bold, ), - leading: IconButton(onPressed: () { - Navigator.of(context).pop('UpdatePage'); - }, icon: const Icon(Icons.arrow_back)), + leading: IconButton( + onPressed: () { + Navigator.of(context).pop('UpdatePage'); + }, + icon: const Icon(Icons.arrow_back)), actions: [ TextButton( onPressed: () { - BlocProvider.of(context).add(SavePasswordEvent(context: context)); + BlocProvider.of(context) + .add(SavePasswordEvent(context: context)); }, child: const Text('Save')) ], ), - - child: state is LoadingInitialState? - const Center(child: CircularProgressIndicator()): SingleChildScrollView( - child: - Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const BodyMedium( - text: - 'Save the password immediately. The password is not displayed in the app.', - fontWeight: FontWeight.normal, - fontColor: ColorsManager.grayColor, - ), - const SizedBox( - height: 20, - ), - const BodyMedium( - text: '7-Digit Password', - fontWeight: FontWeight.normal, - fontColor: ColorsManager.grayColor, - ), - DefaultContainer( - padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 15), - child: Row( + child: state is LoadingInitialState + ? const Center(child: CircularProgressIndicator()) + : SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: PinCodeTextField( - autoDisposeControllers: false, - keyboardType: TextInputType.phone, - length: 7, - enabled: true, - obscureText: false, - animationType: AnimationType.fade, - pinTheme: PinTheme( - shape: PinCodeFieldShape.underline, - fieldHeight: 45, - fieldWidth: 20, - activeFillColor: Colors.white, - disabledColor: Colors.grey, - activeColor: Colors.grey, - errorBorderColor: Colors.grey, - inactiveColor: Colors.grey, - inactiveFillColor: Colors.grey, - selectedColor: Colors.grey - ), - animationDuration: Duration(milliseconds: 300), - backgroundColor: Colors.white, - enableActiveFill: false, - controller: BlocProvider.of(context).passwordController, - appContext: context, - )), + const BodyMedium( + text: + 'Save the password immediately. The password is not displayed in the app.', + fontWeight: FontWeight.normal, + fontColor: ColorsManager.grayColor, + ), const SizedBox( - width: 10, + height: 20, ), - InkWell( - onTap: () { - BlocProvider.of(context).add(GeneratePasswordEvent()); - }, - child: const BodyMedium( - text: 'Generate Randomly', - fontWeight: FontWeight.bold, - fontColor: ColorsManager.primaryColor, - )) - ], - ), - ), - BlocProvider.of(context).passwordController.text.isNotEmpty? - TextButton(onPressed: () async { - await Clipboard.setData(ClipboardData(text: BlocProvider.of(context).passwordController.text)); - }, - child: const Text('Copy')):SizedBox(), - const SizedBox( - height: 20, - ), - DefaultContainer( - padding: const EdgeInsets.all(20), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - - children: [ - Expanded( - child: Container( - child: const BodyMedium( - text: 'Password Name', + const BodyMedium( + text: '7-Digit Password', fontWeight: FontWeight.normal, + fontColor: ColorsManager.grayColor, ), - ), - ) , - SizedBox( - width: MediaQuery.of(context).size.width / 2.6, - child: TextFormField( - controller: - BlocProvider.of(context).passwordNameController, - decoration: const InputDecoration(hintText: 'Enter The Name',hintStyle: TextStyle(fontSize: 14,color: ColorsManager.textGray)), - )),], - ), const Divider(color:ColorsManager.graysColor,), - Padding( - padding: const EdgeInsets.all(10.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - - children: [ - const Expanded( - child: BodyMedium( - text: 'Effective Time', - fontWeight: FontWeight.normal, + DefaultContainer( + padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + children: [ + Flexible( + flex: 2, + child: PinCodeTextField( + autoDisposeControllers: false, + keyboardType: TextInputType.phone, + length: 7, + enabled: true, + obscureText: false, + animationType: AnimationType.fade, + pinTheme: PinTheme( + shape: PinCodeFieldShape.underline, + fieldHeight: 45, + fieldWidth: 20, + activeFillColor: Colors.white, + disabledColor: Colors.grey, + activeColor: Colors.grey, + errorBorderColor: Colors.grey, + inactiveColor: Colors.grey, + inactiveFillColor: Colors.grey, + selectedColor: Colors.grey), + animationDuration: const Duration(milliseconds: 300), + backgroundColor: Colors.white, + enableActiveFill: false, + controller: + BlocProvider.of(context).passwordController, + appContext: context, + )), + const SizedBox( + width: 10, + ), + Flexible( + child: InkWell( + onTap: () { + BlocProvider.of(context) + .add(GeneratePasswordEvent()); + }, + child: const BodyMedium( + text: 'Generate Randomly', + fontWeight: FontWeight.bold, + fontColor: ColorsManager.primaryColor, + )), + ) + ], + ), ), - ), - SizedBox( - width: MediaQuery.of(context).size.width / 3.5, - child: InkWell( - onTap: () { - BlocProvider.of(context)..add(SelectTimeEvent(context: context, isEffective: true)); - }, - child: Text( - BlocProvider.of(context).effectiveTime,style: TextStyle(fontSize: 14,color: ColorsManager.textGray),), - )), - ], - ), - ), - const Divider(color:ColorsManager.graysColor,), - Padding( - padding: const EdgeInsets.all(10.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + BlocProvider.of(context).passwordController.text.isNotEmpty + ? TextButton( + onPressed: () async { + await Clipboard.setData(ClipboardData( + text: BlocProvider.of(context) + .passwordController + .text)); + }, + child: const Text('Copy')) + : const SizedBox(), + const SizedBox( + height: 20, + ), + DefaultContainer( + padding: const EdgeInsets.all(20), + child: Column( children: [ - const Expanded( - child: BodyMedium( - text: 'Expiration Time', - fontWeight: FontWeight.normal, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Container( + padding: const EdgeInsets.all(10.0), + child: const BodyMedium( + text: 'Password Name', + fontWeight: FontWeight.normal, + ), + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width / 2.6, + child: TextFormField( + controller: BlocProvider.of(context) + .passwordNameController, + decoration: const InputDecoration( + hintText: 'Enter The Name', + hintStyle: TextStyle( + fontSize: 14, color: ColorsManager.textGray)), + )), + ], + ), + const Divider( + color: ColorsManager.graysColor, + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Expanded( + child: BodyMedium( + text: 'Effective Time', + fontWeight: FontWeight.normal, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width / 3.5, + child: InkWell( + onTap: () { + BlocProvider.of(context).add( + SelectTimeEvent( + context: context, isEffective: true)); + }, + child: Text( + BlocProvider.of(context).effectiveTime, + style: TextStyle( + fontSize: 14, + color: BlocProvider.of(context) + .effectiveTime == + 'Select Time' + ? ColorsManager.textGray + : null), + ), + )), + ], ), ), - SizedBox( - width: MediaQuery.of(context).size.width / 3.5, - child: InkWell( - onTap: () { - BlocProvider.of(context)..add(SelectTimeEvent(context: context, isEffective: false)); - }, - child: Text( - BlocProvider.of(context) - .expirationTime,style: TextStyle(fontSize: 14,color: ColorsManager.textGray),), + const Divider( + color: ColorsManager.graysColor, + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Expanded( + child: BodyMedium( + text: 'Expiration Time', + fontWeight: FontWeight.normal, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width / 3.5, + child: InkWell( + onTap: () { + BlocProvider.of(context).add( + SelectTimeEvent( + context: context, isEffective: false)); + }, + child: Text( + BlocProvider.of(context).expirationTime, + style: TextStyle( + fontSize: 14, + color: BlocProvider.of(context) + .expirationTime == + 'Select Time' + ? ColorsManager.textGray + : null), + ), + ), + ), + ], ), ), ], - + )), + const SizedBox( + height: 20, + ), + if (type == 'Online Password') + DefaultContainer( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + child: ListTile( + contentPadding: EdgeInsets.zero, + leading: const BodyMedium( + text: 'Repeat', + fontWeight: FontWeight.normal, + ), + trailing: Transform.scale( + scale: .8, + child: CupertinoSwitch( + value: BlocProvider.of(context).repeat, + onChanged: (value) { + BlocProvider.of(context) + .add(ToggleRepeatEvent()); + }, + applyTheme: true, + )), ), ), - ], - )), - const SizedBox( - height: 20, - ), - if(type=='Online Password') - DefaultContainer( - padding: - const EdgeInsets.symmetric(horizontal: 5, vertical: 5), - child: ListTile( - contentPadding: EdgeInsets.zero, - leading: const BodyMedium( - text: 'Repeat', - fontWeight: FontWeight.normal, - ), - trailing: Transform.scale( - scale: .8, - child: CupertinoSwitch( - value: - BlocProvider.of(context).repeat, - onChanged: (value) { - BlocProvider.of(context).add(ToggleRepeatEvent()); - }, - applyTheme: true, - )), + const SizedBox( + height: 20, + ), + BlocProvider.of(context).repeat + ? DefaultContainer( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 5), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + onTap: () { + BlocProvider.of(context) + .add(const SetStartEndTimeEvent(val: true)); + }, + child: BodyMedium( + text: 'Start', + fontColor: BlocProvider.of(context) + .isStartEndTime == + false + ? Colors.black + : Colors.blue, + fontSize: 18, + ), + ), + InkWell( + onTap: () { + BlocProvider.of(context) + .add(const SetStartEndTimeEvent(val: false)); + }, + child: BodyMedium( + text: 'End', + fontColor: BlocProvider.of(context) + .isStartEndTime + ? Colors.black + : Colors.blue, + fontSize: 18, + ), + ) + ], + ), + ), + const Divider( + color: ColorsManager.graysColor, + ), + Container( + height: 110, + child: BlocProvider.of(context).isStartEndTime + ? TimePickerSpinner( + time: + BlocProvider.of(context).startTime, + is24HourMode: false, + itemHeight: 40, + normalTextStyle: const TextStyle( + color: Colors.grey, + fontSize: 24, + ), + highlightedTextStyle: + const TextStyle(fontSize: 30, color: Colors.blue), + onTimeChange: (time) { + BlocProvider.of(context).add( + ChangeTimeEvent( + val: time, + isStartEndTime: + BlocProvider.of(context) + .isStartEndTime)); + }, + ) + : Container( + child: TimePickerSpinner( + time: + BlocProvider.of(context).endTime, + is24HourMode: false, + itemHeight: 40, + normalTextStyle: const TextStyle( + color: Colors.grey, + fontSize: 24, + ), + highlightedTextStyle: const TextStyle( + fontSize: 30, color: Colors.blue), + onTimeChange: (time) { + BlocProvider.of(context).add( + ChangeTimeEvent( + val: time, + isStartEndTime: + BlocProvider.of( + context) + .isStartEndTime)); + }, + ), + ), + ), + const Divider( + color: ColorsManager.graysColor, + ), + const SizedBox(height: 20), + SelectWeekDays( + width: MediaQuery.of(context).size.width / 1, + fontSize: 18, + fontWeight: FontWeight.w600, + days: BlocProvider.of(context).days, + border: false, + selectedDayTextColor: Colors.black, + unSelectedDayTextColor: Colors.grey, + boxDecoration: BoxDecoration( + borderRadius: BorderRadius.circular(30.0), + color: Colors.white), + onSelect: (values) { + BlocProvider.of(context).selectedDay = + values; + }, + ), + ], + )) + : const SizedBox(), + const SizedBox( + height: 40, + ) + ], ), ), - const SizedBox( - height: 20, - ), - BlocProvider.of(context).repeat - ? DefaultContainer( - padding: const EdgeInsets.symmetric( - horizontal: 20, vertical: 5), - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - InkWell( - onTap: () { - BlocProvider.of(context).add(const SetStartEndTimeEvent(val: true)); - }, - child: BodyMedium(text: 'Start', - fontColor: BlocProvider.of(context).isStartEndTime==false? - Colors.black:Colors.blue,fontSize: 18,), - ), - InkWell( - onTap: () { - BlocProvider.of(context).add(const SetStartEndTimeEvent(val: false)); - }, - child:BodyMedium(text: 'End', - fontColor:BlocProvider.of(context).isStartEndTime? - Colors.black:Colors.blue,fontSize: 18,), - ) - ], - ), - ), - const Divider(color:ColorsManager.graysColor,), - Container( - height: 110, - child:BlocProvider.of(context).isStartEndTime? - TimePickerSpinner( - time: BlocProvider.of(context).startTime, - is24HourMode: false, - itemHeight: 40, - normalTextStyle: const TextStyle( - color: Colors.grey, - - fontSize: 24, - ), - highlightedTextStyle: const TextStyle( - fontSize: 30, color: Colors.blue), - onTimeChange: (time) { - BlocProvider.of(context).add(ChangeTimeEvent(val: time, isStartEndTime: BlocProvider.of(context).isStartEndTime)); - }, - ): Container( - child: TimePickerSpinner( - time: BlocProvider.of(context).endTime, - is24HourMode: false, - itemHeight: 40, - normalTextStyle: const TextStyle( - color: Colors.grey, - fontSize: 24, - ), - highlightedTextStyle: const TextStyle( - fontSize: 30, color: Colors.blue), - onTimeChange: (time) { - BlocProvider.of(context).add(ChangeTimeEvent(val: time, isStartEndTime: BlocProvider.of(context).isStartEndTime)); - }, - ), - ), - ), - const Divider(color:ColorsManager.graysColor,), - const SizedBox(height: 20), - SelectWeekDays( - width: MediaQuery.of(context).size.width / 1, - fontSize: 18, - fontWeight: FontWeight.w600, - days: BlocProvider.of(context) - .days, - border: false, - selectedDayTextColor: Colors.black, - unSelectedDayTextColor: Colors.grey, - boxDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(30.0), - color: Colors.white), - onSelect: (values) { - BlocProvider.of(context).selectedDay = values; - }, - ), - ], - )) - : SizedBox(), - const SizedBox( - height: 40, - ) - ], - ), - ), ); })); }