diff --git a/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart b/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart index 68c33ad..b454060 100644 --- a/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart +++ b/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart @@ -47,6 +47,7 @@ class SixSceneBloc extends Bloc { on(_fetchRoomsAndDevices); on(_onSixSceneInitial); on(deleteDevice); + on(_toggleLowBattery); } final TextEditingController nameController = @@ -101,6 +102,19 @@ class SixSceneBloc extends Bloc { ), ); + bool enableAlarm = false; + + void _toggleLowBattery( + ToggleEnableAlarmEvent event, Emitter emit) async { + emit(LoadingNewSate(device: deviceStatus)); + try { + enableAlarm = event.isLowBatteryEnabled; + emit(UpdateState(device: deviceStatus)); + } catch (e) { + emit(SixSceneFailedState(errorMessage: e.toString())); + } + } + List roomsList = []; void _fetchRoomsAndDevices( diff --git a/lib/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart b/lib/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart index 4987e7a..efb89dd 100644 --- a/lib/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart +++ b/lib/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart @@ -48,6 +48,7 @@ class FourSceneBloc extends Bloc { on(getSceneByName); on(_selectScene); on(deleteDevice); + on(_toggleLowBattery); } final TextEditingController nameController = @@ -144,6 +145,7 @@ class FourSceneBloc extends Bloc { } bool selecedScene = false; + bool enableAlarm = false; String _selectedOption = ''; bool _hasSelectionChanged = false; @@ -259,6 +261,18 @@ class FourSceneBloc extends Bloc { } } + + void _toggleLowBattery( + ToggleEnableAlarmEvent event, Emitter emit) async { + emit(LoadingNewSate(device: deviceStatus)); + try { + enableAlarm = event.isLowBatteryEnabled; + emit(UpdateState(device: deviceStatus)); + } catch (e) { + emit(FourSceneFailedState(errorMessage: e.toString())); + } + } + // void _controlDevice( // ControlDeviceScene event, Emitter emit) async { // emit(FourSceneLoadingState()); @@ -320,7 +334,7 @@ class FourSceneBloc extends Bloc { ToggleNotificationEvent event, Emitter emit) async { emit(LoadingNewSate(device: deviceStatus)); try { - closingReminder = event.isClosingEnabled; + enableAlarm = event.isClosingEnabled; emit(UpdateState(device: deviceStatus)); // API call to update the state, if necessary // await DevicesAPI.controlDevice( @@ -483,6 +497,7 @@ class FourSceneBloc extends Bloc { } emit(UpdateStateList(groupDevices: groupDevices, devices: devices)); } + void _assignDevice( AssignRoomEvent event, Emitter emit) async { try { diff --git a/lib/features/devices/bloc/sos_bloc/sos_bloc.dart b/lib/features/devices/bloc/sos_bloc/sos_bloc.dart index 02d385e..3fcf131 100644 --- a/lib/features/devices/bloc/sos_bloc/sos_bloc.dart +++ b/lib/features/devices/bloc/sos_bloc/sos_bloc.dart @@ -38,12 +38,13 @@ class SosBloc extends Bloc { on(_onSaveSelection); on(_assignDevice); on(fetchDeviceInfo); + on(saveName); // on(_unassignDevice); // on(_toggleWaterLeakAlarm); } final TextEditingController nameController = - TextEditingController(text: '${'firstName'}'); + TextEditingController(text: deviceName); bool isSaving = false; bool editName = false; final FocusNode focusNode = FocusNode(); @@ -52,7 +53,7 @@ class SosBloc extends Bloc { bool closingReminder = false; bool waterAlarm = false; SosModel deviceStatus = - SosModel(sosContactState: 'normal', batteryPercentage: 0); + SosModel(sosContactState: 'sos', batteryPercentage: 0); void _fetchStatus(SosInitial event, Emitter emit) async { emit(SosLoadingState()); @@ -156,16 +157,6 @@ class SosBloc extends Bloc { try { closingReminder = event.isClosingReminderEnabled; emit(UpdateState(sensor: deviceStatus)); - - // API call to update the state, if necessary - // await DevicesAPI.controlDevice( - // DeviceControlModel( - // deviceId: sosId, - // code: 'closing_reminder', - // value: closingReminder, - // ), - // sosId, - // ); } catch (e) { emit(SosFailedState(errorMessage: e.toString())); } diff --git a/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_info_page.dart b/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_info_page.dart index 4d133c8..a031651 100644 --- a/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_info_page.dart +++ b/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_info_page.dart @@ -71,9 +71,13 @@ class SixSceneInfoPage extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - BodySmall( - text: _bloc.deviceInfo.productUuid, - fontColor: ColorsManager.primaryTextColor, + SizedBox( + width: + MediaQuery.of(context).size.width * 0.61, + child: BodySmall( + text: _bloc.deviceInfo.productUuid, + fontColor: ColorsManager.primaryTextColor, + ), ), InkWell( onTap: () { diff --git a/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_settings.dart b/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_settings.dart index 43c5fad..60495e4 100644 --- a/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_settings.dart +++ b/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_settings.dart @@ -194,7 +194,12 @@ class SixSceneSettings extends StatelessWidget { child: Column( children: [ SettingWidget( - onChanged: (p0) {}, + value: _bloc.enableAlarm, + onChanged: (p0) { + context + .read() + .add(ToggleEnableAlarmEvent(p0)); + }, isNotification: true, onTap: () {}, text: 'Offline Notification', @@ -430,6 +435,7 @@ class SixSceneSettings extends StatelessWidget { class SettingWidget extends StatelessWidget { final String? text; final bool? isUpdate; + final bool? value; final bool? isNotification; final String? icon; final Function()? onTap; @@ -440,6 +446,7 @@ class SettingWidget extends StatelessWidget { this.text, this.icon, this.onTap, + this.value, this.isUpdate, this.onChanged, this.isNotification = false, @@ -502,7 +509,7 @@ class SettingWidget extends StatelessWidget { : Transform.scale( scale: .8, child: CupertinoSwitch( - value: true, + value: value!, onChanged: onChanged, applyTheme: true, ), diff --git a/lib/features/devices/view/widgets/6_scene_switch/six_scene_screen.dart b/lib/features/devices/view/widgets/6_scene_switch/six_scene_screen.dart index 294649d..25d929c 100644 --- a/lib/features/devices/view/widgets/6_scene_switch/six_scene_screen.dart +++ b/lib/features/devices/view/widgets/6_scene_switch/six_scene_screen.dart @@ -24,50 +24,54 @@ class SixSceneScreen extends StatelessWidget { @override Widget build(BuildContext context) { - return DefaultScaffold( - title: '6 Scene Switch', - actions: [ - InkWell( - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => SixSceneSettings(device: device!)), - ); - }, - child: SvgPicture.asset(Assets.assetsIconsSettings)), - const SizedBox( - width: 10, - ) - ], - child: BlocProvider( - create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '') - ..add(const SixSceneInitial()) - ..add(const SixSceneInitialInfo()) - ..add(const SexSceneSwitchInitial()), - child: BlocBuilder( - builder: (context, state) { - final _bloc = BlocProvider.of(context); - SixSceneModel model = SixSceneModel( - scene_1: '', - scene_2: '', - scene_3: '', - scene_4: '', - scene_5: '', - scene_6: '', - scene_id_group_id: '', - switch_backlight: ''); + return BlocProvider( + create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '') + ..add(const SixSceneInitial()) + ..add(const SixSceneInitialInfo()) + ..add(const SexSceneSwitchInitial()), + child: BlocBuilder( + builder: (context, state) { + final _bloc = BlocProvider.of(context); - if (state is LoadingNewSate) { - model = state.device; - } else if (state is UpdateState) { - model = state.device; - } - return state is SixSceneLoadingState + SixSceneModel model = SixSceneModel( + scene_1: '', + scene_2: '', + scene_3: '', + scene_4: '', + scene_5: '', + scene_6: '', + scene_id_group_id: '', + switch_backlight: '', + ); + + if (state is LoadingNewSate) { + model = state.device; + } else if (state is UpdateState) { + model = state.device; + } + + return DefaultScaffold( + title: _bloc.deviceInfo.subspace.subspaceName, + actions: [ + InkWell( + onTap: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => SixSceneSettings(device: device!), + ), + ); + }, + child: SvgPicture.asset(Assets.assetsIconsSettings), + ), + const SizedBox(width: 10), + ], + child: state is SixSceneLoadingState ? const Center( child: DefaultContainer( - width: 50, - height: 50, - child: CircularProgressIndicator()), + width: 50, + height: 50, + child: CircularProgressIndicator(), + ), ) : RefreshIndicator( onRefresh: () async { @@ -86,30 +90,24 @@ class SixSceneScreen extends StatelessWidget { switch4Title: model.scene_4, switch5Title: model.scene_5, switch6Title: model.scene_6, - switch1Down: - _bloc.deviceStatus.switch_backlight == true - ? Assets.switchOn - : Assets.switchOff, - switch1Up: - _bloc.deviceStatus.switch_backlight == true - ? Assets.switchOn - : Assets.switchOff, - switch2Down: - _bloc.deviceStatus.switch_backlight == true - ? Assets.switchOn - : Assets.switchOff, - switch2Up: - _bloc.deviceStatus.switch_backlight == true - ? Assets.switchOn - : Assets.switchOff, - switch3Up: - _bloc.deviceStatus.switch_backlight == true - ? Assets.switchOn - : Assets.switchOff, - switch3Down: - _bloc.deviceStatus.switch_backlight == true - ? Assets.switchOn - : Assets.switchOff, + switch1Down: _bloc.deviceStatus.switch_backlight + ? Assets.switchOn + : Assets.switchOff, + switch1Up: _bloc.deviceStatus.switch_backlight + ? Assets.switchOn + : Assets.switchOff, + switch2Down: _bloc.deviceStatus.switch_backlight + ? Assets.switchOn + : Assets.switchOff, + switch2Up: _bloc.deviceStatus.switch_backlight + ? Assets.switchOn + : Assets.switchOff, + switch3Up: _bloc.deviceStatus.switch_backlight + ? Assets.switchOn + : Assets.switchOff, + switch3Down: _bloc.deviceStatus.switch_backlight + ? Assets.switchOn + : Assets.switchOff, onSwitch3DownTap: () { debugPrint("onSwitch3DownTap"); }, @@ -136,7 +134,6 @@ class SixSceneScreen extends StatelessWidget { child: DefaultContainer( onTap: () { _bloc.add(ChangeSwitchStatusEvent()); - }, child: Column( crossAxisAlignment: @@ -146,13 +143,13 @@ class SixSceneScreen extends StatelessWidget { children: [ ConstrainedBox( constraints: const BoxConstraints( - maxHeight: 46, maxWidth: 50), + maxHeight: 46, + maxWidth: 50, + ), child: SvgPicture.asset( Assets.backlightIcon), ), - const SizedBox( - height: 15, - ), + const SizedBox(height: 15), const Flexible( child: FittedBox( child: BodySmall( @@ -165,9 +162,7 @@ class SixSceneScreen extends StatelessWidget { ), ), ), - const SizedBox( - width: 10, - ), + const SizedBox(width: 10), Expanded( child: DefaultContainer( onTap: () async { @@ -187,12 +182,12 @@ class SixSceneScreen extends StatelessWidget { confirmTab: (v) { Navigator.of(context).push( MaterialPageRoute( - builder: (context) => - SixSelectSceneFourPage( - deviceId: - device!.uuid, - switchSelected: v, - )), + builder: (context) => + SixSelectSceneFourPage( + deviceId: device!.uuid, + switchSelected: v, + ), + ), ); }, ); @@ -214,13 +209,13 @@ class SixSceneScreen extends StatelessWidget { children: [ ConstrainedBox( constraints: const BoxConstraints( - maxHeight: 46, maxWidth: 50), + maxHeight: 46, + maxWidth: 50, + ), child: SvgPicture.asset( Assets.addSceneIcon), ), - const SizedBox( - height: 15, - ), + const SizedBox(height: 15), const Flexible( child: FittedBox( child: BodySmall( @@ -235,15 +230,15 @@ class SixSceneScreen extends StatelessWidget { ), ], ), - ) + ), ], ), ), ], ), - ); - }, - ), + ), + ); + }, ), ); } diff --git a/lib/features/devices/view/widgets/four_scene_switch/four_scene_screen.dart b/lib/features/devices/view/widgets/four_scene_switch/four_scene_screen.dart index 86bc1d3..224e30b 100644 --- a/lib/features/devices/view/widgets/four_scene_switch/four_scene_screen.dart +++ b/lib/features/devices/view/widgets/four_scene_switch/four_scene_screen.dart @@ -24,47 +24,52 @@ class FourSceneScreen extends StatelessWidget { @override Widget build(BuildContext context) { - return DefaultScaffold( - title: '4 Scene Switch', - actions: [ - InkWell( - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => FourSceneSettings(device: device!)), - ); - }, - child: SvgPicture.asset(Assets.assetsIconsSettings)), - const SizedBox( - width: 10, - ) - ], - child: BlocProvider( - create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '') - ..add(const FourSceneInitial()) - ..add(const FourSceneInitialInfo()) - ..add(const FourSceneSwitchInitial()), - child: BlocBuilder( - builder: (context, state) { - final _bloc = BlocProvider.of(context); - FourSceneModelState model = FourSceneModelState( - scene_1: '', - scene_2: '', - scene_3: '', - scene_4: '', - scene_id_group_id: '', - switch_backlight: ''); - if (state is LoadingNewSate) { - model = state.device; - } else if (state is UpdateState) { - model = state.device; - } - return state is FourSceneLoadingState + return BlocProvider( + create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '') + ..add(const FourSceneInitial()) + ..add(const FourSceneInitialInfo()) + ..add(const FourSceneSwitchInitial()), + child: BlocBuilder( + builder: (context, state) { + final _bloc = BlocProvider.of(context); + + FourSceneModelState model = FourSceneModelState( + scene_1: '', + scene_2: '', + scene_3: '', + scene_4: '', + scene_id_group_id: '', + switch_backlight: '', + ); + + if (state is LoadingNewSate) { + model = state.device; + } else if (state is UpdateState) { + model = state.device; + } + + return DefaultScaffold( + title: _bloc.deviceInfo.name, + actions: [ + InkWell( + onTap: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => FourSceneSettings(device: device!), + ), + ); + }, + child: SvgPicture.asset(Assets.assetsIconsSettings), + ), + const SizedBox(width: 10), + ], + child: state is FourSceneLoadingState ? const Center( child: DefaultContainer( - width: 50, - height: 50, - child: CircularProgressIndicator()), + width: 50, + height: 50, + child: CircularProgressIndicator(), + ), ) : RefreshIndicator( onRefresh: () async { @@ -81,22 +86,18 @@ class FourSceneScreen extends StatelessWidget { title2: model.scene_2, title3: model.scene_3, title4: model.scene_4, - switch1: - _bloc.deviceStatus.switch_backlight == true - ? Assets.switchOn - : Assets.switchOff, - switch2: - _bloc.deviceStatus.switch_backlight == true - ? Assets.switchOn - : Assets.switchOff, - switch3: - _bloc.deviceStatus.switch_backlight == true - ? Assets.switchOn - : Assets.switchOff, - switch4: - _bloc.deviceStatus.switch_backlight == true - ? Assets.switchOn - : Assets.switchOff, + switch1: _bloc.deviceStatus.switch_backlight + ? Assets.switchOn + : Assets.switchOff, + switch2: _bloc.deviceStatus.switch_backlight + ? Assets.switchOn + : Assets.switchOff, + switch3: _bloc.deviceStatus.switch_backlight + ? Assets.switchOn + : Assets.switchOff, + switch4: _bloc.deviceStatus.switch_backlight + ? Assets.switchOn + : Assets.switchOff, onSwitch1UpTap: () { debugPrint("Switch 1 Up tapped"); }, @@ -126,13 +127,13 @@ class FourSceneScreen extends StatelessWidget { children: [ ConstrainedBox( constraints: const BoxConstraints( - maxHeight: 46, maxWidth: 50), + maxHeight: 46, + maxWidth: 50, + ), child: SvgPicture.asset( Assets.backlightIcon), ), - const SizedBox( - height: 15, - ), + const SizedBox(height: 15), const Flexible( child: FittedBox( child: BodySmall( @@ -145,9 +146,7 @@ class FourSceneScreen extends StatelessWidget { ), ), ), - const SizedBox( - width: 10, - ), + const SizedBox(width: 10), Expanded( child: DefaultContainer( onTap: () async { @@ -162,13 +161,17 @@ class FourSceneScreen extends StatelessWidget { cancelTab: () { Navigator.of(context).pop(); }, - confirmTab: (switchSelected) async { + confirmTab: + (switchSelected) async { Navigator.of(context).push( MaterialPageRoute( - builder: (context) => - FourSelectSceneFourPage( - switchSelected:switchSelected, - deviceId: device!.uuid)), + builder: (context) => + FourSelectSceneFourPage( + switchSelected: + switchSelected, + deviceId: device!.uuid, + ), + ), ); }, ); @@ -190,13 +193,13 @@ class FourSceneScreen extends StatelessWidget { children: [ ConstrainedBox( constraints: const BoxConstraints( - maxHeight: 46, maxWidth: 50), + maxHeight: 46, + maxWidth: 50, + ), child: SvgPicture.asset( Assets.addSceneIcon), ), - const SizedBox( - height: 15, - ), + const SizedBox(height: 15), const Flexible( child: FittedBox( child: BodySmall( @@ -211,19 +214,16 @@ class FourSceneScreen extends StatelessWidget { ), ], ), - ) + ), ], ), ), ], ), - ); - }, - ), + ), + ); + }, ), ); } } - - -//MohaM&&&uba1 \ No newline at end of file diff --git a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_info_page.dart b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_info_page.dart index 9b9aea4..991fe57 100644 --- a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_info_page.dart +++ b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_info_page.dart @@ -69,9 +69,13 @@ class FourSceneInfoPage extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - BodySmall( - text: _bloc.deviceInfo.productUuid, - fontColor: ColorsManager.primaryTextColor, + Container( + width: + MediaQuery.of(context).size.width * 0.61, + child: BodySmall( + text: _bloc.deviceInfo.productUuid, + fontColor: ColorsManager.primaryTextColor, + ), ), InkWell( onTap: () { diff --git a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_profile_page.dart b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_profile_page.dart index 0ded218..29a1272 100644 --- a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_profile_page.dart +++ b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_profile_page.dart @@ -144,6 +144,7 @@ class FourSceneProfilePage extends StatelessWidget { fontSize: 12, fontColor: ColorsManager.grayColor, ), + const SizedBox(height: 7), DefaultContainer( padding: const EdgeInsets.all(20), child: InkWell( diff --git a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_settings.dart b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_settings.dart index f012b65..33ab7ec 100644 --- a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_settings.dart +++ b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_settings.dart @@ -207,7 +207,12 @@ class FourSceneSettings extends StatelessWidget { child: Column( children: [ SettingWidget( - onChanged: (p0) {}, + value: _bloc.enableAlarm, + onChanged: (p0) { + context + .read() + .add(ToggleEnableAlarmEvent(p0)); + }, isNotification: true, onTap: () {}, text: 'Offline Notification', @@ -444,6 +449,7 @@ class FourSceneSettings extends StatelessWidget { class SettingWidget extends StatelessWidget { final String? text; final bool? isUpdate; + final bool? value; final bool? isNotification; final String? icon; final Function()? onTap; @@ -453,6 +459,7 @@ class SettingWidget extends StatelessWidget { {super.key, this.text, this.icon, + this.value, this.onTap, this.isUpdate, this.onChanged, @@ -516,7 +523,7 @@ class SettingWidget extends StatelessWidget { : Transform.scale( scale: .8, child: CupertinoSwitch( - value: true, + value: value!, onChanged: onChanged, applyTheme: true, ), diff --git a/lib/features/devices/view/widgets/sos/sos_screen.dart b/lib/features/devices/view/widgets/sos/sos_screen.dart index e55ee41..ea9e7df 100644 --- a/lib/features/devices/view/widgets/sos/sos_screen.dart +++ b/lib/features/devices/view/widgets/sos/sos_screen.dart @@ -18,45 +18,51 @@ import 'package:syncrow_app/generated/assets.dart'; class SosScreen extends StatelessWidget { final DeviceModel? device; - const SosScreen({super.key, this.device}); @override Widget build(BuildContext context) { - return DefaultScaffold( - title: 'SOS', - actions: [ - InkWell( - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => SosSettings(device: device!)), - ); - }, - child: SvgPicture.asset(Assets.assetsIconsSettings)), - const SizedBox( - width: 10, - ) - ], - child: BlocProvider( - create: (context) => - SosBloc(sosId: device?.uuid ?? '')..add(const SosInitial()), - child: BlocBuilder( - builder: (context, state) { - final sensor = BlocProvider.of(context); - SosModel model = - SosModel(batteryPercentage: 0, sosContactState: 'normal'); - if (state is LoadingNewSate) { - model = state.sosSensor; - } else if (state is UpdateState) { - model = state.sensor; - } - return state is SosLoadingState + return BlocProvider( + create: (context) => SosBloc(sosId: device?.uuid ?? '') + ..add(const SosInitial()) + ..add(SosInitialDeviseInfo()), + child: BlocBuilder( + builder: (context, state) { + final sensor = BlocProvider.of(context); + // Default SOS model in case no state is loaded + SosModel model = SosModel( + batteryPercentage: 0, + sosContactState: '', + ); + // Update the model based on the state + if (state is LoadingNewSate) { + model = state.sosSensor; + } else if (state is UpdateState) { + model = state.sensor; + } + + return DefaultScaffold( + title: sensor.deviceInfo.name, + actions: [ + InkWell( + onTap: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => SosSettings(device: device!), + ), + ); + }, + child: SvgPicture.asset(Assets.assetsIconsSettings), + ), + const SizedBox(width: 10), + ], + child: state is SosLoadingState ? const Center( child: DefaultContainer( - width: 50, - height: 50, - child: CircularProgressIndicator()), + width: 50, + height: 50, + child: CircularProgressIndicator(), + ), ) : RefreshIndicator( onRefresh: () async { @@ -69,14 +75,17 @@ class SosScreen extends StatelessWidget { child: Column( children: [ BatteryBar( - batteryPercentage: model.batteryPercentage, + batteryPercentage: + sensor.deviceStatus.batteryPercentage, ), Expanded( flex: 4, child: InkWell( - overlayColor: WidgetStateProperty.all( + overlayColor: MaterialStateProperty.all( Colors.transparent), - onTap: () {}, + onTap: () { + // Add functionality for the main SOS button here + }, child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: @@ -111,7 +120,8 @@ class SosScreen extends StatelessWidget { ], ), child: SvgPicture.asset( - model.sosContactState == 'normal' + sensor.deviceStatus.sosContactState != + 'sos' ? Assets.redSos : Assets.greenSos, fit: BoxFit.fill, @@ -129,9 +139,10 @@ class SosScreen extends StatelessWidget { onTap: () { Navigator.of(context).push( MaterialPageRoute( - builder: (context) => - SosRecordsScreen( - sosId: device!.uuid!)), + builder: (context) => + SosRecordsScreen( + sosId: device!.uuid!), + ), ); }, child: Column( @@ -142,13 +153,13 @@ class SosScreen extends StatelessWidget { children: [ ConstrainedBox( constraints: const BoxConstraints( - maxHeight: 46, maxWidth: 50), + maxHeight: 46, + maxWidth: 50, + ), child: SvgPicture.asset( Assets.doorRecordsIcon), ), - const SizedBox( - height: 15, - ), + const SizedBox(height: 15), const Flexible( child: FittedBox( child: BodySmall( @@ -161,16 +172,15 @@ class SosScreen extends StatelessWidget { ), ), ), - const SizedBox( - width: 10, - ), + const SizedBox(width: 10), Expanded( child: DefaultContainer( onTap: () { Navigator.of(context).push( MaterialPageRoute( - builder: (context) => - const AlarmManagementPage()), + builder: (context) => + const AlarmManagementPage(), + ), ); }, child: Column( @@ -181,13 +191,13 @@ class SosScreen extends StatelessWidget { children: [ ConstrainedBox( constraints: const BoxConstraints( - maxHeight: 46, maxWidth: 50), + maxHeight: 46, + maxWidth: 50, + ), child: SvgPicture.asset(Assets .doorNotificationSetting), ), - const SizedBox( - height: 15, - ), + const SizedBox(height: 15), const Flexible( child: FittedBox( child: BodySmall( @@ -202,15 +212,15 @@ class SosScreen extends StatelessWidget { ), ], ), - ) + ), ], ), ), ], ), - ); - }, - ), + ), + ); + }, ), ); } diff --git a/lib/features/devices/view/widgets/sos/sos_setting/sos_info_page.dart b/lib/features/devices/view/widgets/sos/sos_setting/sos_info_page.dart index 1055cb1..09ed1c1 100644 --- a/lib/features/devices/view/widgets/sos/sos_setting/sos_info_page.dart +++ b/lib/features/devices/view/widgets/sos/sos_setting/sos_info_page.dart @@ -64,9 +64,13 @@ class SosInfoPage extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - BodySmall( - text: _bloc.deviceInfo.productUuid, - fontColor: ColorsManager.primaryTextColor, + SizedBox( + width: + MediaQuery.of(context).size.width * 0.61, + child: BodySmall( + text: _bloc.deviceInfo.productUuid, + fontColor: ColorsManager.primaryTextColor, + ), ), InkWell( onTap: () { diff --git a/lib/features/devices/view/widgets/sos/sos_setting/sos_profile_page.dart b/lib/features/devices/view/widgets/sos/sos_setting/sos_profile_page.dart index bf1d0f9..5d9b033 100644 --- a/lib/features/devices/view/widgets/sos/sos_setting/sos_profile_page.dart +++ b/lib/features/devices/view/widgets/sos/sos_setting/sos_profile_page.dart @@ -64,20 +64,11 @@ class SosProfilePage extends StatelessWidget { radius: 55, backgroundColor: ColorsManager.graysColor, child: ClipOval( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const SizedBox( - height: 10, - ), - Center( - child: SvgPicture.asset( - Assets.fourSceneIcon, - fit: BoxFit.contain, - ), - ), - ], + child: Center( + child: SvgPicture.asset( + Assets.sosProfileIcon, + fit: BoxFit.contain, + ), ), ), ), @@ -139,6 +130,7 @@ class SosProfilePage extends StatelessWidget { fontSize: 12, fontColor: ColorsManager.grayColor, ), + const SizedBox(height: 7), DefaultContainer( padding: const EdgeInsets.all(20), child: InkWell( diff --git a/lib/features/devices/view/widgets/sos/sos_settings.dart b/lib/features/devices/view/widgets/sos/sos_settings.dart index 8971452..dc6487f 100644 --- a/lib/features/devices/view/widgets/sos/sos_settings.dart +++ b/lib/features/devices/view/widgets/sos/sos_settings.dart @@ -7,7 +7,6 @@ import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart'; import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/sos_model.dart'; -import 'package:syncrow_app/features/devices/model/subspace_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/delete_dialog.dart'; import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/sos_profile_page.dart'; import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/faq_sos_page.dart'; @@ -62,14 +61,18 @@ class SosSettings extends StatelessWidget { vertical: 10, ), child: InkWell( - onTap: () { - Navigator.of(context).push( + onTap: () async { + bool val = await Navigator.of(context).push( MaterialPageRoute( builder: (context) => SosProfilePage( device: device, ), ), ); + if (val == true) { + _bloc.add(SosInitialDeviseInfo()); + _bloc.add(const SosInitial()); + } }, child: Stack( children: [ @@ -93,8 +96,8 @@ class SosSettings extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ - const BodyMedium( - text: 'SOS', + BodyMedium( + text: _bloc.deviceInfo.name, fontWeight: FontWeight.bold, ), const SizedBox( @@ -169,7 +172,21 @@ class SosSettings extends StatelessWidget { child: Column( children: [ SettingWidget( - onChanged: (p0) {}, + value: _bloc.enableAlarm, + onChanged: (p0) { + context + .read() + .add(ToggleEnableAlarmEvent(p0)); + // Transform.scale( + // scale: .8, + // child: CupertinoSwitch( + // value: _bloc.enableAlarm, + // onChanged: (value) { + + // }, + // applyTheme: true, + // )), + }, isNotification: true, onTap: () {}, text: 'Offline Notification', @@ -400,6 +417,7 @@ class SosSettings extends StatelessWidget { class SettingWidget extends StatelessWidget { final String? text; final bool? isUpdate; + final bool? value; final bool? isNotification; final String? icon; final Function()? onTap; @@ -409,6 +427,7 @@ class SettingWidget extends StatelessWidget { {super.key, this.text, this.icon, + this.value, this.onTap, this.isUpdate, this.onChanged, @@ -472,7 +491,7 @@ class SettingWidget extends StatelessWidget { : Transform.scale( scale: .8, child: CupertinoSwitch( - value: true, + value: value!, onChanged: onChanged, applyTheme: true, ),