refactor(ui): update DetailDevice screen layout
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:sfm_app/product/shared/model/district_model.dart';
|
||||
import 'package:sfm_app/product/shared/model/province_model.dart';
|
||||
|
||||
import '../../feature/devices/device_model.dart';
|
||||
import '../constant/icon/icon_constants.dart';
|
||||
import '../shared/model/ward_model.dart';
|
||||
|
||||
class DeviceUtils {
|
||||
@@ -63,13 +64,13 @@ class DeviceUtils {
|
||||
}
|
||||
}
|
||||
if (sensor.name == "7") {
|
||||
map['sensorVolt'] = "${(sensor.value!) / 1000} V";
|
||||
map['sensorVolt'] = "${(sensor.value!) / 1000}";
|
||||
}
|
||||
if (sensor.name == "8") {
|
||||
map['sensorTemp'] = "${sensor.value}°C";
|
||||
map['sensorTemp'] = "${sensor.value}";
|
||||
}
|
||||
if (sensor.name == "9") {
|
||||
map['sensorHum'] = "${sensor.value} %";
|
||||
map['sensorHum'] = "${sensor.value}";
|
||||
}
|
||||
if (sensor.name == "10") {
|
||||
map['sensorBattery'] = "${sensor.value}";
|
||||
@@ -270,4 +271,53 @@ class DeviceUtils {
|
||||
return Colors.green;
|
||||
}
|
||||
}
|
||||
|
||||
List<String> deviceBatteryImg = [
|
||||
IconConstants.instance.getIcon("full-battery"),
|
||||
IconConstants.instance.getIcon("half-battery"),
|
||||
IconConstants.instance.getIcon("low-battery"),
|
||||
IconConstants.instance.getIcon("empty-battery"),
|
||||
];
|
||||
|
||||
String getDeviceBatteryImg(int battery) {
|
||||
if (battery <= 5) {
|
||||
return deviceBatteryImg[3];
|
||||
} else if (battery <= 20) {
|
||||
return deviceBatteryImg[2];
|
||||
} else if (battery <= 90) {
|
||||
return deviceBatteryImg[1];
|
||||
} else {
|
||||
return deviceBatteryImg[0];
|
||||
}
|
||||
}
|
||||
|
||||
Color getDeviceTempColor(int temp) {
|
||||
if (temp < 30) {
|
||||
return Colors.green;
|
||||
} else if (temp < 50) {
|
||||
return Colors.orange;
|
||||
} else {
|
||||
return Colors.red;
|
||||
}
|
||||
}
|
||||
|
||||
Color getDeviceBatteryColor(int battery) {
|
||||
if (battery < 20) {
|
||||
return Colors.red;
|
||||
} else if (battery < 80) {
|
||||
return Colors.orange;
|
||||
} else {
|
||||
return Colors.green;
|
||||
}
|
||||
}
|
||||
|
||||
Color getSignalIconColor(BuildContext context, String signal) {
|
||||
if (signal == appLocalization(context).gf_weak_signal_message) {
|
||||
return Colors.red;
|
||||
} else if (signal == appLocalization(context).gf_moderate_signal_message) {
|
||||
return Colors.yellow;
|
||||
} else {
|
||||
return Colors.green;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user