    import 'package:flutter/material.dart';




class BatteryBar extends StatelessWidget {
  const BatteryBar({
    required this.batteryPercentage,
    super.key,
  });

  final int batteryPercentage;
  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        SizedBox(),
        Transform.rotate(
          angle: 1.5708, // 90 degrees in radians (π/2 or 1.5708)
          child: Icon(
            _getBatteryIcon(batteryPercentage),
            color: _getBatteryColor(batteryPercentage),
            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;
    }
  }
}
