update for routing
This commit is contained in:
@ -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){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
// )
|
||||
// ),
|
||||
// );
|
||||
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user