手戻り修正、APK出力
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:io';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
@ -123,6 +126,20 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> saveTemporaryImage(Destination destination) async {
|
||||
final serverUrl = ConstValues.currentServer();
|
||||
final imagePath = '${serverUrl}/media/compressed/${destination.photos}';
|
||||
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
final tempFile = await File('${tempDir.path}/temp_image.jpg').create(recursive: true);
|
||||
final response = await http.get(Uri.parse(imagePath));
|
||||
await tempFile.writeAsBytes(response.bodyBytes);
|
||||
|
||||
destinationController.photos.clear();
|
||||
destinationController.photos.add(tempFile);
|
||||
}
|
||||
|
||||
|
||||
// アクションボタン(チェックイン、ゴールなど)を表示するためのメソッドです。
|
||||
// 現在の状態に基づいて、適切なボタンを返します。
|
||||
// ボタンがタップされたときの処理も含まれています。
|
||||
@ -145,17 +162,83 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
destinationController.currentLat, destinationController.currentLon),
|
||||
LatLng(cdest.lat!, cdest.lon!));
|
||||
|
||||
if (destinationController.rogainingCounted.value == true &&
|
||||
// Check conditions to show confirmation dialog
|
||||
if (destinationController.isInRog.value == false &&
|
||||
(destinationController.distanceToStart() <= 500 || destinationController.isGpsSignalWeak() ) && //追加 Akira 2024-4-5
|
||||
(destination.cp == -1 || destination.cp == 0 ) &&
|
||||
destinationController.rogainingCounted.value == false) {
|
||||
// ゲームが始まってなければ
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
onPressed: destinationController.isInRog.value == false &&
|
||||
(destinationController.distanceToStart() <= 100 || destinationController.isGpsSignalWeak() ) && //追加 Akira 2024-4-5
|
||||
(destination.cp == -1 || destination.cp == 0 ) &&
|
||||
destinationController.rogainingCounted.value == false ? () async {
|
||||
// Show confirmation dialog
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text("確認"), //confirm
|
||||
content: const Text(
|
||||
"ロゲを開始すると、今までのロゲデータが全てクリアされます。本当に開始しますか?"), //are you sure
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text("いいえ"), //no
|
||||
onPressed: () {
|
||||
Get.back(); // Close the dialog
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text("はい"), //yes
|
||||
onPressed: () async {
|
||||
|
||||
await saveTemporaryImage(destination);
|
||||
|
||||
// Clear data and start game logic here
|
||||
destinationController.isInRog.value = true;
|
||||
destinationController.resetRogaining();
|
||||
destinationController.addToRogaining(
|
||||
destinationController.currentLat,
|
||||
destinationController.currentLon,
|
||||
destination.location_id!,
|
||||
);
|
||||
|
||||
saveGameState();
|
||||
await ExternalService().startRogaining();
|
||||
Get.back(); // Close the dialog and potentially navigate away
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
barrierDismissible:
|
||||
false, // User must tap a button to close the dialog
|
||||
);
|
||||
}
|
||||
: null,
|
||||
child: Obx(
|
||||
()=> Text(
|
||||
destinationController.isInRog.value ? '競技中' : 'ロゲ開始',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
//print("counted ${destinationController.rogainingCounted.value}");
|
||||
|
||||
|
||||
}else if (destinationController.rogainingCounted.value == true &&
|
||||
// destinationController.distanceToStart() <= 500 && ... GPS信号が弱い時でもOKとする。
|
||||
(destinationController.distanceToStart() <= 500 || destinationController.isGpsSignalWeak() ) &&
|
||||
destination.cp == -1 &&
|
||||
(destination.cp == 0 || destination.cp == -2 || destination.cp == -1) &&
|
||||
// (destination.cp == 0 || destination.cp == -2 ) &&
|
||||
DestinationController.ready_for_goal == true) {
|
||||
//goal
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
|
||||
onPressed: destinationController.rogainingCounted.value == true &&
|
||||
destinationController.distanceToStart() <= 500 &&
|
||||
destination.cp == -1 &&
|
||||
(destination.cp == 0 || destination.cp == -2|| destination.cp == -1) &&
|
||||
DestinationController.ready_for_goal == true
|
||||
? () async {
|
||||
destinationController.isAtGoal.value = true;
|
||||
@ -204,7 +287,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
print('Error processing check-in: $e');
|
||||
}
|
||||
},
|
||||
/*
|
||||
/*
|
||||
// Check conditions to show confirmation dialog
|
||||
if (destinationController.isInRog.value == false &&
|
||||
(destinationController.distanceToStart() <= 500 || destinationController.isGpsSignalWeak() ) && //追加 Akira 2024-4-5
|
||||
@ -257,7 +340,9 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
return;
|
||||
}
|
||||
},
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
child: Text(
|
||||
destination.cp == -1 &&
|
||||
destinationController.isInRog.value == false &&
|
||||
|
||||
@ -37,6 +37,7 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
|
||||
StreamSubscription? subscription;
|
||||
Timer? _timer;
|
||||
bool curr_marker_display = false;
|
||||
|
||||
Map<LatLng, Marker> _markerCache = {};
|
||||
List<Marker> _markers = [];
|
||||
@ -52,7 +53,12 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_startIdleTimer();
|
||||
|
||||
//_initMarkers();
|
||||
// MapControllerの初期化が完了するまで待機
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
indexController.isMapControllerReady.value = true;
|
||||
});
|
||||
});
|
||||
|
||||
// indexController.mapController = MapController(initCompleter: mapControllerCompleter);
|
||||
|
||||
@ -171,7 +177,9 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
//}else{
|
||||
// labelText=i.properties!['cp'];
|
||||
}
|
||||
//debugPrint("Text=${labelText}");
|
||||
if( i.properties!['cp'] <= 0 ) {
|
||||
debugPrint("Text=${labelText}");
|
||||
}
|
||||
final double maxWidth = labelText.length * 16.0;
|
||||
GeoJSONMultiPoint p = i.geometry as GeoJSONMultiPoint;
|
||||
return InkWell(
|
||||
@ -398,7 +406,11 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
stream: locationController.locationMarkerPositionStream,
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
debugPrint("====== Not display current marker");
|
||||
//debugPrint("====== Not display current marker");
|
||||
curr_marker_display = true;
|
||||
}else if(curr_marker_display){
|
||||
debugPrint("====== Displayed current marker");
|
||||
curr_marker_display = false;
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user