mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
28 lines
909 B
Dart
28 lines
909 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Utility class for battery and signal display helpers
|
|
/// Used across home_screen.dart and contact_tile.dart
|
|
class BatteryDisplayHelper {
|
|
/// Get battery icon based on percentage level
|
|
static IconData getBatteryIcon(double percentage) {
|
|
if (percentage > 80) return Icons.battery_full;
|
|
if (percentage > 50) return Icons.battery_5_bar;
|
|
if (percentage > 20) return Icons.battery_3_bar;
|
|
return Icons.battery_1_bar;
|
|
}
|
|
|
|
/// Get battery color based on percentage level
|
|
static Color getBatteryColor(double percentage) {
|
|
if (percentage > 50) return Colors.green;
|
|
if (percentage > 20) return Colors.orange;
|
|
return Colors.red;
|
|
}
|
|
|
|
/// Get signal strength color based on RSSI value
|
|
static Color getSignalColor(int rssi) {
|
|
if (rssi > -60) return Colors.green;
|
|
if (rssi > -70) return Colors.orange;
|
|
return Colors.red;
|
|
}
|
|
}
|