add settings to flush sensor

This commit is contained in:
mohammad
2025-05-07 10:37:59 +03:00
parent 56007d6a8c
commit a1954b3ad3
2 changed files with 64 additions and 1 deletions

View File

@ -22,6 +22,7 @@ class FlushSensorBloc extends Bloc<FlushSensorEvent, FlushSensorState> {
on<FlushSensorChangeValueEvent>(_changeValue); on<FlushSensorChangeValueEvent>(_changeValue);
on<FlushSensorUpdatedEvent>(_flushSensorUpdated); on<FlushSensorUpdatedEvent>(_flushSensorUpdated);
on<FlushSensorGetDeviceReportsEvent>(_getDeviceReports); on<FlushSensorGetDeviceReportsEvent>(_getDeviceReports);
on<FlushSensorInitialDeviseInfo>(fetchDeviceInfo);
} }
void _fetchFlushSensorStatus( void _fetchFlushSensorStatus(
@ -128,5 +129,50 @@ class FlushSensorBloc extends Bloc<FlushSensorEvent, FlushSensorState> {
} }
} }
DeviceInfoModel deviceInfo = DeviceInfoModel(
activeTime: 0,
category: "",
categoryName: "",
createTime: 0,
gatewayId: "",
icon: "",
ip: "",
lat: "",
localKey: "",
lon: "",
model: "",
name: "",
nodeId: "",
online: false,
ownerId: "",
productName: "",
sub: false,
timeZone: "",
updateTime: 0,
uuid: "",
productUuid: "",
productType: "",
permissionType: "",
macAddress: "",
subspace: Subspace(
uuid: "",
createdAt: "",
updatedAt: "",
subspaceName: "",
),
);
static String deviceName = '';
void fetchDeviceInfo(FlushSensorInitialDeviseInfo event,
Emitter<FlushSensorState> emit) async {
try {
emit(FlushSensorLoadingInitialState());
var response = await DevicesAPI.getDeviceInfo(deviceId);
deviceInfo = DeviceInfoModel.fromJson(response);
deviceName = deviceInfo.name;
emit(FlushSensorLoadingDeviceInfo(deviceInfo: deviceInfo));
} catch (e) {
emit(FlushSensorFailedState(error: e.toString()));
}
}
} }

View File

@ -62,7 +62,24 @@ class FlushMountedInterface extends StatelessWidget {
), ),
child: DefaultScaffold( child: DefaultScaffold(
title: deviceModel.name!, title: deviceModel.name!,
actions: [
InkWell(
onTap: () async {
var val = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
SettingsPage(device: deviceModel),
),
);
if (val == null) {
bloc.add(FlushSensorInitialDeviseInfo());
bloc.add(FlushSensorInitialEvent());
}
},
child: SvgPicture.asset(Assets.assetsIconsSettings),
),
const SizedBox(width: 10),
],
child: Container( child: Container(
width: MediaQuery.sizeOf(context).width, width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height, height: MediaQuery.sizeOf(context).height,