From accd0cad4324eb68cade75e4605b8d08ee23ace2 Mon Sep 17 00:00:00 2001 From: AKIRA Date: Wed, 3 Apr 2024 21:39:12 +0900 Subject: [PATCH] Fix 2803,2802,2800 --- .../destination/destination_controller.dart | 13 +++- lib/pages/index/index_controller.dart | 76 ++++++++++++++++++- lib/pages/login/login_page.dart | 2 +- lib/widgets/bottom_sheet_new.dart | 4 + lib/widgets/map_widget.dart | 5 ++ 5 files changed, 94 insertions(+), 6 deletions(-) diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index e38d51d..9fefede 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -561,7 +561,14 @@ class DestinationController extends GetxController { } }); } else { - Get.snackbar("始まっていない", "ロゲイニングを始める必要があります"); + Get.snackbar( + "始まっていません", + "ロゲ開始ボタンをタップして、ロゲイニングを始める必要があります", + icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue), + snackPosition: SnackPosition.TOP, + duration: const Duration(seconds: 3), + backgroundColor: Colors.yellow, + ); } } } @@ -931,7 +938,11 @@ class DestinationController extends GetxController { } void centerMapToCurrentLocation() { + assert(() { print("center is ${currentLon}, ${currentLon}"); + return true; + }()); + // Akira if (currentLat != 0 || currentLon != 0) { indexController.mapController.move(LatLng(currentLat, currentLon), 17.0); } diff --git a/lib/pages/index/index_controller.dart b/lib/pages/index/index_controller.dart index f381bc3..23fbd6f 100644 --- a/lib/pages/index/index_controller.dart +++ b/lib/pages/index/index_controller.dart @@ -172,11 +172,11 @@ class IndexController extends GetxController { } else { isLoading.value = false; Get.snackbar( - "Failed", - "User login failed, please try again.", + "ログイン失敗", + "ログインIDかパスワードを確認して下さい。", icon: const Icon(Icons.error, size: 40.0, color: Colors.blue), snackPosition: SnackPosition.TOP, - duration: const Duration(milliseconds: 800), + duration: const Duration(seconds: 3), backgroundColor: Colors.yellow, //icon:Image(image:AssetImage("assets/images/dora.png")) ); @@ -282,6 +282,7 @@ class IndexController extends GetxController { }); } +/* void loadLocationsBound() { if (isCustomAreaSelected.value == true) { return; @@ -320,7 +321,7 @@ class IndexController extends GetxController { icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue), snackPosition: SnackPosition.TOP, - duration: const Duration(milliseconds: 800), + duration: const Duration(seconds: 2), backgroundColor: Colors.yellow, //icon:Image(image:AssetImage("assets/images/dora.png")) ); @@ -333,6 +334,73 @@ class IndexController extends GetxController { } }); } +*/ + + // 2024-04-03 Akira .. Update the code . See ticket 2800. + // + void loadLocationsBound() { + if (isCustomAreaSelected.value == true) { + return; + } + locations.clear(); + String cat = currentCat.isNotEmpty ? currentCat[0] : ""; + if (currentCat.isNotEmpty && currentCat[0] == "-all-") { + cat = ""; + } + LatLngBounds bounds = mapController.bounds!; + currentBound.clear(); + currentBound.add(bounds); + + isLoading.value = true; // ローディング状態をtrueに設定 + + LocationService.loadLocationsBound( + bounds.southWest.latitude, + bounds.southWest.longitude, + bounds.northWest.latitude, + bounds.northWest.longitude, + bounds.northEast.latitude, + bounds.northEast.longitude, + bounds.southEast.latitude, + bounds.southEast.longitude, + cat + ).then((value) { + isLoading.value = false; // ローディング状態をfalseに設定 + + if (value == null) { + // APIからのレスポンスがnullの場合は処理を中断 + return; + } + if (value.features.isEmpty) { + if (showPopup == false) { + return; + } + Get.snackbar( + "Too many Points", + "please zoom in", + icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue), + snackPosition: SnackPosition.TOP, + duration: const Duration(seconds: 3), + backgroundColor: Colors.yellow, + ); + showPopup = false; + } + if (value.features.isNotEmpty) { + locations.add(value); + } + }).catchError((error) { + isLoading.value = false; // ローディング状態をfalseに設定 + + // エラーハンドリング: APIリクエストが失敗した場合 + Get.snackbar( + "Error", + "Failed to load locations. Please check your internet connection and try again.", + icon: const Icon(Icons.error, size: 40.0, color: Colors.red), + snackPosition: SnackPosition.TOP, + duration: const Duration(milliseconds: 800), + backgroundColor: Colors.yellow, + ); + }); + } void setBound(LatLngBounds bounds) { currentBound.clear(); diff --git a/lib/pages/login/login_page.dart b/lib/pages/login/login_page.dart index 83719a8..50a1538 100644 --- a/lib/pages/login/login_page.dart +++ b/lib/pages/login/login_page.dart @@ -111,7 +111,7 @@ class LoginPage extends StatelessWidget { snackPosition: SnackPosition.TOP, duration: const Duration( - milliseconds: 800), + seconds: 3), backgroundColor: Colors.yellow, //icon:Image(image:AssetImage("assets/images/dora.png")) ); diff --git a/lib/widgets/bottom_sheet_new.dart b/lib/widgets/bottom_sheet_new.dart index d5f63b5..15a2221 100644 --- a/lib/widgets/bottom_sheet_new.dart +++ b/lib/widgets/bottom_sheet_new.dart @@ -111,10 +111,14 @@ class BottomSheetNew extends GetView { } Widget getActionButton(BuildContext context, Destination destination) { + assert(() { print("getActionButton ${destinationController.rogainingCounted.value}"); print("getActionButton ${destinationController.distanceToStart()}"); print("getActionButton ${destination.cp}"); print("getActionButton ${DestinationController.ready_for_goal}"); + return true; + }()); + // ...2024-04-03 Akira デバッグモードのみ出力するようにした。 Destination cdest = destinationController .festuretoDestination(indexController.currentFeature[0]); diff --git a/lib/widgets/map_widget.dart b/lib/widgets/map_widget.dart index 588e81f..238e41e 100644 --- a/lib/widgets/map_widget.dart +++ b/lib/widgets/map_widget.dart @@ -181,7 +181,12 @@ class _MapWidgetState extends State { } void _centerMapOnUser() { + assert(() { print("showBottomSheet ${destinationController.shouldShowBottomSheet}"); + return true; + }()); + // 2024-04-03 Akira Log enabled only debug mode.. + // //if (destinationController.shouldShowBottomSheet) { destinationController.centerMapToCurrentLocation(); //}