From ba70fa00807c973e7568024a9ffd0f6b01a5f9db Mon Sep 17 00:00:00 2001 From: Mohamed Nouffer Date: Tue, 14 Jun 2022 14:37:59 +0530 Subject: [PATCH] update --- .vscode/launch.json | 25 ++++ ios/Runner/Info.plist | 2 + .../destination/destination_controller.dart | 92 +++++++++++- lib/pages/destination/destination_page.dart | 17 ++- .../destination_map/destination_map_page.dart | 126 ++++++++++++++-- lib/pages/index/index_controller.dart | 135 ++++++++++++++---- lib/pages/index/index_page.dart | 6 +- lib/routes/app_pages.dart | 3 + lib/services/action_service.dart | 12 +- lib/services/auth_service.dart | 36 ++++- lib/services/cat_service.dart | 7 +- lib/services/destination_service.dart | 17 ++- lib/services/location_line_service.dart | 8 +- lib/services/location_polygon_service.dart | 7 +- lib/services/location_service.dart | 44 +++--- lib/services/perfecture_service.dart | 44 ++++-- lib/services/reacking_service.dart | 34 +++++ lib/utils/const.dart | 12 ++ lib/widgets/bottom_sheet_widget.dart | 72 +++++++--- lib/widgets/destination_widget.dart | 21 +++ lib/widgets/perfecture_widget.dart | 34 ++++- pubspec.yaml | 1 + 22 files changed, 640 insertions(+), 115 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 lib/services/reacking_service.dart create mode 100644 lib/utils/const.dart diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..8dd1e7a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "rogapp", + "request": "launch", + "type": "dart" + }, + { + "name": "rogapp (profile mode)", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "rogapp (release mode)", + "request": "launch", + "type": "dart", + "flutterMode": "release" + } + ] +} \ No newline at end of file diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index d150a58..d40e1b6 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -53,5 +53,7 @@ Photo Library Access Warning NSCameraUsageDescription Camera access to take photo + NSMicrophoneUsageDescription + Post videos to profile diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index 2bcee2c..967611a 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -1,15 +1,22 @@ +import 'dart:convert'; + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:geojson/geojson.dart'; import 'package:geolocator/geolocator.dart'; import 'package:get/get.dart'; +import 'package:latlong2/latlong.dart'; import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/routes/app_pages.dart'; import 'package:rogapp/services/destination_service.dart'; import 'package:rogapp/services/maxtrix_service.dart'; +import 'package:rogapp/services/reacking_service.dart'; import 'dart:async'; +import 'package:rogapp/widgets/bottom_sheet_widget.dart'; + class DestinationController extends GetxController { late LocationSettings locationSettings; @@ -17,21 +24,91 @@ class DestinationController extends GetxController { List destinations = [].obs; List> destination_index_data = >[].obs; + bool checking_in = false; + List isSelected = [true].obs; + BuildContext? context; + Map matrix = {}; final IndexController indexController = Get.find(); + + 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 == p.geoSerie!.geoPoints[0].latitude && long == p.geoSerie!.geoPoints[0].longitude){ + return features.collection[0]; + } + } + } + + checkForCheckin(double la, double ln){ + for(final d in destinations){ + double lat = d["location"]["geometry"]["coordinates"][0][1] as double; + double lon = d["location"]["geometry"]["coordinates"][0][0] as double; + LatLng p = LatLng(lat, lon); + getDEstinationForLatLong(lat, lon).then((value){ + var distance = Distance(); + double dist = distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln)); + double rad = value!.properties!["checkin_radious"] ?? double.infinity; + bool auto_checkin = value.properties!["auto_checkin"] ?? false; + + indexController.currentFeature.add(value); + indexController.getAction(); + + if(!checking_in){ + checking_in = true; + if(rad >= dist){ + if(auto_checkin){ + if(indexController.currentAction.isNotEmpty){ + print(indexController.currentAction[0]); + indexController.currentAction[0][0]["checkin"] = true; + Map temp = Map.from(indexController.currentAction[0][0]); + indexController.currentAction.clear(); + print("---temp---${temp}"); + indexController.currentAction.add([temp]); + } + indexController.makeAction(Get.context!); + } + else{ + showModalBottomSheet(context: Get.context!, isScrollControlled: true, + builder:((context) => BottomSheetWidget()) + ).whenComplete((){ + checking_in = false; + }); + } + } + } + print("----- rad is ${rad}"); + }); + + } + } + + @override void onInit() { PopulateDestinations(); - if (defaultTargetPlatform == TargetPlatform.android) { locationSettings = AndroidSettings( accuracy: LocationAccuracy.high, - distanceFilter: 1, + distanceFilter: 30, forceLocationManager: true, intervalDuration: const Duration(seconds: 10), //(Optional) Set foreground notification config to keep the app alive @@ -55,13 +132,20 @@ class DestinationController extends GetxController { } else { locationSettings = LocationSettings( accuracy: LocationAccuracy.high, - distanceFilter: 1, + distanceFilter: 30, ); } StreamSubscription positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen( (Position? position) { + if(isSelected[0]){ + String user_id = indexController.currentUser[0]["user"]["id"].toString(); + TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){ + //checkForCheckin(position!.latitude, position.longitude); + }); + + } print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}'); }); @@ -80,7 +164,7 @@ class DestinationController extends GetxController { void PopulateDestinations(){ if(indexController.currentUser.isNotEmpty){ - int user_id = indexController.currentUser[0]["user"]["id"] as int; + int user_id = indexController.currentUser[0]["user"]["id"]; //print(user_id); DestinationService.getDestinations(user_id).then((value){ diff --git a/lib/pages/destination/destination_page.dart b/lib/pages/destination/destination_page.dart index e04f63b..93c3d48 100644 --- a/lib/pages/destination/destination_page.dart +++ b/lib/pages/destination/destination_page.dart @@ -25,7 +25,6 @@ class _DestinationPageState extends State { final IndexController indexController = Get.find(); final List _items = List.generate(50, (int index) => index); - List isSelected = [true]; Future showCurrentPosition() async { LocationPermission permission = await Geolocator.checkPermission(); @@ -47,6 +46,12 @@ class _DestinationPageState extends State { } } + @override + void initState() { + destinationController.context = context; + super.initState(); + } + @override Widget build(BuildContext context) { final ColorScheme colorScheme = Theme.of(context).colorScheme; @@ -82,6 +87,12 @@ class _DestinationPageState extends State { floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, appBar:AppBar( title: Text("Iternery"), + leading: IconButton( + icon: Icon(Icons.arrow_back_ios), + onPressed: (){ + indexController.switchPage(AppPages.INITIAL); + }, + ), actions: [ ToggleButtons( disabledColor: Colors.grey.shade200, @@ -91,10 +102,10 @@ class _DestinationPageState extends State { )], onPressed: (int index) { setState(() { - isSelected[index] = !isSelected[index]; + destinationController.isSelected[index] = !destinationController.isSelected[index]; }); }, - isSelected: isSelected, + isSelected: destinationController.isSelected, ), IconButton(onPressed: (){ showCurrentPosition(); diff --git a/lib/pages/destination_map/destination_map_page.dart b/lib/pages/destination_map/destination_map_page.dart index 4aeddad..9584672 100644 --- a/lib/pages/destination_map/destination_map_page.dart +++ b/lib/pages/destination_map/destination_map_page.dart @@ -4,7 +4,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; import 'package:flutter_map_location_marker/flutter_map_location_marker.dart'; +import 'package:flutter_map_marker_popup/flutter_map_marker_popup.dart'; import 'package:flutter_polyline_points/flutter_polyline_points.dart'; +import 'package:geojson/geojson.dart'; import 'package:geolocator/geolocator.dart'; import 'package:get/get.dart'; import 'package:latlong2/latlong.dart'; @@ -12,10 +14,12 @@ 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_widget.dart'; class DestinationMapPage extends StatefulWidget { DestinationMapPage({ Key? key }) : super(key: key); + @override State createState() => _DestinationMapPageState(); } @@ -25,6 +29,69 @@ class _DestinationMapPageState extends State { final DestinationController destinationController = Get.find(); StreamSubscription? subscription; + final PopupController _popupLayerController = PopupController(); + + + + Widget examplePopup(Marker marker){ + return Padding( + padding: const EdgeInsets.all(10), + child: Container( + constraints: const BoxConstraints(minWidth: 100, maxWidth: 200), + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'Popup for a marker!', + overflow: TextOverflow.fade, + softWrap: false, + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 14.0, + ), + ), + const Padding(padding: EdgeInsets.symmetric(vertical: 4.0)), + Text( + 'Position: ${marker.point.latitude}, ${marker.point.longitude}', + style: const TextStyle(fontSize: 12.0), + ), + Text( + 'Marker size: ${marker.width}, ${marker.height}', + style: const TextStyle(fontSize: 12.0), + ), + ], + ), + ), + ); + } + + + + + final List _markerPositions = [ + LatLng(35.728728732933455, 137.06878077038706), + LatLng(35.958218259568305, 137.06187578986646), + LatLng(35.76795686324816, 137.08949571194879), + ]; + + + + List get _markers => _markerPositions + .map( + (markerPosition) => Marker( + point: markerPosition, + width: 40, + height: 40, + builder: (_) => const Icon(Icons.location_on, size: 40), + anchorPos: AnchorPos.align(AnchorAlign.top), + ), + ) + .toList(); + + List? getPoints(){ //print("##### --- route point ${indexController.routePoints.length}"); @@ -36,14 +103,34 @@ class _DestinationMapPageState extends State { return pts; } - List? getMarkers(){ + List? getMarkers() { List pts = []; for(dynamic d in destinationController.destinations){ double lat = d["location"]["geometry"]["coordinates"][0][1]; double lan = d["location"]["geometry"]["coordinates"][0][0]; + //print("-----lat ${lat}, ----- lon ${lan}"); Marker m = Marker(point: LatLng(lat, lan), builder:(cts){ - return Icon(Icons.pin_drop); + //return Icon(Icons.pin_drop); + return IconButton( + onPressed: ()async { + GeoJsonFeature? fs = await destinationController.getDEstinationForLatLong(lat, lan); + print("----fsf-----${fs}"); + if(fs != null){ + if(indexController.currentFeature.length > 0) { + indexController.currentFeature.clear(); + } + indexController.currentFeature.add(fs); + indexController.getAction(); + + showModalBottomSheet(context: context, isScrollControlled: true, + builder:((context) => BottomSheetWidget()) + ); + } + }, + icon: Icon(Icons.pin_drop)); + }); + pts.add(m); } return pts; @@ -85,15 +172,15 @@ class _DestinationMapPageState extends State { interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag, plugins: [LocationMarkerPlugin(),] ), - layers: [ - TileLayerOptions( - urlTemplate: - 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c']), - MarkerLayerOptions( - markers: getMarkers()!, + children: [ + TileLayerWidget( + options: TileLayerOptions( + urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c'], + ), ), - PolylineLayerOptions( + PolylineLayerWidget( + options: PolylineLayerOptions( polylines: [ Polyline( points: getPoints()!, @@ -101,8 +188,25 @@ class _DestinationMapPageState extends State { color: Colors.purple), ], ), - LocationMarkerLayerOptions(), + ), + // PopupMarkerLayerWidget( + // options: PopupMarkerLayerOptions( + // popupController: _popupLayerController, + // markers: _markers, + // markerRotateAlignment: + // PopupMarkerLayerOptions.rotationAlignmentFor(AnchorAlign.top), + // popupBuilder: (BuildContext context, Marker marker) => + + // examplePopup(marker), + // ), + // ), + MarkerLayerWidget( + options: MarkerLayerOptions( + markers: getMarkers()! + ), + ) ], + ) )); } diff --git a/lib/pages/index/index_controller.dart b/lib/pages/index/index_controller.dart index dda30e8..15d35bb 100644 --- a/lib/pages/index/index_controller.dart +++ b/lib/pages/index/index_controller.dart @@ -21,6 +21,7 @@ class IndexController extends GetxController { List currentBound = [].obs; List subPerfs = [].obs; List areas = [].obs; + List customAreas = [].obs; List cats = [].obs; List currentCat = [].obs; @@ -36,6 +37,8 @@ class IndexController extends GetxController { var mode = 0.obs; + var rog_mode = 0.obs; + var desination_mode = 0.obs; @@ -43,6 +46,8 @@ class IndexController extends GetxController { String subDropdownValue = "-1"; String areaDropdownValue = "-1"; + late Worker _ever; + void toggleMode(){ if(mode.value==0){ mode += 1; @@ -61,9 +66,33 @@ class IndexController extends GetxController { } } + void switchPage(String page){ + //print("######## ${currentUser[0]["user"]["id"]}"); + switch (page) { + case AppPages.INITIAL :{ + rog_mode.value = 0; + Get.toNamed(page); + } + break; + case AppPages.TRAVEL : { + rog_mode.value = 1; + Get.toNamed(page); + } + break; + case AppPages.LOGIN :{ + rog_mode.value = 2; + Get.toNamed(page); + } + break; + default:{ + rog_mode.value = 0; + Get.toNamed(AppPages.INITIAL); + } + } + } + @override void onInit() { - super.onInit(); // if(locations.length == 0){ // LocationService.loadLocations().then((value){ @@ -71,23 +100,59 @@ class IndexController extends GetxController { // //print(value); // }); // } + + _ever = ever(rog_mode, (_) => print("$_ has been changed (ever)")); + if(perfectures.length == 0){ PerfectureService.loadPerfectures().then((value){ perfectures.add(value); loadAreaFor("9"); + //loadSubPerfFor("9"); }); - } - //loadCats(); - } + } + super.onInit(); +} - void login(String email, String password, BuildContext context){ + +LatLngBounds boundsFromLatLngList(List list) { + double? x0, x1, y0, y1; + for (LatLng latLng in list) { + if (x0 == null || x1 == null || y0 == null || y1 == null) { + x0 = x1 = latLng.latitude; + y0 = y1 = latLng.longitude; + } else { + if (latLng.latitude > x1) x1 = latLng.latitude; + if (latLng.latitude < x0) x0 = latLng.latitude; + if (latLng.longitude > y1) y1 = latLng.longitude; + if (latLng.longitude < y0) y0 = latLng.longitude; + } + } + + return LatLngBounds(LatLng(x1!, y1!), LatLng(x0!, y0!)); +} + + +List getLocationsList(){ + List locs = []; + for(int i=0; i<= locations[0].collection.length - 1; i++){ + GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint; + + LatLng latLng = LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude); + locs.add(latLng); + } + return locs; +} + + +void login(String email, String password, BuildContext context){ AuthService.login(email, password).then((value){ if(value.isNotEmpty){ currentUser.clear(); currentUser.add(value); is_loading.value = false; Navigator.pop(context); + loadUserDetails(); if(currentFeature.isNotEmpty){ getAction(); } @@ -107,6 +172,7 @@ class IndexController extends GetxController { currentUser.add(value); is_loading.value = false; Navigator.pop(context); + loadUserDetails(); Get.toNamed(AppPages.INITIAL); }else{ is_loading.value = false; @@ -121,26 +187,13 @@ class IndexController extends GetxController { bool wanttogo = currentAction[0][0]["wanttogo"]; bool like = currentAction[0][0]["like"]; bool checkin = currentAction[0][0]["checkin"]; - print("----userid----${user_id}"); if(user_id > 0){ ActionService.makeAction(user_id, location_id, wanttogo, like, checkin).then((value){ - print("----action value----${value}"); }); } } - // void loadCats(){ - // dynamic initVal = {'category':'---'}; - // CatService.loadCats().then((value) { - // //value!.add(initVal); - // print("###########"); - // print(value); - // cats.add(value); - // }); - // } - - void loadCatsv2(){ dynamic initVal = {'category':'---'}; @@ -148,7 +201,6 @@ class IndexController extends GetxController { if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){ cats.clear(); CatService.loadCats(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude).then((value) { - print("###########"); print(value); cats.add(value); }); @@ -181,11 +233,30 @@ class IndexController extends GetxController { areas.clear(); dynamic initVal = {'id':'-1', 'adm2_ja':'----'}; PerfectureService.loadGifuAreas(perf).then((value){ - print(value); value!.add(initVal); areas.add(value); - //loadSubPerfFor("9"); - //subDropdownValue = getSubInitialVal(); + }); + } + + void loadUserDetails(){ + if(currentUser.length > 0){ + int user_id = currentUser[0]["user"]["id"] as int; + AuthService.UserDetails(user_id).then((value){ + //print("--------- user details ----- ${value}"); + bool paid = value![0]["paid"] as bool; + if(paid){ + loadCustomAreas(); + } + }); + } + } + + + void loadCustomAreas(){ + customAreas.clear(); + PerfectureService.loadCustomAreas().then((value){ + print("--- loading custom areas ${value}"); + customAreas.add(value); }); } @@ -235,12 +306,20 @@ class IndexController extends GetxController { }); } - void loadCustomLocation(String customarea, MapController mapController) async { + void loadCustomLocation(String customarea) async { String cat = currentCat.isNotEmpty == true ? currentCat[0] : ""; - print(currentCat); - LocationService.loadCustomLocations(cat).then((value){ + print("----- ${customarea}"); + LocationService.loadCustomLocations(customarea, cat).then((value){ locations.clear(); locations.add(value!); + List locs = getLocationsList(); + LatLngBounds bounds = boundsFromLatLngList(locs); + mapController!.fitBounds(bounds); + setBound(bounds); + Future.delayed(Duration(microseconds: 400), () { + mapController!.fitBounds(bounds); + }); + }); } @@ -312,8 +391,9 @@ class IndexController extends GetxController { is_loading.value = false; } - void populateForCustomArea(String customarea, MapController mapController){ - loadCustomLocation("cus", mapController); + void populateSubPerForArea(String area, MapController mapController){ + loadSubPerfFor(area); + //loadCustomLocation("cus", mapController); //zoomtoSubPerf(subperf); is_loading.value = false; } @@ -337,6 +417,7 @@ class IndexController extends GetxController { return; } int user_id = currentUser[0]["user"]["id"] as int; + print("---- loc id ${currentFeature[0].properties}"); int location_id = currentFeature[0].properties!["location_id"] as int; ActionService.userAction(user_id, location_id).then((value){ print("------${value}"); diff --git a/lib/pages/index/index_page.dart b/lib/pages/index/index_page.dart index 189bac8..95650d0 100644 --- a/lib/pages/index/index_page.dart +++ b/lib/pages/index/index_page.dart @@ -37,10 +37,12 @@ class IndexPage extends GetView { const Expanded(child: Text('')), Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){ if(indexController.currentUser.isNotEmpty){ - Get.toNamed(AppPages.TRAVEL); + indexController.switchPage(AppPages.TRAVEL); + //Get.toNamed(AppPages.TRAVEL); } else{ - Get.toNamed(AppPages.LOGIN); + indexController.switchPage(AppPages.LOGIN); + //Get.toNamed(AppPages.LOGIN); } }),), ], diff --git a/lib/routes/app_pages.dart b/lib/routes/app_pages.dart index 3f58fbf..9bc6426 100644 --- a/lib/routes/app_pages.dart +++ b/lib/routes/app_pages.dart @@ -1,7 +1,9 @@ +import 'package:get/get.dart'; import 'package:get/get_navigation/src/routes/get_route.dart'; import 'package:rogapp/pages/destination/destination_binding.dart'; import 'package:rogapp/pages/destination/destination_page.dart'; import 'package:rogapp/pages/index/index_binding.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_page.dart'; import 'package:rogapp/pages/landing/landing_page.dart'; import 'package:rogapp/pages/loading/loading_page.dart'; @@ -14,6 +16,7 @@ import 'package:rogapp/spa/spa_page.dart'; part 'app_routes.dart'; class AppPages { + // ignore: constant_identifier_names static const INITIAL = Routes.INDEX; // ignore: constant_identifier_names diff --git a/lib/services/action_service.dart b/lib/services/action_service.dart index a8f4992..bfe5980 100644 --- a/lib/services/action_service.dart +++ b/lib/services/action_service.dart @@ -1,13 +1,16 @@ import 'dart:convert'; import 'package:http/http.dart' as http; +import 'package:rogapp/utils/const.dart'; class ActionService{ static Future> makeAction(int user_id, int location_id, bool wanttogo, bool like, bool checkin) async { + print("----- action is ---- ${like}-- ${wanttogo}-- ${checkin}"); Map cats = {}; - //String url = "http://container.intranet.sumasen.net:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}"; - String url = "http://localhost:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}"; + String server_url = ConstValues.currentServer(); + String url = "${server_url}/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}"; + //String url = "http://localhost:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}"; final http.Response response = await http.get( Uri.parse(url), headers: { @@ -24,8 +27,9 @@ class ActionService{ static Future?> userAction(int user_id, int location_id) async { List cats = []; - //String url = 'http://container.intranet.sumasen.net:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}'; - String url = 'http://localhost:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}'; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/useraction/?user_id=${user_id}&location_id=${location_id}'; + //String url = 'http://localhost:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/services/auth_service.dart b/lib/services/auth_service.dart index 3be7f36..5c51bc1 100644 --- a/lib/services/auth_service.dart +++ b/lib/services/auth_service.dart @@ -1,13 +1,16 @@ import 'dart:convert'; import 'package:http/http.dart' as http; +import '../utils/const.dart'; + class AuthService{ static Future> login(String email, String password) async { Map cats = {}; - //String url = 'http://container.intranet.sumasen.net:8100/api/login/'; - String url = 'http://localhost:8100/api/login/'; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/login/'; + //String url = 'http://localhost:8100/api/login/'; final http.Response response = await http.post( Uri.parse(url), headers: { @@ -28,8 +31,9 @@ class AuthService{ static Future> register(String email, String password) async { Map cats = {}; - //String url = 'http://container.intranet.sumasen.net:8100/api/register/'; - String url = 'http://localhost:8100/api/register/'; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/register/'; + //String url = 'http://localhost:8100/api/register/'; final http.Response response = await http.post( Uri.parse(url), headers: { @@ -48,6 +52,30 @@ class AuthService{ } + static Future?> UserDetails(int userid) async { + List cats = []; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/userdetials?user_id=${userid}'; + //String url = 'http://localhost:8100/api/userdetials?user_id=${userid}'; + + + //String url = 'http://container.intranet.sumasen.net:8100/api/cats/'; + print("---- cat url is ${url}"); + final response = await http.get(Uri.parse(url), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + ); + + if (response.statusCode == 200) { + + cats = json.decode(utf8.decode(response.bodyBytes)); + } + return cats; + } + + + diff --git a/lib/services/cat_service.dart b/lib/services/cat_service.dart index 79be732..60203c8 100644 --- a/lib/services/cat_service.dart +++ b/lib/services/cat_service.dart @@ -2,13 +2,16 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; +import '../utils/const.dart'; + class CatService{ static Future?> loadCats(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4) async { List cats = []; - //String url = 'http://container.intranet.sumasen.net:8100/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; - String url = 'http://localhost:8100/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; + //String url = 'http://localhost:8100/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; //String url = 'http://container.intranet.sumasen.net:8100/api/cats/'; diff --git a/lib/services/destination_service.dart b/lib/services/destination_service.dart index 6a09de5..7fdfd95 100644 --- a/lib/services/destination_service.dart +++ b/lib/services/destination_service.dart @@ -4,13 +4,16 @@ import 'package:flutter_polyline_points/flutter_polyline_points.dart'; //import 'package:google_maps_webservice/directions.dart'; import 'package:http/http.dart' as http; +import '../utils/const.dart'; + class DestinationService{ static Future> getDestinations(int user_id) async { List cats = []; - //String url = "http://container.intranet.sumasen.net:8100/api/destinations/?user_id=${user_id}"; - String url = "http://localhost:8100/api/destinations/?user_id=${user_id}"; + String server_url = ConstValues.currentServer(); + String url = "${server_url}/api/destinations/?user_id=${user_id}"; + //String url = "http://localhost:8100/api/destinations/?user_id=${user_id}"; final http.Response response = await http.get( Uri.parse(url), headers: { @@ -26,8 +29,9 @@ class DestinationService{ static Future> deleteDestination(int dest_id) async { Map cats = {}; - //String url = "http://container.intranet.sumasen.net:8100/api/delete_destination/?dest_id=${dest_id}"; - String url = "http://localhost:8100/api/delete_destination/?dest_id=${dest_id}"; + String server_url = ConstValues.currentServer(); + String url = "${server_url}/api/delete_destination/?dest_id=${dest_id}"; + //String url = "http://localhost:8100/api/delete_destination/?dest_id=${dest_id}"; final http.Response response = await http.get( Uri.parse(url), headers: { @@ -44,8 +48,9 @@ class DestinationService{ static Future updateOrder(int action_id, int order, String dir) async { int cats = 0; - //String url = "http://container.intranet.sumasen.net:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}"; - String url = "http://localhost:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}"; + String server_url = ConstValues.currentServer(); + String url = "${server_url}/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}"; + //String url = "http://localhost:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}"; final http.Response response = await http.get( Uri.parse(url), headers: { diff --git a/lib/services/location_line_service.dart b/lib/services/location_line_service.dart index 9094ac6..6cadb4e 100644 --- a/lib/services/location_line_service.dart +++ b/lib/services/location_line_service.dart @@ -1,14 +1,16 @@ import 'package:geojson/geojson.dart'; import 'package:http/http.dart' as http; +import '../utils/const.dart'; + class LocationLineService{ static Future loadLocationLines() async { final geo = GeoJson(); GeoJsonFeature? fs; - - //String url = 'http://container.intranet.sumasen.net:8100/api/location_line/'; - String url = 'http://localhost:8100/api/location_line/'; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/location_line/'; + //String url = 'http://localhost:8100/api/location_line/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/services/location_polygon_service.dart b/lib/services/location_polygon_service.dart index 4a7fa2b..84e8e04 100644 --- a/lib/services/location_polygon_service.dart +++ b/lib/services/location_polygon_service.dart @@ -1,14 +1,17 @@ import 'package:geojson/geojson.dart'; import 'package:http/http.dart' as http; +import '../utils/const.dart'; + class LocationPolygonervice{ static Future loadLocationLines() async { final geo = GeoJson(); GeoJsonFeature? fs; - //String url = 'http://container.intranet.sumasen.net:8100/api/location_polygon/'; - String url = 'http://localhost:8100/api/location_polygon/'; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/location_polygon/'; + //String url = 'http://localhost:8100/api/location_polygon/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/services/location_service.dart b/lib/services/location_service.dart index eef04fa..0f4e325 100644 --- a/lib/services/location_service.dart +++ b/lib/services/location_service.dart @@ -2,12 +2,14 @@ import 'dart:convert'; import 'package:geojson/geojson.dart'; import 'package:http/http.dart' as http; +import 'package:rogapp/utils/const.dart'; class LocationService{ static Future loadLocations() async { - //String url = 'http://container.intranet.sumasen.net:8100/api/location/'; - String url = 'http://localhost:8100/api/location/'; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/location/'; + //String url = 'http://localhost:8100/api/location/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -23,13 +25,14 @@ class LocationService{ static Future loadLocationsFor(String perfecture, String cat) async { String url = ""; + String server_url = ConstValues.currentServer(); if(cat.isNotEmpty){ - //url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat; - url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat; + url = '${server_url}/api/inperf/?perf=' + perfecture + '&cat=' + cat; + //url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat; } else{ - //url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture; - url = 'http://localhost:8100/api/inperf/?perf=' + perfecture; + url = '${server_url}/api/inperf/?perf=' + perfecture; + //url = 'http://localhost:8100/api/inperf/?perf=' + perfecture; } //print("----- url ---- ${url} --- ${cat}"); //String url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat; @@ -50,14 +53,15 @@ class LocationService{ static Future loadLocationsSubFor(String subperfecture, String cat) async { String url = ""; + String server_url = ConstValues.currentServer(); if(cat.isNotEmpty){ - //url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat; - url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat; + url = '${server_url}/api/insubperf?subperf=' + subperfecture + '&cat=' + cat; + //url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat; } else{ print("------ loading location in sub----"); - //url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture; - url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture; + url = '${server_url}/api/insubperf?subperf=' + subperfecture; + //url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture; } final response = await http.get(Uri.parse(url), headers: { @@ -76,14 +80,15 @@ class LocationService{ static Future loadLocationsBound(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4, String cat) async { String url = ""; + String server_url = ConstValues.currentServer(); print("cat is ----- ${cat}"); if(cat.isNotEmpty){ - //url = 'http://container.intranet.sumasen.net:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat; - url = 'http://localhost:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat; + url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat; + //url = 'http://localhost:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat; } else{ - //url = 'http://container.intranet.sumasen.net:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; - url = 'http://localhost:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; + url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; + //url = 'http://localhost:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; } print("----url --- ${url}"); final response = await http.get(Uri.parse(url), @@ -109,16 +114,17 @@ class LocationService{ } - static Future loadCustomLocations(String cat) async { + static Future loadCustomLocations(String name, String cat) async { String url = ""; + String server_url = ConstValues.currentServer(); print("cat is ----- ${cat}"); if(cat.isNotEmpty){ - //url = 'http://container.intranet.sumasen.net:8100/api/custom_area/?&cat=' + cat; - url = 'http://localhost:8100/api/custom_area/?&cat=' + cat; + url = '${server_url}/api/custom_area/?&cat=' + cat; + //url = 'http://localhost:8100/api/customarea?name=${name}&cat=' + cat; } else{ - //url = 'http://container.intranet.sumasen.net:8100/api/custom_area/'; - url = 'http://localhost:8100/api/custom_area/'; + url = '${server_url}/api/customarea?name=${name}&'; + //url = 'http://localhost:8100/api/customarea?name=${name}&'; } print("----url --- ${url}"); final response = await http.get(Uri.parse(url), diff --git a/lib/services/perfecture_service.dart b/lib/services/perfecture_service.dart index 13c695c..1e730a6 100644 --- a/lib/services/perfecture_service.dart +++ b/lib/services/perfecture_service.dart @@ -1,13 +1,15 @@ import 'dart:convert'; import 'package:http/http.dart' as http; +import 'package:rogapp/utils/const.dart'; class PerfectureService{ static Future?> loadPerfectures() async { List perfs = []; - //String url = 'http://container.intranet.sumasen.net:8100/api/perf_main/'; - String url = 'http://localhost:8100/api/perf_main/'; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/perf_main/'; + //String url = 'http://localhost:8100/api/perf_main/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -23,8 +25,9 @@ class PerfectureService{ static Future?> loadSubPerfectures(String area) async { List perfs = []; - //String url = 'http://container.intranet.sumasen.net:8100/api/subperfinmain/?perf=' + sub; - String url = 'http://localhost:8100/api/subperfinmain/?area=' + area; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/subperfinmain/?area=' + area; + //String url = 'http://localhost:8100/api/subperfinmain/?area=' + area; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -41,8 +44,9 @@ class PerfectureService{ static Future?> getMainPerfExt(String id) async { List perfs = []; - //String url = 'http://container.intranet.sumasen.net:8100/api/mainperfext/?perf=' + id; - String url = 'http://localhost:8100/api/mainperfext/?perf=' + id; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/mainperfext/?perf=' + id; + //String url = 'http://localhost:8100/api/mainperfext/?perf=' + id; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -58,8 +62,27 @@ class PerfectureService{ static Future?> loadGifuAreas(String perf) async { List perfs = []; - //String url = 'http://container.intranet.sumasen.net:8100/api/allgifuareas/?perf' + perf; - String url = 'http://localhost:8100/api/allgifuareas/?perf=' + perf; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/allgifuareas/?perf=' + perf; + //String url = 'http://localhost:8100/api/allgifuareas/?perf=' + perf; + final response = await http.get(Uri.parse(url), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + ); + + if (response.statusCode == 200) { + + perfs = json.decode(utf8.decode(response.bodyBytes)); + } + return perfs; + } + + static Future?> loadCustomAreas() async { + List perfs = []; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/customareanames'; + //String url = 'http://localhost:8100/api/customareanames'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -76,8 +99,9 @@ class PerfectureService{ static Future?> getSubExt(String id) async { List perfs = []; - //String url = 'http://container.intranet.sumasen.net:8100/api/perfext/?sub_perf=' + id; - String url = 'http://localhost:8100/api/perfext/?sub_perf=' + id; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/perfext/?sub_perf=' + id; + //String url = 'http://localhost:8100/api/perfext/?sub_perf=' + id; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/services/reacking_service.dart b/lib/services/reacking_service.dart new file mode 100644 index 0000000..77697c2 --- /dev/null +++ b/lib/services/reacking_service.dart @@ -0,0 +1,34 @@ + +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:rogapp/utils/const.dart'; + + +class TrackingService { + + static Future> addTrack(String user_id, double lat, double lon) async { + Map cats = {}; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/track/'; + //String url = 'http://localhost:8100/api/track/'; + final geom = '{"type": "MULTIPOINT", "coordinates": [[${lon}, ${lat}]]}'; + final http.Response response = await http.post( + Uri.parse(url), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + body: jsonEncode({ + 'user_id': user_id, + 'geom': geom + }), + ); + + if (response.statusCode == 200) { + cats = json.decode(utf8.decode(response.bodyBytes)); + } + return cats; + } + +} \ No newline at end of file diff --git a/lib/utils/const.dart b/lib/utils/const.dart new file mode 100644 index 0000000..5636713 --- /dev/null +++ b/lib/utils/const.dart @@ -0,0 +1,12 @@ + + + +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.100:8100"; + + static String currentServer(){ + return dev_ip_server; + } +} \ No newline at end of file diff --git a/lib/widgets/bottom_sheet_widget.dart b/lib/widgets/bottom_sheet_widget.dart index 15a1bc9..77d4f36 100644 --- a/lib/widgets/bottom_sheet_widget.dart +++ b/lib/widgets/bottom_sheet_widget.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:geojson/geojson.dart'; import 'package:get/get.dart'; +import 'package:image_picker/image_picker.dart'; import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/routes/app_pages.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -207,7 +208,17 @@ class BottomSheetWidget extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - indexController.currentAction[0][0]["wanttogo"] == false ? + indexController.rog_mode == 0 ? + + + + + + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + indexController.currentAction[0][0]["wanttogo"] == false ? ElevatedButton( onPressed: (){ if(indexController.currentAction.isNotEmpty){ @@ -277,21 +288,49 @@ class BottomSheetWidget extends StatelessWidget { ) ), + ], + ) + + + + + + : + Container(width: 0, height: 0,), + indexController.rog_mode == 1 ? indexController.currentAction[0][0]["checkin"] == false ? - ElevatedButton( - onPressed: (){ - if(indexController.currentAction.isNotEmpty){ - print(indexController.currentAction[0]); - indexController.currentAction[0][0]["checkin"] = true; - Map temp = Map.from(indexController.currentAction[0][0]); - indexController.currentAction.clear(); - print("---temp---${temp}"); - indexController.currentAction.add([temp]); - } - indexController.makeAction(context); - }, - child: Text("checkin".tr) - ) : + Column( + children: [ + Row( + mainAxisSize: MainAxisSize.max, + children: [ + ElevatedButton( + child: Text("Image"), onPressed: (){ + final ImagePicker _picker = ImagePicker(); + _picker.pickImage(source: ImageSource.camera).then((value){ + print("----- image---- ${value!.path}"); + }); + }, + ) + ], + ), + ElevatedButton( + onPressed: (){ + if(indexController.currentAction.isNotEmpty){ + print(indexController.currentAction[0]); + indexController.currentAction[0][0]["checkin"] = true; + Map temp = Map.from(indexController.currentAction[0][0]); + indexController.currentAction.clear(); + print("---temp---${temp}"); + indexController.currentAction.add([temp]); + } + indexController.makeAction(context); + }, + child: Text("checkin".tr) + ) + ], + ) + : ElevatedButton( onPressed: (){ if(indexController.currentAction.isNotEmpty){ @@ -309,7 +348,8 @@ class BottomSheetWidget extends StatelessWidget { Icons.favorite, color: Colors.red) , - ) + ): + Container(width: 0, height: 0,), ], ): Row( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/widgets/destination_widget.dart b/lib/widgets/destination_widget.dart index bd452bb..7b3ddd0 100644 --- a/lib/widgets/destination_widget.dart +++ b/lib/widgets/destination_widget.dart @@ -1,9 +1,11 @@ import 'dart:ffi'; import 'package:flutter/material.dart'; +import 'package:geojson/geojson.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/widgets/bottom_sheet_widget.dart'; import 'package:timeline_tile/timeline_tile.dart'; class DestinationWidget extends StatelessWidget { @@ -110,6 +112,25 @@ class DestinationWidget extends StatelessWidget { minHeight: 80, ), child: ListTile( + onTap: () async { + { + double lat = destinationController.destinations[index]["location"]["geometry"]["coordinates"][0][1] as double; + double lon = destinationController.destinations[index]["location"]["geometry"]["coordinates"][0][0] as double; + GeoJsonFeature? fs = await destinationController.getDEstinationForLatLong(lat, lon); + print("----fsf-----${fs}"); + if(fs != null){ + if(indexController.currentFeature.length > 0) { + indexController.currentFeature.clear(); + } + indexController.currentFeature.add(fs); + indexController.getAction(); + + showModalBottomSheet(context: context, isScrollControlled: true, + builder:((context) => BottomSheetWidget()) + ); + } + }; + }, onLongPress: (){ print("#### long press #### ${destinationController.destination_index_data.length}"); diff --git a/lib/widgets/perfecture_widget.dart b/lib/widgets/perfecture_widget.dart index a1efa7f..8e0aa82 100644 --- a/lib/widgets/perfecture_widget.dart +++ b/lib/widgets/perfecture_widget.dart @@ -18,6 +18,14 @@ class PerfectureWidget extends StatefulWidget { } class _PerfectureWidgetState extends State { + + + bool isNumeric(String s) { + if (s == null) { + return false; + } + return double.tryParse(s) != null; + } List> getDropdownItems() { @@ -64,7 +72,22 @@ class _PerfectureWidgetState extends State { dropDownItems.add(newDropdown); } + } + + if(widget.indexController.customAreas.isNotEmpty){ + + for (Map currency in widget.indexController.customAreas[0]) { + var newDropdown = DropdownMenuItem( + child: Text(currency["event_name"].toString()), + value: currency["event_name"].toString(), + ); + + dropDownItems.add(newDropdown); + } + + } + return dropDownItems; } @@ -94,7 +117,7 @@ class _PerfectureWidgetState extends State { items: getDropdownItems() ), - // Custom events area + // Gifu areas widget.indexController.areas.isNotEmpty ? DropdownButton( value: widget.indexController.areaDropdownValue, @@ -107,10 +130,17 @@ class _PerfectureWidgetState extends State { color: Colors.deepPurpleAccent, ), onChanged: (String? newValue) { + if (isNumeric(newValue!)){ + + } + else{ + widget.indexController.loadCustomLocation(newValue); + } setState(() { if(newValue != null){ widget.indexController.is_loading.value = true; - widget.indexController.populateForCustomArea(newValue, widget.mapController); + widget.indexController.areaDropdownValue = newValue; + widget.indexController.populateSubPerForArea(newValue, widget.mapController); } }); }, diff --git a/pubspec.yaml b/pubspec.yaml index ee8e31b..b00d868 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,6 +62,7 @@ dependencies: flutter_breadcrumb: ^1.0.1 timeline_tile: ^2.0.0 google_maps_flutter: ^2.1.5 + #flutter_map_marker_popup: any flutter_polyline_points: ^1.0.0 google_maps_webservice: ^0.0.19