mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
Merge pull request #97 from SyncrowIOT/SP-1522-FE-Implement-Device-Settings-Screen-Edit-Name-Location-Device-Info
Sp 1522 fe implement device settings screen edit name location device info
This commit is contained in:
@ -22,6 +22,7 @@ class FlushSensorBloc extends Bloc<FlushSensorEvent, FlushSensorState> {
|
||||
on<FlushSensorChangeValueEvent>(_changeValue);
|
||||
on<FlushSensorUpdatedEvent>(_flushSensorUpdated);
|
||||
on<FlushSensorGetDeviceReportsEvent>(_getDeviceReports);
|
||||
on<FlushSensorInitialDeviseInfo>(fetchDeviceInfo);
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,44 +49,7 @@ class SettingProfilePage extends StatelessWidget {
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: device!.type != "SOS" ? 60 : 52,
|
||||
backgroundColor: Colors.white,
|
||||
child: device!.type == "SOS"
|
||||
? ClipOval(
|
||||
child: SvgPicture.asset(
|
||||
Assets.sosHomeIcon,
|
||||
fit: BoxFit.fitHeight,
|
||||
height:
|
||||
MediaQuery.of(context).size.height * 0.13,
|
||||
))
|
||||
: CircleAvatar(
|
||||
radius: 55,
|
||||
backgroundColor: ColorsManager.graysColor,
|
||||
child: ClipOval(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: SvgPicture.asset(
|
||||
device!.type == "4S"
|
||||
? Assets.fourSceneIcon
|
||||
: Assets.sixSceneIcon,
|
||||
fit: BoxFit.contain,
|
||||
height: MediaQuery.of(context)
|
||||
.size
|
||||
.height *
|
||||
0.08,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
buildDeviceAvatar(context, device!),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
@ -198,4 +161,45 @@ class SettingProfilePage extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildDeviceAvatar(BuildContext context, DeviceModel device) {
|
||||
final isSOSDevice = device.type == "SOS";
|
||||
|
||||
final assetIcon = isSOSDevice
|
||||
? Assets.sosHomeIcon
|
||||
: device.type == 'NCPS'
|
||||
? Assets.flushIcon
|
||||
: device.type == '4S'
|
||||
? Assets.fourSceneIcon
|
||||
: Assets.sixSceneIcon;
|
||||
|
||||
final avatarRadius = isSOSDevice ? 52.0 : 60.0;
|
||||
final innerAvatarRadius = 55.0;
|
||||
final assetHeightFactor = isSOSDevice ? 0.13 : 0.08;
|
||||
|
||||
return CircleAvatar(
|
||||
radius: avatarRadius,
|
||||
backgroundColor: Colors.white,
|
||||
child: ClipOval(
|
||||
child: isSOSDevice
|
||||
? SvgPicture.asset(
|
||||
assetIcon,
|
||||
fit: BoxFit.fitHeight,
|
||||
height: MediaQuery.of(context).size.height * assetHeightFactor,
|
||||
)
|
||||
: CircleAvatar(
|
||||
radius: innerAvatarRadius,
|
||||
backgroundColor: ColorsManager.graysColor,
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
assetIcon,
|
||||
fit: BoxFit.contain,
|
||||
height:
|
||||
MediaQuery.of(context).size.height * assetHeightFactor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -130,6 +130,15 @@ class SettingsPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
device!.type == 'NCPS'
|
||||
? SizedBox(
|
||||
height: 80,
|
||||
width: 50,
|
||||
child: SvgPicture.asset(
|
||||
Assets.flushIcon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
):
|
||||
device!.type == "SOS"
|
||||
? ClipOval(
|
||||
child: SvgPicture.asset(
|
||||
|
@ -62,7 +62,24 @@ class FlushMountedInterface extends StatelessWidget {
|
||||
),
|
||||
child: DefaultScaffold(
|
||||
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(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
|
Reference in New Issue
Block a user