mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
push nobody_time update
This commit is contained in:
@ -10,7 +10,7 @@ abstract class CeilingSensorEvent extends Equatable {
|
|||||||
class CeilingInitialEvent extends CeilingSensorEvent {}
|
class CeilingInitialEvent extends CeilingSensorEvent {}
|
||||||
|
|
||||||
class CeilingChangeValueEvent extends CeilingSensorEvent {
|
class CeilingChangeValueEvent extends CeilingSensorEvent {
|
||||||
final int value;
|
final dynamic value;
|
||||||
final String code;
|
final String code;
|
||||||
const CeilingChangeValueEvent({required this.value, required this.code});
|
const CeilingChangeValueEvent({required this.value, required this.code});
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
||||||
|
|
||||||
class CeilingSensorModel {
|
class CeilingSensorModel {
|
||||||
@ -7,48 +8,63 @@ class CeilingSensorModel {
|
|||||||
int presenceRange;
|
int presenceRange;
|
||||||
int sportsPara;
|
int sportsPara;
|
||||||
String bodyMovement;
|
String bodyMovement;
|
||||||
int noBodyTime;
|
String noBodyTime;
|
||||||
int maxDistance;
|
int maxDistance;
|
||||||
|
|
||||||
CeilingSensorModel(
|
CeilingSensorModel({
|
||||||
{required this.presenceState,
|
required this.presenceState,
|
||||||
required this.sensitivity,
|
required this.sensitivity,
|
||||||
required this.checkingResult,
|
required this.checkingResult,
|
||||||
required this.presenceRange,
|
required this.presenceRange,
|
||||||
required this.sportsPara,
|
required this.sportsPara,
|
||||||
required this.bodyMovement,
|
required this.bodyMovement,
|
||||||
required this.noBodyTime,
|
required this.noBodyTime,
|
||||||
required this.maxDistance});
|
required this.maxDistance,
|
||||||
|
});
|
||||||
|
|
||||||
factory CeilingSensorModel.fromJson(List<Status> jsonList) {
|
factory CeilingSensorModel.fromJson(List<Status> jsonList) {
|
||||||
late String _presenceState;
|
late String _presenceState = 'none';
|
||||||
late int _sensitivity;
|
late int _sensitivity = 1;
|
||||||
late String _checkingResult;
|
late String _checkingResult = '';
|
||||||
int _presenceRange = 1;
|
int _presenceRange = 1;
|
||||||
int _sportsPara = 1;
|
int _sportsPara = 1;
|
||||||
String _bodyMovement = 'none';
|
String _bodyMovement = 'none';
|
||||||
int _noBodyTime = 0;
|
String _noBodyTime = 'none';
|
||||||
int _maxDis = 0;
|
int _maxDis = 0;
|
||||||
|
|
||||||
for (int i = 0; i < jsonList.length; i++) {
|
try {
|
||||||
if (jsonList[i].code == 'presence_state') {
|
for (var status in jsonList) {
|
||||||
_presenceState = jsonList[i].value ?? 'none';
|
switch (status.code) {
|
||||||
} else if (jsonList[i].code == 'sensitivity') {
|
case 'presence_state':
|
||||||
_sensitivity = jsonList[i].value ?? 1;
|
_presenceState = status.value ?? 'none';
|
||||||
} else if (jsonList[i].code == 'checking_result') {
|
break;
|
||||||
_checkingResult = jsonList[i].value ?? '';
|
case 'sensitivity':
|
||||||
} else if (jsonList[i].code == 'presence_range') {
|
_sensitivity = status.value is int ? status.value : int.tryParse(status.value ?? '1') ?? 1;
|
||||||
_presenceRange = jsonList[i].value ?? 0;
|
break;
|
||||||
} else if (jsonList[i].code == 'sports_para') {
|
case 'checking_result':
|
||||||
_sportsPara = jsonList[i].value ?? 0;
|
_checkingResult = status.value ?? '';
|
||||||
} else if (jsonList[i].code == 'body_movement') {
|
break;
|
||||||
_bodyMovement = jsonList[i].value ?? '';
|
case 'presence_range':
|
||||||
} else if (jsonList[i].code == 'none_body_time') {
|
_presenceRange = status.value is int ? status.value : int.tryParse(status.value ?? '0') ?? 0;
|
||||||
_noBodyTime = jsonList[i].value ?? 0;
|
break;
|
||||||
} else if (jsonList[i].code == 'moving_max_dis') {
|
case 'sports_para':
|
||||||
_maxDis = jsonList[i].value ?? 0;
|
_sportsPara = status.value is int ? status.value : int.tryParse(status.value ?? '0') ?? 0;
|
||||||
|
break;
|
||||||
|
case 'body_movement':
|
||||||
|
_bodyMovement = status.value ?? '';
|
||||||
|
break;
|
||||||
|
case 'nobody_time':
|
||||||
|
_noBodyTime = status.value ?? 'none';
|
||||||
|
break;
|
||||||
|
case 'moving_max_dis':
|
||||||
|
_maxDis = status.value is int ? status.value : int.tryParse(status.value ?? '0') ?? 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint(e.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return CeilingSensorModel(
|
return CeilingSensorModel(
|
||||||
presenceState: _presenceState,
|
presenceState: _presenceState,
|
||||||
sensitivity: _sensitivity,
|
sensitivity: _sensitivity,
|
||||||
@ -57,6 +73,7 @@ class CeilingSensorModel {
|
|||||||
sportsPara: _sportsPara,
|
sportsPara: _sportsPara,
|
||||||
bodyMovement: _bodyMovement,
|
bodyMovement: _bodyMovement,
|
||||||
noBodyTime: _noBodyTime,
|
noBodyTime: _noBodyTime,
|
||||||
maxDistance: _maxDis);
|
maxDistance: _maxDis,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presen
|
|||||||
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_static_widget.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_static_widget.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_status.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_status.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_update_data.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_update_data.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presense_nobody_time.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/table/description_view.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/table/description_view.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
@ -134,18 +135,17 @@ class CeilingSensorControls extends StatelessWidget
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PresenceUpdateData(
|
PresenceNoBodyTime(
|
||||||
value: (model.noBodyTime.toDouble() / 3600).roundToDouble(),
|
value: model.noBodyTime,
|
||||||
title: 'Nobody Time:',
|
title: 'Nobody Time:',
|
||||||
minValue: 0,
|
// description: 'hr',
|
||||||
maxValue: 300000,
|
action: (String value) => context.read<CeilingSensorBloc>().add(
|
||||||
steps: 5000,
|
CeilingChangeValueEvent(
|
||||||
description: 'hr',
|
code: 'nobody_time',
|
||||||
action: (int value) =>
|
|
||||||
context.read<CeilingSensorBloc>().add(CeilingChangeValueEvent(
|
|
||||||
code: 'none_body_time',
|
|
||||||
value: value,
|
value: value,
|
||||||
))),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<CeilingSensorBloc>().add(GetCeilingDeviceReportsEvent(
|
context.read<CeilingSensorBloc>().add(GetCeilingDeviceReportsEvent(
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/increament_decreament.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
|
class PresenceNoBodyTime extends StatefulWidget {
|
||||||
|
const PresenceNoBodyTime({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
required this.value,
|
||||||
|
required this.action,
|
||||||
|
this.description,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String title;
|
||||||
|
final String value;
|
||||||
|
final Function(String) action;
|
||||||
|
final String? description;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PresenceNoBodyTime> createState() => _PresenceUpdateDataState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PresenceUpdateDataState extends State<PresenceNoBodyTime> {
|
||||||
|
late String _currentValue;
|
||||||
|
|
||||||
|
final List<String> nobodyTimeRange = [
|
||||||
|
'none',
|
||||||
|
'10s',
|
||||||
|
'30s',
|
||||||
|
'1min',
|
||||||
|
'2min',
|
||||||
|
'5min',
|
||||||
|
'10min',
|
||||||
|
'30min',
|
||||||
|
'1hour'
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_currentValue = widget.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onValueChanged(String newValue) {
|
||||||
|
widget.action(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _incrementValue() {
|
||||||
|
int currentIndex = nobodyTimeRange.indexOf(_currentValue);
|
||||||
|
if (currentIndex < nobodyTimeRange.length - 1) {
|
||||||
|
setState(() {
|
||||||
|
_currentValue = nobodyTimeRange[currentIndex + 1];
|
||||||
|
});
|
||||||
|
_onValueChanged(_currentValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _decrementValue() {
|
||||||
|
int currentIndex = nobodyTimeRange.indexOf(_currentValue);
|
||||||
|
if (currentIndex > 0) {
|
||||||
|
setState(() {
|
||||||
|
_currentValue = nobodyTimeRange[currentIndex - 1];
|
||||||
|
});
|
||||||
|
_onValueChanged(_currentValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return DeviceControlsContainer(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.title,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 10),
|
||||||
|
),
|
||||||
|
IncrementDecrementWidget(
|
||||||
|
value: _currentValue,
|
||||||
|
description: widget.description ?? '',
|
||||||
|
descriptionColor: ColorsManager.blackColor,
|
||||||
|
onIncrement: _incrementValue,
|
||||||
|
onDecrement: _decrementValue),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user