update for routing

This commit is contained in:
Mohamed Nouffer
2022-09-22 20:36:56 +05:30
parent e0c33435ef
commit 5a183867bd
36 changed files with 762 additions and 185 deletions

View File

@ -30,34 +30,33 @@ class DestinationController extends GetxController {
List<Destination> currentSelectedDestinations = <Destination>[].obs;
bool checking_in = false;
List<bool> isSelected = [true].obs;
var isSelected = false.obs;
BuildContext? context;
List<String> gps = <String>["-- stating --"].obs;
List<String> locationPermission = <String>[" -- starting -- "].obs;
var travelMode = 0.obs;
Map<String, dynamic> matrix = {};
final IndexController indexController = Get.find<IndexController>();
void getRoutePoints() {
indexController.routePoints = [];
indexController.routePointLenght.value = 0;
DestinationService.getDestinationLine(destinations)?.then((value){
indexController.routePoints = value;
indexController.routePointLenght.value = indexController.routePoints.length;
});
}
Future<Destination?> getDEstinationForLatLong(double lat, double long)async {
String jjjj = '{"id":1,"type":"Feature","geometry":{"type":"MultiPoint","coordinates":[[136.731357,35.370094]]},"properties":{"location_id":915101,"location_name":"柳津","category":"買い物","zip":"〒501-6100","address":"柳津町字仙右城7696-1"}}';
for(final d in destinations){
// var geom = d["location"]["geometry"];
// var props = d["location"]["properties"];
// print("--props- ${d["location"]["geometry"]["coordinates"][0][1]}");
// List<dynamic> geom_multi = [geom];
// Map<String, dynamic> final_geom = {"features":[{"id":d["id"],"type":"Feature", "geometry": geom, "properties": props}]};
// //print("----- geom : ${final_geom}");
// String js = json.encode(final_geom);
// //print("---features-- ${js}-----");
// GeoJsonFeatureCollection features = await featuresFromGeoJson(js);
// GeoJsonMultiPoint p = features.collection[0].geometry as GeoJsonMultiPoint;
if(lat == d.lat && long == d.lon){
return d;
}
@ -145,11 +144,9 @@ class DestinationController extends GetxController {
@override
void onInit() async {
super.onInit();
checkPermission();
PopulateDestinations();
//print("------ in iniit");
@ -190,7 +187,7 @@ class DestinationController extends GetxController {
StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
(Position? position) {
if(isSelected[0]){
if(isSelected.value){
double czoom = indexController.rogMapController!.zoom;
indexController.rogMapController!.move(LatLng(position!.latitude, position!.longitude), czoom);
//String user_id = indexController.currentUser[0]["user"]["id"].toString();
@ -209,6 +206,7 @@ class DestinationController extends GetxController {
locationPermission.add(err.toString());
}
super.onInit();
}
@ -266,10 +264,10 @@ class DestinationController extends GetxController {
void PopulateDestinations(){
print("--------- destination controller populsting destinations ----------- ::::::");
destinations.clear();
destinationCount.value = 0;
DatabaseHelper db = DatabaseHelper.instance;
db.getDestinations().then((value){
destinations.clear();
destinationCount.value = 0;
for(Destination d in value){
for(Destination s in currentSelectedDestinations){
if(d.location_id == s.location_id){
@ -280,27 +278,24 @@ class DestinationController extends GetxController {
destinations.add(d);
}
// destinationCount.value = 0;
destinationCount.value = destinations.length;
print("------ destination controller destinationcount-------- ${destinationCount}-------- :::::");
MatrixService.getDestinations(value).then((mat){
print(mat);
print(" matrix is ------- ${mat}");
matrix = mat;
getRoutePoints();
destinationCount.value = destinations.length;
});
});
}
void makeOrder(int action_id, int order, String dir){
DestinationService.updateOrder(action_id, order, dir).then((value){
//print("----action value----${value}");
PopulateDestinations();
destination_index_data.clear();
});
void makeOrder(String locationId){
}

View File

@ -12,15 +12,9 @@ import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/widgets/destination_widget.dart';
import 'package:timeline_tile/timeline_tile.dart';
class DestnationPage extends StatelessWidget {
DestnationPage({Key? key}) : super(key: key);
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>();
@ -47,14 +41,20 @@ class _DestinationPageState extends State<DestinationPage> {
}
}
@override
void initState() {
//destinationController.context = context;
//destinationController.PopulateDestinations();
super.initState();
Widget getRoutingImage(int route){
switch (route) {
case 0:
return Image(image: AssetImage('assets/images/p4_9_man.png'), width: 35.0,);
case 1:
return Image(image: AssetImage('assets/images/p4_8_car.png'), width: 35.0,);
case 2:
return Image(image: AssetImage('assets/images/p4_10_train.png'), width: 35.0,);
default:
return Image(image: AssetImage('assets/images/p4_9_man.png'), width: 35.0,);
}
}
@override
@override
Widget build(BuildContext context) {
final ColorScheme colorScheme = Theme.of(context).colorScheme;
final Color oddItemColor = colorScheme.primary.withOpacity(0.05);
@ -68,13 +68,72 @@ class _DestinationPageState extends State<DestinationPage> {
drawer: DrawerPage(),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(child: Container(width: 0, height: 0,),),
const Expanded(child: Text('')),
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
indexController.switchPage(AppPages.INITIAL);
}),),
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: TextStyle(fontSize: 22.0, color:Colors.red, fontWeight:FontWeight.bold),),),
),
ListTile(
selected: destinationController.travelMode == 0 ? true : false,
selectedTileColor: Colors.amber.shade200,
leading: 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 == 1 ? true : false,
selectedTileColor: Colors.amber.shade200,
leading: 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);
}
),
],
),
),
@ -84,7 +143,12 @@ class _DestinationPageState extends State<DestinationPage> {
indexController.toggleDestinationMode();
},
tooltip: 'Increment',
child: const Icon(Icons.document_scanner),
child: Obx(() =>
indexController.desination_mode == 1 ?
Image(image: AssetImage('assets/images/list2.png'))
:
Image(image: AssetImage('assets/images/map.png'))
),
elevation: 4.0,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
@ -92,21 +156,19 @@ class _DestinationPageState extends State<DestinationPage> {
automaticallyImplyLeading: true,
title: Text("app_title".tr),
actions: [
//Obx(() =>
Obx(() =>
ToggleButtons(
disabledColor: Colors.grey.shade200,
selectedColor: Colors.red,
children: <Widget>[
Icon(Icons.explore
Icon(Icons.explore, size: 35.0,
)],
onPressed: (int index) {
setState(() {
destinationController.isSelected[index] = !destinationController.isSelected[index];
});
destinationController.isSelected.value = !destinationController.isSelected.value;
},
isSelected: destinationController.isSelected,
isSelected: [destinationController.isSelected.value],
),
//),
),
// IconButton(onPressed: (){
// showCurrentPosition();
// },
@ -122,4 +184,194 @@ class _DestinationPageState extends State<DestinationPage> {
);
}
}
}
// class DestinationPage extends StatefulWidget {
// DestinationPage({ Key? key }) : super(key: key);
// @override
// State<DestinationPage> createState() => _DestinationPageState();
// }
// class DestinationPage 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);
// DestinationWidget dest = DestinationWidget();
// DestinationMapPage destMap = DestinationMapPage();
// 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!));
// }
// }
// Widget getRoutingImage(int route){
// switch (route) {
// case 0:
// return Image(image: AssetImage('assets/images/p4_9_man.png'), width: 27.0,);
// case 1:
// return Image(image: AssetImage('assets/images/p4_8_car.png'), width: 27.0,);
// case 2:
// return Image(image: AssetImage('assets/images/p4_10_train.png'), width: 27.0,);
// default:
// return Image(image: AssetImage('assets/images/p4_9_man.png'), width: 27.0,);
// }
// }
// @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: 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: TextStyle(fontSize: 22.0, color:Colors.red, fontWeight:FontWeight.bold),),),
// ),
// ListTile(
// selected: destinationController.travelMode == 0 ? true : false,
// selectedTileColor: Colors.amber.shade200,
// leading: Image(image: AssetImage('assets/images/p4_9_man.png'),),
// title: Text("walking".tr),
// onTap:(){
// destinationController.travelMode.value = 0;
// Get.back();
// },
// ),
// ListTile(
// selected: destinationController.travelMode == 1 ? true : false,
// selectedTileColor: Colors.amber.shade200,
// leading: Image(image: AssetImage('assets/images/p4_8_car.png'),),
// title: Text("driving".tr),
// onTap:(){
// destinationController.travelMode.value = 1;
// 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;
// Get.back();
// },
// ),
// ],
// ),
// ),
// isScrollControlled:false,
// backgroundColor: Colors.white,
// );
// destinationController.PopulateDestinations();
// destMap.
// }
// ),
// )
// ,
// IconButton(
// icon: const Icon(Icons.travel_explore),
// onPressed: (){
// indexController.switchPage(AppPages.INITIAL);
// }
// ),
// ],
// ),
// ),
// floatingActionButton: FloatingActionButton(
// onPressed: (){
// //print("######");
// indexController.toggleDestinationMode();
// },
// tooltip: 'Increment',
// child: Obx(() =>
// indexController.desination_mode == 1 ?
// Image(image: AssetImage('assets/images/list2.png'))
// :
// Image(image: AssetImage('assets/images/map.png'))
// ),
// 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 ?
// dest:
// destMap
// )
// ),
// );
// }
// }

View File

@ -12,22 +12,16 @@ import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
//import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/services/destination_service.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
import 'package:rogapp/widgets/bread_crum_widget.dart';
class DestinationMapPage extends StatefulWidget {
DestinationMapPage({ Key? key }) : super(key: key);
class DestinationMapPage extends StatelessWidget {
DestinationMapPage({Key? key}) : super(key: key);
@override
State<DestinationMapPage> createState() => _DestinationMapPageState();
}
class _DestinationMapPageState extends State<DestinationMapPage> {
final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>();
@ -35,7 +29,7 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
final PopupController _popupLayerController = PopupController();
List<LatLng>? getPoints(){
//print("##### --- route point ${indexController.routePoints.length}");
print("##### --- route point ${indexController.routePoints.length}");
List<LatLng> pts = [];
for(PointLatLng p in indexController.routePoints){
LatLng l = LatLng(p.latitude, p.longitude);
@ -63,8 +57,6 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
int index = -1;
for (int i = 0; i < destinationController.destinations.length; i++) {
Destination d = destinationController.destinations[i];
//for(Destination d in destinationController.destinations){
//print("-----lat ${lat}, ----- lon ${lan}");
Marker m = Marker(
point: LatLng(d.lat!, d.lon!),
anchorPos: AnchorPos.align(AnchorAlign.center),
@ -80,8 +72,7 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
indexController.currentDestinationFeature.add(d);
//indexController.getAction();
showModalBottomSheet(context: context, isScrollControlled: true,
//builder:((context) => BottomSheetWidget())
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
builder:((context) => BottomSheetNew())
);
}
@ -111,36 +102,6 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
],
),
);
//return Icon(Icons.pin_drop);
// return IconButton(
// onPressed: ()async {
// Destination? fs = await destinationController.getDEstinationForLatLong(d.lat!, d.lon!);
// print("-- Destination is --- ${fs!.name} ------");
// if(fs != null){
// if(indexController.currentDestinationFeature.length > 0) {
// indexController.currentDestinationFeature.clear();
// }
// indexController.currentDestinationFeature.add(fs);
// //indexController.getAction();
// showModalBottomSheet(context: context, isScrollControlled: true,
// //builder:((context) => BottomSheetWidget())
// builder:((context) => BottomSheetNew())
// );
// }
// },
// icon: Container(
// width: 60,
// height: 60,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(d.checkin_radious ?? 0),
// color: Colors.transparent,
// border: BoxBorder()
// ),
// child: Icon(Icons.pin_drop)
// )
// );
});
@ -149,19 +110,6 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
return pts;
}
@override
void initState() {
DestinationService.getDestinationLine(destinationController.destinations)?.then((value){
//print("---- loading destination points ------ ${value}");
indexController.routePoints.clear();
setState(() {
indexController.routePoints = value;
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Obx((() =>
@ -177,19 +125,6 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
child:
TravelMap(),
),
// Positioned(
// bottom: 200,
// left: 10,
// child: Container(
// color: Colors.white,
// child: Row(
// children: [
// Text(destinationController.gps[0]),
// Text(destinationController.locationPermission[0])
// ],
// ),
// )
// ),
],
)
));
@ -204,14 +139,9 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
indexController.is_rog_mapcontroller_loaded.value = true;
subscription = indexController.rogMapController!.mapEventStream.listen((MapEvent mapEvent) {
if (mapEvent is MapEventMoveStart) {
//print(DateTime.now().toString() + ' [MapEventMoveStart] START');
// do something
}
if (mapEvent is MapEventMoveEnd) {
destinationController.isSelected.clear();
destinationController.isSelected.add(false);
//print(DateTime.now().toString() + ' [MapEventMoveStart] END');
//indexController.loadLocationsBound();
destinationController.isSelected.value = false;
}
});
});
@ -220,7 +150,6 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
zoom: 1,
maxZoom: 42,
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
//plugins: [LocationMarkerPlugin(),]
),
children: [
TileLayerWidget(
@ -229,32 +158,22 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
subdomains: ['a', 'b', 'c'],
),
),
//Obx(() =>
indexController.routePoints.length > 0 ?
Obx(() =>
indexController.routePointLenght > 0 ?
PolylineLayerWidget(
options: PolylineLayerOptions(
polylines: [
Polyline(
points: getPoints()!,
strokeWidth: 6.0,
color: Colors.indigo),
color: Colors.indigo
),
],
),
)
:
Container(),
//),
// PopupMarkerLayerWidget(
// options: PopupMarkerLayerOptions(
// popupController: _popupLayerController,
// markers: _markers,
// markerRotateAlignment:
// PopupMarkerLayerOptions.rotationAlignmentFor(AnchorAlign.top),
// popupBuilder: (BuildContext context, Marker marker) =>
// examplePopup(marker),
// ),
// ),
),
LocationMarkerLayerWidget(),
MarkerLayerWidget(
options: MarkerLayerOptions(
@ -265,4 +184,261 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
);
}
}
}
// class DestinationMapPage extends StatefulWidget {
// DestinationMapPage({ Key? key }) : super(key: key);
// @override
// State<DestinationMapPage> createState() => _DestinationMapPageState();
// }
//class _DestinationMapPageState extends State<DestinationMapPage> {
// final IndexController indexController = Get.find<IndexController>();
// final DestinationController destinationController = Get.find<DestinationController>();
// StreamSubscription? subscription;
// final PopupController _popupLayerController = PopupController();
// List<LatLng>? getPoints(List<PointLatLng> ptts){
// //print("##### --- route point ${indexController.routePoints.length}");
// List<LatLng> pts = [];
// for(PointLatLng p in ptts){
// LatLng l = LatLng(p.latitude, p.longitude);
// pts.add(l);
// }
// return pts;
// }
// String getDisplaytext(Destination dp){
// String txt = "";
// if(dp.cp! > 0){
// txt = "${dp.cp}";
// if(dp.checkin_point != null && dp.checkin_point! > 0){
// txt = txt + "{${dp.checkin_point}}";
// }
// if(dp.buy_point != null && dp.buy_point! > 0){
// txt = txt + "[${dp.buy_point}]";
// }
// }
// return txt;
// }
// List<Marker>? getMarkers() {
// List<Marker> pts = [];
// int index = -1;
// for (int i = 0; i < destinationController.destinations.length; i++) {
// Destination d = destinationController.destinations[i];
// //for(Destination d in destinationController.destinations){
// //print("-----lat ${lat}, ----- lon ${lan}");
// Marker m = Marker(
// point: LatLng(d.lat!, d.lon!),
// anchorPos: AnchorPos.align(AnchorAlign.center),
// builder:(cts){
// return InkWell(
// onTap: (){
// print("-- Destination is --- ${d.name} ------");
// if(d != null){
// if(indexController.currentDestinationFeature.length > 0) {
// indexController.currentDestinationFeature.clear();
// }
// indexController.currentDestinationFeature.add(d);
// //indexController.getAction();
// showModalBottomSheet(context: context, isScrollControlled: true,
// //builder:((context) => BottomSheetWidget())
// builder:((context) => BottomSheetNew())
// );
// }
// },
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Container(
// width:20,
// height:20,
// decoration: BoxDecoration(
// color: Colors.red,
// shape: BoxShape.circle,
// border: new Border.all(
// color: Colors.white,
// width: d.checkin_radious != null ? d.checkin_radious! : 1,
// ),
// ),
// child: new Center(
// child: new Text(
// (i + 1).toString(),
// style: TextStyle(color: Colors.white),
// ),
// ),
// ),
// Container( color: Colors.yellow, child: Text(getDisplaytext(d), style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, overflow: TextOverflow.visible),)),
// ],
// ),
// );
// //return Icon(Icons.pin_drop);
// // return IconButton(
// // onPressed: ()async {
// // Destination? fs = await destinationController.getDEstinationForLatLong(d.lat!, d.lon!);
// // print("-- Destination is --- ${fs!.name} ------");
// // if(fs != null){
// // if(indexController.currentDestinationFeature.length > 0) {
// // indexController.currentDestinationFeature.clear();
// // }
// // indexController.currentDestinationFeature.add(fs);
// // //indexController.getAction();
// // showModalBottomSheet(context: context, isScrollControlled: true,
// // //builder:((context) => BottomSheetWidget())
// // builder:((context) => BottomSheetNew())
// // );
// // }
// // },
// // icon: Container(
// // width: 60,
// // height: 60,
// // decoration: BoxDecoration(
// // borderRadius: BorderRadius.circular(d.checkin_radious ?? 0),
// // color: Colors.transparent,
// // border: BoxBorder()
// // ),
// // child: Icon(Icons.pin_drop)
// // )
// // );
// });
// pts.add(m);
// }
// return pts;
// }
// @override
// void initState() {
// //indexController.routePoints.clear();
// DestinationService.getDestinationLine(destinationController.destinations)?.then((value){
// //print("---- loading destination points ------ ${value}");
// setState(() {
// indexController.routePoints = value;
// });
// });
// super.initState();
// }
// void reload(){
// setState(() {
// });
// }
// @override
// Widget build(BuildContext context) {
// return Obx((() =>
// Stack(
// children: [
// indexController.is_rog_mapcontroller_loaded.value == false ?
// Center(child: CircularProgressIndicator())
// :
// BreadCrumbWidget(mapController:indexController.rogMapController),
// Padding(
// padding: const EdgeInsets.only(top:50.0),
// //child: TravelMap(),
// child:
// TravelMap(indexController.routePoints),
// ),
// // Positioned(
// // bottom: 200,
// // left: 10,
// // child: Container(
// // color: Colors.white,
// // child: Row(
// // children: [
// // Text(destinationController.gps[0]),
// // Text(destinationController.locationPermission[0])
// // ],
// // ),
// // )
// // ),
// ],
// )
// ));
// }
// FlutterMap TravelMap(List<PointLatLng> ptts) {
// return FlutterMap(
// options: MapOptions(
// onMapCreated: (c){
// indexController.rogMapController = c;
// indexController.rogMapController!.onReady.then((_) {
// indexController.is_rog_mapcontroller_loaded.value = true;
// subscription = indexController.rogMapController!.mapEventStream.listen((MapEvent mapEvent) {
// if (mapEvent is MapEventMoveStart) {
// //print(DateTime.now().toString() + ' [MapEventMoveStart] START');
// // do something
// }
// if (mapEvent is MapEventMoveEnd) {
// destinationController.isSelected.value = false;
// //print(DateTime.now().toString() + ' [MapEventMoveStart] END');
// //indexController.loadLocationsBound();
// }
// });
// });
// } ,
// bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]),
// zoom: 1,
// maxZoom: 42,
// interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
// //plugins: [LocationMarkerPlugin(),]
// ),
// children: [
// TileLayerWidget(
// options: TileLayerOptions(
// urlTemplate: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
// subdomains: ['a', 'b', 'c'],
// ),
// ),
// //Obx(() =>
// indexController.routePoints.length > 0 ?
// PolylineLayerWidget(
// options: PolylineLayerOptions(
// polylines: [
// Polyline(
// points: getPoints(ptts)!,
// strokeWidth: 6.0,
// color: Colors.indigo
// ),
// ],
// ),
// )
// :
// Container(),
// //),
// // PopupMarkerLayerWidget(
// // options: PopupMarkerLayerOptions(
// // popupController: _popupLayerController,
// // markers: _markers,
// // markerRotateAlignment:
// // PopupMarkerLayerOptions.rotationAlignmentFor(AnchorAlign.top),
// // popupBuilder: (BuildContext context, Marker marker) =>
// // examplePopup(marker),
// // ),
// // ),
// LocationMarkerLayerWidget(),
// MarkerLayerWidget(
// options: MarkerLayerOptions(
// markers: getMarkers()!
// ),
// ),
// ],
// );
// }
//}

View File

@ -1,14 +1,20 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:url_launcher/url_launcher.dart';
class DrawerPage extends StatelessWidget {
DrawerPage({ Key? key }) : super(key: key);
final IndexController indexController = Get.find<IndexController>();
void _launchURL(url) async {
if (!await launch(url)) throw 'Could not launch $url';
}
@override
Widget build(BuildContext context) {
return SafeArea(
@ -47,7 +53,7 @@ class DrawerPage extends StatelessWidget {
leading: const Icon(Icons.login),
title: Text("logout".tr),
onTap: (){
indexController.currentUser.clear();
indexController.logout();
Get.toNamed(AppPages.TRAVEL);
},
)
@ -88,7 +94,9 @@ class DrawerPage extends StatelessWidget {
ListTile(
leading: const Icon(Icons.featured_video),
title: Text("rog_web".tr),
onTap: (){},
onTap: (){
_launchURL("https://www.gifuai.net/?page_id=4425");
},
) :
Container(width: 0, height: 0,),
// ListTile(

View File

@ -1,6 +1,7 @@
import 'package:flutter_map/plugin_api.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
class IndexBinding extends Bindings {

View File

@ -11,7 +11,6 @@ import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/destination/destination_binding.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/destination/destination_page.dart';
import 'package:rogapp/pages/destination_map/destination_map_page.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/action_service.dart';
import 'package:rogapp/services/auth_service.dart';
@ -36,6 +35,7 @@ class IndexController extends GetxController {
List<Map<String, dynamic>> currentUser = <Map<String, dynamic>>[].obs;
List<dynamic> currentAction = <dynamic>[].obs;
List<PointLatLng> routePoints = <PointLatLng>[].obs;
var routePointLenght = 0.obs;
var is_loading = false.obs;
@ -94,7 +94,7 @@ class IndexController extends GetxController {
case AppPages.TRAVEL : {
rog_mode.value = 1;
//Get.back();
Get.off(DestinationPage(), binding: DestinationBinding());
Get.off(DestnationPage(), binding: DestinationBinding());
}
break;
@ -199,6 +199,18 @@ void login(String email, String password, BuildContext context){
});
}
void logout() async{
locations.clear();
DatabaseHelper db = DatabaseHelper.instance;
db.deleteAllDestinations().then((value){
DestinationController destinationController = Get.find<DestinationController>();
if(destinationController != null){
destinationController.PopulateDestinations();
}
});
currentUser.clear();
}
void register(String email, String password, BuildContext context){
AuthService.register(email, password).then((value){
if(value.isNotEmpty){

View File

@ -3,6 +3,7 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/model/destination.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';
@ -19,6 +20,7 @@ class IndexPage extends GetView<IndexController> {
IndexPage({Key? key}) : super(key: key);
final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>();
@override
Widget build(BuildContext context) {
@ -59,13 +61,31 @@ class IndexPage extends GetView<IndexController> {
),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Expanded(child: Container(width: 0, height: 0,),),
const Expanded(child: Text('')),
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
indexController.switchPage(AppPages.TRAVEL);
}),),
Padding(
padding: const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
child: InkWell(
child:
Obx(() =>
destinationController.isSelected == true ?
Padding(
padding: const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
child: InkWell(
child: Image(image: AssetImage('assets/images/route3_off.png'), width: 35, height: 35,),
onTap: (){Get.toNamed(AppPages.DESTINATION_MAP);},
),
) :
Padding(
padding: const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
child: InkWell(
child: Image(image: AssetImage('assets/images/route2_on.png'),width: 35, height: 35,),
onTap: (){Get.toNamed(AppPages.DESTINATION_MAP);},
),
)
)
),
),
],
),
),
@ -78,7 +98,12 @@ class IndexPage extends GetView<IndexController> {
},
tooltip: 'Increment',
child: const Icon(Icons.document_scanner),
child: Obx(() =>
indexController.mode == 0 ?
Image(image: AssetImage('assets/images/list2.png'))
:
Image(image: AssetImage('assets/images/map.png')),
),
elevation: 4.0,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,

View File

@ -63,12 +63,6 @@ class LoginPage extends StatelessWidget {
padding: EdgeInsets.only(top: 3,left: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
border: Border(
bottom: BorderSide(color: Colors.black),
top: BorderSide(color: Colors.black),
right: BorderSide(color: Colors.black),
left: BorderSide(color: Colors.black)
)
),
child: Obx((() =>
indexController.is_loading == true ? MaterialButton(