import 'package:flutter/material.dart';
import 'package:gifunavi/widgets/GameState/Colors.dart';

enum ConnectionStatus { none, mobile, wifi }

class ConnectionStatusIndicator extends StatelessWidget {
  final ConnectionStatus connectionStatus;
  final bool minimized;

  const ConnectionStatusIndicator({
    super.key,
    required this.connectionStatus,
    this.minimized = false,
  });

  @override
  Widget build(BuildContext context) {
    Color backgroundColor;
    IconData iconData;
    String text;

    switch (connectionStatus) {
      case ConnectionStatus.none:
        backgroundColor = JapaneseColors.ume;
        iconData = Icons.signal_cellular_off;
        text = 'No Connection';
        break;
      case ConnectionStatus.mobile:
        backgroundColor = JapaneseColors.take;
        iconData = Icons.signal_cellular_alt;
        text = 'Mobile Data';
        break;
      case ConnectionStatus.wifi:
        backgroundColor = JapaneseColors.sora;
        iconData = Icons.wifi;
        text = 'Wi-Fi';
        break;
      default:
        backgroundColor = Colors.grey; // Fallback color
        iconData = Icons.device_unknown;
        text = 'Unknown';
    }

    return Container(
      height: minimized ? 40 : null,
      width: minimized ? 40 : null,
      padding:
          minimized ? null : const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
      decoration: BoxDecoration(
        color: backgroundColor,
        shape: minimized ? BoxShape.circle : BoxShape.rectangle,
        borderRadius: minimized ? null : BorderRadius.circular(10),
      ),
      child: minimized
          ? Center(
              child: Icon(iconData, color: Colors.white, size: 24),
            )
          : Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                Icon(iconData, color: Colors.white),
                const SizedBox(width: 8),
                Text(
                  text,
                  style: const TextStyle(
                      color: Colors.white, fontWeight: FontWeight.bold),
                ),
              ],
            ),
    );
  }
}
