mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 20:47:55 +00:00
Add status model and fetch device statuses
Added a new StatusModel class to represent device statuses and implemented functionality to fetch and update device statuses in the DevicesCubit and DeviceModel classes. Also updated UI components to display device status information.
This commit is contained in:
@@ -72,7 +72,11 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
||||
),
|
||||
// min: DeviceModel.bounds.min,
|
||||
// max: DeviceModel.bounds.max,
|
||||
// initialValue: DeviceModel.temperature,
|
||||
initialValue: deviceModel.status
|
||||
.firstWhere(
|
||||
(element) => element.code == 'temp_current')
|
||||
.value /
|
||||
10,
|
||||
onChange: (value) {
|
||||
String valueAsString = value.toStringAsFixed(1);
|
||||
if (valueAsString.endsWith(".0") ||
|
||||
@@ -107,7 +111,8 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
||||
children: [
|
||||
BodyLarge(
|
||||
// text: "${DeviceModel.coolTo}° C",
|
||||
text: '24° C',
|
||||
text:
|
||||
'${deviceModel.status.firstWhere((element) => element.code == 'temp_set').value / 10}° C',
|
||||
style: context.bodyLarge.copyWith(
|
||||
color:
|
||||
ColorsManager.primaryColor.withOpacity(0.6),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
|
||||
@@ -17,18 +18,18 @@ class ACModeControlUnit extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ACModeControlUnitState extends State<ACModeControlUnit> {
|
||||
var fanSpeeds = [
|
||||
Assets.iconsFan0,
|
||||
Assets.iconsFan1,
|
||||
Assets.iconsFan2,
|
||||
Assets.iconsFan3,
|
||||
];
|
||||
Map<String, String> fanSpeedsMap = {
|
||||
'auto': Assets.iconsFan0,
|
||||
'iconsFan1': Assets.iconsFan1,
|
||||
'iconsFan2': Assets.iconsFan2,
|
||||
'iconsFan3': Assets.iconsFan3,
|
||||
};
|
||||
|
||||
var tempModes = [
|
||||
Assets.iconsSunnyMode,
|
||||
Assets.iconsColdMode,
|
||||
Assets.iconsWindyMode,
|
||||
];
|
||||
Map<String, String> tempModesMap = {
|
||||
'sunny': Assets.iconsSunnyMode,
|
||||
'cold': Assets.iconsColdMode,
|
||||
'windy': Assets.iconsWindyMode,
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -43,11 +44,13 @@ class _ACModeControlUnitState extends State<ACModeControlUnit> {
|
||||
// widget.model.fanSpeed == 3 ? 0 : widget.model.fanSpeed + 1;
|
||||
});
|
||||
},
|
||||
child: const DefaultContainer(
|
||||
child: DefaultContainer(
|
||||
height: 55,
|
||||
child: Center(
|
||||
// child: SvgPicture.asset(fanSpeeds[widget.model.fanSpeed]),
|
||||
),
|
||||
child: SvgPicture.asset(fanSpeedsMap[widget.model.status
|
||||
.firstWhere((element) => element.code == 'level')
|
||||
.value]!),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -60,12 +63,13 @@ class _ACModeControlUnitState extends State<ACModeControlUnit> {
|
||||
// widget.model.tempMode == 2 ? 0 : widget.model.tempMode + 1;
|
||||
});
|
||||
},
|
||||
child: const DefaultContainer(
|
||||
child: DefaultContainer(
|
||||
height: 55,
|
||||
child: Center(
|
||||
// child: SvgPicture.asset(tempModes[widget.model.tempMode]),
|
||||
|
||||
),
|
||||
child: SvgPicture.asset(tempModesMap[widget.model.status
|
||||
.firstWhere((element) => element.code == 'mode')
|
||||
.value]!),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user