mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-03-10 22:41:44 +00:00
sos
This commit is contained in:
@ -42,7 +42,7 @@ class SosBloc extends Bloc<SosEvent, SosState> {
|
||||
bool closingReminder = false;
|
||||
bool waterAlarm = false;
|
||||
SosModel deviceStatus =
|
||||
SosModel(waterContactState: 'normal', batteryPercentage: 0);
|
||||
SosModel(sosContactState: 'normal', batteryPercentage: 0);
|
||||
|
||||
void _fetchStatus(SosInitial event, Emitter<SosState> emit) async {
|
||||
emit(SosLoadingState());
|
||||
|
||||
@ -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<StatusModel> 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,
|
||||
);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ class SosScreen extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SosBloc>(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,
|
||||
|
||||
@ -26,7 +26,7 @@ class LocationSosPage extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SosBloc>(context);
|
||||
SosModel model =
|
||||
SosModel(batteryPercentage: 0, waterContactState: 'normal');
|
||||
SosModel(batteryPercentage: 0, sosContactState: 'normal');
|
||||
|
||||
return state is SosLoadingState
|
||||
? const Center(
|
||||
|
||||
@ -29,7 +29,7 @@ class QuestionPage extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SosBloc>(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) {
|
||||
|
||||
@ -28,7 +28,7 @@ class ShareSosPage extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SosBloc>(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) {
|
||||
|
||||
@ -28,7 +28,7 @@ class SosInfoPge extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SosBloc>(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) {
|
||||
|
||||
@ -32,7 +32,7 @@ class SosProfilePage extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SosBloc>(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) {
|
||||
|
||||
@ -37,7 +37,7 @@ class SosSettings extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SosBloc>(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) {
|
||||
|
||||
Reference in New Issue
Block a user