optimized

This commit is contained in:
Mohamed Nouffer
2023-10-06 16:25:21 +05:30
parent 7fdb6c05ee
commit 0e2a8f89f3
101 changed files with 50948 additions and 4137 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
@ -10,10 +9,11 @@ import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/widgets/destination_widget.dart';
class DestnationPage extends StatelessWidget {
DestnationPage({Key? key}) : super(key: key);
class XDestnationPage extends StatelessWidget {
XDestnationPage({Key? key}) : super(key: key);
final DestinationController destinationController = Get.find<DestinationController>();
final DestinationController destinationController =
Get.find<DestinationController>();
final IndexController indexController = Get.find<IndexController>();
@ -26,33 +26,49 @@ class DestnationPage extends StatelessWidget {
permission = await Geolocator.requestPermission();
}
Position position = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high, forceAndroidLocationManager: true);
indexController.rogMapController.move(LatLng(position.latitude, position.longitude), 14);
desiredAccuracy: LocationAccuracy.high,
forceAndroidLocationManager: true);
indexController.rogMapController
.move(LatLng(position.latitude, position.longitude), 14);
}
Image getImage(int index){
if(destinationController.destinations[index].photos == null || destinationController.destinations[index].photos == ""){
Image getImage(int index) {
if (destinationController.destinations[index].photos == null ||
destinationController.destinations[index].photos == "") {
return const Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
return Image(image: NetworkImage(destinationController.destinations[index].photos!));
} else {
return Image(
image:
NetworkImage(destinationController.destinations[index].photos!));
}
}
Widget getRoutingImage(int route){
Widget getRoutingImage(int route) {
switch (route) {
case 0:
return const Image(image: AssetImage('assets/images/p4_9_man.png'), width: 35.0,);
return const Image(
image: AssetImage('assets/images/p4_9_man.png'),
width: 35.0,
);
case 1:
return const Image(image: AssetImage('assets/images/p4_8_car.png'), width: 35.0,);
return const Image(
image: AssetImage('assets/images/p4_8_car.png'),
width: 35.0,
);
case 2:
return const Image(image: AssetImage('assets/images/p4_10_train.png'), width: 35.0,);
return const Image(
image: AssetImage('assets/images/p4_10_train.png'),
width: 35.0,
);
default:
return const Image(image: AssetImage('assets/images/p4_9_man.png'), width: 35.0,);
return const Image(
image: AssetImage('assets/images/p4_9_man.png'),
width: 35.0,
);
}
}
@override
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
@ -60,149 +76,177 @@ class DestnationPage extends StatelessWidget {
return false;
},
child: Scaffold(
drawer: DrawerPage(),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left:13.0),
child: InkWell(
child: Obx((() => getRoutingImage(destinationController.travelMode.value))),
onTap: (){
Get.bottomSheet(
Obx(() =>
ListView(
children: [
Padding(
padding: const EdgeInsets.only(top:30.0, bottom: 30),
child: Center(child: Text("select_travel_mode".tr, style: const TextStyle(fontSize: 22.0, color:Colors.red, fontWeight:FontWeight.bold),),),
),
ListTile(
selected: destinationController.travelMode == 0 ? true : false,
selectedTileColor: Colors.amber.shade200,
leading: const Image(image: AssetImage('assets/images/p4_9_man.png'),),
title: Text("walking".tr),
onTap:(){
destinationController.travelMode.value = 0;
destinationController.PopulateDestinations();
Get.back();
},
drawer: DrawerPage(),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 13.0),
child: InkWell(
child: Obx((() => getRoutingImage(
destinationController.travelMode.value))),
onTap: () {
Get.bottomSheet(
Obx(
() => ListView(
children: [
Padding(
padding: const EdgeInsets.only(
top: 30.0, bottom: 30),
child: Center(
child: Text(
"select_travel_mode".tr,
style: const TextStyle(
fontSize: 22.0,
color: Colors.red,
fontWeight: FontWeight.bold),
),
),
),
ListTile(
selected: destinationController.travelMode == 1 ? true : false,
selectedTileColor: Colors.amber.shade200,
leading: const Image(image: AssetImage('assets/images/p4_8_car.png'),),
title: Text("driving".tr),
onTap:(){
destinationController.travelMode.value = 1;
destinationController.PopulateDestinations();
Get.back();
},
ListTile(
selected:
destinationController.travelMode.value ==
0
? true
: false,
selectedTileColor: Colors.amber.shade200,
leading: const Image(
image: AssetImage(
'assets/images/p4_9_man.png'),
),
title: Text("walking".tr),
onTap: () {
destinationController.travelMode.value = 0;
destinationController
.populateDestinations();
Get.back();
},
),
// ListTile(
// selected: destinationController.travelMode == 2 ? true : false,
// selectedTileColor: Colors.amber.shade200,
// leading: Image(image: AssetImage('assets/images/p4_10_train.png'),),
// title: Text("transit".tr),
// onTap:(){
// destinationController.travelMode.value = 2;
// destinationController.PopulateDestinations();
// Get.back();
// },
// ),
],
ListTile(
selected:
destinationController.travelMode.value ==
1
? true
: false,
selectedTileColor: Colors.amber.shade200,
leading: const Image(
image: AssetImage(
'assets/images/p4_8_car.png'),
),
title: Text("driving".tr),
onTap: () {
destinationController.travelMode.value = 1;
destinationController
.populateDestinations();
Get.back();
},
),
// ListTile(
// selected: destinationController.travelMode == 2 ? true : false,
// selectedTileColor: Colors.amber.shade200,
// leading: Image(image: AssetImage('assets/images/p4_10_train.png'),),
// title: Text("transit".tr),
// onTap:(){
// destinationController.travelMode.value = 2;
// destinationController.PopulateDestinations();
// Get.back();
// },
// ),
],
),
),
),
isScrollControlled:false,
backgroundColor: Colors.white,
);
//destinationController.PopulateDestinations();
}
),
)
,
IconButton(
icon: const Icon(Icons.travel_explore, size: 35,),
onPressed: (){
indexController.switchPage(AppPages.INITIAL);
}
isScrollControlled: false,
backgroundColor: Colors.white,
);
//destinationController.PopulateDestinations();
}),
),
],
IconButton(
icon: const Icon(
Icons.travel_explore,
size: 35,
),
onPressed: () {
indexController.switchPage(AppPages.INITIAL);
}),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: (){
floatingActionButton: FloatingActionButton(
onPressed: () {
//print("######");
indexController.toggleDestinationMode();
},
tooltip: 'Increment',
child: Obx(() =>
indexController.desination_mode == 1 ?
const Image(image: AssetImage('assets/images/list2.png'))
:
const Image(image: AssetImage('assets/images/map.png'))
),
elevation: 4.0,
child: Obx(() => indexController.desinationMode.value == 1
? const Image(image: AssetImage('assets/images/list2.png'))
: const Image(image: AssetImage('assets/images/map.png'))),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
appBar:AppBar(
automaticallyImplyLeading: true,
title: Text("app_title".tr),
actions: [
InkWell(
onTap: (){
Get.toNamed(AppPages.CAMERA_PAGE);
},
child: destinationController.is_in_rog == true ?
Image.asset("assets/images/basic-walking.gif",height: 10.0,)
:
destinationController.is_at_goal == true ?
IconButton(
onPressed:(){Get.toNamed(AppPages.CAMERA_PAGE);},
icon: const Icon(Icons.assistant_photo),
)
:
IconButton(
onPressed:(){Get.toNamed(AppPages.CAMERA_PAGE);},
icon: const Icon(Icons.accessibility),
),
),
// Obx(() =>
// Text(indexController.connectionStatusName.value)
// ),
Obx(() =>
ToggleButtons(
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
appBar: AppBar(
automaticallyImplyLeading: true,
title: Text("app_title".tr),
actions: [
InkWell(
onTap: () {
Get.toNamed(AppPages.CAMERA_PAGE);
},
child: destinationController.isInRog.value == true
? Image.asset(
"assets/images/basic-walking.gif",
height: 10.0,
)
: destinationController.isAtGoal.value == true
? IconButton(
onPressed: () {
Get.toNamed(AppPages.CAMERA_PAGE);
},
icon: const Icon(Icons.assistant_photo),
)
: IconButton(
onPressed: () {
Get.toNamed(AppPages.CAMERA_PAGE);
},
icon: const Icon(Icons.accessibility),
),
),
// Obx(() =>
// Text(indexController.connectionStatusName.value)
// ),
Obx(
() => ToggleButtons(
disabledColor: Colors.grey.shade200,
selectedColor: Colors.red,
children: const <Widget>[
Icon(Icons.explore, size: 35.0,
)],
onPressed: (int index) {
destinationController.is_gps_selected.value = !destinationController.is_gps_selected.value;
if(destinationController.is_gps_selected.value){
destinationController.chekcs = 0;
destinationController.skip_gps = false;
//destinationController.resetRogaining();
}
},
isSelected: [destinationController.is_gps_selected.value],
onPressed: (int index) {
destinationController.isGpsSelected.value =
!destinationController.isGpsSelected.value;
if (destinationController.isGpsSelected.value) {
destinationController.chekcs = 0;
destinationController.skipGps = false;
//destinationController.resetRogaining();
}
},
isSelected: [destinationController.isGpsSelected.value],
children: const <Widget>[
Icon(
Icons.explore,
size: 35.0,
)
],
),
),
),
// IconButton(onPressed: (){
// showCurrentPosition();
// },
// icon: Icon(Icons.location_on_outlined))
],
),
body: Obx(() =>
indexController.desination_mode.value == 0 ?
DestinationWidget():
DestinationMapPage()
)
),
// IconButton(onPressed: (){
// showCurrentPosition();
// },
// icon: Icon(Icons.location_on_outlined))
],
),
body: Obx(() => indexController.desinationMode.value == 0
? DestinationWidget()
: DestinationMapPage())),
);
}
}