CPラベルが1文字しか出ない、起動が遅い

This commit is contained in:
2024-04-14 20:16:13 +09:00
parent f6b2a6c7d4
commit 4ef42216f8
18 changed files with 1520 additions and 372 deletions

View File

@ -24,7 +24,7 @@ import 'package:rogapp/services/perfecture_service.dart';
import 'package:rogapp/utils/database_gps.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'package:rogapp/utils/location_controller.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:rogapp/widgets/bottom_sheets/bottom_sheet_normal_point.dart';
import 'dart:async';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
@ -33,14 +33,12 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:geolocator/geolocator.dart';
// 目的地に関連する状態管理とロジックを担当するクラスです。
//
class DestinationController extends GetxController {
late LocationSettings locationSettings; // 位置情報の設定を保持する変数です。
Timer? _GPStimer; // GPSタイマーを保持する変数です。
//Timer? _GPStimer; // GPSタイマーを保持する変数です。
var destinationCount = 0.obs; // 目的地の数を保持するReactive変数です。
List<Destination> destinations = <Destination>[].obs; // 目的地のリストを保持するObservable変数です。
@ -92,7 +90,20 @@ class DestinationController extends GetxController {
int _start = 0; // 開始時刻を保持する変数です。
int chekcs = 0; // チェックポイントの数を保持する変数です。
var rogainingCounted = false.obs; // ロゲイニングがカウントされたかどうかを示すReactive変数です。
// destinationController.rogainingCountedは、現在のロゲイニングセッションでポイントがカウントされたかどうかを管理するフラグです。
//
// このフラグは以下のような状況で使用されます:
//
// ロゲイニングを開始したとき、rogainingCountedはfalseに初期化されます。これは、まだポイントがカウントされていないことを示します。
// チェックポイントに到着し、チェックインが成功したとき、rogainingCountedはtrueに設定されます。これは、そのセッションでポイントがカウントされたことを示します。
// ロゲイニングを終了したとき、rogainingCountedは再びfalseに設定されます。これは、次のセッションに備えてフラグをリセットするためです。
// このフラグは、主に以下の目的で使用されます:
//
// ゴール地点でのロジックの制御rogainingCountedがtrueの場合、つまりポイントがカウントされている場合にのみ、ゴール処理を実行できます。
// UI の更新rogainingCountedの状態に基づいて、適切なメッセージやボタンを表示することができます。
/*
//==== Akira .. GPS信号シミュレーション用 ===== ここから、2024-4-5
@ -317,15 +328,17 @@ class DestinationController extends GetxController {
isAtStart.value = true;
if (shouldShowBottomSheet) {
shouldShowBottomSheet = false;
if (d.cp == -1) return;
if (d.cp == -1||d.cp==-2||d.cp==0) return;
Widget bottomSheet = BottomSheetNormalPoint(destination: d);
await showModalBottomSheet(
constraints:
BoxConstraints.loose(Size(Get.width, Get.height * 0.85)),
context: Get.context!,
isScrollControlled: true,
builder: ((context) => BottomSheetNew(
destination: d,
))).whenComplete(() {
builder: ((context) => bottomSheet)
).whenComplete(() {
shouldShowBottomSheet = true;
skipGps = false;
chekcs = 0;
@ -342,15 +355,17 @@ class DestinationController extends GetxController {
isInCheckin.value = true;
if (shouldShowBottomSheet) {
shouldShowBottomSheet = false;
if (d.cp == -1) return;
if (d.cp == -1||d.cp==-2||d.cp==0) return;
Widget bottomSheet = BottomSheetNormalPoint(destination: d);
await showModalBottomSheet(
constraints:
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
context: Get.context!,
isScrollControlled: true,
builder: ((context) => BottomSheetNew(
destination: d,
))).whenComplete(() {
builder: ((context) => bottomSheet)
).whenComplete(() {
shouldShowBottomSheet = true;
skipGps = false;
chekcs = 0;
@ -412,14 +427,16 @@ class DestinationController extends GetxController {
isInCheckin.value = true;
if (shouldShowBottomSheet) {
shouldShowBottomSheet = false;
if (d.cp == -1) return;
if (d.cp == -1||d.cp==-2||d.cp==0) return;
Widget bottomSheet = BottomSheetNormalPoint(destination: d);
await showMaterialModalBottomSheet(
expand: true,
context: Get.context!,
backgroundColor: Colors.transparent,
builder: (context) => BottomSheetNew(
destination: d,
)).whenComplete(() {
builder: (context) => bottomSheet
).whenComplete(() {
shouldShowBottomSheet = true;
skipGps = false;
chekcs = 0;
@ -506,15 +523,17 @@ class DestinationController extends GetxController {
isAtStart.value = true;
if (shouldShowBottomSheet) {
shouldShowBottomSheet = false;
if (d.cp == -1) return;
if (d.cp == -1||d.cp==-2||d.cp==0) return;
Widget bottomSheet = BottomSheetNormalPoint(destination: d);
await showModalBottomSheet(
constraints:
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
context: Get.context!,
isScrollControlled: true,
builder: ((context) => BottomSheetNew(
destination: d,
))).whenComplete(() {
builder: ((context) => bottomSheet)
).whenComplete(() {
shouldShowBottomSheet = true;
//print("----- finished start -------");
skipGps = false;
@ -932,11 +951,11 @@ class DestinationController extends GetxController {
//
locationController.locationMarkerPositionStream.listen(
(locationMarkerPosition) {
if (locationMarkerPosition != null) {
//if (locationMarkerPosition != null) {
handleLocationUpdate(locationMarkerPosition);
}
//}
}, onError: (err) {
print("Error: $err");
print("Location Error: $err");
});
startGame();
@ -957,7 +976,7 @@ class DestinationController extends GetxController {
//
void handleLocationUpdate(LocationMarkerPosition? position) async {
try {
final DestinationController destinationController = Get.find<DestinationController>();
//final DestinationController destinationController = Get.find<DestinationController>();
//final signalStrength = locationController.getGpsSignalStrength();
okToUseGPS = false;
@ -1209,10 +1228,7 @@ class DestinationController extends GetxController {
// 地図を現在位置に中央揃えする関数です。
//
void centerMapToCurrentLocation() {
assert(() {
print("center is ${currentLat}, ${currentLon}");
return true;
}());
//print("center is ${currentLat}, ${currentLon}");
// Akira ... 状況によって呼ぶか呼ばないか
if (currentLat != 0 || currentLon != 0) {
indexController.mapController.move(LatLng(currentLat, currentLon), 17.0);

View File

@ -12,8 +12,24 @@ import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/utils/text_util.dart';
import 'package:rogapp/widgets/base_layer_widget.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
//import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:rogapp/widgets/bottom_sheets/bottom_sheet_start.dart';
import 'package:rogapp/widgets/bottom_sheets/bottom_sheet_goal.dart';
import 'package:rogapp/widgets/bottom_sheets/bottom_sheet_normal_point.dart';
// FlutterMapウィジェットを使用して、地図を表示します。
// IndexControllerから目的地のリストを取得し、マーカーとしてマップ上に表示します。
// マーカーがタップされると、BottomSheetウィジェットを表示します。
// 現在地の表示、ルートの表示、ベースレイヤーの表示などの機能を提供します。
// 主なロジック:
// FlutterMapウィジェットを使用して、地図を表示します。
// IndexControllerから目的地のリストを取得し、MarkerLayerを使用してマーカーを表示します。
// getMarkerShapeメソッドを使用して、マーカーの見た目をカスタマイズします。目的地の種類に応じて、異なるマーカーを表示します。
// マーカーがタップされると、festuretoDestinationメソッドを使用してGeoJSONFeatureをDestinationオブジェクトに変換し、showModalBottomSheetを使用してBottomSheetウィジェットを表示します。
// CurrentLocationLayerを使用して、現在地をマップ上に表示します。
// PolylineLayerを使用して、ルートをマップ上に表示します。getPointsメソッドを使用して、ルートの座標を取得します。
// BaseLayerを使用して、マップのベースレイヤーを表示します。
//
class DestinationMapPage extends StatelessWidget {
DestinationMapPage({Key? key}) : super(key: key);
@ -54,14 +70,23 @@ class DestinationMapPage extends StatelessWidget {
indexController.currentDestinationFeature.add(d);
//indexController.getAction();
Widget bottomSheet;
if (d.cp == -1 || d.cp == 0) {
bottomSheet = BottomSheetStart(destination: d);
} else if (d.cp == -2 || d.cp == 0) {
bottomSheet = BottomSheetGoal(destination: d);
} else {
bottomSheet = BottomSheetNormalPoint(destination: d);
}
showModalBottomSheet(
context: Get.context!,
isScrollControlled: true,
constraints:
BoxConstraints.loose(Size(Get.width, Get.height * 0.85)),
builder: ((context) => BottomSheetNew(
destination: d,
))).whenComplete(() {
builder: ((context) => bottomSheet ),
).whenComplete(() {
//print("---- set skip gps to false -----");
destinationController.skipGps = false;
});

View File

@ -408,11 +408,11 @@ class IndexController extends GetxController {
if (value == null) {
// APIからのレスポンスがnullの場合
print("LocationService.loadLocationsBound からの回答がnullのため、マップをリロード");
//DestinationController destinationController = Get.find<DestinationController>(); // 追加
//final tk = currentUser[0]["token"]; // 追加
//if (tk != null) { // 追加
// destinationController.fixMapBound(tk); // 追加
//} // 追加
DestinationController destinationController = Get.find<DestinationController>(); // 追加
final tk = currentUser[0]["token"]; // 追加
if (tk != null) { // 追加
destinationController.fixMapBound(tk); // 追加
} // 追加
return;
}
isLoading.value = false; // ローディング状態をfalseに設定

View File

@ -104,13 +104,39 @@ class IndexPage extends GetView<IndexController> {
// タップすることでGPS信号の強弱をシミュレーションできるようにする
// Akira 2024-4-5
//
Obx(() {
if (locationController.isSimulationMode) {
return DropdownButton<String>(
value: locationController.getSimulatedSignalStrength(),
onChanged: (value) {
debugPrint("DropDown changed!");
locationController.setSimulatedSignalStrength(value!);
},
items: ['low', 'medium', 'high', 'real']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
);
} else {
return InkWell(
onTap: () {
locationController.setSimulatedSignalStrength('high');
},
child: const Icon(Icons.info),
);
}
}),
/*
Obx(() => locationController.isSimulationMode
? DropdownButton<String>(
value: locationController.getSimulatedSignalStrength(),
onChanged: (value) {
locationController.setSimulatedSignalStrength(value!);
},
items: ['high', 'medium', 'low']
items: ['low', 'medium', 'high','real']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
@ -120,6 +146,7 @@ class IndexPage extends GetView<IndexController> {
)
: Container(),
),
*/
],
),
// bottomNavigationBar: BottomAppBar(

