47 lines
1.5 KiB
Dart
47 lines
1.5 KiB
Dart
import 'package:geolocator/geolocator.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:rogapp/utils/location_controller.dart';
|
|
|
|
class DebugController extends GetxController {
|
|
final LocationController locationController = Get.find<LocationController>();
|
|
final gpsSignalStrength = 'high'.obs;
|
|
final currentPosition = Rx<Position?>(null);
|
|
final isSimulationMode = false.obs;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
// 位置情報の更新を監視
|
|
locationController.locationMarkerPositionStream.listen((position) {
|
|
if (position != null) {
|
|
currentPosition.value = Position(
|
|
latitude: position.latitude,
|
|
longitude: position.longitude,
|
|
accuracy: position.accuracy,
|
|
altitudeAccuracy: 30,
|
|
headingAccuracy: 30,
|
|
heading: 0,
|
|
altitude: 0,
|
|
speed: 0,
|
|
speedAccuracy: 0,
|
|
timestamp: DateTime.now(),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
void setGpsSignalStrength(String value) {
|
|
gpsSignalStrength.value = value;
|
|
locationController.setSimulatedSignalStrength(value);
|
|
}
|
|
|
|
void toggleSimulationMode() {
|
|
isSimulationMode.value = !isSimulationMode.value;
|
|
locationController.setSimulationMode(isSimulationMode.value);
|
|
if (!isSimulationMode.value) {
|
|
// 標準モードに切り替えた場合は、シミュレートされた信号強度をリセット
|
|
locationController.setSimulatedSignalStrength('low');
|
|
gpsSignalStrength.value = 'low';
|
|
}
|
|
}
|
|
} |