まだ#2800検証中
This commit is contained in:
@ -16,6 +16,7 @@ import 'package:rogapp/services/location_service.dart';
|
||||
import 'package:rogapp/utils/database_helper.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
|
||||
class IndexController extends GetxController {
|
||||
List<GeoJSONFeatureCollection> locations = <GeoJSONFeatureCollection>[].obs;
|
||||
List<GeoJSONFeature> currentFeature = <GeoJSONFeature>[].obs;
|
||||
@ -42,8 +43,11 @@ class IndexController extends GetxController {
|
||||
|
||||
var isCustomAreaSelected = false.obs;
|
||||
|
||||
RxBool isMapControllerReady = RxBool(false); // MapControllerの初期化状態を管理するフラグ
|
||||
//final mapControllerReadyStream = Stream<bool>.value(false); // MapControllerの初期化状態を通知するためのストリーム
|
||||
|
||||
MapController mapController = MapController();
|
||||
MapController rogMapController = MapController();
|
||||
//MapController rogMapController = MapController();
|
||||
|
||||
String? userToken;
|
||||
|
||||
@ -166,8 +170,9 @@ class IndexController extends GetxController {
|
||||
AuthService.login(email, password).then((value) {
|
||||
print("------- logged in user details ######## $value ###### --------");
|
||||
if (value.isNotEmpty) {
|
||||
Navigator.pop(context);
|
||||
// Navigator.pop(context);
|
||||
print("--------- user details login ----- $value");
|
||||
//await Future.delayed(const Duration(milliseconds: 500)); // Added Akira:2024-4-6, #2800
|
||||
changeUser(value);
|
||||
} else {
|
||||
isLoading.value = false;
|
||||
@ -283,7 +288,7 @@ class IndexController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
/* Old code
|
||||
void loadLocationsBound() {
|
||||
if (isCustomAreaSelected.value == true) {
|
||||
return;
|
||||
@ -337,17 +342,33 @@ class IndexController extends GetxController {
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// 2024-04-03 Akira .. Update the code . See ticket 2800.
|
||||
//
|
||||
void loadLocationsBound() {
|
||||
void loadLocationsBound() async {
|
||||
if (isCustomAreaSelected.value == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Akira 追加:2024-4-6 #2800
|
||||
await waitForMapControllerReady(); // MapControllerの初期化が完了するまで待機
|
||||
// Akira 追加:2024-4-6 #2800
|
||||
|
||||
locations.clear();
|
||||
String cat = currentCat.isNotEmpty ? currentCat[0] : "";
|
||||
if (currentCat.isNotEmpty && currentCat[0] == "-all-") {
|
||||
cat = "";
|
||||
}
|
||||
/*
|
||||
// Akira Add 2024-4-6
|
||||
if( mapController.controller == null ) {
|
||||
print("操作が完了する前にMapControllerまたはウィジェットが破棄されました。");
|
||||
isLoading.value = true; // ローディング状態をtrueに設定
|
||||
return;
|
||||
}
|
||||
//
|
||||
*/
|
||||
|
||||
LatLngBounds bounds = mapController.bounds!;
|
||||
currentBound.clear();
|
||||
currentBound.add(bounds);
|
||||
@ -370,24 +391,14 @@ class IndexController extends GetxController {
|
||||
cat
|
||||
);
|
||||
if ( value == null ) {
|
||||
// エラーハンドリング: APIからのレスポンスがnullの場合
|
||||
/*
|
||||
Get.snackbar(
|
||||
"Error",
|
||||
"Failed to load locations. Please try again. === 1",
|
||||
icon: const Icon(Icons.error, size: 40.0, color: Colors.red),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: const Duration(seconds: 3),
|
||||
backgroundColor: Colors.yellow,
|
||||
);
|
||||
*/
|
||||
// APIからのレスポンスがnullの場合
|
||||
DestinationController destinationController = Get.find<DestinationController>(); // 追加
|
||||
final tk = currentUser[0]["token"]; // 追加
|
||||
if (tk != null) { // 追加
|
||||
destinationController.fixMapBound(tk); // 追加
|
||||
} // 追加
|
||||
// return;
|
||||
print("LocationService.loadLocationsBound からの回答がnullのため、マップをリロード");
|
||||
//DestinationController destinationController = Get.find<DestinationController>(); // 追加
|
||||
//final tk = currentUser[0]["token"]; // 追加
|
||||
//if (tk != null) { // 追加
|
||||
// destinationController.fixMapBound(tk); // 追加
|
||||
//} // 追加
|
||||
return;
|
||||
}
|
||||
isLoading.value = false; // ローディング状態をfalseに設定
|
||||
|
||||
@ -412,6 +423,18 @@ class IndexController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//===Akira 追加:2024-4-6 #2800
|
||||
Future<void> waitForMapControllerReady() async {
|
||||
if (!isMapControllerReady.value) {
|
||||
await Future.doWhile(() async {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
return !isMapControllerReady.value;
|
||||
});
|
||||
}
|
||||
}
|
||||
//===Akira 追加:2024-4-6 #2800
|
||||
|
||||
void setBound(LatLngBounds bounds) {
|
||||
currentBound.clear();
|
||||
currentBound.add(bounds);
|
||||
|
||||
@ -11,19 +11,41 @@ import 'package:rogapp/utils/database_gps.dart';
|
||||
import 'package:rogapp/utils/database_helper.dart';
|
||||
import 'package:rogapp/widgets/list_widget.dart';
|
||||
import 'package:rogapp/widgets/map_widget.dart';
|
||||
import 'package:rogapp/utils/location_controller.dart';
|
||||
|
||||
// index_page.dartファイルの主な内容です。
|
||||
// このファイルは、アプリのメインページのUIを構築し、各機能へのナビゲーションを提供しています。
|
||||
// また、IndexControllerとDestinationControllerを使用して、状態管理と各種機能の実装を行っています。
|
||||
//
|
||||
// MapWidgetとListWidgetは、それぞれ別のファイルで定義されているウィジェットであり、マップモードとリストモードの表示を担当しています。
|
||||
//
|
||||
// 全体的に、index_page.dartはアプリのメインページの構造を定義し、他のコンポーネントやページへの橋渡しを行っているファイルです。
|
||||
//
|
||||
|
||||
|
||||
// IndexPageクラスは、GetView<IndexController>を継承したStatelessWidgetです。このクラスは、アプリのメインページを表すウィジェットです。
|
||||
//
|
||||
class IndexPage extends GetView<IndexController> {
|
||||
IndexPage({Key? key}) : super(key: key);
|
||||
|
||||
// IndexControllerとDestinationControllerのインスタンスを取得しています。
|
||||
//
|
||||
final LocationController locationController = Get.find<LocationController>();
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
|
||||
// buildメソッドは、ウィジェットのUIを構築するメソッドです。
|
||||
// ここでは、WillPopScopeウィジェットを使用して、端末の戻るボタンが押された際の動作を制御しています。
|
||||
//
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
//
|
||||
// Scaffoldウィジェットを使用して、アプリのメインページのレイアウトを構築しています。
|
||||
//
|
||||
drawer: DrawerPage(),
|
||||
appBar: AppBar(
|
||||
title: Text("add_location".tr),
|
||||
@ -35,6 +57,10 @@ class IndexPage extends GetView<IndexController> {
|
||||
// },
|
||||
// icon: const Icon(Icons.ten_k_sharp)),
|
||||
|
||||
//
|
||||
// AppBarには、タイトルとアクションアイコンが含まれています。
|
||||
// アクションアイコンには、GPSデータの表示、履歴の表示、マップの更新、検索などの機能が含まれています。
|
||||
//
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
// GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
||||
@ -75,6 +101,28 @@ class IndexPage extends GetView<IndexController> {
|
||||
),
|
||||
),
|
||||
//CatWidget(indexController: indexController,),
|
||||
//
|
||||
// デバッグ時のみリロードボタンの横にGPS信号レベルの設定ボタンを設置し、
|
||||
// タップすることでGPS信号の強弱をシミュレーションできるようにする
|
||||
// Akira 2024-4-5
|
||||
//
|
||||
Obx(
|
||||
() => destinationController.isSimulationMode.value
|
||||
? DropdownButton<String>(
|
||||
value: locationController.getSimulatedSignalStrength(),
|
||||
onChanged: (value) {
|
||||
locationController.setSimulatedSignalStrength(value!);
|
||||
},
|
||||
items: ['high', 'medium', 'low']
|
||||
.map<DropdownMenuItem<String>>((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
)
|
||||
: Container(),
|
||||
),
|
||||
],
|
||||
),
|
||||
// bottomNavigationBar: BottomAppBar(
|
||||
@ -139,11 +187,18 @@ class IndexPage extends GetView<IndexController> {
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
|
||||
//
|
||||
// マップモードとリストモードを切り替えるためのボタンです。
|
||||
//
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
indexController.toggleMode();
|
||||
},
|
||||
elevation: 1.0,
|
||||
//
|
||||
// Obxウィジェットを使用して、indexController.mode.valueの値に基づいて、MapWidgetまたはListWidgetを表示しています。
|
||||
//
|
||||
child: Obx(
|
||||
() => indexController.mode.value == 0
|
||||
? const Image(image: AssetImage('assets/images/list2.png'))
|
||||
@ -151,6 +206,9 @@ class IndexPage extends GetView<IndexController> {
|
||||
),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
//
|
||||
// bodyには、SafeAreaウィジェットを使用して、画面の安全な領域内にUIを構築しています。
|
||||
//
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user