diff --git a/lib/pages/index/index_controller.dart b/lib/pages/index/index_controller.dart index 87408e0..dda30e8 100644 --- a/lib/pages/index/index_controller.dart +++ b/lib/pages/index/index_controller.dart @@ -20,6 +20,7 @@ class IndexController extends GetxController { List perfectures = [].obs; List currentBound = [].obs; List subPerfs = [].obs; + List areas = [].obs; List cats = [].obs; List currentCat = [].obs; @@ -40,6 +41,7 @@ class IndexController extends GetxController { String dropdownValue = "9"; String subDropdownValue = "-1"; + String areaDropdownValue = "-1"; void toggleMode(){ if(mode.value==0){ @@ -72,7 +74,8 @@ class IndexController extends GetxController { if(perfectures.length == 0){ PerfectureService.loadPerfectures().then((value){ perfectures.add(value); - loadSubPerfFor("9"); + loadAreaFor("9"); + //loadSubPerfFor("9"); }); } //loadCats(); @@ -174,6 +177,19 @@ class IndexController extends GetxController { // } } + void loadAreaFor(String perf){ + 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 loadSubPerfFor(String perf){ subPerfs.clear(); dynamic initVal = {'id':'-1', 'adm2_ja':'----'}; @@ -219,6 +235,15 @@ class IndexController extends GetxController { }); } + void loadCustomLocation(String customarea, MapController mapController) async { + String cat = currentCat.isNotEmpty == true ? currentCat[0] : ""; + print(currentCat); + LocationService.loadCustomLocations(cat).then((value){ + locations.clear(); + locations.add(value!); + }); + } + void loadLocationsBound(){ String cat = currentCat.isNotEmpty ? currentCat[0] : ""; LatLngBounds bounds = mapController!.bounds!; @@ -287,6 +312,12 @@ class IndexController extends GetxController { is_loading.value = false; } + void populateForCustomArea(String customarea, MapController mapController){ + loadCustomLocation("cus", mapController); + //zoomtoSubPerf(subperf); + is_loading.value = false; + } + GeoJsonFeature? getFeatureForLatLong(double lat, double long){ if(locations.length > 0){ diff --git a/lib/pages/index/index_page.dart b/lib/pages/index/index_page.dart index aecec35..189bac8 100644 --- a/lib/pages/index/index_page.dart +++ b/lib/pages/index/index_page.dart @@ -26,17 +26,7 @@ class IndexPage extends GetView { automaticallyImplyLeading: false, title: Text("app_title".tr), actions: [ - ElevatedButton(onPressed: (){}, child: CatWidget(indexController: indexController,)), CatWidget(indexController: indexController,), - ElevatedButton( - onPressed: () async{ - PolylinePoints polylinePoints = PolylinePoints(); - PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", PointLatLng(35.389282, 136.498027), PointLatLng(36.285848, 137.575186)); - print(result.points); - indexController.routePoints = result.points; - }, - child: Text("Google") - ) ], ), bottomNavigationBar: BottomAppBar( diff --git a/lib/services/action_service.dart b/lib/services/action_service.dart index 2c01098..a8f4992 100644 --- a/lib/services/action_service.dart +++ b/lib/services/action_service.dart @@ -6,7 +6,8 @@ class ActionService{ static Future> makeAction(int user_id, int location_id, bool wanttogo, bool like, bool checkin) async { 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://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}"; final http.Response response = await http.get( Uri.parse(url), headers: { @@ -23,7 +24,8 @@ 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://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}'; 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 aa91db3..3be7f36 100644 --- a/lib/services/auth_service.dart +++ b/lib/services/auth_service.dart @@ -6,7 +6,8 @@ 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://container.intranet.sumasen.net:8100/api/login/'; + String url = 'http://localhost:8100/api/login/'; final http.Response response = await http.post( Uri.parse(url), headers: { @@ -27,7 +28,8 @@ 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://container.intranet.sumasen.net:8100/api/register/'; + String url = 'http://localhost:8100/api/register/'; final http.Response response = await http.post( Uri.parse(url), headers: { diff --git a/lib/services/cat_service.dart b/lib/services/cat_service.dart index 9119aa2..79be732 100644 --- a/lib/services/cat_service.dart +++ b/lib/services/cat_service.dart @@ -7,7 +7,9 @@ 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://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 url = 'http://container.intranet.sumasen.net:8100/api/cats/'; print("---- cat url is ${url}"); diff --git a/lib/services/destination_service.dart b/lib/services/destination_service.dart index efab9bf..6a09de5 100644 --- a/lib/services/destination_service.dart +++ b/lib/services/destination_service.dart @@ -9,7 +9,8 @@ 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://container.intranet.sumasen.net:8100/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: { @@ -25,7 +26,8 @@ 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://container.intranet.sumasen.net:8100/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: { @@ -42,7 +44,8 @@ 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://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}"; 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 a5adc70..9094ac6 100644 --- a/lib/services/location_line_service.dart +++ b/lib/services/location_line_service.dart @@ -7,7 +7,8 @@ class LocationLineService{ final geo = GeoJson(); GeoJsonFeature? fs; - String url = 'http://container.intranet.sumasen.net:8100/api/location_line/'; + //String url = 'http://container.intranet.sumasen.net:8100/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 cf4b03d..4a7fa2b 100644 --- a/lib/services/location_polygon_service.dart +++ b/lib/services/location_polygon_service.dart @@ -7,7 +7,8 @@ class LocationPolygonervice{ final geo = GeoJson(); GeoJsonFeature? fs; - String url = 'http://container.intranet.sumasen.net:8100/api/location_polygon/'; + //String url = 'http://container.intranet.sumasen.net:8100/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 d63a782..eef04fa 100644 --- a/lib/services/location_service.dart +++ b/lib/services/location_service.dart @@ -6,7 +6,8 @@ import 'package:http/http.dart' as http; class LocationService{ static Future loadLocations() async { - String url = 'http://container.intranet.sumasen.net:8100/api/location/'; + //String url = 'http://container.intranet.sumasen.net:8100/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,10 +24,12 @@ class LocationService{ static Future loadLocationsFor(String perfecture, String cat) async { String url = ""; if(cat.isNotEmpty){ - url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat; + //url = 'http://container.intranet.sumasen.net:8100/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://container.intranet.sumasen.net:8100/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; @@ -48,11 +51,13 @@ class LocationService{ static Future loadLocationsSubFor(String subperfecture, String cat) async { String url = ""; if(cat.isNotEmpty){ - url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat; + //url = 'http://container.intranet.sumasen.net:8100/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://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture; + url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture; } final response = await http.get(Uri.parse(url), headers: { @@ -73,10 +78,47 @@ class LocationService{ String url = ""; 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://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; } 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://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}'; + } + print("----url --- ${url}"); + final response = await http.get(Uri.parse(url), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + ); + + if (response.statusCode == 500) { + return GeoJsonFeatureCollection(); //featuresFromGeoJson(utf8.decode(response.bodyBytes)); + } + + if (response.statusCode == 200) { + GeoJsonFeatureCollection cc = await featuresFromGeoJson(utf8.decode(response.bodyBytes)); + if(cc.collection.isEmpty){ + return null; + } + else{ + return cc; + } + } + return null; + } + + + static Future loadCustomLocations(String cat) async { + String url = ""; + 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; + } + else{ + //url = 'http://container.intranet.sumasen.net:8100/api/custom_area/'; + url = 'http://localhost:8100/api/custom_area/'; } print("----url --- ${url}"); final response = await http.get(Uri.parse(url), @@ -103,4 +145,5 @@ class LocationService{ + } \ No newline at end of file diff --git a/lib/services/perfecture_service.dart b/lib/services/perfecture_service.dart index 635ddcf..13c695c 100644 --- a/lib/services/perfecture_service.dart +++ b/lib/services/perfecture_service.dart @@ -6,7 +6,8 @@ class PerfectureService{ static Future?> loadPerfectures() async { List perfs = []; - String url = 'http://container.intranet.sumasen.net:8100/api/perf_main/'; + //String url = 'http://container.intranet.sumasen.net:8100/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', @@ -20,10 +21,10 @@ class PerfectureService{ return perfs; } - static Future?> loadSubPerfectures(String sub) async { + static Future?> loadSubPerfectures(String area) async { List perfs = []; - String url = 'http://container.intranet.sumasen.net:8100/api/subperfinmain/?perf=' + sub; - //String url = 'http://container.intranet.sumasen.net:8100/api/insubperf/?perf=' + sub; + //String url = 'http://container.intranet.sumasen.net:8100/api/subperfinmain/?perf=' + sub; + 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', @@ -40,7 +41,25 @@ 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://container.intranet.sumasen.net:8100/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', + }, + ); + + if (response.statusCode == 200) { + + perfs = json.decode(utf8.decode(response.bodyBytes)); + } + return perfs; + } + + 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; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -57,7 +76,8 @@ 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://container.intranet.sumasen.net:8100/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/widgets/perfecture_widget.dart b/lib/widgets/perfecture_widget.dart index 6906173..a1efa7f 100644 --- a/lib/widgets/perfecture_widget.dart +++ b/lib/widgets/perfecture_widget.dart @@ -52,6 +52,22 @@ class _PerfectureWidgetState extends State { return dropDownItems; } + List> getCustomArea(){ + List> dropDownItems = []; + if(widget.indexController.areas.isNotEmpty){ + + for (Map currency in widget.indexController.areas[0]) { + var newDropdown = DropdownMenuItem( + child: Text(currency["area_nm"].toString()), + value: currency["id"].toString(), + ); + + dropDownItems.add(newDropdown); + } + } + return dropDownItems; + } + @override Widget build(BuildContext context) { return Obx(() => @@ -78,6 +94,29 @@ class _PerfectureWidgetState extends State { items: getDropdownItems() ), + // Custom events area + widget.indexController.areas.isNotEmpty ? + DropdownButton( + value: widget.indexController.areaDropdownValue, + icon: const Icon(Icons.arrow_downward), + elevation: 16, + style: const TextStyle(color: Colors.deepPurple), + hint: const Text("select"), + underline: Container( + height: 2, + color: Colors.deepPurpleAccent, + ), + onChanged: (String? newValue) { + setState(() { + if(newValue != null){ + widget.indexController.is_loading.value = true; + widget.indexController.populateForCustomArea(newValue, widget.mapController); + } + }); + }, + items: getCustomArea(), + ): const Text(""), + widget.indexController.subPerfs.isNotEmpty ? DropdownButton(