added game status
This commit is contained in:
72
lib/widgets/GameState/ConnectionStatus.dart
Normal file
72
lib/widgets/GameState/ConnectionStatus.dart
Normal file
@ -0,0 +1,72 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rogapp/widgets/GameState/Colors.dart';
|
||||
|
||||
enum ConnectionStatus { none, mobile, wifi }
|
||||
|
||||
class ConnectionStatusIndicator extends StatelessWidget {
|
||||
final ConnectionStatus connectionStatus;
|
||||
final bool minimized;
|
||||
|
||||
const ConnectionStatusIndicator({
|
||||
Key? key,
|
||||
required this.connectionStatus,
|
||||
this.minimized = false,
|
||||
}) : super(key: key);
|
||||
|
||||
@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 : 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),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user