大幅変更&環境バージョンアップ
This commit is contained in:
78
lib/widgets/gps_status.dart
Normal file
78
lib/widgets/gps_status.dart
Normal file
@ -0,0 +1,78 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gifunavi/utils/location_controller.dart';
|
||||
|
||||
enum GPSStatus { high, middle, low }
|
||||
|
||||
class GpsSignalStrengthIndicator extends StatelessWidget {
|
||||
LocationController locationController;
|
||||
final bool minimized;
|
||||
|
||||
// コンストラクタにminimizedパラメータを追加し、デフォルト値をfalseに設定
|
||||
GpsSignalStrengthIndicator({
|
||||
super.key,
|
||||
required this.locationController,
|
||||
this.minimized = false, // ここでデフォルト値を指定
|
||||
}) ;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// final LocationController locationController = Get.find<LocationController>();
|
||||
return Obx(() {
|
||||
String signalStrength = locationController.latestSignalStrength.value;
|
||||
//debugPrint("GpsSignalStrengthIndicator : signalStrength=${signalStrength}");
|
||||
IconData iconData;
|
||||
Color backgroundColor;
|
||||
String text;
|
||||
|
||||
// signalStrengthに応じて、アイコン、背景色、テキストを設定
|
||||
switch (signalStrength) {
|
||||
case 'high':
|
||||
backgroundColor = Colors.green;
|
||||
iconData = Icons.signal_cellular_alt;
|
||||
// iconData = CustomIcons.gps_signal_high;
|
||||
text = 'GPS 強';
|
||||
break;
|
||||
case 'medium':
|
||||
backgroundColor = Colors.orange;
|
||||
iconData = Icons.signal_cellular_alt_2_bar;
|
||||
// iconData = CustomIcons.gps_signal_middle;
|
||||
text = 'GPS 中';
|
||||
break;
|
||||
default:
|
||||
backgroundColor = Colors.grey; // Fallback color
|
||||
iconData = Icons.signal_cellular_connected_no_internet_4_bar;
|
||||
// iconData = CustomIcons.gps_signal_low;
|
||||
text = 'GPS 弱';
|
||||
}
|
||||
|
||||
// コンテナの設定をminimizedの値に応じて調整
|
||||
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),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user