should have push notifs as well as Battery SOC monitoring

This commit is contained in:
2026-03-09 02:31:49 -05:00
parent 8776fe9679
commit ea0326394f
22 changed files with 354 additions and 16 deletions

View File

@@ -24,6 +24,7 @@ class _DeviceScreenState extends State<DeviceScreen> {
List occports = [];
Widget? peripheralList;
String deviceName = "...";
int? batterySoc;
@override
void initState() {
@@ -48,7 +49,8 @@ class _DeviceScreenState extends State<DeviceScreen> {
final body = json.decode(response.body) as Map<String, dynamic>;
setState(() {
deviceName = body['device_name'];
});
batterySoc = body['battery_soc'] as int?;
});
}
} catch (e) {
if (!mounted) return;
@@ -355,12 +357,30 @@ class _DeviceScreenState extends State<DeviceScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
deviceName,
style: GoogleFonts.aBeeZee(),
),
title: Text(deviceName, style: GoogleFonts.aBeeZee()),
backgroundColor: Theme.of(context).primaryColorLight,
foregroundColor: Colors.white,
actions: [
if (batterySoc != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Icon(
batterySoc! <= 10 ? Icons.battery_alert
: batterySoc! <= 20 ? Icons.battery_1_bar
: batterySoc! <= 40 ? Icons.battery_2_bar
: batterySoc! <= 60 ? Icons.battery_3_bar
: batterySoc! <= 80 ? Icons.battery_5_bar
: Icons.battery_full,
color: batterySoc! <= 10 ? Colors.red : Colors.white,
),
const SizedBox(width: 4),
Text('$batterySoc%', style: const TextStyle(color: Colors.white)),
],
),
),
],
),
body: peripheralList ?? SizedBox(
height: MediaQuery.of(context).size.height * 0.8,