mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +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 CeilingChangeValueEvent extends CeilingSensorEvent {
|
||||
final int value;
|
||||
final dynamic value;
|
||||
final String 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';
|
||||
|
||||
class CeilingSensorModel {
|
||||
@ -7,48 +8,63 @@ class CeilingSensorModel {
|
||||
int presenceRange;
|
||||
int sportsPara;
|
||||
String bodyMovement;
|
||||
int noBodyTime;
|
||||
String noBodyTime;
|
||||
int maxDistance;
|
||||
|
||||
CeilingSensorModel(
|
||||
{required this.presenceState,
|
||||
CeilingSensorModel({
|
||||
required this.presenceState,
|
||||
required this.sensitivity,
|
||||
required this.checkingResult,
|
||||
required this.presenceRange,
|
||||
required this.sportsPara,
|
||||
required this.bodyMovement,
|
||||
required this.noBodyTime,
|
||||
required this.maxDistance});
|
||||
required this.maxDistance,
|
||||
});
|
||||
|
||||
factory CeilingSensorModel.fromJson(List<Status> jsonList) {
|
||||
late String _presenceState;
|
||||
late int _sensitivity;
|
||||
late String _checkingResult;
|
||||
late String _presenceState = 'none';
|
||||
late int _sensitivity = 1;
|
||||
late String _checkingResult = '';
|
||||
int _presenceRange = 1;
|
||||
int _sportsPara = 1;
|
||||
String _bodyMovement = 'none';
|
||||
int _noBodyTime = 0;
|
||||
String _noBodyTime = 'none';
|
||||
int _maxDis = 0;
|
||||
|
||||
for (int i = 0; i < jsonList.length; i++) {
|
||||
if (jsonList[i].code == 'presence_state') {
|
||||
_presenceState = jsonList[i].value ?? 'none';
|
||||
} else if (jsonList[i].code == 'sensitivity') {
|
||||
_sensitivity = jsonList[i].value ?? 1;
|
||||
} else if (jsonList[i].code == 'checking_result') {
|
||||
_checkingResult = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'presence_range') {
|
||||
_presenceRange = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'sports_para') {
|
||||
_sportsPara = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'body_movement') {
|
||||
_bodyMovement = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'none_body_time') {
|
||||
_noBodyTime = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'moving_max_dis') {
|
||||
_maxDis = jsonList[i].value ?? 0;
|
||||
try {
|
||||
for (var status in jsonList) {
|
||||
switch (status.code) {
|
||||
case 'presence_state':
|
||||
_presenceState = status.value ?? 'none';
|
||||
break;
|
||||
case 'sensitivity':
|
||||
_sensitivity = status.value is int ? status.value : int.tryParse(status.value ?? '1') ?? 1;
|
||||
break;
|
||||
case 'checking_result':
|
||||
_checkingResult = status.value ?? '';
|
||||
break;
|
||||
case 'presence_range':
|
||||
_presenceRange = status.value is int ? status.value : int.tryParse(status.value ?? '0') ?? 0;
|
||||
break;
|
||||
case 'sports_para':
|
||||
_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(
|
||||
presenceState: _presenceState,
|
||||
sensitivity: _sensitivity,
|
||||
@ -57,6 +73,7 @@ class CeilingSensorModel {
|
||||
sportsPara: _sportsPara,
|
||||
bodyMovement: _bodyMovement,
|
||||
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_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/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/report_table.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
@ -134,18 +135,17 @@ class CeilingSensorControls extends StatelessWidget
|
||||
),
|
||||
),
|
||||
),
|
||||
PresenceUpdateData(
|
||||
value: (model.noBodyTime.toDouble() / 3600).roundToDouble(),
|
||||
PresenceNoBodyTime(
|
||||
value: model.noBodyTime,
|
||||
title: 'Nobody Time:',
|
||||
minValue: 0,
|
||||
maxValue: 300000,
|
||||
steps: 5000,
|
||||
description: 'hr',
|
||||
action: (int value) =>
|
||||
context.read<CeilingSensorBloc>().add(CeilingChangeValueEvent(
|
||||
code: 'none_body_time',
|
||||
// description: 'hr',
|
||||
action: (String value) => context.read<CeilingSensorBloc>().add(
|
||||
CeilingChangeValueEvent(
|
||||
code: 'nobody_time',
|
||||
value: value,
|
||||
))),
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
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