From 577ed9784887c1cfd1535f10ab62d056fcb668b2 Mon Sep 17 00:00:00 2001 From: mohammad Date: Tue, 2 Jul 2024 15:02:07 +0300 Subject: [PATCH] door lock changes --- .../bloc/smart_door_bloc/smart_door_bloc.dart | 98 ++++- .../smart_door_bloc/smart_door_event.dart | 17 +- .../view/widgets/name_time_widget.dart | 117 ++++++ .../smart_door/create_temporary_password.dart | 385 +++++------------- .../widgets/smart_door/repeat_widget.dart | 135 ++++++ .../smart_door/temporary_password_page.dart | 12 +- .../smart_door/view_temporary_password.dart | 12 +- .../widgets/scene_view_widget/scene_item.dart | 7 +- 8 files changed, 461 insertions(+), 322 deletions(-) create mode 100644 lib/features/devices/view/widgets/name_time_widget.dart create mode 100644 lib/features/devices/view/widgets/smart_door/repeat_widget.dart 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 811953d..23ce31f 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,7 +31,25 @@ class SmartDoorBloc extends Bloc { on(generate7DigitNumber); on(selectTime); on(deletePassword); + on(generateAndSavePasswordTimeLimited); + on(generateAndSavePasswordOneTime); } + + + TextEditingController passwordController = TextEditingController(); + TextEditingController passwordNameController = TextEditingController(); + String effectiveTime = 'Select Time'; + int? effectiveTimeTimeStamp; + String expirationTime = 'Select Time'; + int? expirationTimeTimeStamp; + bool repeat = false; + bool isStartEndTime = true; + List? selectedDay; + DateTime? startTime; + DateTime? endTime; + List? temporaryPasswords = []; + List? oneTimePasswords = []; + void _fetchSmartDoorStatus(InitialEvent event, Emitter emit) async { try { emit(LoadingInitialState()); @@ -58,8 +76,6 @@ class SmartDoorBloc extends Bloc { } else if (response is Map && response.containsKey('data')) { temporaryPasswords = (response['data'] as List).map((item) => TemporaryPassword.fromJson(item)).toList(); - } else { - throw Exception("Unexpected response format"); } emit(TemporaryPasswordsLoadedState(temporaryPassword: temporaryPasswords!)); } catch (e) { @@ -67,20 +83,6 @@ class SmartDoorBloc extends Bloc { } } - TextEditingController passwordController = TextEditingController(); - TextEditingController passwordNameController = TextEditingController(); - String effectiveTime = 'Select Time'; - int? effectiveTimeTimeStamp; - String expirationTime = 'Select Time'; - int? expirationTimeTimeStamp; - bool repeat = false; - bool isStartEndTime = true; - List? selectedDay; - DateTime? startTime; - DateTime? endTime; - List? temporaryPasswords = []; - List? oneTimePasswords = []; - changeTime(ChangeTimeEvent event, Emitter emit) { emit(LoadingInitialState()); if (event.isStartEndTime == true) { @@ -225,6 +227,66 @@ class SmartDoorBloc extends Bloc { isSavingPassword = false; } } + + Future generateAndSavePasswordTimeLimited (GenerateAndSavePasswordTimeLimitEvent event, Emitter emit) async { + if (_validateInputs() || isSavingPassword) return; + try { + isSavingPassword = true; + emit(LoadingSaveState()); + var res = await DevicesAPI.createPassword( + pageType: pageType, + deviceId: deviceId, + effectiveTime: effectiveTimeTimeStamp.toString(), + invalidTime: expirationTimeTimeStamp.toString(), + name: passwordNameController.text, + password: passwordController.text, + scheduleList: [ + if (repeat) + Schedule( + effectiveTime: getTimeOnly(startTime), + invalidTime: getTimeOnly(endTime).toString(), + workingDay: selectedDay!, + ), + ], + ); + CustomSnackBar.displaySnackBar('Save Successfully'); + emit(SaveState()); + } catch (_) {}finally { + isSavingPassword = false; + } + } + Future generateAndSavePasswordOneTime (GenerateAndSavePasswordOneTimeEvent event, Emitter emit) async { + try { + if (passwordNameController.text.isEmpty) { + CustomSnackBar.displaySnackBar('Password name required'); + }else { + if (isSavingPassword) return; + isSavingPassword = true; + emit(LoadingSaveState()); + var res = await DevicesAPI.createPassword( + pageType: pageType, + deviceId: deviceId, + effectiveTime: effectiveTimeTimeStamp.toString(), + invalidTime: expirationTimeTimeStamp.toString(), + name: passwordNameController.text, + password: passwordController.text, + scheduleList: [ + if (repeat) + Schedule( + effectiveTime: getTimeOnly(startTime), + invalidTime: getTimeOnly(endTime).toString(), + workingDay: selectedDay!, + ), + ], + ); + CustomSnackBar.displaySnackBar('Save Successfully'); + emit(SaveState()); + } + } catch (_) {}finally { + isSavingPassword = false; + } + } + Future deletePassword(DeletePasswordEvent event, Emitter emit) async { try { emit(LoadingInitialState()); @@ -239,11 +301,11 @@ class SmartDoorBloc extends Bloc { } bool _validateInputs() { - if (passwordController.text.length < 7) { + if (passwordController.text.length < 7 && pageType=='Online Password') { CustomSnackBar.displaySnackBar('Password less than 7'); return true; } - if (passwordController.text.isEmpty) { + if (passwordController.text.isEmpty && pageType=='Online Password') { CustomSnackBar.displaySnackBar('Password required'); return true; } diff --git a/lib/features/devices/bloc/smart_door_bloc/smart_door_event.dart b/lib/features/devices/bloc/smart_door_bloc/smart_door_event.dart index df138ae..e6172a2 100644 --- a/lib/features/devices/bloc/smart_door_bloc/smart_door_event.dart +++ b/lib/features/devices/bloc/smart_door_bloc/smart_door_event.dart @@ -28,8 +28,23 @@ class SavePasswordEvent extends SmartDoorEvent { @override List get props => [context]; } +class GenerateAndSavePasswordTimeLimitEvent extends SmartDoorEvent { + final BuildContext context; + const GenerateAndSavePasswordTimeLimitEvent({required this.context}); + @override + List get props => [context]; +} -class GeneratePasswordEvent extends SmartDoorEvent {} +class GenerateAndSavePasswordOneTimeEvent extends SmartDoorEvent { + final BuildContext context; + const GenerateAndSavePasswordOneTimeEvent({required this.context}); + @override + List get props => [context]; +} + +class GeneratePasswordEvent extends SmartDoorEvent { + +} class SelectTimeEvent extends SmartDoorEvent { final BuildContext context; final bool isEffective; diff --git a/lib/features/devices/view/widgets/name_time_widget.dart b/lib/features/devices/view/widgets/name_time_widget.dart new file mode 100644 index 0000000..9302ced --- /dev/null +++ b/lib/features/devices/view/widgets/name_time_widget.dart @@ -0,0 +1,117 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart'; +import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_event.dart'; +import 'package:syncrow_app/features/shared_widgets/default_container.dart'; +import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart'; +import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; + +class NameTimeWidget extends StatelessWidget { + final String type; + const NameTimeWidget({super.key,required this.type}); + + @override + Widget build(BuildContext context) { + return DefaultContainer( + padding: const EdgeInsets.all(20), + child: Column( + children: [ + 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)), + )), + ], + ), + if(type!='One-Time') + Column( + children: [ + 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), + ), + )), + ],), + ), + 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), + ), + ), + ), + ], + ), + ), + ], + ), + ], + )); + } +} 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 0cf50f7..98c063e 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 @@ -1,4 +1,3 @@ -import 'package:day_picker/day_picker.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -7,6 +6,9 @@ import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart'; import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_event.dart'; import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_state.dart'; +import 'package:syncrow_app/features/devices/view/widgets/name_time_widget.dart'; +import 'package:syncrow_app/features/devices/view/widgets/smart_door/repeat_widget.dart'; +import 'package:syncrow_app/features/shared_widgets/default_button.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart'; @@ -14,12 +16,10 @@ import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dar import 'package:syncrow_app/utils/helpers/snack_bar.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; import 'package:syncrow_app/utils/resource_manager/font_manager.dart'; -import 'package:time_picker_spinner/time_picker_spinner.dart'; class CreateTemporaryPassword extends StatelessWidget { final String? deviceId; final String? type; - const CreateTemporaryPassword({super.key, this.deviceId, this.type}); @override Widget build(BuildContext context) { @@ -46,19 +46,19 @@ class CreateTemporaryPassword extends StatelessWidget { ), leading: IconButton( onPressed: () { - Navigator.of(context).pop('UpdatePage'); + Navigator.of(context).pop(true); }, icon: const Icon(Icons.arrow_back) ), - actions: [ + actions: + type == 'Online Password'?[ TextButton( onPressed: () { - BlocProvider.of(context) - .add(SavePasswordEvent(context: context)); + BlocProvider.of(context).add(SavePasswordEvent(context: context)); }, child: const Text('Save') ) - ], + ]:null, ), child: state is LoadingInitialState ? const Center(child: CircularProgressIndicator()) @@ -82,181 +82,80 @@ class CreateTemporaryPassword extends StatelessWidget { ), DefaultContainer( padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 15), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.max, - children: [ - Flexible( - flex: 2, - child: PinCodeTextField( - onCompleted: (value) { - if (value.split('').every((char) => char == '1')) { - BlocProvider.of(context).passwordController.clear(); - CustomSnackBar.displaySnackBar('All characters cannot be 1.'); - } - }, - 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, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: type == 'Online Password'?0:25), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + children: [ + Flexible( + flex: 2, + child: PinCodeTextField( + onCompleted: (value) { + if (value.split('').every((char) => char == '1')) { + BlocProvider.of(context).passwordController.clear(); + CustomSnackBar.displaySnackBar('All characters cannot be 1.'); + } + }, + autoDisposeControllers: false, + keyboardType: TextInputType.phone, + length: 7, + enabled:type == 'Online Password'? true:false, + 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, + ), + if(type == 'Online Password') + Flexible( + child: 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( + if(BlocProvider.of(context).passwordController.text.isNotEmpty) + TextButton( onPressed: () async { await Clipboard.setData(ClipboardData( - text: BlocProvider.of(context) - .passwordController - .text)); + text: BlocProvider.of(context).passwordController.text)); }, - child: const Text('Copy')) - : const SizedBox(), + child: const Text('Copy') + ), const SizedBox( height: 20, ), + NameTimeWidget(type:type!), + const SizedBox( + height: 20, + ), + type == 'Online Password'? DefaultContainer( - padding: const EdgeInsets.all(20), - child: Column( - children: [ - 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), - ), - )), - ], - ), - ), - 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, @@ -269,130 +168,38 @@ class CreateTemporaryPassword extends StatelessWidget { child: CupertinoSwitch( value: BlocProvider.of(context).repeat, onChanged: (value) { - BlocProvider.of(context) - .add(ToggleRepeatEvent()); + BlocProvider.of(context).add(ToggleRepeatEvent()); }, applyTheme: true, )), ), + ) : + Center( + child: SizedBox( + width: MediaQuery.of(context).size.width/1.5, + child: DefaultButton( + isLoading: BlocProvider.of(context).isSavingPassword , + borderRadius: 30, + backgroundColor:Colors.blueGrey , + onPressed: () { + if(type =='Time-Limited'){ + BlocProvider.of(context).add(GenerateAndSavePasswordTimeLimitEvent(context: context)); + }else{ + BlocProvider.of(context).add(GenerateAndSavePasswordOneTimeEvent(context: context)); + } + }, + child: const BodyMedium( + text: 'Generate & Save Password', + fontWeight: FontWeight.normal, + fontColor: Colors.white, + ),), ), + ), 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; - }, - ), - ], - )) + ? RepeatWidget() : const SizedBox(), const SizedBox( height: 40, @@ -404,3 +211,5 @@ class CreateTemporaryPassword extends StatelessWidget { })); } } + + diff --git a/lib/features/devices/view/widgets/smart_door/repeat_widget.dart b/lib/features/devices/view/widgets/smart_door/repeat_widget.dart new file mode 100644 index 0000000..5371db2 --- /dev/null +++ b/lib/features/devices/view/widgets/smart_door/repeat_widget.dart @@ -0,0 +1,135 @@ + + +import 'package:day_picker/day_picker.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart'; +import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_event.dart'; +import 'package:syncrow_app/features/shared_widgets/default_container.dart'; +import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart'; +import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; +import 'package:time_picker_spinner/time_picker_spinner.dart'; + + +class RepeatWidget extends StatelessWidget { + const RepeatWidget({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return 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; + }, + ), + ], + )); + } +} 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 3b9718f..8a7f7e8 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 @@ -46,7 +46,11 @@ class TemporaryPasswordPage extends StatelessWidget { fontWeight: FontWeight.normal, ), onTap: () { - Navigator.of(context).push(MaterialPageRoute(builder: (context) => ViewTemporaryPassword(deviceId:deviceId,type:'Online Password'),)); + Navigator.of(context).push(MaterialPageRoute(builder: (context) => + ViewTemporaryPassword( + deviceId:deviceId, + type:'Online Password'), + )); }, trailing: const Icon( Icons.arrow_forward_ios, @@ -57,7 +61,6 @@ class TemporaryPasswordPage extends StatelessWidget { ), ], ), - const SizedBox(height: 10), Column( mainAxisAlignment: MainAxisAlignment.start, @@ -76,7 +79,8 @@ class TemporaryPasswordPage extends StatelessWidget { const SizedBox(height: 10), DefaultContainer( padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 20), - child: Column(children: [ + child: Column( + children: [ ListTile( contentPadding: EdgeInsets.zero, leading: SvgPicture.asset(Assets.oneTimePassword), @@ -87,7 +91,6 @@ class TemporaryPasswordPage extends StatelessWidget { ), onTap: () { Navigator.of(context).push(MaterialPageRoute(builder: (context) => ViewTemporaryPassword(deviceId:deviceId,type:'One-Time'),)); - }, trailing: const Icon( Icons.arrow_forward_ios, @@ -95,7 +98,6 @@ class TemporaryPasswordPage extends StatelessWidget { size: 15, ), ), - const Divider(color:ColorsManager.graysColor,), ListTile( contentPadding: EdgeInsets.zero, diff --git a/lib/features/devices/view/widgets/smart_door/view_temporary_password.dart b/lib/features/devices/view/widgets/smart_door/view_temporary_password.dart index 75350e4..fcad19f 100644 --- a/lib/features/devices/view/widgets/smart_door/view_temporary_password.dart +++ b/lib/features/devices/view/widgets/smart_door/view_temporary_password.dart @@ -32,7 +32,8 @@ class ViewTemporaryPassword extends StatelessWidget { ), ); } - }, builder: (context, state) { + }, + builder: (context, state) { final smartDoorBloc = BlocProvider.of(context); return DefaultScaffold( title: 'Passwords', @@ -47,7 +48,8 @@ class ViewTemporaryPassword extends StatelessWidget { } }); }, - icon: const Icon(Icons.add)) + icon: const Icon(Icons.add) + ) ], child: Builder( builder: (context) { @@ -68,8 +70,7 @@ class ViewTemporaryPassword extends StatelessWidget { leading: SvgPicture.asset( Assets.timeLimitedPasswordIcon), title: BodyMedium( - text: - 'Password Name: ${smartDoorBloc.temporaryPasswords![index].name}', + text: 'Password Name: ${smartDoorBloc.temporaryPasswords![index].name}', fontWeight: FontWeight.normal, ), onTap: () async { @@ -110,6 +111,7 @@ class ViewTemporaryPassword extends StatelessWidget { ); }, )); - })); + }) + ); } } diff --git a/lib/features/scene/widgets/scene_view_widget/scene_item.dart b/lib/features/scene/widgets/scene_view_widget/scene_item.dart index 1830475..ad75c73 100644 --- a/lib/features/scene/widgets/scene_view_widget/scene_item.dart +++ b/lib/features/scene/widgets/scene_view_widget/scene_item.dart @@ -36,8 +36,7 @@ class SceneItem extends StatelessWidget { sceneName: scene.name, ), ); - BlocProvider.of(context) - .add(FetchSceneTasksEvent(sceneId: scene.id)); + BlocProvider.of(context).add(FetchSceneTasksEvent(sceneId: scene.id)); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -55,9 +54,7 @@ class SceneItem extends StatelessWidget { IconButton( padding: EdgeInsets.zero, onPressed: () { - context - .read() - .add(SceneTrigger(scene.id, scene.name)); + context.read().add(SceneTrigger(scene.id, scene.name)); }, icon: isLoading ? const Center(