mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
power_clamp_issue
This commit is contained in:
41
assets/icons/voltage_icon.svg
Normal file
41
assets/icons/voltage_icon.svg
Normal file
@ -0,0 +1,41 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M11.998 2.5882C11.8004 2.5882 11.6403 2.42817 11.6403 2.23069V0.357516C11.6403 0.160078 11.8004 0 11.998 0C12.1956 0 12.3558 0.160031 12.3558 0.357516V2.23073C12.3558 2.42817 12.1956 2.5882 11.998 2.5882Z" fill="#E6E2E6"/>
|
||||
<path d="M5.22457 2.5882C5.02699 2.5882 4.86682 2.42817 4.86682 2.23069V0.357516C4.86682 0.160078 5.02699 0 5.22457 0C5.42215 0 5.58232 0.160031 5.58232 0.357516V2.23073C5.58232 2.42817 5.42215 2.5882 5.22457 2.5882Z" fill="#E6E2E6"/>
|
||||
<path d="M18.7714 2.5882C18.5738 2.5882 18.4137 2.42817 18.4137 2.23069V0.357516C18.4137 0.160078 18.5739 0 18.7714 0C18.969 0 19.1292 0.160031 19.1292 0.357516V2.23073C19.1292 2.42817 18.969 2.5882 18.7714 2.5882Z" fill="#E6E2E6"/>
|
||||
<path d="M17.6937 1.7467H19.8492C20.0782 1.7467 20.2814 1.8937 20.3528 2.1112L20.7326 3.26672C20.7832 3.42084 20.6683 3.57942 20.506 3.57942H17.0369C16.8746 3.57942 16.7596 3.42084 16.8103 3.26672L17.19 2.1112C17.2615 1.8937 17.4647 1.7467 17.6937 1.7467Z" fill="#545454"/>
|
||||
<path d="M17.6935 3.57938H19.8492C20.0782 3.57938 20.2814 3.72638 20.3528 3.94383L20.7326 5.0993C20.7832 5.25342 20.6683 5.412 20.506 5.412H17.0369C16.8746 5.412 16.7596 5.25342 16.8103 5.0993L17.1901 3.94359C17.2615 3.72628 17.4646 3.57938 17.6935 3.57938Z" fill="#545454"/>
|
||||
<path d="M17.6935 5.41205H19.8492C20.0782 5.41205 20.2814 5.55905 20.3528 5.77655L20.7326 6.93206C20.7832 7.08619 20.6683 7.24477 20.506 7.24477H17.0369C16.8746 7.24477 16.7596 7.08619 16.8103 6.93206L17.1901 5.77636C17.2615 5.55895 17.4646 5.41205 17.6935 5.41205Z" fill="#545454"/>
|
||||
<path d="M13.0759 1.7467H10.9203C10.6912 1.7467 10.488 1.8937 10.4166 2.1112L10.0369 3.26672C9.9862 3.42084 10.1011 3.57942 10.2635 3.57942H13.7325C13.8949 3.57942 14.0098 3.42084 13.9591 3.26672L13.5793 2.11102C13.5079 1.89361 13.3049 1.7467 13.0759 1.7467Z" fill="#545454"/>
|
||||
<path d="M13.0757 3.57938H10.9203C10.6912 3.57938 10.4881 3.72638 10.4166 3.94383L10.0369 5.0993C9.9862 5.25342 10.1011 5.412 10.2635 5.412H13.7325C13.8949 5.412 14.0098 5.25342 13.9591 5.0993L13.5794 3.94378C13.508 3.72638 13.3048 3.57938 13.0757 3.57938Z" fill="#545454"/>
|
||||
<path d="M13.0759 5.41205H10.9203C10.6912 5.41205 10.4881 5.55905 10.4166 5.77655L10.0369 6.93206C9.9862 7.08619 10.1011 7.24477 10.2635 7.24477H13.7325C13.8949 7.24477 14.0098 7.08619 13.9591 6.93206L13.5793 5.77636C13.5079 5.55895 13.3049 5.41205 13.0759 5.41205Z" fill="#545454"/>
|
||||
<path d="M6.30253 1.7467H4.14689C3.91781 1.7467 3.71465 1.8937 3.64321 2.1112L3.26343 3.26667C3.21276 3.4208 3.3277 3.57938 3.49003 3.57938H6.9591C7.12143 3.57938 7.23637 3.4208 7.1857 3.26667L6.80592 2.11097C6.73448 1.89361 6.53146 1.7467 6.30253 1.7467Z" fill="#545454"/>
|
||||
<path d="M3.44264 2.72137L3.26343 3.26667C3.21276 3.4208 3.3277 3.57937 3.49003 3.57937H6.9591C7.12143 3.57937 7.23637 3.4208 7.1857 3.26667L7.0065 2.72137H3.44264Z" fill="#494949"/>
|
||||
<path d="M6.30248 3.57938H4.14684C3.91776 3.57938 3.71461 3.72638 3.64317 3.94383L3.26343 5.0993C3.21276 5.25342 3.3277 5.412 3.49003 5.412H6.95911C7.12143 5.412 7.23637 5.25342 7.1857 5.0993L6.80592 3.94359C6.73443 3.72628 6.53142 3.57938 6.30248 3.57938Z" fill="#545454"/>
|
||||
<path d="M3.44264 4.55405L3.26343 5.09934C3.21276 5.25347 3.3277 5.41205 3.49003 5.41205H6.9591C7.12143 5.41205 7.23637 5.25347 7.1857 5.09934L7.0065 4.55405H3.44264Z" fill="#494949"/>
|
||||
<path d="M6.30225 5.41205H4.14684C3.91776 5.41205 3.71461 5.55905 3.64317 5.77655L3.26343 6.93206C3.21276 7.08619 3.3277 7.24477 3.49003 7.24477H6.95911C7.12143 7.24477 7.23637 7.08619 7.1857 6.93206L6.80596 5.77655C6.73448 5.55905 6.53132 5.41205 6.30225 5.41205Z" fill="#545454"/>
|
||||
<path d="M3.44264 6.38666L3.26343 6.93196C3.21276 7.08608 3.3277 7.24466 3.49003 7.24466H6.9591C7.12143 7.24466 7.23637 7.08608 7.1857 6.93196L7.0065 6.38666H3.44264Z" fill="#494949"/>
|
||||
<path d="M10.2161 2.72137L10.0369 3.26667C9.9862 3.4208 10.1011 3.57937 10.2635 3.57937H13.7325C13.8949 3.57937 14.0098 3.4208 13.9591 3.26667L13.7799 2.72137H10.2161Z" fill="#494949"/>
|
||||
<path d="M10.2161 4.55405L10.0369 5.09934C9.9862 5.25347 10.1011 5.41205 10.2635 5.41205H13.7325C13.8949 5.41205 14.0098 5.25347 13.9591 5.09934L13.7799 4.55405H10.2161Z" fill="#494949"/>
|
||||
<path d="M10.2161 6.38666L10.0369 6.93196C9.9862 7.08608 10.1011 7.24466 10.2635 7.24466H13.7325C13.8949 7.24466 14.0098 7.08608 13.9591 6.93196L13.7799 6.38666H10.2161Z" fill="#494949"/>
|
||||
<path d="M16.9895 2.72137L16.8103 3.26667C16.7596 3.4208 16.8746 3.57937 17.0369 3.57937H20.506C20.6683 3.57937 20.7832 3.4208 20.7326 3.26667L20.5534 2.72137H16.9895Z" fill="#494949"/>
|
||||
<path d="M16.9895 4.55405L16.8103 5.09934C16.7596 5.25347 16.8746 5.41205 17.0369 5.41205H20.506C20.6683 5.41205 20.7832 5.25347 20.7326 5.09934L20.5534 4.55405H16.9895Z" fill="#494949"/>
|
||||
<path d="M16.9895 6.38666L16.8103 6.93196C16.7596 7.08608 16.8746 7.24466 17.0369 7.24466H20.506C20.6683 7.24466 20.7832 7.08608 20.7326 6.93196L20.5534 6.38666H16.9895Z" fill="#494949"/>
|
||||
<path d="M11.0522 7.24466H12.9437V8.88885H11.0522V7.24466Z" fill="#545454"/>
|
||||
<path d="M4.27881 7.24466H6.17031V8.88885H4.27881V7.24466Z" fill="#545454"/>
|
||||
<path d="M19.7172 8.88892H17.8257V7.24473H19.7172V8.88892Z" fill="#545454"/>
|
||||
<path d="M1.21143 10.9806H22.7886V21.9083H1.21143V10.9806Z" fill="#545454"/>
|
||||
<path d="M1.21143 10.9806H22.7886V11.8386H1.21143V10.9806Z" fill="#494949"/>
|
||||
<path d="M11.998 12.3605C11.8004 12.3605 11.6403 12.2004 11.6403 12.003V10.7935C11.6403 10.596 11.8004 10.436 11.998 10.436C12.1956 10.436 12.3558 10.596 12.3558 10.7935V12.003C12.3558 12.2004 12.1956 12.3605 11.998 12.3605Z" fill="#E6E2E6"/>
|
||||
<path d="M5.22457 12.3605C5.02699 12.3605 4.86682 12.2004 4.86682 12.003V10.7935C4.86682 10.596 5.02699 10.436 5.22457 10.436C5.42215 10.436 5.58232 10.596 5.58232 10.7935V12.003C5.58232 12.2004 5.42215 12.3605 5.22457 12.3605Z" fill="#E6E2E6"/>
|
||||
<path d="M18.7714 12.3605C18.5738 12.3605 18.4137 12.2004 18.4137 12.003V10.7935C18.4137 10.596 18.5739 10.436 18.7714 10.436C18.969 10.436 19.1292 10.596 19.1292 10.7935V12.003C19.1292 12.2004 18.969 12.3605 18.7714 12.3605Z" fill="#E6E2E6"/>
|
||||
<path d="M23.5233 10.9806H0.476672C0.213422 10.9806 0 10.7672 0 10.5039V9.36559C0 9.10234 0.213422 8.88892 0.476672 8.88892H23.5233C23.7865 8.88892 24 9.10234 24 9.36559V10.5039C24 10.7672 23.7866 10.9806 23.5233 10.9806Z" fill="#A8A7A8"/>
|
||||
<path d="M23.5231 10.1226H0.476859C0.213516 10.1226 0 9.90929 0 9.64609V10.5041C0 10.7673 0.213516 10.9806 0.476859 10.9806H23.5231C23.7865 10.9806 24 10.7673 24 10.5041V9.64609C24 9.90929 23.7865 10.1226 23.5231 10.1226Z" fill="#818181"/>
|
||||
<path d="M23.5233 24H0.476672C0.213422 24 0 23.7866 0 23.5234V22.385C0 22.1217 0.213422 21.9083 0.476672 21.9083H23.5233C23.7865 21.9083 24 22.1217 24 22.385V23.5234C24 23.7866 23.7866 24 23.5233 24Z" fill="#A8A7A8"/>
|
||||
<path d="M23.5231 23.142H0.476859C0.213516 23.142 0 22.9287 0 22.6655V23.5235C0 23.7867 0.213516 24 0.476859 24H23.5231C23.7865 24 24 23.7867 24 23.5235V22.6655C24 22.9287 23.7865 23.142 23.5231 23.142Z" fill="#818181"/>
|
||||
<path d="M15.6454 19.172L12.6056 14.0633C12.3317 13.6029 11.6644 13.6029 11.3904 14.0633L8.35062 19.172C8.07068 19.6425 8.4102 20.2384 8.95816 20.2384H15.0378C15.5858 20.2384 15.9253 19.6425 15.6454 19.172Z" fill="#F6E266"/>
|
||||
<path d="M15.6023 19.0995C15.4767 19.2667 15.2772 19.3804 15.0379 19.3804H8.95829C8.71894 19.3804 8.51944 19.2667 8.39387 19.0995L8.35074 19.172C8.0708 19.6425 8.41032 20.2384 8.95829 20.2384H15.0379C15.5859 20.2384 15.9254 19.6425 15.6454 19.172L15.6023 19.0995Z" fill="#FFC239"/>
|
||||
<path d="M11.0522 8.06677H12.9437V8.88887H11.0522V8.06677Z" fill="#494949"/>
|
||||
<path d="M4.27881 8.06677H6.17031V8.88887H4.27881V8.06677Z" fill="#494949"/>
|
||||
<path d="M17.8257 8.06677H19.7172V8.88887H17.8257V8.06677Z" fill="#494949"/>
|
||||
<path d="M11.9225 15.9461L10.9958 17.4033C10.9256 17.5136 10.9211 17.6534 10.9841 17.7679C11.0471 17.8825 11.1675 17.9536 11.2983 17.9536H11.7902L11.2135 18.8605C11.1073 19.0275 11.1567 19.2488 11.3237 19.355C11.4658 19.449 11.7038 19.4221 11.8185 19.2448L12.7453 17.7876C12.8154 17.6773 12.8198 17.5376 12.7569 17.423C12.6939 17.3085 12.5735 17.2373 12.4427 17.2373H11.9508L12.5276 16.3304C12.6338 16.1634 12.5844 15.942 12.4173 15.8359C12.2503 15.7298 12.0287 15.7792 11.9225 15.9461Z" fill="#DD636E"/>
|
||||
</svg>
|
After Width: | Height: | Size: 8.1 KiB |
@ -23,7 +23,6 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
on<FilterRecordsByDateEvent>(_filterRecordsByDate);
|
||||
on<SelectDateEvent>(checkDayMonthYearSelected);
|
||||
on<SmartPowerFactoryReset>(_onFactoryReset);
|
||||
// FetchPowerClampBatchStatusEvent
|
||||
}
|
||||
|
||||
late PowerClampModel deviceStatus;
|
||||
@ -223,27 +222,27 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
phaseData = [
|
||||
{
|
||||
'name': 'Phase A',
|
||||
'voltage': '${deviceStatus.status.phaseA.dataPoints[0].value} V',
|
||||
'current': '${deviceStatus.status.phaseA.dataPoints[1].value} A',
|
||||
'voltage': '${deviceStatus.status.phaseA.dataPoints[0].value / 10} V',
|
||||
'current': '${deviceStatus.status.phaseA.dataPoints[1].value / 10} A',
|
||||
'activePower': '${deviceStatus.status.phaseA.dataPoints[2].value} W',
|
||||
'powerFactor': '${deviceStatus.status.phaseA.dataPoints[3].value}',
|
||||
},
|
||||
{
|
||||
'name': 'Phase B',
|
||||
'voltage': '${deviceStatus.status.phaseB.dataPoints[0].value} V',
|
||||
'current': '${deviceStatus.status.phaseB.dataPoints[1].value} A',
|
||||
'voltage': '${deviceStatus.status.phaseB.dataPoints[0].value / 10} V',
|
||||
'current': '${deviceStatus.status.phaseB.dataPoints[1].value / 10} A',
|
||||
'activePower': '${deviceStatus.status.phaseB.dataPoints[2].value} W',
|
||||
'powerFactor': '${deviceStatus.status.phaseB.dataPoints[3].value}',
|
||||
},
|
||||
{
|
||||
'name': 'Phase C',
|
||||
'voltage': '${deviceStatus.status.phaseC.dataPoints[0].value} V',
|
||||
'current': '${deviceStatus.status.phaseC.dataPoints[1].value} A',
|
||||
'voltage': '${deviceStatus.status.phaseC.dataPoints[0].value / 10} V',
|
||||
'current': '${deviceStatus.status.phaseC.dataPoints[1].value / 10} A',
|
||||
'activePower': '${deviceStatus.status.phaseC.dataPoints[2].value} W',
|
||||
'powerFactor': '${deviceStatus.status.phaseC.dataPoints[3].value}',
|
||||
},
|
||||
];
|
||||
emit(SmartPowerStatusLoaded(deviceStatus, currentPage));
|
||||
emit(GetDeviceStatus());
|
||||
} catch (e) {
|
||||
emit(SmartPowerError(e.toString()));
|
||||
}
|
||||
@ -253,12 +252,14 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
SmartPowerArrowPressedEvent event, Emitter<SmartPowerState> emit) {
|
||||
currentPage = (currentPage + event.direction + 4) % 4;
|
||||
emit(SmartPowerStatusLoaded(deviceStatus, currentPage));
|
||||
emit(GetDeviceStatus());
|
||||
}
|
||||
|
||||
FutureOr<void> _onPageChanged(
|
||||
SmartPowerPageChangedEvent event, Emitter<SmartPowerState> emit) {
|
||||
currentPage = event.page;
|
||||
emit(SmartPowerStatusLoaded(deviceStatus, currentPage));
|
||||
emit(GetDeviceStatus());
|
||||
}
|
||||
|
||||
Future<void> _onFactoryReset(
|
||||
@ -588,14 +589,16 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Pops without value, returning null
|
||||
Navigator.of(context)
|
||||
.pop(); // Pops without value, returning null
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
final selectedDateTime = DateTime(selectedYear);
|
||||
Navigator.of(context).pop(selectedDateTime); // Pops with the selected date
|
||||
Navigator.of(context).pop(
|
||||
selectedDateTime); // Pops with the selected date
|
||||
},
|
||||
),
|
||||
],
|
||||
@ -635,8 +638,7 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
minimumYear: 1900,
|
||||
maximumYear: DateTime.now().year,
|
||||
onDateTimeChanged: (DateTime newDateTime) {
|
||||
selectedDate =
|
||||
newDateTime; // Update the selected date when changed
|
||||
selectedDate = newDateTime;
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -650,15 +652,13 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pop(); // Dismiss the modal without returning a value
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pop(selectedDate); // Return the selected date
|
||||
Navigator.of(context).pop(selectedDate);
|
||||
},
|
||||
),
|
||||
],
|
||||
@ -674,6 +674,7 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
}
|
||||
|
||||
DateTime? dateTime = DateTime.now();
|
||||
|
||||
String formattedDate = DateFormat('yyyy/MM/dd').format(DateTime.now());
|
||||
|
||||
void checkDayMonthYearSelected(
|
||||
@ -708,12 +709,17 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
emit(SmartPowerLoading());
|
||||
});
|
||||
// Use the selected picker
|
||||
|
||||
await dateSelector(event.context).then((newDate) {
|
||||
add(FilterRecordsByDateEvent(
|
||||
selectedDate: dateTime!,
|
||||
viewType: views[currentIndex],
|
||||
));
|
||||
if (newDate.toString() == 'null') {
|
||||
emit(GetDeviceStatus());
|
||||
} else {
|
||||
dateTime = newDate;
|
||||
add(FilterRecordsByDateEvent(
|
||||
selectedDate: newDate!,
|
||||
viewType: views[currentIndex],
|
||||
));
|
||||
}
|
||||
// formattedDate = newDate.toString();
|
||||
});
|
||||
emit(FilterRecordsState(filteredRecords: energyDataList));
|
||||
|
||||
@ -725,21 +731,24 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
FilterRecordsByDateEvent event, Emitter<SmartPowerState> emit) {
|
||||
emit(SmartPowerLoading());
|
||||
|
||||
print('FilterRecordsByDate method called');
|
||||
print('Selected date: ${event.selectedDate}');
|
||||
print('View type: ${event.viewType}');
|
||||
|
||||
if (event.viewType == 'Year') {
|
||||
formattedDate = event.selectedDate.year.toString();
|
||||
filteredRecords = record
|
||||
.where((record) => record.eventTime!.year == event.selectedDate.year)
|
||||
.toList();
|
||||
} else if (event.viewType == 'Month') {
|
||||
formattedDate =
|
||||
"${event.selectedDate.year.toString()}-${getMonthShortName(event.selectedDate.month)}";
|
||||
|
||||
filteredRecords = record
|
||||
.where((record) =>
|
||||
record.eventTime!.year == event.selectedDate.year &&
|
||||
record.eventTime!.month == event.selectedDate.month)
|
||||
.toList();
|
||||
} else if (event.viewType == 'Day') {
|
||||
formattedDate =
|
||||
"${event.selectedDate.year.toString()}-${getMonthShortName(event.selectedDate.month)}-${event.selectedDate.day}";
|
||||
|
||||
filteredRecords = record
|
||||
.where((record) =>
|
||||
record.eventTime!.year == event.selectedDate.year &&
|
||||
@ -748,9 +757,7 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
.toList();
|
||||
}
|
||||
|
||||
print('Filtered Records: ${filteredRecords.length} items found.');
|
||||
|
||||
// Update `energyDataList` with filtered records.
|
||||
selectDateRange();
|
||||
energyDataList = filteredRecords.map((eventDevice) {
|
||||
return EnergyData(
|
||||
event.viewType == 'Year'
|
||||
@ -762,14 +769,6 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
double.parse(eventDevice.value!),
|
||||
);
|
||||
}).toList();
|
||||
|
||||
// if (filteredRecords.isEmpty) {
|
||||
// print('No records found for the selected date');
|
||||
// } else {
|
||||
// print('Filtered energyDataList: ${energyDataList.length} items found.');
|
||||
// }
|
||||
|
||||
// Emitting state for filtered data
|
||||
emit(FilterRecordsState(filteredRecords: energyDataList));
|
||||
}
|
||||
|
||||
@ -777,4 +776,13 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
||||
final date = DateTime(0, month);
|
||||
return DateFormat.MMM().format(date);
|
||||
}
|
||||
|
||||
String endChartDate = '';
|
||||
void selectDateRange() async {
|
||||
DateTime startDate = dateTime!;
|
||||
DateTime endDate = DateTime(startDate.year, startDate.month + 1, 1)
|
||||
.subtract(Duration(days: 1));
|
||||
String formattedEndDate = DateFormat('dd/MM/yyyy').format(endDate);
|
||||
endChartDate = ' - $formattedEndDate';
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ class SmartPowerState extends Equatable {
|
||||
class SmartPowerInitial extends SmartPowerState {}
|
||||
|
||||
class SmartPowerLoading extends SmartPowerState {}
|
||||
class GetDeviceStatus extends SmartPowerState {}
|
||||
//GetDeviceStatus
|
||||
|
||||
class SmartPowerLoadBatchControll extends SmartPowerState {
|
||||
final PowerClampBatchModel status;
|
||||
|
@ -90,188 +90,179 @@ class _EnergyConsumptionPageState extends State<EnergyConsumptionPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: LineChart(
|
||||
LineChartData(
|
||||
lineTouchData: LineTouchData(
|
||||
handleBuiltInTouches: true,
|
||||
touchSpotThreshold: 2,
|
||||
getTouchLineEnd: (barData, spotIndex) {
|
||||
return 10.0;
|
||||
Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.15,
|
||||
child: LineChart(
|
||||
LineChartData(
|
||||
lineTouchData: LineTouchData(
|
||||
handleBuiltInTouches: true,
|
||||
touchSpotThreshold: 2,
|
||||
getTouchLineEnd: (barData, spotIndex) {
|
||||
return 10.0;
|
||||
},
|
||||
touchTooltipData: LineTouchTooltipData(
|
||||
getTooltipColor: (touchTooltipItem) => Colors.white,
|
||||
tooltipRoundedRadius: 10.0,
|
||||
tooltipPadding: const EdgeInsets.all(8.0),
|
||||
tooltipBorder: const BorderSide(
|
||||
color: ColorsManager.grayColor, width: 1),
|
||||
getTooltipItems: (List<LineBarSpot> touchedSpots) {
|
||||
return touchedSpots.map((spot) {
|
||||
return LineTooltipItem(
|
||||
'${spot.x},\n ${spot.y.toStringAsFixed(2)} kWh',
|
||||
const TextStyle(
|
||||
color: Colors.blue,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
touchTooltipData: LineTouchTooltipData(
|
||||
getTooltipColor: (touchTooltipItem) =>
|
||||
Colors.white,
|
||||
tooltipRoundedRadius: 10.0,
|
||||
tooltipPadding: const EdgeInsets.all(8.0),
|
||||
tooltipBorder:
|
||||
BorderSide(color: Colors.grey, width: 1),
|
||||
getTooltipItems:
|
||||
(List<LineBarSpot> touchedSpots) {
|
||||
return touchedSpots.map((spot) {
|
||||
return LineTooltipItem(
|
||||
'${spot.x},\n ${spot.y.toStringAsFixed(2)} kWh',
|
||||
const TextStyle(
|
||||
color: Colors.blue,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
)),
|
||||
titlesData: FlTitlesData(
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: false,
|
||||
),
|
||||
),
|
||||
leftTitles: const AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: false,
|
||||
),
|
||||
),
|
||||
rightTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: false,
|
||||
),
|
||||
),
|
||||
topTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: false,
|
||||
reservedSize: 70,
|
||||
getTitlesWidget: (value, meta) {
|
||||
int index = value.toInt();
|
||||
if (index >= 0 && index < _chartData.length) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: RotatedBox(
|
||||
quarterTurns: -1,
|
||||
child: Text(_chartData[index].time,
|
||||
style: TextStyle(fontSize: 10)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
)),
|
||||
titlesData: FlTitlesData(
|
||||
bottomTitles: const AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: false,
|
||||
),
|
||||
),
|
||||
gridData: FlGridData(
|
||||
leftTitles: const AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: false,
|
||||
),
|
||||
),
|
||||
rightTitles: const AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: false,
|
||||
),
|
||||
),
|
||||
topTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: false,
|
||||
reservedSize: 70,
|
||||
getTitlesWidget: (value, meta) {
|
||||
int index = value.toInt();
|
||||
if (index >= 0 && index < _chartData.length) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: RotatedBox(
|
||||
quarterTurns: -1,
|
||||
child: Text(_chartData[index].time,
|
||||
style: TextStyle(fontSize: 10)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
gridData: FlGridData(
|
||||
show: true,
|
||||
drawVerticalLine: true,
|
||||
horizontalInterval: 1,
|
||||
verticalInterval: 1,
|
||||
getDrawingVerticalLine: (value) {
|
||||
return FlLine(
|
||||
color: Colors.grey.withOpacity(0.2),
|
||||
dashArray: [8, 8],
|
||||
strokeWidth: 1,
|
||||
);
|
||||
},
|
||||
getDrawingHorizontalLine: (value) {
|
||||
return FlLine(
|
||||
color: Colors.grey.withOpacity(0.2),
|
||||
dashArray: [5, 5],
|
||||
strokeWidth: 1,
|
||||
);
|
||||
},
|
||||
drawHorizontalLine: false,
|
||||
),
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
preventCurveOvershootingThreshold: 0.1,
|
||||
curveSmoothness: 0.5,
|
||||
preventCurveOverShooting: true,
|
||||
aboveBarData: BarAreaData(),
|
||||
spots: _chartData
|
||||
.asMap()
|
||||
.entries
|
||||
.map((entry) => FlSpot(entry.key.toDouble(),
|
||||
entry.value.consumption))
|
||||
.toList(),
|
||||
isCurved: true,
|
||||
color: ColorsManager.primaryColor.withOpacity(0.6),
|
||||
show: true,
|
||||
drawVerticalLine: true,
|
||||
horizontalInterval: 1,
|
||||
verticalInterval: 1,
|
||||
getDrawingVerticalLine: (value) {
|
||||
return FlLine(
|
||||
color: Colors.grey.withOpacity(0.2),
|
||||
dashArray: [8, 8],
|
||||
strokeWidth: 1,
|
||||
);
|
||||
},
|
||||
getDrawingHorizontalLine: (value) {
|
||||
return FlLine(
|
||||
color: Colors.grey.withOpacity(0.2),
|
||||
dashArray: [5, 5],
|
||||
strokeWidth: 1,
|
||||
);
|
||||
},
|
||||
drawHorizontalLine: false,
|
||||
),
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
preventCurveOvershootingThreshold: 0.1,
|
||||
curveSmoothness: 0.5,
|
||||
preventCurveOverShooting: true,
|
||||
aboveBarData: BarAreaData(),
|
||||
spots: _chartData
|
||||
.asMap()
|
||||
.entries
|
||||
.map((entry) => FlSpot(entry.key.toDouble(),
|
||||
entry.value.consumption))
|
||||
.toList(),
|
||||
isCurved: true,
|
||||
color: ColorsManager.primaryColor.withOpacity(0.6),
|
||||
shadow: const Shadow(color: Colors.black12),
|
||||
belowBarData: BarAreaData(
|
||||
show: true,
|
||||
shadow: Shadow(color: Colors.black12),
|
||||
belowBarData: BarAreaData(
|
||||
show: true,
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
ColorsManager.primaryColor.withOpacity(0.5),
|
||||
Colors.blue.withOpacity(0.1),
|
||||
],
|
||||
begin: Alignment.center,
|
||||
end: Alignment.bottomCenter,
|
||||
),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
ColorsManager.primaryColor.withOpacity(0.5),
|
||||
Colors.blue.withOpacity(0.1),
|
||||
],
|
||||
begin: Alignment.center,
|
||||
end: Alignment.bottomCenter,
|
||||
),
|
||||
dotData: FlDotData(
|
||||
show: false,
|
||||
),
|
||||
isStrokeCapRound: true,
|
||||
barWidth: 2,
|
||||
),
|
||||
],
|
||||
borderData: FlBorderData(
|
||||
show: false,
|
||||
border: Border.all(
|
||||
color: Color(0xff023DFE).withOpacity(0.7),
|
||||
width: 10,
|
||||
dotData: const FlDotData(
|
||||
show: false,
|
||||
),
|
||||
isStrokeCapRound: true,
|
||||
barWidth: 2,
|
||||
),
|
||||
],
|
||||
borderData: FlBorderData(
|
||||
show: false,
|
||||
border: Border.all(
|
||||
color: Color(0xff023DFE).withOpacity(0.7),
|
||||
width: 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.graysColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child:
|
||||
Expanded(child: Container(child: widget.widget)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.graysColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Container(child: widget.widget),
|
||||
),
|
||||
Spacer(),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.graysColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: widget.onTap,
|
||||
child: Center(
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(widget.formattedDate),
|
||||
),
|
||||
)),
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.graysColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: widget.onTap,
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(widget.formattedDate),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -284,4 +275,3 @@ class EnergyData {
|
||||
final String time;
|
||||
final double consumption;
|
||||
}
|
||||
//
|
@ -29,14 +29,13 @@ class SmartPowerDeviceControl extends StatelessWidget
|
||||
|
||||
if (state is SmartPowerLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (state is SmartPowerLoadBatchControll) {
|
||||
} else if (state is GetDeviceStatus) {
|
||||
return _buildStatusControls(
|
||||
currentPage: _blocProvider.currentPage,
|
||||
context: context,
|
||||
blocProvider: _blocProvider,
|
||||
);
|
||||
} else if (state is FilterRecordsState) {
|
||||
// Handle the state when the records are filtered
|
||||
return _buildStatusControls(
|
||||
currentPage: _blocProvider.currentPage,
|
||||
context: context,
|
||||
@ -103,14 +102,14 @@ class SmartPowerDeviceControl extends StatelessWidget
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
PhaseWidget(
|
||||
phaseData: blocProvider.phaseData,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10,
|
||||
left: 20,
|
||||
right: 20,
|
||||
@ -136,7 +135,7 @@ class SmartPowerDeviceControl extends StatelessWidget
|
||||
onPressed: () {
|
||||
blocProvider.add(SmartPowerArrowPressedEvent(-1));
|
||||
_pageController.previousPage(
|
||||
duration: Duration(milliseconds: 300),
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
},
|
||||
@ -149,14 +148,14 @@ class SmartPowerDeviceControl extends StatelessWidget
|
||||
: currentPage == 2
|
||||
? 'Phase B'
|
||||
: 'Phase C',
|
||||
style: TextStyle(fontSize: 18),
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_right),
|
||||
icon: const Icon(Icons.arrow_right),
|
||||
onPressed: () {
|
||||
blocProvider.add(SmartPowerArrowPressedEvent(1));
|
||||
_pageController.nextPage(
|
||||
duration: Duration(milliseconds: 300),
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
},
|
||||
@ -164,7 +163,7 @@ class SmartPowerDeviceControl extends StatelessWidget
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Expanded(
|
||||
@ -173,9 +172,11 @@ class SmartPowerDeviceControl extends StatelessWidget
|
||||
onPageChanged: (int page) {
|
||||
blocProvider.add(SmartPowerPageChangedEvent(page));
|
||||
},
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: [
|
||||
EnergyConsumptionPage(
|
||||
formattedDate: blocProvider.formattedDate,
|
||||
formattedDate:
|
||||
'${blocProvider.formattedDate}${blocProvider.endChartDate}',
|
||||
onTap: () {
|
||||
blocProvider.add(SelectDateEvent(context: context));
|
||||
blocProvider.add(FilterRecordsByDateEvent(
|
||||
@ -201,7 +202,7 @@ class SmartPowerDeviceControl extends StatelessWidget
|
||||
EnergyData('11:00 AM', 4.0),
|
||||
],
|
||||
totalConsumption: 10000,
|
||||
date: '10/08/2024',
|
||||
date: blocProvider.formattedDate,
|
||||
),
|
||||
EnergyConsumptionPage(
|
||||
formattedDate: blocProvider.formattedDate,
|
||||
@ -226,7 +227,7 @@ class SmartPowerDeviceControl extends StatelessWidget
|
||||
EnergyData('11:00 AM', 4.0),
|
||||
],
|
||||
totalConsumption: 10000,
|
||||
date: '10/08/2024',
|
||||
date: blocProvider.formattedDate,
|
||||
),
|
||||
EnergyConsumptionPage(
|
||||
formattedDate: blocProvider.formattedDate,
|
||||
@ -251,7 +252,7 @@ class SmartPowerDeviceControl extends StatelessWidget
|
||||
EnergyData('11:00 AM', 6.0),
|
||||
],
|
||||
totalConsumption: 10000,
|
||||
date: '10/08/2024',
|
||||
date: blocProvider.formattedDate,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -205,7 +205,6 @@ class DevicesManagementApi {
|
||||
queryParameters: queryParameters,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
print('object======$json');
|
||||
return json;
|
||||
},
|
||||
);
|
||||
|
Reference in New Issue
Block a user