手戻り修正、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 &&
|
||||
|
||||
Reference in New Issue
Block a user