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:
@ -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