20240903 pre release

This commit is contained in:
2024-09-03 22:17:09 +09:00
parent fe46d46ab6
commit 2c0bb06e74
44 changed files with 610 additions and 154 deletions

View File

@ -96,6 +96,8 @@ class IndexController extends GetxController with WidgetsBindingObserver {
final selectedEventName = 'add_location'.tr.obs;
RxBool isLoadingLocations = true.obs;
void setSelectedEventName(String eventName) {
selectedEventName.value = eventName;
}
@ -256,6 +258,9 @@ class IndexController extends GetxController with WidgetsBindingObserver {
tz.initializeTimeZones();
//teamController = Get.find<TeamController>();
loadLocations();
}catch(e,stacktrace){
print('Error in IndexController.onInit: $e');
print('Stack trace: $stacktrace');
@ -265,6 +270,20 @@ class IndexController extends GetxController with WidgetsBindingObserver {
}
}
Future<void> loadLocations() async {
isLoadingLocations.value = true;
try {
await waitForMapControllerReady();
String eventCode = currentUser.isNotEmpty ? currentUser[0]["user"]["event_code"] ?? "" : "";
await loadLocationsBound(eventCode);
} catch (e) {
print('Error loading locations: $e');
// エラーハンドリングを追加(例:スナックバーでユーザーに通知)
} finally {
isLoadingLocations.value = false;
}
}
void _updateConnectionStatus(List<ConnectivityResult> results) {
final result = results.isNotEmpty ? results.first : ConnectivityResult.none;
@ -873,7 +892,7 @@ class IndexController extends GetxController with WidgetsBindingObserver {
// 要検討Future.delayedを使用して非同期処理を待たずに先に進むようにしていますが、
// これによってメモリリークが発生する可能性があります。非同期処理の結果を適切に処理することを検討してください。
//
void loadLocationsBound(String eventCode) async {
Future<void> loadLocationsBound(String eventCode) async {
if (isCustomAreaSelected.value == true) {
return;
}
@ -881,6 +900,19 @@ class IndexController extends GetxController with WidgetsBindingObserver {
// MapControllerの初期化が完了するまで待機
await waitForMapControllerReady();
// null チェックを追加
if (mapController.bounds == null) {
print("MapController bounds are null");
return;
}
// バウンドが有効かどうかを確認する
LatLngBounds bounds = mapController.bounds!;
if (!_isValidBounds(bounds)) {
print("MapController bounds are not valid");
return;
}
locations.clear();
String cat = currentCat.isNotEmpty ? currentCat[0] : "";
if (currentCat.isNotEmpty && currentCat[0] == "-all-") {
@ -896,7 +928,7 @@ class IndexController extends GetxController with WidgetsBindingObserver {
//
*/
LatLngBounds bounds = mapController.bounds!;
//LatLngBounds bounds = mapController.bounds!;
currentBound.clear();
currentBound.add(bounds);
@ -987,6 +1019,15 @@ class IndexController extends GetxController with WidgetsBindingObserver {
}
// バウンドが有効かどうかを確認するヘルパーメソッド
bool _isValidBounds(LatLngBounds bounds) {
// 緯度と経度が有効な範囲内にあるかチェック
return bounds.southWest.latitude.abs() <= 90 &&
bounds.southWest.longitude.abs() <= 180 &&
bounds.northEast.latitude.abs() <= 90 &&
bounds.northEast.longitude.abs() <= 180 &&
bounds.southWest.latitude < bounds.northEast.latitude;
}
//===Akira 追加:2024-4-6 #2800
// 要検討MapControllerの初期化が完了するまで待機していますが、タイムアウトを設定することを検討してください。