diff --git a/lib/features/devices/bloc/sos_bloc/sos_bloc.dart b/lib/features/devices/bloc/sos_bloc/sos_bloc.dart index 17c782a..77f0359 100644 --- a/lib/features/devices/bloc/sos_bloc/sos_bloc.dart +++ b/lib/features/devices/bloc/sos_bloc/sos_bloc.dart @@ -42,7 +42,7 @@ class SosBloc extends Bloc { bool closingReminder = false; bool waterAlarm = false; SosModel deviceStatus = - SosModel(waterContactState: 'normal', batteryPercentage: 0); + SosModel(sosContactState: 'normal', batteryPercentage: 0); void _fetchStatus(SosInitial event, Emitter emit) async { emit(SosLoadingState()); diff --git a/lib/features/devices/model/sos_model.dart b/lib/features/devices/model/sos_model.dart index 69c567b..7534b60 100644 --- a/lib/features/devices/model/sos_model.dart +++ b/lib/features/devices/model/sos_model.dart @@ -1,27 +1,27 @@ import 'package:syncrow_app/features/devices/model/status_model.dart'; class SosModel { - String waterContactState; + String sosContactState; int batteryPercentage; SosModel({ - required this.waterContactState, + required this.sosContactState, required this.batteryPercentage, }); factory SosModel.fromJson(List jsonList) { - late String _waterContactState; + late String _sosContactState; late int _batteryPercentage; for (int i = 0; i < jsonList.length; i++) { - if (jsonList[i].code == 'sossensor_state') { - _waterContactState = jsonList[i].value ?? false; + if (jsonList[i].code == 'sos') { + _sosContactState = jsonList[i].value ?? ''; } else if (jsonList[i].code == 'battery_percentage') { _batteryPercentage = jsonList[i].value ?? 0; } } return SosModel( - waterContactState: _waterContactState, + sosContactState: _sosContactState, batteryPercentage: _batteryPercentage, ); } diff --git a/lib/features/devices/view/widgets/sos/sos_screen.dart b/lib/features/devices/view/widgets/sos/sos_screen.dart index 4d3bc40..228b514 100644 --- a/lib/features/devices/view/widgets/sos/sos_screen.dart +++ b/lib/features/devices/view/widgets/sos/sos_screen.dart @@ -44,7 +44,7 @@ class SosScreen extends StatelessWidget { builder: (context, state) { final sensor = BlocProvider.of(context); SosModel model = - SosModel(batteryPercentage: 0, waterContactState: 'normal'); + SosModel(batteryPercentage: 0, sosContactState: 'normal'); if (state is LoadingNewSate) { model = state.sosSensor; } else if (state is UpdateState) { @@ -68,6 +68,7 @@ class SosScreen extends StatelessWidget { child: Column( children: [ BatteryBar( + batteryPercentage: model.batteryPercentage, ), Expanded( @@ -110,7 +111,7 @@ class SosScreen extends StatelessWidget { ], ), child: SvgPicture.asset( - model.waterContactState == 'normal' + model.sosContactState == 'normal' ? Assets.redSos : Assets.greenSos, fit: BoxFit.fill, diff --git a/lib/features/devices/view/widgets/sos/sos_setting/location_setting.dart b/lib/features/devices/view/widgets/sos/sos_setting/location_setting.dart index 07ab1b9..a383bad 100644 --- a/lib/features/devices/view/widgets/sos/sos_setting/location_setting.dart +++ b/lib/features/devices/view/widgets/sos/sos_setting/location_setting.dart @@ -26,7 +26,7 @@ class LocationSosPage extends StatelessWidget { builder: (context, state) { final sensor = BlocProvider.of(context); SosModel model = - SosModel(batteryPercentage: 0, waterContactState: 'normal'); + SosModel(batteryPercentage: 0, sosContactState: 'normal'); return state is SosLoadingState ? const Center( 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 26118e8..0ae5bd8 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 @@ -29,7 +29,7 @@ class QuestionPage extends StatelessWidget { builder: (context, state) { final sensor = BlocProvider.of(context); SosModel model = - SosModel(batteryPercentage: 0, waterContactState: 'normal'); + SosModel(batteryPercentage: 0, sosContactState: 'normal'); if (state is LoadingNewSate) { model = state.sosSensor; } else if (state is UpdateState) { diff --git a/lib/features/devices/view/widgets/sos/sos_setting/share_sos_page.dart b/lib/features/devices/view/widgets/sos/sos_setting/share_sos_page.dart index ba1f4f6..97e76d6 100644 --- a/lib/features/devices/view/widgets/sos/sos_setting/share_sos_page.dart +++ b/lib/features/devices/view/widgets/sos/sos_setting/share_sos_page.dart @@ -28,7 +28,7 @@ class ShareSosPage extends StatelessWidget { builder: (context, state) { final sensor = BlocProvider.of(context); SosModel model = - SosModel(batteryPercentage: 0, waterContactState: 'normal'); + SosModel(batteryPercentage: 0, sosContactState: 'normal'); if (state is LoadingNewSate) { model = state.sosSensor; } else if (state is UpdateState) { 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 caa3e18..0286af1 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 @@ -28,7 +28,7 @@ class SosInfoPge extends StatelessWidget { builder: (context, state) { final sensor = BlocProvider.of(context); SosModel model = - SosModel(batteryPercentage: 0, waterContactState: 'normal'); + SosModel(batteryPercentage: 0, sosContactState: 'normal'); if (state is LoadingNewSate) { model = state.sosSensor; } else if (state is UpdateState) { 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 57bdfe4..6dfb586 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 @@ -32,7 +32,7 @@ class SosProfilePage extends StatelessWidget { builder: (context, state) { final sensor = BlocProvider.of(context); SosModel model = - SosModel(batteryPercentage: 0, waterContactState: 'normal'); + SosModel(batteryPercentage: 0, sosContactState: 'normal'); if (state is LoadingNewSate) { model = state.sosSensor; } else if (state is UpdateState) { diff --git a/lib/features/devices/view/widgets/sos/sos_settings.dart b/lib/features/devices/view/widgets/sos/sos_settings.dart index be27f9f..7a8eb2e 100644 --- a/lib/features/devices/view/widgets/sos/sos_settings.dart +++ b/lib/features/devices/view/widgets/sos/sos_settings.dart @@ -37,7 +37,7 @@ class SosSettings extends StatelessWidget { builder: (context, state) { final sensor = BlocProvider.of(context); SosModel model = - SosModel(batteryPercentage: 0, waterContactState: 'normal'); + SosModel(batteryPercentage: 0, sosContactState: 'normal'); if (state is LoadingNewSate) { model = state.sosSensor; } else if (state is UpdateState) {