mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
fixes bugs and re add checkboxes theme
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:syncrow_web/core/extension/build_context_x.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/helper/route_controls_based_code.dart';
|
||||
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/core/extension/build_context_x.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
@ -9,10 +10,12 @@ class PresenceSpaceType extends StatelessWidget {
|
||||
super.key,
|
||||
required this.listOfIcons,
|
||||
required this.description,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
final List<String> listOfIcons;
|
||||
final String description;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -36,10 +39,20 @@ class PresenceSpaceType extends StatelessWidget {
|
||||
runSpacing: 8,
|
||||
spacing: 16,
|
||||
children: [
|
||||
...listOfIcons.map((icon) => SvgPicture.asset(
|
||||
icon,
|
||||
width: 40,
|
||||
height: 40,
|
||||
...listOfIcons.map((icon) => Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
border: Border.all(
|
||||
color: icon.contains(value)
|
||||
? ColorsManager.blueColor
|
||||
: Colors.transparent,
|
||||
),
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
icon,
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
|
@ -23,6 +23,8 @@ class PresenceNoBodyTime extends StatefulWidget {
|
||||
|
||||
class _PresenceUpdateDataState extends State<PresenceNoBodyTime> {
|
||||
late String _currentValue;
|
||||
late String _numericValue;
|
||||
late String _unit;
|
||||
|
||||
final List<String> nobodyTimeRange = [
|
||||
'none',
|
||||
@ -40,29 +42,45 @@ class _PresenceUpdateDataState extends State<PresenceNoBodyTime> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_currentValue = widget.value;
|
||||
_numericValue = _extractNumericValue(_currentValue);
|
||||
_unit = _extractUnit(_currentValue);
|
||||
}
|
||||
|
||||
String _extractNumericValue(String value) {
|
||||
if (value == 'none') return '0';
|
||||
return value.replaceAll(RegExp(r'[a-zA-Z]'), '').trim();
|
||||
}
|
||||
|
||||
String _extractUnit(String value) {
|
||||
if (value == 'none') return '';
|
||||
if (value.endsWith('s')) return 's';
|
||||
if (value.endsWith('min')) return 'min';
|
||||
if (value.endsWith('hour')) return 'hr';
|
||||
return '';
|
||||
}
|
||||
|
||||
void _onValueChanged(String newValue) {
|
||||
setState(() {
|
||||
_currentValue = newValue;
|
||||
_numericValue = _extractNumericValue(newValue);
|
||||
_unit = _extractUnit(newValue);
|
||||
});
|
||||
widget.action(newValue);
|
||||
}
|
||||
|
||||
void _incrementValue() {
|
||||
int currentIndex = nobodyTimeRange.indexOf(_currentValue);
|
||||
if (currentIndex < nobodyTimeRange.length - 1) {
|
||||
setState(() {
|
||||
_currentValue = nobodyTimeRange[currentIndex + 1];
|
||||
});
|
||||
_onValueChanged(_currentValue);
|
||||
String newValue = nobodyTimeRange[currentIndex + 1];
|
||||
_onValueChanged(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
void _decrementValue() {
|
||||
int currentIndex = nobodyTimeRange.indexOf(_currentValue);
|
||||
if (currentIndex > 0) {
|
||||
setState(() {
|
||||
_currentValue = nobodyTimeRange[currentIndex - 1];
|
||||
});
|
||||
_onValueChanged(_currentValue);
|
||||
String newValue = nobodyTimeRange[currentIndex - 1];
|
||||
_onValueChanged(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,11 +99,12 @@ class _PresenceUpdateDataState extends State<PresenceNoBodyTime> {
|
||||
fontSize: 10),
|
||||
),
|
||||
IncrementDecrementWidget(
|
||||
value: _currentValue,
|
||||
description: widget.description ?? '',
|
||||
descriptionColor: ColorsManager.blackColor,
|
||||
onIncrement: _incrementValue,
|
||||
onDecrement: _decrementValue),
|
||||
value: _numericValue,
|
||||
description: _unit,
|
||||
descriptionColor: ColorsManager.blackColor,
|
||||
onIncrement: _incrementValue,
|
||||
onDecrement: _decrementValue,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user