View File

@ -6,7 +6,9 @@ import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/pages/search/search_controller.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:rogapp/widgets/bottom_sheets/bottom_sheet_start.dart';
import 'package:rogapp/widgets/bottom_sheets/bottom_sheet_goal.dart';
import 'package:rogapp/widgets/bottom_sheets/bottom_sheet_normal_point.dart';
class SearchPage extends StatelessWidget {
SearchPage({Key? key}) : super(key: key);
@ -75,15 +77,22 @@ class SearchPage extends StatelessWidget {
Destination des =
destinationController.festuretoDestination(suggestion);
Get.back();
Widget bottomSheet;
if (des.cp == -1 || des.cp == 0) {
bottomSheet = BottomSheetStart(destination: des);
} else if (des.cp == -2 || des.cp == 0) {
bottomSheet = BottomSheetGoal(destination: des);
} else {
bottomSheet = BottomSheetNormalPoint(destination: des);
}
showModalBottomSheet(
constraints:
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
isScrollControlled: true,
context: context,
//builder: (context) => BottomSheetWidget(),
builder: ((context) => BottomSheetNew(
destination: des,
)));
builder: ((context) => bottomSheet)
);
},
suggestionsCallback: (pattern) async {
@ -106,29 +115,6 @@ class SearchPage extends StatelessWidget {
},
),
),
// Obx(() =>
// ListView.builder(
// itemCount: searchController.searchResults.length,
// itemBuilder: (context, index){
// return ListTile(
// title: searchController.searchResults[index].properties!["location_name"] != null ? Text(searchController.searchResults[index].properties!["location_name"]) : Text(""),
// subtitle: searchController.searchResults[index].properties!["category"] != null ? Text(searchController.searchResults[index].properties!["category"]) : Text(""),
// leading: getImage(index),
// onTap: (){
// indexController.currentFeature.clear();
// indexController.currentFeature.add(searchController.searchResults[index]);
// Get.back();
// showModalBottomSheet(
// isScrollControlled: true,
// context: context,
// //builder: (context) => BottomSheetWidget(),
// builder:((context) => BottomSheetNew())
// );
// },
// );
// },
// ),
// )
);
}
}