Fix GPS信号表示・制御
This commit is contained in:
30
.metadata
30
.metadata
@ -4,7 +4,33 @@
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 5f105a6ca7a5ac7b8bc9b241f4c2d86f4188cf5c
|
||||
channel: stable
|
||||
revision: "300451adae589accbece3490f4396f10bdf15e6e"
|
||||
channel: "stable"
|
||||
|
||||
project_type: app
|
||||
|
||||
# Tracks metadata for the flutter migrate command
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||
base_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||
- platform: android
|
||||
create_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||
base_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||
- platform: ios
|
||||
create_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||
base_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||
- platform: macos
|
||||
create_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||
base_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||
|
||||
# User provided section
|
||||
|
||||
# List of Local paths (relative to this file) that should be
|
||||
# ignored by the migrate tool.
|
||||
#
|
||||
# Files that are not part of the templates will be ignored by default.
|
||||
unmanaged_files:
|
||||
- 'lib/main.dart'
|
||||
- 'ios/Runner.xcodeproj/project.pbxproj'
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
package com.example.rog_app
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
class MainActivity: FlutterActivity()
|
||||
@ -94,7 +94,7 @@ class DestinationController extends GetxController {
|
||||
bool kDebugMode = true;
|
||||
|
||||
// シミュレーションモードのフラグ
|
||||
RxBool isSimulationMode = RxBool(false);
|
||||
RxBool isSimulationMode = RxBool(true);
|
||||
|
||||
// シミュレーションモードを切り替えるための関数
|
||||
void toggleSimulationMode(bool value) {
|
||||
@ -106,6 +106,7 @@ class DestinationController extends GetxController {
|
||||
//
|
||||
String getGpsSignalStrength() {
|
||||
// デバッグモードかつシミュレーションモードの場合は、シミュレートされた信号強度を返す
|
||||
print("kDebugMode : ${kDebugMode}, isSimulationMode : ${isSimulationMode.value}");
|
||||
if (kDebugMode && isSimulationMode.value) {
|
||||
return locationController.getSimulatedSignalStrength();
|
||||
}
|
||||
|
||||
@ -12,6 +12,8 @@ import 'package:rogapp/widgets/GameState/CheckinState.dart';
|
||||
import 'package:rogapp/widgets/GameState/ConnectionStatus.dart';
|
||||
import 'package:rogapp/widgets/GameState/DashboardWidget.dart';
|
||||
import 'package:rogapp/widgets/GameState/game_on_off.dart';
|
||||
import 'package:rogapp/widgets/GameState/Colors.dart';
|
||||
import 'package:rogapp/widgets/gps_status.dart';
|
||||
|
||||
class GameStateManager {
|
||||
static final GameStateManager _instance = GameStateManager._internal();
|
||||
@ -190,7 +192,14 @@ class _GameStateWidgetState extends State<GameStateWidget> {
|
||||
: ConnectionStatus.mobile
|
||||
: ConnectionStatus.none,
|
||||
minimized: !isExpanded)),
|
||||
) // Expanded view
|
||||
), // Expanded view
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child:GpsSignalStrengthIndicator(
|
||||
destinationController: Get.find<DestinationController>(),
|
||||
minimized: !isExpanded, // isExpanded はあなたのロジックに依存した変数),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
// child: Obx(
|
||||
|
||||
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:rogapp/widgets/GameState/Colors.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
//import 'package:rogapp/widgets/custom_icons.dart';
|
||||
|
||||
enum GPSStatus { high, middle, low }
|
||||
|
||||
class GpsSignalStrengthIndicator extends StatelessWidget {
|
||||
final DestinationController destinationController; // = Get.find<DestinationController>();
|
||||
final bool minimized;
|
||||
|
||||
// コンストラクタにminimizedパラメータを追加し、デフォルト値をfalseに設定
|
||||
const GpsSignalStrengthIndicator({
|
||||
Key? key,
|
||||
required this.destinationController,
|
||||
this.minimized = false, // ここでデフォルト値を指定
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(() {
|
||||
final signalStrength = destinationController.getGpsSignalStrength();
|
||||
IconData iconData;
|
||||
Color backgroundColor;
|
||||
String text;
|
||||
|
||||
// signalStrengthに応じて、アイコン、背景色、テキストを設定
|
||||
switch (signalStrength) {
|
||||
case 'high':
|
||||
backgroundColor = Colors.green;
|
||||
iconData = Icons.signal_cellular_alt;
|
||||
//iconData = CustomIcons.gps_signal_high_0;
|
||||
text = 'GPS 強';
|
||||
break;
|
||||
case 'medium':
|
||||
backgroundColor = Colors.orange;
|
||||
iconData = Icons.signal_cellular_alt_2_bar;
|
||||
//iconData = CustomIcons.gps_signal_middle_0;
|
||||
text = 'GPS 中';
|
||||
break;
|
||||
default:
|
||||
backgroundColor = Colors.grey; // Fallback color
|
||||
iconData = Icons.signal_cellular_connected_no_internet_4_bar;
|
||||
//iconData = CustomIcons.gps_signal_low_0;
|
||||
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