mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-09 22:57:18 +00:00
Refactor device avatar and add icon to setting
This commit is contained in:
@ -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(
|
||||
|
Reference in New Issue
Block a user