Files
rog_app/lib/pages/index/index_page.dart

170 lines
6.4 KiB
Dart
Raw Normal View History

2022-04-17 11:45:21 +05:30
import 'package:flutter/material.dart';
import 'package:get/get.dart';
2024-02-04 19:14:41 +05:30
import 'package:rogapp/model/destination.dart';
2023-10-31 14:12:48 +05:30
import 'package:rogapp/model/gps_data.dart';
2022-09-22 20:36:56 +05:30
import 'package:rogapp/pages/destination/destination_controller.dart';
2022-04-17 11:45:21 +05:30
import 'package:rogapp/pages/drawer/drawer_page.dart';
2022-05-12 02:17:08 +05:30
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
2024-02-04 19:14:41 +05:30
import 'package:rogapp/services/DatabaseService.dart';
2023-10-31 14:12:48 +05:30
import 'package:rogapp/utils/database_gps.dart';
2024-02-04 19:14:41 +05:30
import 'package:rogapp/utils/database_helper.dart';
2022-04-17 11:45:21 +05:30
import 'package:rogapp/widgets/list_widget.dart';
import 'package:rogapp/widgets/map_widget.dart';
class IndexPage extends GetView<IndexController> {
IndexPage({Key? key}) : super(key: key);
final IndexController indexController = Get.find<IndexController>();
2023-09-04 22:46:53 +05:30
final DestinationController destinationController =
Get.find<DestinationController>();
2022-04-17 11:45:21 +05:30
@override
Widget build(BuildContext context) {
2022-07-22 19:36:04 +05:30
return WillPopScope(
2023-06-11 21:03:30 +05:30
onWillPop: () async => false,
2022-07-22 19:36:04 +05:30
child: Scaffold(
2023-07-11 12:11:41 +05:30
drawer: DrawerPage(),
2023-09-04 22:46:53 +05:30
appBar: AppBar(
title: Text("add_location".tr),
actions: [
// IconButton(
// onPressed: () {
// DatabaseService ds = DatabaseService();
// ds.updateDatabase();
// },
// icon: const Icon(Icons.ten_k_sharp)),
2024-02-04 19:14:41 +05:30
2023-10-31 14:12:48 +05:30
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)),
2023-09-04 22:46:53 +05:30
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);
},
child: Container(
height: 32,
width: 75,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(25),
),
child: const Center(
child: Icon(Icons.search),
2022-07-22 19:36:04 +05:30
),
2023-09-04 22:46:53 +05:30
),
),
//CatWidget(indexController: indexController,),
2022-07-22 19:36:04 +05:30
],
),
2023-10-06 16:25:21 +05:30
// 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);
// },
// ),
// ))),
// ),
// ],
// ),
// ),
2022-07-22 19:36:04 +05:30
floatingActionButton: FloatingActionButton(
2023-09-04 22:46:53 +05:30
onPressed: () {
2022-07-22 19:36:04 +05:30
indexController.toggleMode();
},
2023-10-06 16:25:21 +05:30
elevation: 1.0,
2023-09-04 22:46:53 +05:30
child: Obx(
2023-10-06 16:25:21 +05:30
() => indexController.mode.value == 0
2023-09-04 22:46:53 +05:30
? const Image(image: AssetImage('assets/images/list2.png'))
: const Image(image: AssetImage('assets/images/map.png')),
2022-09-22 20:36:56 +05:30
),
2022-07-22 19:36:04 +05:30
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
body: SafeArea(
child: Column(
children: [
Expanded(
2023-09-04 22:46:53 +05:30
child: Obx(
2023-10-06 16:25:21 +05:30
() => indexController.mode.value == 0
2023-09-04 22:46:53 +05:30
? MapWidget()
: const ListWidget(),
))
2022-07-22 19:36:04 +05:30
],
),
2022-04-17 11:45:21 +05:30
),
),
);
}
2023-09-04 22:46:53 +05:30
}