mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
Added battery icon in the door lock screen
This commit is contained in:
@ -85,7 +85,7 @@ class _DoorLockButtonState extends State<DoorLockButton> with SingleTickerProvid
|
||||
),
|
||||
child: InkWell(
|
||||
overlayColor:
|
||||
MaterialStateProperty.all(ColorsManager.primaryColorWithOpacity.withOpacity(0.1)),
|
||||
WidgetStateProperty.all(ColorsManager.primaryColorWithOpacity.withOpacity(0.1)),
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
onTapDown: (details) {
|
||||
if (_animationController.status == AnimationStatus.dismissed) {
|
||||
@ -114,7 +114,7 @@ class _DoorLockButtonState extends State<DoorLockButton> with SingleTickerProvid
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
blurRadius: 18,
|
||||
offset: Offset(6, 7),
|
||||
// offset: Offset(6, 7),
|
||||
blurStyle: BlurStyle.outer,
|
||||
),
|
||||
],
|
||||
|
@ -13,18 +13,46 @@ class DoorLockStatusBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String batteryIc = Assets.assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstChargeddmOn;
|
||||
if (smartDoorModel.residualElectricity < 90) {
|
||||
batteryIc = Assets.assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstChargeddmOn;
|
||||
} else if (smartDoorModel.residualElectricity < 10) {
|
||||
batteryIc = Assets.assetsIconsBatteryDmOnPerOnchargOnlowOnpmOffstlowBatterydmOn;
|
||||
}
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SvgPicture.asset(Assets.assetsIconsWifi),
|
||||
SvgPicture.asset(batteryIc),
|
||||
Transform.rotate(
|
||||
angle: 1.5708, // 90 degrees in radians (π/2 or 1.5708)
|
||||
child: Icon(
|
||||
_getBatteryIcon(smartDoorModel.residualElectricity),
|
||||
color: _getBatteryColor(smartDoorModel.residualElectricity),
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
IconData _getBatteryIcon(int batteryLevel) {
|
||||
// if (batteryState == BatteryState.charging) {
|
||||
// return Icons.battery_charging_full;
|
||||
// } else
|
||||
if (batteryLevel >= 80) {
|
||||
return Icons.battery_full;
|
||||
} else if (batteryLevel >= 60) {
|
||||
return Icons.battery_4_bar;
|
||||
} else if (batteryLevel >= 40) {
|
||||
return Icons.battery_3_bar;
|
||||
} else if (batteryLevel >= 20) {
|
||||
return Icons.battery_2_bar;
|
||||
} else {
|
||||
return Icons.battery_alert;
|
||||
}
|
||||
}
|
||||
|
||||
Color _getBatteryColor(int batteryLevel) {
|
||||
if (batteryLevel >= 80) {
|
||||
return Colors.green;
|
||||
} else if (batteryLevel >= 40) {
|
||||
return Colors.yellowAccent;
|
||||
} else {
|
||||
return Colors.red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user