handle Lux description for illumnance sensor

This commit is contained in:
ashrafzarkanisala
2024-09-03 13:37:33 +03:00
parent ece37fc3c1
commit 040e678b1e
4 changed files with 8 additions and 5 deletions

View File

@ -58,7 +58,7 @@ class ReportsTable extends StatelessWidget {
TableCellWidget(value: date), TableCellWidget(value: date),
TableCellWidget(value: time), TableCellWidget(value: time),
TableCellWidget( TableCellWidget(
value: '${data.value!} $thirdColumnDescription', value: '${data.value!} ${thirdColumnDescription ?? ''}',
onTap: () => onRowTap(index), onTap: () => onRowTap(index),
), ),
], ],

View File

@ -99,7 +99,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
try { try {
await DevicesManagementApi.getDeviceReports(deviceId, event.code) await DevicesManagementApi.getDeviceReports(deviceId, event.code)
.then((value) { .then((value) {
emit(DeviceReportsState(deviceReport: value)); emit(DeviceReportsState(deviceReport: value, code:event.code));
}); });
} catch (e) { } catch (e) {
emit(DeviceReportsFailedState(error: e.toString())); emit(DeviceReportsFailedState(error: e.toString()));

View File

@ -42,7 +42,8 @@ class DeviceReportsLoadingState extends WallSensorState {}
class DeviceReportsState extends WallSensorState { class DeviceReportsState extends WallSensorState {
final DeviceReport deviceReport; final DeviceReport deviceReport;
const DeviceReportsState({required this.deviceReport}); final String code;
const DeviceReportsState({required this.deviceReport, required this.code});
} }
class DeviceReportsFailedState extends WallSensorState { class DeviceReportsFailedState extends WallSensorState {

View File

@ -38,8 +38,10 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
} else if (state is DeviceReportsState) { } else if (state is DeviceReportsState) {
return ReportsTable( return ReportsTable(
report: state.deviceReport, report: state.deviceReport,
thirdColumnTitle: "Value", thirdColumnTitle:
thirdColumnDescription: "Lux", state.code == 'illuminance_value' ? "Value" : 'Status',
thirdColumnDescription:
state.code == 'illuminance_value' ? "Lux" : null,
onRowTap: (index) {}, onRowTap: (index) {},
onClose: () { onClose: () {
context.read<WallSensorBloc>().add(BackToGridViewEvent()); context.read<WallSensorBloc>().add(BackToGridViewEvent());