125 lines
4.4 KiB
Dart
125 lines
4.4 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:geolocator/geolocator.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:latlong2/latlong.dart';
|
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
|
import 'package:rogapp/pages/destination_map/destination_map_page.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/destination_widget.dart';
|
|
import 'package:timeline_tile/timeline_tile.dart';
|
|
|
|
|
|
class DestinationPage extends StatefulWidget {
|
|
DestinationPage({ Key? key }) : super(key: key);
|
|
|
|
@override
|
|
State<DestinationPage> createState() => _DestinationPageState();
|
|
}
|
|
|
|
class _DestinationPageState extends State<DestinationPage> {
|
|
final DestinationController destinationController = Get.find<DestinationController>();
|
|
|
|
final IndexController indexController = Get.find<IndexController>();
|
|
|
|
final List<int> _items = List<int>.generate(50, (int index) => index);
|
|
|
|
Future<void> showCurrentPosition() async {
|
|
LocationPermission permission = await Geolocator.checkPermission();
|
|
if (permission != LocationPermission.whileInUse ||
|
|
permission != LocationPermission.always) {
|
|
permission = await Geolocator.requestPermission();
|
|
}
|
|
Position position = await Geolocator.getCurrentPosition(
|
|
desiredAccuracy: LocationAccuracy.high);
|
|
indexController.rogMapController?.move(LatLng(position.latitude, position.longitude), 14);
|
|
}
|
|
|
|
Image getImage(int index){
|
|
if(destinationController.destinations[index].photos == null || destinationController.destinations[index].photos == ""){
|
|
return Image(image: AssetImage('assets/images/empty_image.png'));
|
|
}
|
|
else{
|
|
return Image(image: NetworkImage(destinationController.destinations[index].photos!));
|
|
}
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
//destinationController.context = context;
|
|
//destinationController.PopulateDestinations();
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final ColorScheme colorScheme = Theme.of(context).colorScheme;
|
|
final Color oddItemColor = colorScheme.primary.withOpacity(0.05);
|
|
final Color evenItemColor = colorScheme.primary.withOpacity(0.15);
|
|
return WillPopScope(
|
|
onWillPop: () async {
|
|
indexController.switchPage(AppPages.INITIAL);
|
|
return false;
|
|
},
|
|
child: Scaffold(
|
|
drawer: const DrawerPage(),
|
|
bottomNavigationBar: BottomAppBar(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),),
|
|
const Expanded(child: Text('')),
|
|
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
|
|
indexController.switchPage(AppPages.INITIAL);
|
|
}),),
|
|
],
|
|
),
|
|
),
|
|
floatingActionButton: FloatingActionButton(
|
|
onPressed: (){
|
|
//print("######");
|
|
indexController.toggleDestinationMode();
|
|
},
|
|
tooltip: 'Increment',
|
|
child: const Icon(Icons.document_scanner),
|
|
elevation: 4.0,
|
|
),
|
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
|
appBar:AppBar(
|
|
automaticallyImplyLeading: true,
|
|
title: Text("app_title".tr),
|
|
actions: [
|
|
//Obx(() =>
|
|
ToggleButtons(
|
|
disabledColor: Colors.grey.shade200,
|
|
selectedColor: Colors.red,
|
|
children: <Widget>[
|
|
Icon(Icons.explore
|
|
)],
|
|
onPressed: (int index) {
|
|
setState(() {
|
|
destinationController.isSelected[index] = !destinationController.isSelected[index];
|
|
});
|
|
},
|
|
isSelected: destinationController.isSelected,
|
|
),
|
|
//),
|
|
// IconButton(onPressed: (){
|
|
// showCurrentPosition();
|
|
// },
|
|
// icon: Icon(Icons.location_on_outlined))
|
|
],
|
|
),
|
|
body: Obx(() =>
|
|
indexController.desination_mode.value == 0 ?
|
|
DestinationWidget():
|
|
DestinationMapPage()
|
|
)
|
|
),
|
|
);
|
|
|
|
}
|
|
} |