Fix all features
This commit is contained in:
@ -1628,7 +1628,7 @@ class DestinationController extends GetxController {
|
||||
// 地図のイベントリスナーを設定
|
||||
indexController.mapController.mapEventStream.listen((MapEvent mapEvent) {
|
||||
if (mapEvent is MapEventMoveEnd) {
|
||||
indexController.loadLocationsBound();
|
||||
indexController.loadLocationsBound(indexController.currentUser[0]["user"]["event_code"]);
|
||||
}
|
||||
});
|
||||
|
||||
@ -1653,7 +1653,7 @@ class DestinationController extends GetxController {
|
||||
);
|
||||
indexController.currentBound.clear();
|
||||
indexController.currentBound.add(bnds);
|
||||
indexController.loadLocationsBound();
|
||||
indexController.loadLocationsBound(indexController.currentUser[0]["user"]["event_code"]);
|
||||
centerMapToCurrentLocation();
|
||||
}
|
||||
});
|
||||
|
||||
@ -170,7 +170,7 @@ class DestinationMapPage extends StatelessWidget {
|
||||
indexController.currentBound.clear();
|
||||
indexController.currentBound.add(bounds);
|
||||
if (indexController.currentUser.isEmpty) {
|
||||
indexController.loadLocationsBound();
|
||||
indexController.loadLocationsBound(indexController.currentUser[0]["user"]["event_code"]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -79,6 +79,33 @@ class DrawerPage extends StatelessWidget {
|
||||
),
|
||||
)),
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: Icon(Icons.group),
|
||||
title: Text('チーム管理'),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Get.toNamed(AppPages.TEAM_LIST);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.event),
|
||||
title: Text('エントリー管理'),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Get.toNamed(AppPages.ENTRY_LIST);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.event),
|
||||
title: Text('イベント参加'),
|
||||
onTap: () {
|
||||
Get.back(); // ドロワーを閉じる
|
||||
Get.toNamed(AppPages.EVENT_ENTRY);
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
Obx(() => indexController.currentUser.isEmpty
|
||||
? ListTile(
|
||||
leading: const Icon(Icons.login),
|
||||
@ -206,22 +233,7 @@ class DrawerPage extends StatelessWidget {
|
||||
width: 0,
|
||||
height: 0,
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.group),
|
||||
title: Text('チーム管理'),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Get.toNamed(AppPages.TEAM_LIST);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.event),
|
||||
title: Text('エントリー管理'),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Get.toNamed(AppPages.ENTRY_LIST);
|
||||
},
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: const Icon(Icons.privacy_tip),
|
||||
title: Text("privacy".tr),
|
||||
|
||||
9
lib/pages/entry/event_entries_binding.dart
Normal file
9
lib/pages/entry/event_entries_binding.dart
Normal file
@ -0,0 +1,9 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/entry/event_entries_controller.dart';
|
||||
|
||||
class EventEntriesBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut<EventEntriesController>(() => EventEntriesController());
|
||||
}
|
||||
}
|
||||
48
lib/pages/entry/event_entries_controller.dart
Normal file
48
lib/pages/entry/event_entries_controller.dart
Normal file
@ -0,0 +1,48 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/model/entry.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/services/api_service.dart';
|
||||
|
||||
class EventEntriesController extends GetxController {
|
||||
final ApiService _apiService = Get.find<ApiService>();
|
||||
final IndexController _indexController = Get.find<IndexController>();
|
||||
|
||||
final entries = <Entry>[].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
fetchEntries();
|
||||
}
|
||||
|
||||
Future<void> fetchEntries() async {
|
||||
try {
|
||||
final fetchedEntries = await _apiService.getEntries();
|
||||
entries.assignAll(fetchedEntries);
|
||||
} catch (e) {
|
||||
print('Error fetching entries: $e');
|
||||
// エラー処理を追加
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> joinEvent(Entry entry) async {
|
||||
try {
|
||||
|
||||
final userid = _indexController.currentUser[0]["user"]["id"];
|
||||
|
||||
await _apiService.updateUserInfo(userid,entry);
|
||||
|
||||
_indexController.currentUser[0]["user"]["event_code"] = entry.event.eventName;
|
||||
_indexController.currentUser[0]["user"]["team_name"] = entry.team.teamName;
|
||||
_indexController.currentUser[0]["user"]["group"] = entry.team.category.categoryName;
|
||||
_indexController.currentUser[0]["user"]["zekken_number"] = entry.team.zekkenNumber;
|
||||
|
||||
Get.back(); // エントリー一覧ページを閉じる
|
||||
//_indexController.isLoading.value = true;
|
||||
_indexController.reloadMap(entry.event.eventName); // マップをリロード
|
||||
} catch (e) {
|
||||
print('Error joining event: $e');
|
||||
// エラー処理を追加
|
||||
}
|
||||
}
|
||||
}
|
||||
23
lib/pages/entry/event_entries_page.dart
Normal file
23
lib/pages/entry/event_entries_page.dart
Normal file
@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/entry/event_entries_controller.dart';
|
||||
|
||||
class EventEntriesPage extends GetView<EventEntriesController> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('イベント参加')),
|
||||
body: Obx(() => ListView.builder(
|
||||
itemCount: controller.entries.length,
|
||||
itemBuilder: (context, index) {
|
||||
final entry = controller.entries[index];
|
||||
return ListTile(
|
||||
title: Text(entry.event.eventName),
|
||||
subtitle: Text('${entry.category.categoryName} - ${entry.date}'),
|
||||
onTap: () => controller.joinEvent(entry),
|
||||
);
|
||||
},
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/model/entry.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/auth_service.dart';
|
||||
@ -59,6 +60,9 @@ class IndexController extends GetxController with WidgetsBindingObserver {
|
||||
|
||||
String? userToken;
|
||||
|
||||
//late final ApiService _apiService;
|
||||
final ApiService _apiService = Get.find<ApiService>();
|
||||
|
||||
// mode = 0 is map mode, mode = 1 list mode
|
||||
var mode = 0.obs;
|
||||
|
||||
@ -79,6 +83,16 @@ class IndexController extends GetxController with WidgetsBindingObserver {
|
||||
final Connectivity _connectivity = Connectivity();
|
||||
late StreamSubscription<ConnectivityResult> _connectivitySubscription;
|
||||
|
||||
final Rx<DateTime> lastUserUpdateTime = DateTime.now().obs;
|
||||
|
||||
/*
|
||||
void updateUserInfo(Map<String, dynamic> newUserInfo) {
|
||||
currentUser.clear();
|
||||
currentUser.add(newUserInfo);
|
||||
lastUserUpdateTime.value = DateTime.now();
|
||||
}
|
||||
*/
|
||||
|
||||
void toggleMode() {
|
||||
if (mode.value == 0) {
|
||||
mode += 1;
|
||||
@ -202,6 +216,7 @@ class IndexController extends GetxController with WidgetsBindingObserver {
|
||||
if (currentUser.isNotEmpty) {
|
||||
// 既にログインしている場合
|
||||
await Get.putAsync(() => ApiService().init());
|
||||
//await Get.putAsync(() => ApiService().init());
|
||||
// 必要に応じて追加の初期化処理
|
||||
}
|
||||
}
|
||||
@ -492,7 +507,7 @@ class IndexController extends GetxController with WidgetsBindingObserver {
|
||||
saveToDevice(currentUser[0]["token"]);
|
||||
}
|
||||
isLoading.value = false;
|
||||
loadLocationsBound();
|
||||
loadLocationsBound( currentUser[0]["user"]["even_code"]);
|
||||
if (currentUser.isNotEmpty) {
|
||||
rogMode.value = 0;
|
||||
restoreGame();
|
||||
@ -577,7 +592,7 @@ class IndexController extends GetxController with WidgetsBindingObserver {
|
||||
// 要検討:Future.delayedを使用して非同期処理を待たずに先に進むようにしていますが、
|
||||
// これによってメモリリークが発生する可能性があります。非同期処理の結果を適切に処理することを検討してください。
|
||||
//
|
||||
void loadLocationsBound() async {
|
||||
void loadLocationsBound(String eventCode) async {
|
||||
if (isCustomAreaSelected.value == true) {
|
||||
return;
|
||||
}
|
||||
@ -609,12 +624,13 @@ class IndexController extends GetxController with WidgetsBindingObserver {
|
||||
currentBound.clear();
|
||||
currentBound.add(bounds);
|
||||
|
||||
isLoading.value = true; // ローディング状態をtrueに設定
|
||||
//isLoading.value = true; // ローディング状態をtrueに設定
|
||||
|
||||
//print("bounds --- (${bounds.southWest.latitude},${bounds.southWest.longitude}),(${bounds.northWest.latitude},${bounds.northWest.longitude}),(${bounds.northEast.latitude},${bounds.northEast.longitude}),(${bounds.southEast.latitude},${bounds.southEast.longitude})");
|
||||
|
||||
// 要検討:APIからのレスポンスがnullの場合のエラーハンドリングが不十分です。適切なエラーメッセージを表示するなどの処理を追加してください。
|
||||
try {
|
||||
final eventCode = currentUser[0]["user"]["event_code"];
|
||||
final value = await LocationService.loadLocationsBound(
|
||||
bounds.southWest.latitude,
|
||||
bounds.southWest.longitude,
|
||||
@ -624,7 +640,8 @@ class IndexController extends GetxController with WidgetsBindingObserver {
|
||||
bounds.northEast.longitude,
|
||||
bounds.southEast.latitude,
|
||||
bounds.southEast.longitude,
|
||||
cat
|
||||
cat,
|
||||
eventCode
|
||||
);
|
||||
/*
|
||||
if (value == null) {
|
||||
@ -728,4 +745,11 @@ class IndexController extends GetxController with WidgetsBindingObserver {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
void reloadMap( String eventCode ) {
|
||||
// マップをリロードするロジックを実装
|
||||
// 例: 現在の位置情報を再取得し、マップを更新する
|
||||
loadLocationsBound( eventCode );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user