diff --git a/assets/images/list2.png b/assets/images/list2.png new file mode 100644 index 0000000..869dd45 Binary files /dev/null and b/assets/images/list2.png differ diff --git a/assets/images/list2_off.png b/assets/images/list2_off.png new file mode 100644 index 0000000..e6bf69a Binary files /dev/null and b/assets/images/list2_off.png differ diff --git a/assets/images/map.png b/assets/images/map.png new file mode 100644 index 0000000..a4a31a3 Binary files /dev/null and b/assets/images/map.png differ diff --git a/assets/images/map2.png b/assets/images/map2.png new file mode 100644 index 0000000..eb3dd1b Binary files /dev/null and b/assets/images/map2.png differ diff --git a/assets/images/map3.png b/assets/images/map3.png new file mode 100644 index 0000000..429a568 Binary files /dev/null and b/assets/images/map3.png differ diff --git a/assets/images/map_off.png b/assets/images/map_off.png new file mode 100644 index 0000000..6549359 Binary files /dev/null and b/assets/images/map_off.png differ diff --git a/assets/images/p4_10_train.png b/assets/images/p4_10_train.png new file mode 100644 index 0000000..9b0c274 Binary files /dev/null and b/assets/images/p4_10_train.png differ diff --git a/assets/images/p4_13_position__down.png b/assets/images/p4_13_position__down.png new file mode 100644 index 0000000..6549359 Binary files /dev/null and b/assets/images/p4_13_position__down.png differ diff --git a/assets/images/p4_13_position_map2.png b/assets/images/p4_13_position_map2.png new file mode 100644 index 0000000..eb3dd1b Binary files /dev/null and b/assets/images/p4_13_position_map2.png differ diff --git a/assets/images/p4_6_map_destination_icon.png b/assets/images/p4_6_map_destination_icon.png new file mode 100644 index 0000000..617ab0b Binary files /dev/null and b/assets/images/p4_6_map_destination_icon.png differ diff --git a/assets/images/p4_8_car.png b/assets/images/p4_8_car.png new file mode 100644 index 0000000..d1ac37f Binary files /dev/null and b/assets/images/p4_8_car.png differ diff --git a/assets/images/p4_9_man.png b/assets/images/p4_9_man.png new file mode 100644 index 0000000..61ae1a0 Binary files /dev/null and b/assets/images/p4_9_man.png differ diff --git a/assets/images/route2_off.png b/assets/images/route2_off.png new file mode 100644 index 0000000..42ce921 Binary files /dev/null and b/assets/images/route2_off.png differ diff --git a/assets/images/route2_on.png b/assets/images/route2_on.png new file mode 100644 index 0000000..844ce2d Binary files /dev/null and b/assets/images/route2_on.png differ diff --git a/assets/images/route3_off.png b/assets/images/route3_off.png new file mode 100644 index 0000000..7e80fb2 Binary files /dev/null and b/assets/images/route3_off.png differ diff --git a/assets/images/route3_on.png b/assets/images/route3_on.png new file mode 100644 index 0000000..3b3bb99 Binary files /dev/null and b/assets/images/route3_on.png differ diff --git a/assets/images/viaicon.png b/assets/images/viaicon.png new file mode 100644 index 0000000..617ab0b Binary files /dev/null and b/assets/images/viaicon.png differ diff --git a/ios/Podfile.lock b/ios/Podfile.lock index d113457..bcddbcf 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -9,7 +9,7 @@ PODS: - FMDB/standard (2.7.5) - geolocator_apple (1.2.0): - Flutter - - google_maps_flutter (0.0.1): + - google_maps_flutter_ios (0.0.1): - Flutter - GoogleMaps - GoogleMaps (4.1.0): @@ -34,7 +34,7 @@ DEPENDENCIES: - flutter_compass (from `.symlinks/plugins/flutter_compass/ios`) - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) - geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`) - - google_maps_flutter (from `.symlinks/plugins/google_maps_flutter/ios`) + - google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) @@ -55,8 +55,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_keyboard_visibility/ios" geolocator_apple: :path: ".symlinks/plugins/geolocator_apple/ios" - google_maps_flutter: - :path: ".symlinks/plugins/google_maps_flutter/ios" + google_maps_flutter_ios: + :path: ".symlinks/plugins/google_maps_flutter_ios/ios" image_picker_ios: :path: ".symlinks/plugins/image_picker_ios/ios" path_provider_ios: @@ -74,7 +74,7 @@ SPEC CHECKSUMS: flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069 FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401 - google_maps_flutter: c59fc576c0d0c7f4dc4bd63832c862d22d5a7c6d + google_maps_flutter_ios: 66201f392bf62d500f07670a30488a247b9bb5b9 GoogleMaps: 008e2c80e38605b56b560e8deb73d4194ff30bef image_picker_ios: b786a5dcf033a8336a657191401bfdf12017dabb path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02 diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index 3e7060e..5c7ee71 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -30,34 +30,33 @@ class DestinationController extends GetxController { List currentSelectedDestinations = [].obs; bool checking_in = false; - List isSelected = [true].obs; + var isSelected = false.obs; BuildContext? context; List gps = ["-- stating --"].obs; List locationPermission = [" -- starting -- "].obs; + var travelMode = 0.obs; + Map matrix = {}; final IndexController indexController = Get.find(); + void getRoutePoints() { + indexController.routePoints = []; + indexController.routePointLenght.value = 0; + DestinationService.getDestinationLine(destinations)?.then((value){ + indexController.routePoints = value; + indexController.routePointLenght.value = indexController.routePoints.length; + }); + } Future 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 geom_multi = [geom]; - // Map 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 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){ + } diff --git a/lib/pages/destination/destination_page.dart b/lib/pages/destination/destination_page.dart index d7a54cb..bad5142 100644 --- a/lib/pages/destination/destination_page.dart +++ b/lib/pages/destination/destination_page.dart @@ -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 createState() => _DestinationPageState(); -} - -class _DestinationPageState extends State { final DestinationController destinationController = Get.find(); final IndexController indexController = Get.find(); @@ -47,14 +41,20 @@ class _DestinationPageState extends State { } } - @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 { drawer: DrawerPage(), bottomNavigationBar: BottomAppBar( child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - 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 { 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 { automaticallyImplyLeading: true, title: Text("app_title".tr), actions: [ - //Obx(() => + Obx(() => ToggleButtons( disabledColor: Colors.grey.shade200, selectedColor: Colors.red, children: [ - 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 { ); } -} \ No newline at end of file +} + + +// class DestinationPage extends StatefulWidget { +// DestinationPage({ Key? key }) : super(key: key); + +// @override +// State createState() => _DestinationPageState(); +// } + +// class DestinationPage extends State { +// final DestinationController destinationController = Get.find(); + +// final IndexController indexController = Get.find(); + +// final List _items = List.generate(50, (int index) => index); + +// DestinationWidget dest = DestinationWidget(); +// DestinationMapPage destMap = DestinationMapPage(); + +// Future 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: [ +// 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: [ +// 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 +// ) +// ), +// ); + +// } +// } \ No newline at end of file diff --git a/lib/pages/destination_map/destination_map_page.dart b/lib/pages/destination_map/destination_map_page.dart index 7b3b79d..cfb1bd2 100644 --- a/lib/pages/destination_map/destination_map_page.dart +++ b/lib/pages/destination_map/destination_map_page.dart @@ -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 createState() => _DestinationMapPageState(); -} - -class _DestinationMapPageState extends State { final IndexController indexController = Get.find(); final DestinationController destinationController = Get.find(); @@ -35,7 +29,7 @@ class _DestinationMapPageState extends State { final PopupController _popupLayerController = PopupController(); List? getPoints(){ - //print("##### --- route point ${indexController.routePoints.length}"); + print("##### --- route point ${indexController.routePoints.length}"); List pts = []; for(PointLatLng p in indexController.routePoints){ LatLng l = LatLng(p.latitude, p.longitude); @@ -63,8 +57,6 @@ class _DestinationMapPageState extends State { 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 { 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 { ], ), ); - - //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 { 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 { 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 { 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 { zoom: 1, maxZoom: 42, interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag, - //plugins: [LocationMarkerPlugin(),] ), children: [ TileLayerWidget( @@ -229,32 +158,22 @@ class _DestinationMapPageState extends State { 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 { ); } -} \ No newline at end of file +} + + + + +// class DestinationMapPage extends StatefulWidget { +// DestinationMapPage({ Key? key }) : super(key: key); + + +// @override +// State createState() => _DestinationMapPageState(); +// } + +//class _DestinationMapPageState extends State { + // final IndexController indexController = Get.find(); + + // final DestinationController destinationController = Get.find(); + // StreamSubscription? subscription; + // final PopupController _popupLayerController = PopupController(); + + // List? getPoints(List ptts){ + // //print("##### --- route point ${indexController.routePoints.length}"); + // List 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? getMarkers() { + // List 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 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()! + // ), + // ), + // ], + + // ); + // } +//} \ No newline at end of file diff --git a/lib/pages/drawer/drawer_page.dart b/lib/pages/drawer/drawer_page.dart index 422ad90..f502f2c 100644 --- a/lib/pages/drawer/drawer_page.dart +++ b/lib/pages/drawer/drawer_page.dart @@ -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(); + 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( diff --git a/lib/pages/index/index_binding.dart b/lib/pages/index/index_binding.dart index 2d969ff..6202ebb 100644 --- a/lib/pages/index/index_binding.dart +++ b/lib/pages/index/index_binding.dart @@ -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 { diff --git a/lib/pages/index/index_controller.dart b/lib/pages/index/index_controller.dart index 77bfa30..4803fe8 100644 --- a/lib/pages/index/index_controller.dart +++ b/lib/pages/index/index_controller.dart @@ -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> currentUser = >[].obs; List currentAction = [].obs; List routePoints = [].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(); + if(destinationController != null){ + destinationController.PopulateDestinations(); + } + }); + currentUser.clear(); + } + void register(String email, String password, BuildContext context){ AuthService.register(email, password).then((value){ if(value.isNotEmpty){ diff --git a/lib/pages/index/index_page.dart b/lib/pages/index/index_page.dart index 30bd5cb..6aac0d2 100644 --- a/lib/pages/index/index_page.dart +++ b/lib/pages/index/index_page.dart @@ -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 { IndexPage({Key? key}) : super(key: key); final IndexController indexController = Get.find(); + final DestinationController destinationController = Get.find(); @override Widget build(BuildContext context) { @@ -59,13 +61,31 @@ class IndexPage extends GetView { ), bottomNavigationBar: BottomAppBar( child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.end, children: [ - 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 { }, 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, diff --git a/lib/pages/login/login_page.dart b/lib/pages/login/login_page.dart index d44f438..bef5ff9 100644 --- a/lib/pages/login/login_page.dart +++ b/lib/pages/login/login_page.dart @@ -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( diff --git a/lib/routes/app_pages.dart b/lib/routes/app_pages.dart index fd98d57..fcbed9e 100644 --- a/lib/routes/app_pages.dart +++ b/lib/routes/app_pages.dart @@ -81,7 +81,7 @@ class AppPages { ), GetPage( name: Routes.TRAVEL, - page: () => DestinationPage(), + page: () => DestnationPage(), binding: DestinationBinding(), ), GetPage( @@ -91,7 +91,7 @@ class AppPages { ), GetPage( name: Routes.DESTINATION_MAP, - page: () => DestinationPage(), + page: () => DestnationPage(), //binding: DestinationBinding(), ), GetPage( diff --git a/lib/services/destination_service.dart b/lib/services/destination_service.dart index 525b1c7..d0acace 100644 --- a/lib/services/destination_service.dart +++ b/lib/services/destination_service.dart @@ -1,8 +1,10 @@ import 'dart:convert'; import 'package:flutter_polyline_points/flutter_polyline_points.dart'; +import 'package:get/get.dart'; //import 'package:google_maps_webservice/directions.dart'; import 'package:http/http.dart' as http; import 'package:rogapp/model/destination.dart'; +import 'package:rogapp/pages/destination/destination_controller.dart'; import '../utils/const.dart'; @@ -92,8 +94,20 @@ class DestinationService{ wayPoints.add(pwp); i+=1; } + + final DestinationController destinationController = Get.find(); + int trav_mode = destinationController.travelMode.value; + TravelMode _mode = TravelMode.walking; + if(trav_mode == 1){ + _mode = TravelMode.driving; + } + else if(trav_mode == 2) { + _mode = TravelMode.transit; + } + + //PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", PointLatLng(35.389282, 136.498027), PointLatLng(36.285848, 137.575186)); - PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", origin,dest, travelMode: TravelMode.driving, wayPoints: wayPoints); + PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", origin,dest, travelMode: _mode, wayPoints: wayPoints); //print("#####@@@@@ ${result.points}"); return result.points; } diff --git a/lib/services/maxtrix_service.dart b/lib/services/maxtrix_service.dart index acc7aa9..03c6473 100644 --- a/lib/services/maxtrix_service.dart +++ b/lib/services/maxtrix_service.dart @@ -1,13 +1,17 @@ import 'dart:convert'; +import 'package:get/get.dart'; import 'package:http/http.dart' as http; import 'package:rogapp/model/destination.dart'; +import 'package:rogapp/pages/destination/destination_controller.dart'; class MatrixService{ static Future> getDestinations(List destinations) async { + final DestinationController destinationController = Get.find(); + String locs = ""; String origin = ""; int i = 0; @@ -24,10 +28,21 @@ class MatrixService{ i++; } - //print(locs); + String _mode = "walking"; + switch (destinationController.travelMode.value) { + case 1: + _mode = "driving"; + break; + case 2: + _mode = "transit"; + break; + default: + _mode = "walking"; + break; + } Map cats = {}; - String url = "https://maps.googleapis.com/maps/api/distancematrix/json?destinations=${locs}&origins=${origin}&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE"; + String url = "https://maps.googleapis.com/maps/api/distancematrix/json?destinations=${locs}&mode=${_mode}&origins=${origin}&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE"; print(url); final http.Response response = await http.get( Uri.parse(url), diff --git a/lib/utils/const.dart b/lib/utils/const.dart index e837171..77df041 100644 --- a/lib/utils/const.dart +++ b/lib/utils/const.dart @@ -4,9 +4,10 @@ class ConstValues{ static const server_uri = "http://container.intranet.sumasen.net:8100"; static const dev_server = "http://localhost:8100"; - static const dev_ip_server = "http://192.168.8.103:8100"; + static const dev_ip_server = "http://192.168.8.100:8100"; + static const dev_home_ip_server = "http://192.168.1.10:8100"; static String currentServer(){ - return dev_ip_server; + return server_uri; } } diff --git a/lib/utils/database_helper.dart b/lib/utils/database_helper.dart index 3a31be1..96063fb 100644 --- a/lib/utils/database_helper.dart +++ b/lib/utils/database_helper.dart @@ -66,17 +66,22 @@ class DatabaseHelper{ return destList; } - Future deleteDestination(int location_id) async { + Future deleteDestination(int location_id) async { Database db = await instance.database; var dest = await db.delete('destination', where: "location_id = ${location_id}"); int ret = dest > 0 ? dest : -1; return ret; } + Future deleteAllDestinations() async { + Database db = await instance.database; + await db.delete('destination'); + } + FutureisAlreadyAvailable(int location_id) async{ Database db = await instance.database; - var dest = await db.delete('destination', where: "location_id = ${location_id}"); - return dest > 0 ? true : false; + var dest = await db.query('destination', where: "location_id = ${location_id}"); + return dest.length > 0 ? true : false; } Future insertDestination(Destination dest) async { @@ -108,6 +113,42 @@ class DatabaseHelper{ ); } + Future updateOrder(Destination d, int dir)async { + Database db = await instance.database; + var target = await db.query('destination', where: "list_order = ${d.list_order! + dir}"); + var dest = await db.query('destination', where: "location_id = ${d.location_id}"); + if(target.isNotEmpty){ + + List target_indb = target.isNotEmpty + ? target.map((e) => Destination.fromMap(e)).toList() : []; + + List dest_indb = dest.isNotEmpty + ? dest.map((e) => Destination.fromMap(e)).toList() : []; + + Map row_target = { + "list_order": d.list_order + }; + + Map row_des = { + "list_order": dest_indb[0].list_order + }; + + await db.update( + "destination", + row_target, + where: 'location_id = ?', + whereArgs: [target_indb[0]!.location_id] + ); + + await db.update( + "destination", + row_des, + where: 'location_id = ?', + whereArgs: [dest_indb[0]!.location_id] + ); + } + } + // Future getPending() async{ // Database db = await instance.database; // return await Sqflite.firstIntValue(await db.rawQuery("SELECT COUNT(*) FROM incidents")); diff --git a/lib/utils/string_values.dart b/lib/utils/string_values.dart index e24954d..8de8082 100644 --- a/lib/utils/string_values.dart +++ b/lib/utils/string_values.dart @@ -31,7 +31,11 @@ class StringValues extends Translations{ 'no_values': 'No Values', 'email_and_password_required': 'Email and password required', 'rogaining_user_need_tosign_up': "Rogaining participants do need to sign up.", - 'add_location': 'Add Location' + 'add_location': 'Add Location', + 'select_travel_mode':'Select your travel mode', + 'walking':'Walking', + 'driving': 'Driving', + 'transit': 'Transit' }, 'ja_JP': { 'drawer_title':'ロゲイニング参加者はログイン するとチェックポイントが参照 できます', @@ -63,7 +67,11 @@ class StringValues extends Translations{ 'no_values': '値なし', 'email_and_password_required': 'メールとパスワードが必要です', 'rogaining_user_need_tosign_up': "ロゲイニング参加者はサインアップの必要はありません。", - 'add_location': '目的地選択' + 'add_location': '目的地選択', + 'select_travel_mode':'移動モードを選択してください', + 'walking':'ウォーキング', + 'driving': '運転中', + 'transit': 'トランジット' }, }; } \ No newline at end of file diff --git a/lib/widgets/destination_widget.dart b/lib/widgets/destination_widget.dart index 056594c..be9ae82 100644 --- a/lib/widgets/destination_widget.dart +++ b/lib/widgets/destination_widget.dart @@ -6,6 +6,7 @@ import 'package:get/get.dart'; import 'package:rogapp/model/destination.dart'; import 'package:rogapp/pages/destination/destination_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart'; +import 'package:rogapp/utils/database_helper.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart'; import 'package:rogapp/widgets/bottom_sheet_widget.dart'; import 'package:timeline_tile/timeline_tile.dart'; @@ -59,6 +60,11 @@ class DestinationWidget extends StatelessWidget { } void moveUp() { + for(Destination d in destinationController.destinations){ + // if(d.selected){ + + // } + } destinationController.destination_index_data.forEach((element) { //print(element["index"]); //int action_id = destinationController.destinations[element["index"]]["id"] as int; @@ -84,6 +90,11 @@ class DestinationWidget extends StatelessWidget { // }); } + Future getIsLocationAvilable(int location_id) async { + DatabaseHelper db = DatabaseHelper.instance; + return await db.isAlreadyAvailable(location_id); + } + @override Widget build(BuildContext context) { @@ -97,7 +108,6 @@ class DestinationWidget extends StatelessWidget { padding: const EdgeInsets.only(top:45.0), child: ListView.builder( itemCount: destinationController.destinationCount.value, - itemBuilder: (BuildContext context, int index) { return TimelineTile( @@ -105,7 +115,10 @@ class DestinationWidget extends StatelessWidget { lineXY: 0.2, isFirst: index == 0 ? true : false, indicatorStyle: IndicatorStyle( - color: index == 0 ? (Colors.red) : (Colors.grey[400])! + indicator: CircleAvatar( + child: Text(destinationController.destinations[index].list_order.toString(), style: TextStyle(color: Colors.white),), + backgroundColor: Colors.red, + ), ), key: Key(index.toString()), endChild: Card( @@ -165,8 +178,8 @@ class DestinationWidget extends StatelessWidget { Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - //Text(destinationController.matrix["rows"][0]["elements"][index]["distance"]["text"].toString()), - //Text(destinationController.matrix["rows"][0]["elements"][index]["duration"]["text"].toString()) + Text(destinationController.matrix["rows"][0]["elements"][index]["distance"] != null ? destinationController.matrix["rows"][0]["elements"][index]["distance"]["text"].toString(): ''), + Text(destinationController.matrix["rows"][0]["elements"][index]["distance"] != null ? destinationController.matrix["rows"][0]["elements"][index]["duration"]["text"].toString() : '') ], ): Container() diff --git a/lib/widgets/list_widget.dart b/lib/widgets/list_widget.dart index 1451f52..255f29a 100644 --- a/lib/widgets/list_widget.dart +++ b/lib/widgets/list_widget.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:geojson/geojson.dart'; import 'package:get/get.dart'; +import 'package:rogapp/model/destination.dart'; +import 'package:rogapp/pages/destination/destination_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart'; import 'package:rogapp/widgets/bottom_sheet_widget.dart'; @@ -9,6 +11,7 @@ class ListWidget extends StatelessWidget { ListWidget({ Key? key }) : super(key: key); final IndexController indexController = Get.find(); + final DestinationController destinationController = Get.find(); Image getImage(int index){ if(indexController.locations[0].collection[index].properties!["photos"] == null || indexController.locations[0].collection[index].properties!["photos"] == ""){ @@ -39,8 +42,18 @@ class ListWidget extends StatelessWidget { itemCount: indexController.locations[0].collection.length, shrinkWrap: true, itemBuilder: (_, index){ + bool _is_found = false; + for(Destination d in destinationController.destinations){ + if(indexController.locations[0].collection[index].properties!['location_id'] == d.location_id){ + _is_found = true; + break; + } + } return Card( child: ListTile( + selected: _is_found, + + selectedTileColor: Colors.yellow.shade200, onTap: (){ GeoJsonFeature gf = indexController.locations[0].collection[index]; changeCurrentFeature(gf); @@ -54,6 +67,7 @@ class ListWidget extends StatelessWidget { leading: getImage(index), title: indexController.locations[0].collection[index].properties!['location_name'] != null ? Text(indexController.locations[0].collection[index].properties!['location_name'].toString()) : Text(""), subtitle: indexController.locations[0].collection[index].properties!['category'] != null ? Text(indexController.locations[0].collection[index].properties!['category']) : Text(""), + trailing: Text(indexController.locations[0].collection[index].properties!['sub_loc_id'] ), ), ); }, diff --git a/pubspec.lock b/pubspec.lock index d16bd9f..63e4748 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -57,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + circular_menu: + dependency: "direct main" + description: + name: circular_menu + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" cli_util: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a7d0f82..9ac933f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -68,6 +68,7 @@ dependencies: flutter_typeahead: ^4.0.0 flutter_launcher_icons: ^0.10.0 rename: ^2.0.1 + circular_menu: ^2.0.1 flutter_icons: android: true