大幅変更&環境バージョンアップ
This commit is contained in:
@ -1,17 +1,14 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:gifunavi/pages/destination/destination_controller.dart';
|
||||
import 'package:gifunavi/pages/index/index_controller.dart';
|
||||
import 'package:gifunavi/utils/location_controller.dart';
|
||||
|
||||
class IndexBinding extends Bindings {
|
||||
|
||||
IndexBinding(this.token);
|
||||
|
||||
String? token;
|
||||
|
||||
@override
|
||||
void dependencies() {
|
||||
final IndexController indexController = IndexController();
|
||||
indexController.userToken = token;
|
||||
Get.put<IndexController>(indexController);
|
||||
Get.lazyPut<IndexController>(() => IndexController());
|
||||
//Get.put<IndexController>(IndexController());
|
||||
Get.put<LocationController>(LocationController());
|
||||
Get.put<DestinationController>(DestinationController());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,38 +1,147 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/drawer/drawer_page.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/widgets/list_widget.dart';
|
||||
import 'package:rogapp/widgets/map_widget.dart';
|
||||
import 'package:gifunavi/pages/destination/destination_controller.dart';
|
||||
import 'package:gifunavi/pages/drawer/drawer_page.dart';
|
||||
import 'package:gifunavi/pages/index/index_controller.dart';
|
||||
import 'package:gifunavi/routes/app_pages.dart';
|
||||
import 'package:gifunavi/widgets/list_widget.dart';
|
||||
import 'package:gifunavi/widgets/map_widget.dart';
|
||||
import 'package:gifunavi/utils/location_controller.dart';
|
||||
|
||||
class IndexPage extends GetView<IndexController> {
|
||||
IndexPage({Key? key}) : super(key: key);
|
||||
// index_page.dartファイルの主な内容です。
|
||||
// このファイルは、アプリのメインページのUIを構築し、各機能へのナビゲーションを提供しています。
|
||||
// また、IndexControllerとDestinationControllerを使用して、状態管理と各種機能の実装を行っています。
|
||||
//
|
||||
// MapWidgetとListWidgetは、それぞれ別のファイルで定義されているウィジェットであり、マップモードとリストモードの表示を担当しています。
|
||||
//
|
||||
// 全体的に、index_page.dartはアプリのメインページの構造を定義し、他のコンポーネントやページへの橋渡しを行っているファイルです。
|
||||
//
|
||||
|
||||
// 要検討:GPSデータの表示アイコンをタップした際のエラーハンドリングを追加することをお勧めします。
|
||||
// MapWidgetとListWidgetの切り替えにObxを使用していますが、パフォーマンスを考慮して、必要な場合にのみウィジェットを再構築するようにしてください。
|
||||
// DestinationControllerのisSimulationModeを使用してGPS信号の強弱をシミュレーションしていますが、本番環境では適切に実際のGPS信号を使用するようにしてください。
|
||||
|
||||
// IndexPageクラスは、GetView<IndexController>を継承したStatelessWidgetです。このクラスは、アプリのメインページを表すウィジェットです。
|
||||
//
|
||||
|
||||
class IndexPage extends StatefulWidget {
|
||||
const IndexPage({super.key});
|
||||
|
||||
@override
|
||||
_IndexPageState createState() => _IndexPageState();
|
||||
}
|
||||
|
||||
class _IndexPageState extends State<IndexPage> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
//checkLoginAndShowDialog();
|
||||
});
|
||||
}
|
||||
|
||||
void checkLoginAndShowDialog() {
|
||||
if (indexController.currentUser.isEmpty) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('ログインが必要です'),
|
||||
content: const Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('1) ログインされていません。ロゲに参加するにはログインが必要です。'),
|
||||
SizedBox(height: 10),
|
||||
Text('2) ログイン後、個人情報入力、チーム登録、エントリー登録を行なってください。'),
|
||||
SizedBox(height: 10),
|
||||
Text('3) エントリー登録は場所と日にちごとに行なってください。'),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('キャンセル'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('ログイン'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Get.toNamed(AppPages.LOGIN);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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 {
|
||||
indexController.switchPage(AppPages.INITIAL);
|
||||
return false;
|
||||
},
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: Scaffold(
|
||||
//
|
||||
// Scaffoldウィジェットを使用して、アプリのメインページのレイアウトを構築しています。
|
||||
//
|
||||
drawer: DrawerPage(),
|
||||
appBar: AppBar(
|
||||
// leading: IconButton(
|
||||
// icon: const Icon(Icons.arrow_back_ios),
|
||||
// onPressed: (){
|
||||
// indexController.switchPage(AppPages.TRAVEL);
|
||||
// },
|
||||
// ),
|
||||
//automaticallyImplyLeading: false,
|
||||
title: Text("add_location".tr),
|
||||
title: Obx(() => Text(indexController.selectedEventName.value)),
|
||||
//title: Text("add_location".tr),
|
||||
actions: [
|
||||
// IconButton(
|
||||
// onPressed: () {
|
||||
// DatabaseService ds = DatabaseService();
|
||||
// ds.updateDatabase();
|
||||
// },
|
||||
// icon: const Icon(Icons.ten_k_sharp)),
|
||||
|
||||
//
|
||||
// AppBarには、タイトルとアクションアイコンが含まれています。
|
||||
// アクションアイコンには、GPSデータの表示、履歴の表示、マップの更新、検索などの機能が含まれています。
|
||||
//
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
// GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
||||
// List<GpsData> data = await db.getGPSData(
|
||||
// indexController.currentUser[0]["user"]['team_name'],
|
||||
// indexController.currentUser[0]["user"]["event_code"]);
|
||||
// print("GPS data is ${data.length}");
|
||||
Get.toNamed(AppPages.GPS);
|
||||
},
|
||||
icon: const Icon(Icons.telegram)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Get.toNamed(AppPages.HISTORY);
|
||||
},
|
||||
icon: const Icon(Icons.history)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
final tk = indexController.currentUser[0]["token"];
|
||||
if (tk != null) {
|
||||
destinationController.fixMapBound(tk);
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.refresh)),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(AppPages.SEARCH);
|
||||
@ -41,6 +150,7 @@ class IndexPage extends GetView<IndexController> {
|
||||
height: 32,
|
||||
width: 75,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue,
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
),
|
||||
child: const Center(
|
||||
@ -48,125 +158,129 @@ class IndexPage extends GetView<IndexController> {
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(onPressed: () {
|
||||
Get.toNamed(AppPages.HISTORY);
|
||||
}, icon: const Icon(Icons.history))
|
||||
|
||||
//CatWidget(indexController: indexController,),
|
||||
//
|
||||
// デバッグ時のみリロードボタンの横にGPS信号レベルの設定ボタンを設置し、
|
||||
// タップすることで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 Container();
|
||||
}
|
||||
}),
|
||||
*/
|
||||
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
|
||||
child: InkWell(
|
||||
child:
|
||||
Obx(() => destinationController.is_gps_selected == true
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 10.0, top: 4.0, bottom: 4.0),
|
||||
child: InkWell(
|
||||
child: const Image(
|
||||
image: AssetImage(
|
||||
'assets/images/route3_off.png'),
|
||||
width: 35,
|
||||
height: 35,
|
||||
),
|
||||
onTap: () {
|
||||
indexController.switchPage(AppPages.TRAVEL);
|
||||
},
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 10.0, top: 4.0, bottom: 4.0),
|
||||
child: InkWell(
|
||||
child: const Image(
|
||||
image: AssetImage(
|
||||
'assets/images/route2_on.png'),
|
||||
width: 35,
|
||||
height: 35,
|
||||
),
|
||||
onTap: () {
|
||||
indexController.switchPage(AppPages.TRAVEL);
|
||||
},
|
||||
),
|
||||
))),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// bottomNavigationBar: BottomAppBar(
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: <Widget>[
|
||||
// Obx(
|
||||
// () => destinationController.isInRog.value == true
|
||||
// ? IconButton(
|
||||
// onPressed: () {},
|
||||
// icon: const Icon(
|
||||
// Icons.run_circle,
|
||||
// size: 44,
|
||||
// color: Colors.green,
|
||||
// ))
|
||||
// : IconButton(
|
||||
// onPressed: () {},
|
||||
// icon: const Icon(
|
||||
// Icons.run_circle,
|
||||
// size: 44,
|
||||
// color: Colors.black12,
|
||||
// )),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding:
|
||||
// const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
|
||||
// child: InkWell(
|
||||
// child: Obx(() => destinationController
|
||||
// .isGpsSelected.value ==
|
||||
// true
|
||||
// ? Padding(
|
||||
// padding: const EdgeInsets.only(
|
||||
// right: 10.0, top: 4.0, bottom: 4.0),
|
||||
// child: InkWell(
|
||||
// child: const Image(
|
||||
// image:
|
||||
// AssetImage('assets/images/route3_off.png'),
|
||||
// width: 35,
|
||||
// height: 35,
|
||||
// ),
|
||||
// onTap: () {
|
||||
// //indexController.switchPage(AppPages.TRAVEL);
|
||||
// },
|
||||
// ),
|
||||
// )
|
||||
// : Padding(
|
||||
// padding: const EdgeInsets.only(
|
||||
// right: 10.0, top: 4.0, bottom: 4.0),
|
||||
// child: InkWell(
|
||||
// child: const Image(
|
||||
// image:
|
||||
// AssetImage('assets/images/route2_on.png'),
|
||||
// width: 35,
|
||||
// height: 35,
|
||||
// ),
|
||||
// onTap: () {
|
||||
// //indexController.switchPage(AppPages.TRAVEL);
|
||||
// },
|
||||
// ),
|
||||
// ))),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
|
||||
//
|
||||
// マップモードとリストモードを切り替えるためのボタンです。
|
||||
//
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
indexController.toggleMode();
|
||||
if (indexController.currentCat.isNotEmpty) {
|
||||
print(indexController.currentCat[0].toString());
|
||||
}
|
||||
},
|
||||
tooltip: 'Increment',
|
||||
elevation: 4.0,
|
||||
elevation: 1.0,
|
||||
//
|
||||
// Obxウィジェットを使用して、indexController.mode.valueの値に基づいて、MapWidgetまたはListWidgetを表示しています。
|
||||
//
|
||||
child: Obx(
|
||||
() => indexController.mode == 0
|
||||
() => indexController.mode.value == 0
|
||||
? const Image(image: AssetImage('assets/images/list2.png'))
|
||||
: const Image(image: AssetImage('assets/images/map.png')),
|
||||
),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
//
|
||||
// bodyには、SafeAreaウィジェットを使用して、画面の安全な領域内にUIを構築しています。
|
||||
//
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
// Container(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// height: 50.0,
|
||||
// //child: SingleChildScrollView(
|
||||
// // scrollDirection: Axis.horizontal,
|
||||
// // child:Row(
|
||||
// // mainAxisAlignment: MainAxisAlignment.start,
|
||||
// // children: [
|
||||
// // TextButton(child:Text("Main Pef >", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.MAINPERF);},),
|
||||
// // TextButton(child:Text("Sub Pef >", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.SUBPERF);},),
|
||||
// // TextButton(child:Text("Cities >", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.CITY);},),
|
||||
// // TextButton(child:Text("Categories", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.CATEGORY);},),
|
||||
// // ],
|
||||
// // )
|
||||
// // ),
|
||||
// child: SingleChildScrollView(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// child: Obx(() =>
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// indexController.is_mapController_loaded.value == false ?
|
||||
// Center(child: CircularProgressIndicator())
|
||||
// :
|
||||
// BreadCrumbWidget(mapController: indexController.mapController),
|
||||
// Container(width: 24.0,),
|
||||
// // Row(
|
||||
// // children: [
|
||||
// // indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text(""),
|
||||
// // indexController.currentCat.isNotEmpty ?
|
||||
// // IconButton(
|
||||
// // onPressed: (){
|
||||
// // indexController.currentCat.clear();
|
||||
// // indexController.loadLocationsBound();
|
||||
// // },
|
||||
// // icon: Icon(Icons.cancel, color: Colors.red,)
|
||||
// // ) :
|
||||
// // Container(width: 0, height: 0,)
|
||||
// // ],
|
||||
// // )
|
||||
// ],
|
||||
// )
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
Expanded(
|
||||
child: Obx(
|
||||
() => indexController.mode == 0 ? MapWidget() : ListWidget(),
|
||||
() => indexController.mode.value == 0
|
||||
? const MapWidget()
|
||||
: const ListWidget(),
|
||||
))
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user