From db9ab530ea6e8cae171d9d39932ffadef6473e29 Mon Sep 17 00:00:00 2001 From: mohammad Date: Mon, 25 Nov 2024 10:47:09 +0300 Subject: [PATCH] 4 scene & 6scene & sos --- .../6_scene_switch_bloc/6_scene_bloc.dart | 30 +++++- .../6_scene_switch_bloc/6_scene_event.dart | 13 +++ .../6_scene_switch_bloc/6_scene_state.dart | 2 +- .../bloc/four_scene_bloc/four_scene_bloc.dart | 31 +++++- .../four_scene_bloc/four_scene_event.dart | 10 ++ .../devices/bloc/sos_bloc/sos_bloc.dart | 27 ++++- .../devices/bloc/sos_bloc/sos_event.dart | 10 ++ .../devices/bloc/sos_bloc/sos_state.dart | 3 + ...del.dart => six_scene_question_model.dart} | 0 .../6_scene_setting/faq_six_scene_page.dart | 14 ++- .../6_scene_setting/question_page.dart | 30 ++++-- .../six_scene_update_page.dart | 15 ++- .../faq_four_scene_page.dart | 12 ++- .../four_scene_update_page.dart | 15 ++- .../question_page_four_scene.dart | 28 +++-- .../widgets/sos/sos_setting/faq_sos_page.dart | 101 ++++++++++-------- .../sos/sos_setting/question_page.dart | 28 +++-- .../sos/sos_setting/sos_update_page.dart | 21 ++-- .../view/widgets/sos/sos_settings.dart | 11 +- 19 files changed, 293 insertions(+), 108 deletions(-) rename lib/features/devices/model/{sex_scene_question_model.dart => six_scene_question_model.dart} (100%) 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 b454060..5ce176b 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 @@ -9,7 +9,7 @@ import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/device_report_model.dart'; import 'package:syncrow_app/features/devices/model/group_devices_model.dart'; import 'package:syncrow_app/features/devices/model/device_info_model.dart'; -import 'package:syncrow_app/features/devices/model/sex_scene_question_model.dart'; +import 'package:syncrow_app/features/devices/model/six_scene_question_model.dart'; import 'package:syncrow_app/features/devices/model/six_scene_model.dart'; import 'package:syncrow_app/features/devices/model/status_model.dart'; import 'package:syncrow_app/features/devices/model/subspace_model.dart'; @@ -48,6 +48,8 @@ class SixSceneBloc extends Bloc { on(_onSixSceneInitial); on(deleteDevice); on(_toggleLowBattery); + on(_toggleUpdate); + on(_toggleHelpful); } final TextEditingController nameController = @@ -506,4 +508,30 @@ class SixSceneBloc extends Bloc { } return null; } + + bool enableUpdate = false; + + void _toggleUpdate( + ToggleUpdateEvent event, Emitter emit) async { + try { + emit(SixSceneLoadingState()); + enableUpdate = event.isUpdateEnabled!; + emit(SaveState()); + } catch (e) { + emit(const SixSceneFailedState(errorMessage: 'Something went wrong')); + } + } + + bool isHelpful = false; + + void _toggleHelpful( + ToggleHelpfulEvent event, Emitter emit) async { + try { + emit(SixSceneLoadingState()); + isHelpful = event.isHelpful!; + emit(SaveState()); + } catch (e) { + emit(const SixSceneFailedState(errorMessage: 'Something went wrong')); + } + } } diff --git a/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart b/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart index 7efceb6..5600510 100644 --- a/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart +++ b/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart @@ -222,3 +222,16 @@ class AssignRoomEvent extends SixSceneEvent { context, ]; } + + + +class ToggleUpdateEvent extends SixSceneEvent { + final bool? isUpdateEnabled; + const ToggleUpdateEvent({this.isUpdateEnabled}); +} + + +class ToggleHelpfulEvent extends SixSceneEvent { + final bool? isHelpful; + const ToggleHelpfulEvent({this.isHelpful}); +} \ No newline at end of file diff --git a/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart b/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart index 318d37a..01f72b0 100644 --- a/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart +++ b/lib/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart @@ -2,7 +2,7 @@ import 'package:equatable/equatable.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/group_devices_model.dart'; import 'package:syncrow_app/features/devices/model/device_info_model.dart'; -import 'package:syncrow_app/features/devices/model/sex_scene_question_model.dart'; +import 'package:syncrow_app/features/devices/model/six_scene_question_model.dart'; import 'package:syncrow_app/features/devices/model/six_scene_model.dart'; import 'package:syncrow_app/features/devices/model/subspace_model.dart'; import 'package:syncrow_app/features/scene/model/scenes_model.dart'; 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 efb89dd..9cdf3ef 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 @@ -49,6 +49,8 @@ class FourSceneBloc extends Bloc { on(_selectScene); on(deleteDevice); on(_toggleLowBattery); + on(_toggleUpdate); + on(_toggleHelpful); } final TextEditingController nameController = @@ -261,8 +263,7 @@ class FourSceneBloc extends Bloc { } } - - void _toggleLowBattery( + void _toggleLowBattery( ToggleEnableAlarmEvent event, Emitter emit) async { emit(LoadingNewSate(device: deviceStatus)); try { @@ -544,4 +545,30 @@ class FourSceneBloc extends Bloc { } return null; } + + bool enableUpdate = false; + + void _toggleUpdate( + ToggleUpdateEvent event, Emitter emit) async { + try { + emit(FourSceneLoadingState()); + enableUpdate = event.isUpdateEnabled!; + emit(SaveState()); + } catch (e) { + emit(const FourSceneFailedState(errorMessage: 'Something went wrong')); + } + } + + bool isHelpful = false; + + void _toggleHelpful( + ToggleHelpfulEvent event, Emitter emit) async { + try { + emit(FourSceneLoadingState()); + isHelpful = event.isHelpful!; + emit(SaveState()); + } catch (e) { + emit(const FourSceneFailedState(errorMessage: 'Something went wrong')); + } + } } diff --git a/lib/features/devices/bloc/four_scene_bloc/four_scene_event.dart b/lib/features/devices/bloc/four_scene_bloc/four_scene_event.dart index 52ed6ee..9a75285 100644 --- a/lib/features/devices/bloc/four_scene_bloc/four_scene_event.dart +++ b/lib/features/devices/bloc/four_scene_bloc/four_scene_event.dart @@ -232,3 +232,13 @@ class GetSceneBySwitchName extends FourSceneEvent { const GetSceneBySwitchName({this.switchName}); } +class ToggleUpdateEvent extends FourSceneEvent { + final bool? isUpdateEnabled; + const ToggleUpdateEvent({this.isUpdateEnabled}); +} + + +class ToggleHelpfulEvent extends FourSceneEvent { + final bool? isHelpful; + const ToggleHelpfulEvent({this.isHelpful}); +} \ No newline at end of file diff --git a/lib/features/devices/bloc/sos_bloc/sos_bloc.dart b/lib/features/devices/bloc/sos_bloc/sos_bloc.dart index 3fcf131..b2d322a 100644 --- a/lib/features/devices/bloc/sos_bloc/sos_bloc.dart +++ b/lib/features/devices/bloc/sos_bloc/sos_bloc.dart @@ -39,7 +39,8 @@ class SosBloc extends Bloc { on(_assignDevice); on(fetchDeviceInfo); on(saveName); - // on(_unassignDevice); + on(_toggleUpdate); + on(_toggleHelpful); // on(_toggleWaterLeakAlarm); } @@ -440,4 +441,28 @@ class SosBloc extends Bloc { } return null; } + + bool enableUpdate = false; + + void _toggleUpdate(ToggleUpdateEvent event, Emitter emit) async { + try { + emit(SosLoadingState()); + enableUpdate = event.isUpdateEnabled!; + emit(SaveState()); + } catch (e) { + emit(SosFailedState(errorMessage: e.toString())); + } + } + + bool isHelpful = false; + + void _toggleHelpful(ToggleHelpfulEvent event, Emitter emit) async { + try { + emit(SosLoadingState()); + isHelpful = event.isHelpful!; + emit(SaveState()); + } catch (e) { + emit(SosFailedState(errorMessage: e.toString())); + } + } } diff --git a/lib/features/devices/bloc/sos_bloc/sos_event.dart b/lib/features/devices/bloc/sos_bloc/sos_event.dart index 8a882a9..f002304 100644 --- a/lib/features/devices/bloc/sos_bloc/sos_event.dart +++ b/lib/features/devices/bloc/sos_bloc/sos_event.dart @@ -193,4 +193,14 @@ class LoadingDeviceInfo extends SosEvent { @override List get props => [deviceInfo]; +} + +class ToggleUpdateEvent extends SosEvent { + final bool? isUpdateEnabled; + const ToggleUpdateEvent({this.isUpdateEnabled}); +} + +class ToggleHelpfulEvent extends SosEvent { + final bool? isHelpful; + const ToggleHelpfulEvent({this.isHelpful}); } \ No newline at end of file diff --git a/lib/features/devices/bloc/sos_bloc/sos_state.dart b/lib/features/devices/bloc/sos_bloc/sos_state.dart index 1ffee2d..3f125cb 100644 --- a/lib/features/devices/bloc/sos_bloc/sos_state.dart +++ b/lib/features/devices/bloc/sos_bloc/sos_state.dart @@ -15,6 +15,9 @@ class SosState extends Equatable { class SosInitialState extends SosState {} class SosLoadingState extends SosState {} + + + class SaveState extends SosState {} class LoadingSosDeviceInfo extends SosState { diff --git a/lib/features/devices/model/sex_scene_question_model.dart b/lib/features/devices/model/six_scene_question_model.dart similarity index 100% rename from lib/features/devices/model/sex_scene_question_model.dart rename to lib/features/devices/model/six_scene_question_model.dart diff --git a/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/faq_six_scene_page.dart b/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/faq_six_scene_page.dart index d843fd6..5870ecf 100644 --- a/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/faq_six_scene_page.dart +++ b/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/faq_six_scene_page.dart @@ -5,7 +5,7 @@ import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bl import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart'; import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart'; -import 'package:syncrow_app/features/devices/model/sex_scene_question_model.dart'; +import 'package:syncrow_app/features/devices/model/six_scene_question_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/question_page.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart'; @@ -89,6 +89,9 @@ class FaqSixScenePage extends StatelessWidget { fontSize: 12, fontColor: ColorsManager.grayColor, ), + const SizedBox( + height: 8, + ), displayedQuestions.isEmpty ? const SizedBox() : DefaultContainer( @@ -132,9 +135,12 @@ class FaqSixScenePage extends StatelessWidget { ], ), ), - const Divider( - color: ColorsManager.dividerColor, - ), + if (index != + displayedQuestions.length - + 1) // Exclude divider for the last item + const Divider( + color: ColorsManager.dividerColor, + ), ], ), ), diff --git a/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/question_page.dart b/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/question_page.dart index 26fa712..c5b1ce9 100644 --- a/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/question_page.dart +++ b/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/question_page.dart @@ -4,7 +4,7 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart'; import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart'; import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart'; -import 'package:syncrow_app/features/devices/model/sex_scene_question_model.dart'; +import 'package:syncrow_app/features/devices/model/six_scene_question_model.dart'; import 'package:syncrow_app/features/devices/model/six_scene_model.dart'; import 'package:syncrow_app/features/shared_widgets/default_button.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; @@ -86,9 +86,14 @@ class QuestionPage extends StatelessWidget { child: SizedBox( width: 180, child: DefaultButton( - backgroundColor: ColorsManager.grayButtonColors, + backgroundColor: sensor.isHelpful == true + ? ColorsManager.grayColor + : ColorsManager.grayButtonColors, borderRadius: 50, - onPressed: () {}, + onPressed: () { + sensor + .add(ToggleHelpfulEvent(isHelpful: true)); + }, child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, @@ -97,10 +102,10 @@ class QuestionPage extends StatelessWidget { Assets.thumbUp, fit: BoxFit.fill, ), - SizedBox( + const SizedBox( width: 10, ), - BodyMedium( + const BodyMedium( text: 'Helpful', fontSize: 12, fontWeight: FontWeight.w400, @@ -110,16 +115,21 @@ class QuestionPage extends StatelessWidget { )), ), ), - SizedBox( + const SizedBox( height: 15, ), Center( child: SizedBox( width: 180, child: DefaultButton( - backgroundColor: ColorsManager.grayButtonColors, + backgroundColor: sensor.isHelpful == false + ? ColorsManager.grayColor + : ColorsManager.grayButtonColors, borderRadius: 50, - onPressed: () {}, + onPressed: () { + sensor.add( + ToggleHelpfulEvent(isHelpful: false)); + }, child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, @@ -128,10 +138,10 @@ class QuestionPage extends StatelessWidget { Assets.thumbDown, fit: BoxFit.fill, ), - SizedBox( + const SizedBox( width: 10, ), - BodyMedium( + const BodyMedium( text: 'Not Helpful', fontSize: 12, fontWeight: FontWeight.w400, diff --git a/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_update_page.dart b/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_update_page.dart index b8c0019..489f65b 100644 --- a/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_update_page.dart +++ b/lib/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_update_page.dart @@ -26,6 +26,8 @@ class SixSceneUpdatePage extends StatelessWidget { SixSceneBloc(sixSceneId: '')..add(const SixSceneInitial()), child: BlocBuilder( builder: (context, state) { + final _bloc = BlocProvider.of(context); + return state is SixSceneLoadingState ? const Center( child: DefaultContainer( @@ -87,15 +89,20 @@ class SixSceneUpdatePage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.end, children: [ - const BodyMedium( - text: 'Off', + BodyMedium( + text: _bloc.enableUpdate + ? 'true' + : 'Off', fontColor: ColorsManager.textGray, ), Transform.scale( scale: .8, child: CupertinoSwitch( - value: true, - onChanged: (value) {}, + value: _bloc.enableUpdate, + onChanged: (value) { + _bloc.add(ToggleUpdateEvent( + isUpdateEnabled: value)); + }, applyTheme: true, ), ), diff --git a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/faq_four_scene_page.dart b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/faq_four_scene_page.dart index 30e30e2..7e67462 100644 --- a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/faq_four_scene_page.dart +++ b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/faq_four_scene_page.dart @@ -89,6 +89,9 @@ class FaqFourScenePage extends StatelessWidget { fontSize: 12, fontColor: ColorsManager.grayColor, ), + const SizedBox( + height: 8, + ), displayedQuestions.isEmpty ? const SizedBox() : DefaultContainer( @@ -133,9 +136,12 @@ class FaqFourScenePage extends StatelessWidget { ], ), ), - const Divider( - color: ColorsManager.dividerColor, - ), + if (index != + displayedQuestions.length - + 1) // Exclude divider for the last item + const Divider( + color: ColorsManager.dividerColor, + ), ], ), ), diff --git a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_page.dart b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_page.dart index 8fcee56..b028b52 100644 --- a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_page.dart +++ b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_page.dart @@ -26,6 +26,8 @@ class FourSceneUpdatePage extends StatelessWidget { FourSceneBloc(fourSceneId: '')..add(const FourSceneInitial()), child: BlocBuilder( builder: (context, state) { + final _bloc = BlocProvider.of(context); + return state is FourSceneLoadingState ? const Center( child: DefaultContainer( @@ -87,15 +89,20 @@ class FourSceneUpdatePage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.end, children: [ - const BodyMedium( - text: 'Off', + BodyMedium( + text: _bloc.enableUpdate + ? 'true' + : 'Off', fontColor: ColorsManager.textGray, ), Transform.scale( scale: .8, child: CupertinoSwitch( - value: true, - onChanged: (value) {}, + value: _bloc.enableUpdate, + onChanged: (value) { + _bloc.add(ToggleUpdateEvent( + isUpdateEnabled: value)); + }, applyTheme: true, ), ), diff --git a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/question_page_four_scene.dart b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/question_page_four_scene.dart index 5ebbc8b..06cd0df 100644 --- a/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/question_page_four_scene.dart +++ b/lib/features/devices/view/widgets/four_scene_switch/four_scene_setting/question_page_four_scene.dart @@ -84,9 +84,14 @@ class QuestionPageFourScene extends StatelessWidget { child: SizedBox( width: 180, child: DefaultButton( - backgroundColor: ColorsManager.grayButtonColors, + backgroundColor: sensor.isHelpful == true + ? ColorsManager.grayColor + : ColorsManager.grayButtonColors, borderRadius: 50, - onPressed: () {}, + onPressed: () { + sensor + .add(ToggleHelpfulEvent(isHelpful: true)); + }, child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, @@ -95,10 +100,10 @@ class QuestionPageFourScene extends StatelessWidget { Assets.thumbUp, fit: BoxFit.fill, ), - SizedBox( + const SizedBox( width: 10, ), - BodyMedium( + const BodyMedium( text: 'Helpful', fontSize: 12, fontWeight: FontWeight.w400, @@ -108,16 +113,21 @@ class QuestionPageFourScene extends StatelessWidget { )), ), ), - SizedBox( + const SizedBox( height: 15, ), Center( child: SizedBox( width: 180, child: DefaultButton( - backgroundColor: ColorsManager.grayButtonColors, + backgroundColor: sensor.isHelpful == false + ? ColorsManager.grayColor + : ColorsManager.grayButtonColors, borderRadius: 50, - onPressed: () {}, + onPressed: () { + sensor.add( + ToggleHelpfulEvent(isHelpful: false)); + }, child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, @@ -126,10 +136,10 @@ class QuestionPageFourScene extends StatelessWidget { Assets.thumbDown, fit: BoxFit.fill, ), - SizedBox( + const SizedBox( width: 10, ), - BodyMedium( + const BodyMedium( text: 'Not Helpful', fontSize: 12, fontWeight: FontWeight.w400, diff --git a/lib/features/devices/view/widgets/sos/sos_setting/faq_sos_page.dart b/lib/features/devices/view/widgets/sos/sos_setting/faq_sos_page.dart index bbb75f7..aa93159 100644 --- a/lib/features/devices/view/widgets/sos/sos_setting/faq_sos_page.dart +++ b/lib/features/devices/view/widgets/sos/sos_setting/faq_sos_page.dart @@ -89,57 +89,70 @@ class FaqSosPage extends StatelessWidget { fontSize: 12, fontColor: ColorsManager.grayColor, ), - Expanded( - child: DefaultContainer( - child: ListView.builder( - shrinkWrap: true, - itemCount: displayedQuestions.length, - itemBuilder: (context, index) { - final faq = displayedQuestions[index]; - return InkWell( - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => QuestionPage( - questionModel: faq, - )), - ); - }, - child: SizedBox( - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Row( + const SizedBox( + height: 8, + ), + displayedQuestions.isEmpty + ? const SizedBox() + : DefaultContainer( + child: ListView.builder( + shrinkWrap: true, + itemCount: displayedQuestions.length, + itemBuilder: (context, index) { + final faq = displayedQuestions[index]; + return InkWell( + onTap: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + QuestionPage( + questionModel: faq, + )), + ); + }, + child: SizedBox( + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Expanded( - child: BodyMedium( - fontSize: 14, - fontWeight: FontWeight.w400, - text: faq.question, + Padding( + padding: + const EdgeInsets.all(8.0), + child: Row( + children: [ + Expanded( + child: BodyMedium( + fontSize: 14, + fontWeight: + FontWeight.w400, + text: faq.question, + ), + ), + const Icon( + Icons.keyboard_arrow_right, + color: + ColorsManager.textGray, + ), + ], ), ), - const Icon( - Icons.keyboard_arrow_right, - color: ColorsManager.textGray, - ), + if (index != + displayedQuestions.length - + 1) // Exclude divider for the last item + const Divider( + color: + ColorsManager.dividerColor, + ), ], ), ), - const Divider( - color: ColorsManager.dividerColor, - ), - ], - ), + ); + }, ), - ); - }, - )), - ), + ) ], ), ); diff --git a/lib/features/devices/view/widgets/sos/sos_setting/question_page.dart b/lib/features/devices/view/widgets/sos/sos_setting/question_page.dart index 0ae5bd8..27da97a 100644 --- a/lib/features/devices/view/widgets/sos/sos_setting/question_page.dart +++ b/lib/features/devices/view/widgets/sos/sos_setting/question_page.dart @@ -78,9 +78,14 @@ class QuestionPage extends StatelessWidget { child: SizedBox( width: 180, child: DefaultButton( - backgroundColor: ColorsManager.grayButtonColors, + backgroundColor: sensor.isHelpful == true + ? ColorsManager.grayColor + : ColorsManager.grayButtonColors, borderRadius: 50, - onPressed: () {}, + onPressed: () { + sensor + .add(ToggleHelpfulEvent(isHelpful: true)); + }, child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, @@ -89,10 +94,10 @@ class QuestionPage extends StatelessWidget { Assets.thumbUp, fit: BoxFit.fill, ), - SizedBox( + const SizedBox( width: 10, ), - BodyMedium( + const BodyMedium( text: 'Helpful', fontSize: 12, fontWeight: FontWeight.w400, @@ -102,16 +107,21 @@ class QuestionPage extends StatelessWidget { )), ), ), - SizedBox( + const SizedBox( height: 15, ), Center( child: SizedBox( width: 180, child: DefaultButton( - backgroundColor: ColorsManager.grayButtonColors, + backgroundColor: sensor.isHelpful == false + ? ColorsManager.grayColor + : ColorsManager.grayButtonColors, borderRadius: 50, - onPressed: () {}, + onPressed: () { + sensor.add( + ToggleHelpfulEvent(isHelpful: false)); + }, child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, @@ -120,10 +130,10 @@ class QuestionPage extends StatelessWidget { Assets.thumbDown, fit: BoxFit.fill, ), - SizedBox( + const SizedBox( width: 10, ), - BodyMedium( + const BodyMedium( text: 'Not Helpful', fontSize: 12, fontWeight: FontWeight.w400, diff --git a/lib/features/devices/view/widgets/sos/sos_setting/sos_update_page.dart b/lib/features/devices/view/widgets/sos/sos_setting/sos_update_page.dart index fabd7b2..67ab647 100644 --- a/lib/features/devices/view/widgets/sos/sos_setting/sos_update_page.dart +++ b/lib/features/devices/view/widgets/sos/sos_setting/sos_update_page.dart @@ -25,6 +25,8 @@ class SosUpdatePage extends StatelessWidget { create: (context) => SosBloc(sosId: '')..add(const SosInitial()), child: BlocBuilder( builder: (context, state) { + final _bloc = BlocProvider.of(context); + return state is SosLoadingState ? const Center( child: DefaultContainer( @@ -72,6 +74,7 @@ class SosUpdatePage extends StatelessWidget { InkWell( onTap: () {}, child: const BodyMedium( + text: 'Automatic Update', fontWeight: FontWeight.normal, ), @@ -85,21 +88,27 @@ class SosUpdatePage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.end, children: [ - const BodyMedium( - text: 'Off', + BodyMedium( + text: _bloc.enableUpdate + ? 'true' + : 'Off', fontColor: ColorsManager.textGray, ), Transform.scale( scale: .8, child: CupertinoSwitch( - value: true, - onChanged: (value) {}, + value: _bloc.enableUpdate, + onChanged: (value) { + _bloc.add(ToggleUpdateEvent( + isUpdateEnabled: value)); + }, applyTheme: true, ), ), ], ), - )), + ) + ), ), ], ), @@ -107,7 +116,7 @@ class SosUpdatePage extends StatelessWidget { const SizedBox( height: 10, ), - UpdateSosContainerWithProgressBar( + const UpdateSosContainerWithProgressBar( sosDescription: 'Connectivity Issue Resolved Fixed a bug that caused the SOS button to disconnect from the app intermittently.', sosVersion: 'SOS v2.0.5', diff --git a/lib/features/devices/view/widgets/sos/sos_settings.dart b/lib/features/devices/view/widgets/sos/sos_settings.dart index dc6487f..6d27019 100644 --- a/lib/features/devices/view/widgets/sos/sos_settings.dart +++ b/lib/features/devices/view/widgets/sos/sos_settings.dart @@ -39,7 +39,6 @@ class SosSettings extends StatelessWidget { child: BlocBuilder( builder: (context, state) { final _bloc = BlocProvider.of(context); - SosModel model = SosModel(batteryPercentage: 0, sosContactState: 'normal'); if (state is LoadingNewSate) { @@ -177,15 +176,7 @@ class SosSettings extends StatelessWidget { context .read() .add(ToggleEnableAlarmEvent(p0)); - // Transform.scale( - // scale: .8, - // child: CupertinoSwitch( - // value: _bloc.enableAlarm, - // onChanged: (value) { - - // }, - // applyTheme: true, - // )), + }, isNotification: true, onTap: () {},