diff --git a/assets/images/gradient_japanese_temple.jpg b/assets/images/gradient_japanese_temple.jpg new file mode 100644 index 0000000..23ec19f Binary files /dev/null and b/assets/images/gradient_japanese_temple.jpg differ diff --git a/lib/main.dart b/lib/main.dart index 4bd2834..9b930d0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:rogapp/index/index_binding.dart'; +import 'package:rogapp/pages/index/index_binding.dart'; import 'package:rogapp/routes/app_pages.dart'; import 'package:rogapp/utils/string_values.dart'; diff --git a/lib/pages/destination/destination_binding.dart b/lib/pages/destination/destination_binding.dart new file mode 100644 index 0000000..89af555 --- /dev/null +++ b/lib/pages/destination/destination_binding.dart @@ -0,0 +1,10 @@ +import 'package:get/get.dart'; +import 'package:rogapp/pages/destination/destination_controller.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; + +class DestinationBinding extends Bindings { + @override + void dependencies() { + Get.put(DestinationController()); + } +} diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart new file mode 100644 index 0000000..a25327c --- /dev/null +++ b/lib/pages/destination/destination_controller.dart @@ -0,0 +1,46 @@ + + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; +import 'package:rogapp/routes/app_pages.dart'; +import 'package:rogapp/services/destination_service.dart'; + +class DestinationController extends GetxController { + + + List destinations = [].obs; + + final IndexController indexController = Get.find(); + + @override + void onInit() { + PopulateDestinations(); + super.onInit(); + } + + void PopulateDestinations(){ + if(indexController.currentUser.isNotEmpty){ + int user_id = indexController.currentUser[0]["user"]["id"] as int; + //print(user_id); + DestinationService.getDestinations(user_id).then((value){ + destinations.clear(); + destinations = value; + //var val = value[2]["location"]["id"]; + //print("-----current destinations ----- ${val}"); + }); + } + else{ + Get.toNamed(AppPages.LOGIN); + } + } + + void makeOrder(BuildContext context, int action_id, int order, String dir){ + DestinationService.updateOrder(action_id, order, dir).then((value){ + //print("----action value----${value}"); + PopulateDestinations(); + }); + + } + +} \ No newline at end of file diff --git a/lib/pages/destination/destination_page.dart b/lib/pages/destination/destination_page.dart new file mode 100644 index 0000000..35fe570 --- /dev/null +++ b/lib/pages/destination/destination_page.dart @@ -0,0 +1,124 @@ +import 'dart:developer'; + +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:timeline_tile/timeline_tile.dart'; + + +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(); + + final List _items = List.generate(50, (int index) => index); + + Image getImage(int index){ + if(destinationController.destinations[index]["location"]["properties"]["photos"] == null || destinationController.destinations[index]["location"]["properties"]["photos"] == ""){ + return Image(image: AssetImage('assets/images/empty_image.png')); + } + else{ + return Image(image: NetworkImage(destinationController.destinations[index]["location"]["properties"]["photos"])); + } + } + + @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 Scaffold( + bottomNavigationBar: BottomAppBar( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),), + const Expanded(child: Text('')), + Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){ + if(indexController.currentUser.isNotEmpty){ + Get.toNamed(AppPages.TRAVEL); + } + else{ + Get.toNamed(AppPages.LOGIN); + } + }),), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: (){ + indexController.toggleMode(); + if(indexController.currentCat.isNotEmpty){ + print("###############"); + print(indexController.currentCat[0].toString()); + } + + }, + tooltip: 'Increment', + child: const Icon(Icons.document_scanner), + elevation: 4.0, + ), + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + appBar:AppBar( + title: Text("Iternery"), + ), + body:Obx(() => + ReorderableListView.builder( + itemCount: destinationController.destinations.length, + onReorder: (int oldIndex, int newIndex){ + int action_id = destinationController.destinations[oldIndex]["id"] as int; + //print(action_id); + if(oldIndex > newIndex){ + destinationController.makeOrder(context, action_id, newIndex, "up"); + } + else if(oldIndex < newIndex){ + destinationController.makeOrder(context, action_id, newIndex, "down"); + } + + }, + itemBuilder: (BuildContext context, int index) { + return TimelineTile( + alignment: TimelineAlign.manual, + lineXY: 0.2, + isFirst: index == 0 ? true : false, + indicatorStyle: IndicatorStyle( + color: Colors.red //index == 0 ? (Colors.red)! : (Colors.grey[400])! + ), + key: Key(index.toString()), + endChild: Card( + child: Container( + constraints: const BoxConstraints( + minHeight: 80, + ), + child: ListTile( + leading: getImage(index), + title: Text(destinationController.destinations[index]["location"]["properties"]["location_name"]), + subtitle: Text(destinationController.destinations[index]["location"]["properties"]["category"]), + ), + ), + + ), + startChild: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Text("12:30"), + Text("01:20"), + ], + ), + ); + } + ) + ) + ); + + } +} \ No newline at end of file diff --git a/lib/pages/drawer/drawer_page.dart b/lib/pages/drawer/drawer_page.dart index b50eb2a..466cb42 100644 --- a/lib/pages/drawer/drawer_page.dart +++ b/lib/pages/drawer/drawer_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:rogapp/routes/app_pages.dart'; class DrawerPage extends StatelessWidget { const DrawerPage({ Key? key }) : super(key: key); @@ -22,7 +23,9 @@ class DrawerPage extends StatelessWidget { ListTile( leading: const Icon(Icons.login), title: Text("login".tr), - onTap: (){}, + onTap: (){ + Get.toNamed(AppPages.LANDING); + }, ), ListTile( leading: const Icon(Icons.password), diff --git a/lib/pages/home/home_binding_t.dart b/lib/pages/home/home_binding_t.dart deleted file mode 100644 index 87df97c..0000000 --- a/lib/pages/home/home_binding_t.dart +++ /dev/null @@ -1,13 +0,0 @@ -// import 'package:flutter_map/flutter_map.dart'; -// import 'package:get/get_core/src/get_main.dart'; -// import 'package:get/get_instance/src/bindings_interface.dart'; -// import 'package:get/get_instance/src/extension_instance.dart'; -// import 'package:rogapp/pages/home/home_controller.dart'; - - -// class HomeBinding extends Bindings { -// @override -// void dependencies() { -// Get.put(HomeController()); -// } -// } diff --git a/lib/pages/home/home_controller_t.dart b/lib/pages/home/home_controller_t.dart deleted file mode 100644 index 5542b04..0000000 --- a/lib/pages/home/home_controller_t.dart +++ /dev/null @@ -1,199 +0,0 @@ - - -// import 'package:flutter_map/plugin_api.dart'; -// import 'package:geojson/geojson.dart'; -// import 'package:get/get.dart'; -// import 'package:latlong2/latlong.dart'; -// import 'package:meta/meta.dart'; -// import 'package:rogapp/pages/map/map_page.dart'; -// import 'package:rogapp/services/location_service.dart'; -// import 'package:rogapp/services/perfecture_service.dart'; - -// class HomeController extends GetxController { - -// List locations = [].obs; -// List currentFeature = [].obs; -// List perfectures = [].obs; -// List currentBound = [].obs; -// List subPerfs = [].obs; - -// String SubDropdownValue = "-1"; - - -// @override -// void onInit() { -// super.onInit(); - -// if(locations.length == 0){ -// LocationService.loadLocations().then((value){ -// locations.add(value!); -// //print(value); -// }); -// } -// if(perfectures.length == 0){ -// PerfectureService.loadPerfectures().then((value){ -// perfectures.add(value); -// loadSubPerfFor("9"); -// }); -// } -// } - -// void getBoundFromLatLng(List list) { -// double? x0, x1, y0, y1; -// for (LatLng latLng in list) { -// if (x0 == 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; -// } -// } -// currentBound.clear(); -// if(x0 != null && x1 != null && y0 != null && y1 != null ){ -// currentBound.add(LatLngBounds(LatLng(x1, y1), LatLng(x0, y0))); -// } -// } - -// void setBounds(){ -// List lts = []; -// if(locations.length > 0){ -// for(GeoJsonFeature i in locations[0].collection){ -// GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint; -// LatLng lt = LatLng(p.geoSerie!.geoPoints[0].latitude , p.geoSerie!.geoPoints[0].longitude) ; -// lts.add(lt); -// } -// } -// else{ -// LatLng lt = LatLng(37.15319600454702, 139.58765950528198); -// lts.add(lt); -// } -// getBoundFromLatLng(lts); -// } - -// void zoomtoMainPerf(String id, MapController mapController){ - -// PerfectureService.getMainPerfExt(id).then((value){ -// print(value); -// LatLng lat1 = LatLng(value![1], value[0]); -// LatLng lat2 = LatLng(value[3], value[2]); -// LatLngBounds bound = LatLngBounds(lat1, lat2); -// mapController.fitBounds(bound); -// }); - -// } - -// void zoomtoSubPerf(String id, MapController mapController){ - -// PerfectureService.getSubExt(id).then((value){ -// LatLng lat1 = LatLng(value![1], value[0]); -// LatLng lat2 = LatLng(value[3], value[2]); -// LatLngBounds bound = LatLngBounds(lat1, lat2); -// mapController.fitBounds(bound); -// }); - -// } - -// void loadLocationforPerf(String perf, MapController mapController) async { -// locations.clear(); -// LocationService.loadLocationsFor(perf).then((value){ -// locations.add(value!); -// setBounds(); -// mapController.fitBounds(currentBound[0]); -// }); -// } - -// void loadLocationforSubPerf(String subperf, MapController mapController) async { -// locations.clear(); -// LocationService.loadLocationsSubFor(subperf).then((value){ -// locations.add(value!); -// //setBounds(); -// //mapController!.fitBounds(currentBound[0]); -// }); -// } - -// void loadSubPerfFor(String perf){ -// subPerfs.clear(); -// dynamic initVal = {'id':'-1', 'adm2_ja':'----'}; -// PerfectureService.loadSubPerfectures(perf).then((value){ -// value!.add(initVal); -// subPerfs.add(value); -// SubDropdownValue = getSubInitialVal(); -// //print(subPerfs[0]); -// }); -// } - -// String getSubInitialVal(){ -// int min = 0; -// if(subPerfs.length > 0){ -// min = subPerfs[0][0]['id'] as int; -// for(var sub in subPerfs[0]){ -// int x = int.parse(sub['id'].toString()); // as int; -// if(x < min){ -// min = x; -// } -// } -// } -// return min.toString(); -// } - -// GeoJsonFeature? getFeatureForLatLong(double lat, double long){ -// if(locations.length > 0){ -// for(GeoJsonFeature i in locations[0].collection){ -// GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint; -// if(p.geoSerie!.geoPoints[0].latitude == lat && p.geoSerie!.geoPoints[0].longitude == long){ -// return i; -// } -// } -// } -// } - -// void makeNext(GeoJsonFeature fs){ -// GeoJsonFeature pt = fs as GeoJsonFeature; - -// for(int i=0; i<= locations[0].collection.length - 1; i++){ -// GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint; - -// if(p.geoSerie!.geoPoints[0].latitude == pt.geometry!.geoSerie!.geoPoints[0].latitude && p.geoSerie!.geoPoints[0].longitude == pt.geometry!.geoSerie!.geoPoints[0].longitude ){ - -// if(currentFeature.length > 0){ -// currentFeature.clear(); -// } -// if(i >= locations[0].collection.length - 1 ){ -// currentFeature.add(locations[0].collection[0] as GeoJsonFeature); -// } -// else{ -// currentFeature.add(locations[0].collection[i + 1] as GeoJsonFeature); -// } -// } -// } - -// } - -// void makePrevious(GeoJsonFeature fs){ -// GeoJsonFeature pt = fs as GeoJsonFeature; - -// for(int i=0; i<= locations[0].collection.length - 1; i++){ -// GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint; - -// if(p.geoSerie!.geoPoints[0].latitude == pt.geometry!.geoSerie!.geoPoints[0].latitude && p.geoSerie!.geoPoints[0].longitude == pt.geometry!.geoSerie!.geoPoints[0].longitude ){ - -// if(currentFeature.length > 0){ -// currentFeature.clear(); -// } -// if(i == 0 ){ -// currentFeature.add(locations[0].collection[locations[0].collection.length -1] as GeoJsonFeature); -// } -// else{ -// currentFeature.add(locations[0].collection[i - 1] as GeoJsonFeature); -// } -// } -// } - -// } - - - -// } \ No newline at end of file diff --git a/lib/pages/home/home_page_t.dart b/lib/pages/home/home_page_t.dart deleted file mode 100644 index 62dd35a..0000000 --- a/lib/pages/home/home_page_t.dart +++ /dev/null @@ -1,129 +0,0 @@ - -// import 'dart:ui'; - -// import 'package:flutter/material.dart'; -// import 'package:flutter_map/plugin_api.dart'; -// import 'package:geojson/geojson.dart'; -// import 'package:get/get.dart'; -// import 'package:rogapp/pages/drawer/drawer_page.dart'; -// import 'package:rogapp/pages/home/home_controller.dart'; -// import 'package:rogapp/routes/app_pages.dart'; -// import 'package:rogapp/services/perfecture_service.dart'; -// import 'package:rogapp/widgets/bottom_sheet_widget.dart'; -// import 'package:flutter_breadcrumb/flutter_breadcrumb.dart'; -// import 'package:rogapp/widgets/perfecture_widget.dart'; - -// class HomePage extends GetView { - -// final HomeController homeController = Get.find(); -// MapController mapController = Get.arguments[0]; - -// void changeCurrentFeature(GeoJsonFeature fs){ -// if(homeController.currentFeature.length > 0){ -// homeController.currentFeature.clear(); -// } -// homeController.currentFeature.add(fs); -// } - -// Image getImage(int index){ -// if(homeController.locations[0].collection[index].properties!["photos"] == null || homeController.locations[0].collection[index].properties!["photos"] == ""){ -// return Image(image: AssetImage('assets/images/empty_image.png')); -// } -// else{ -// return Image(image: NetworkImage(homeController.locations[0].collection[index].properties!["photos"])); -// } -// } - -// Widget getBreadCurms(){ -// return Obx(() => -// homeController.perfectures.length > 0 ? -// BreadCrumb.builder( -// itemCount: homeController.perfectures.length, -// builder: (index) { -// return BreadCrumbItem( -// content: PerfectureWidget(homeController: homeController, mapController: mapController) //Text('Item$index') -// ); -// }, -// divider: Icon(Icons.chevron_right), -// ) : -// Container(width: 0, height: 0,), -// ); -// } - -// @override -// Widget build(BuildContext context) { -// return Scaffold( -// drawer: DrawerPage(), -// appBar: AppBar( -// title: Text("app_title".tr), -// centerTitle: true, -// actions: [ -// IconButton( -// icon: const Icon(Icons.map), -// onPressed: (){ -// //print(homeController.locations.length); -// }, -// ) -// ], -// ), -// floatingActionButton: new FloatingActionButton( -// onPressed: (){ -// Get.toNamed(AppPages.MAP); -// }, -// tooltip: 'Increment', -// child: new Icon(Icons.document_scanner), -// elevation: 4.0, -// ), -// bottomNavigationBar: BottomAppBar( -// child: new Row( -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// Expanded(child: IconButton(icon: Icon(Icons.camera_enhance), onPressed: (){},),), -// Expanded(child: new Text('')), -// Expanded(child: IconButton(icon: Icon(Icons.travel_explore), onPressed: (){}),), -// ], -// ), -// ), -// floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, -// body:Column( -// children: [ -// Padding( -// padding: const EdgeInsets.symmetric(horizontal: 8.0), -// child: Container( -// alignment: Alignment.centerLeft, -// height: 50.0, -// child: getBreadCurms(), -// ), -// ), -// Expanded( -// child: Obx(() => -// homeController.locations.length > 0 ? -// ListView.builder( -// itemCount: homeController.locations[0].collection.length, -// shrinkWrap: true, -// itemBuilder: (_, index){ -// return Card( -// child: ListTile( -// onTap: (){ -// GeoJsonFeature gf = homeController.locations[0].collection[index]; -// changeCurrentFeature(gf); -// showModalBottomSheet( -// isScrollControlled: true, -// context: context, -// builder: (context) => BottomSheetWidget(), -// ); -// }, -// leading: getImage(index), -// title: Text(homeController.locations[0].collection[index].properties!['location_name'].toString()), -// subtitle: Text(homeController.locations[0].collection[index].properties!['category']), -// ), -// ); -// }, -// ) : Container(width: 0, height: 0,), -// ) -// ) -// ], -// ) -// ); -// } -// } diff --git a/lib/index/index_binding.dart b/lib/pages/index/index_binding.dart similarity index 77% rename from lib/index/index_binding.dart rename to lib/pages/index/index_binding.dart index d657f4b..2d969ff 100644 --- a/lib/index/index_binding.dart +++ b/lib/pages/index/index_binding.dart @@ -1,7 +1,7 @@ import 'package:flutter_map/plugin_api.dart'; import 'package:get/get.dart'; -import 'package:rogapp/index/index_controller.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; class IndexBinding extends Bindings { @override diff --git a/lib/index/index_controller.dart b/lib/pages/index/index_controller.dart similarity index 58% rename from lib/index/index_controller.dart rename to lib/pages/index/index_controller.dart index 44a1a78..4a9b70c 100644 --- a/lib/index/index_controller.dart +++ b/lib/pages/index/index_controller.dart @@ -1,9 +1,12 @@ - - +import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:geojson/geojson.dart'; import 'package:get/get.dart'; import 'package:latlong2/latlong.dart'; +import 'package:rogapp/routes/app_pages.dart'; +import 'package:rogapp/services/action_service.dart'; +import 'package:rogapp/services/auth_service.dart'; +import 'package:rogapp/services/cat_service.dart'; import 'package:rogapp/services/location_service.dart'; import 'package:rogapp/services/perfecture_service.dart'; @@ -13,11 +16,22 @@ class IndexController extends GetxController { List perfectures = [].obs; List currentBound = [].obs; List subPerfs = [].obs; + List cats = [].obs; + + List currentCat = [].obs; + + List> currentUser = >[].obs; + List currentAction = [].obs; + + + var is_loading = false.obs; MapController? mapController; var mode = 0.obs; + + String dropdownValue = "9"; String subDropdownValue = "-1"; void toggleMode(){ @@ -45,6 +59,78 @@ class IndexController extends GetxController { loadSubPerfFor("9"); }); } + loadCats(); + + } + + 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); + if(currentFeature.isNotEmpty){ + getAction(); + } + Get.toNamed(AppPages.INITIAL); + }else{ + is_loading.value = false; + Get.snackbar("Failed", "User login failed, please try again."); + } + + }); + } + + void register(String email, String password, BuildContext context){ + AuthService.register(email, password).then((value){ + if(value.isNotEmpty){ + currentUser.clear(); + currentUser.add(value); + is_loading.value = false; + Navigator.pop(context); + Get.toNamed(AppPages.INITIAL); + }else{ + is_loading.value = false; + Get.snackbar("Failed", "User registration failed, please try again."); + } + }); + } + + void makeAction(BuildContext context){ + int user_id = currentUser[0]["user"]["id"] as int; + int location_id = currentFeature[0].properties!["location_id"] as int; + 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 refreshLocationForCat(){ + if(subDropdownValue == "-1"){ + LocationService.loadLocationsFor(dropdownValue, currentCat[0]); + print("loading main------"); + } + else{ + LocationService.loadLocationsSubFor(subDropdownValue, currentCat[0]); + print("loading sub------"); + } } void loadSubPerfFor(String perf){ @@ -73,7 +159,7 @@ class IndexController extends GetxController { void loadLocationforPerf(String perf, MapController mapController) async { locations.clear(); - LocationService.loadLocationsFor(perf).then((value){ + LocationService.loadLocationsFor(perf, currentCat[0]).then((value){ locations.add(value!); mapController.fitBounds(currentBound[0]); }); @@ -81,7 +167,7 @@ class IndexController extends GetxController { void loadLocationforSubPerf(String subperf, MapController mapController) async { locations.clear(); - LocationService.loadLocationsSubFor(subperf).then((value){ + LocationService.loadLocationsSubFor(subperf, currentCat[0]).then((value){ locations.add(value!); }); } @@ -140,6 +226,28 @@ class IndexController extends GetxController { } } + void getAction(){ + //print(currentUser[0]["user"]["id"]); + //print(currentFeature[0].properties!["location_id"]); + if(currentUser.length == 0){ + return; + } + int user_id = currentUser[0]["user"]["id"] as int; + int location_id = currentFeature[0].properties!["location_id"] as int; + ActionService.userAction(user_id, location_id).then((value){ + print("------${value}"); + if(value != null && value.length > 0){ + currentAction.clear(); + currentAction.add(value); + print("------${currentAction[0]}"); + }else{ + List initval = [{"user": user_id, "location": location_id, "wanttogo": false, "like": false, "checkin": false}]; + currentAction.clear(); + currentAction.add(initval); + } + }); + } + void makeNext(GeoJsonFeature fs){ GeoJsonFeature pt = fs as GeoJsonFeature; @@ -153,9 +261,11 @@ class IndexController extends GetxController { } if(i >= locations[0].collection.length - 1 ){ currentFeature.add(locations[0].collection[0] as GeoJsonFeature); + getAction(); } else{ currentFeature.add(locations[0].collection[i + 1] as GeoJsonFeature); + getAction(); } } } @@ -175,9 +285,11 @@ class IndexController extends GetxController { } if(i == 0 ){ currentFeature.add(locations[0].collection[locations[0].collection.length -1] as GeoJsonFeature); + getAction(); } else{ currentFeature.add(locations[0].collection[i - 1] as GeoJsonFeature); + getAction(); } } } diff --git a/lib/index/index_page.dart b/lib/pages/index/index_page.dart similarity index 63% rename from lib/index/index_page.dart rename to lib/pages/index/index_page.dart index ab9641b..040ae7c 100644 --- a/lib/index/index_page.dart +++ b/lib/pages/index/index_page.dart @@ -2,9 +2,11 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:rogapp/index/index_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'; import 'package:rogapp/widgets/bread_crum_widget.dart'; +import 'package:rogapp/widgets/cat_widget.dart'; import 'package:rogapp/widgets/list_widget.dart'; import 'package:rogapp/widgets/map_widget.dart'; @@ -20,10 +22,8 @@ class IndexPage extends GetView { appBar: AppBar( title: Text("app_title".tr), actions: [ - IconButton( - icon: const Icon(Icons.map), - onPressed: () => {}, - ) + ElevatedButton(onPressed: (){}, child: CatWidget(indexController: indexController,)), + //CatWidget(indexController: indexController,), ], ), bottomNavigationBar: BottomAppBar( @@ -32,13 +32,25 @@ class IndexPage extends GetView { children: [ Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),), const Expanded(child: Text('')), - Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){}),), + Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){ + if(indexController.currentUser.isNotEmpty){ + Get.toNamed(AppPages.TRAVEL); + } + else{ + Get.toNamed(AppPages.LOGIN); + } + }),), ], ), ), floatingActionButton: FloatingActionButton( onPressed: (){ indexController.toggleMode(); + if(indexController.currentCat.isNotEmpty){ + print("###############"); + print(indexController.currentCat[0].toString()); + } + }, tooltip: 'Increment', child: const Icon(Icons.document_scanner), @@ -54,7 +66,16 @@ class IndexPage extends GetView { height: 50.0, child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: BreadCrumbWidget(), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + BreadCrumbWidget(), + Container(width: 24.0,), + Obx(()=> + indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text("") + ), + ], + ), ), ), Expanded( diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart new file mode 100644 index 0000000..62aa073 --- /dev/null +++ b/lib/pages/landing/landing_page.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:rogapp/routes/app_pages.dart'; + +class LandingPage extends StatefulWidget { + const LandingPage({ Key? key }) : super(key: key); + + @override + State createState() => _LandingPageState(); +} + +class _LandingPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height, + padding: EdgeInsets.symmetric(horizontal: 30,vertical: 30), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "こんにちは!", + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 40), + ), + SizedBox(height: 30,), + Text("ログインを有効にして本人確認を行うと、サーバーが改善されます", + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.grey[700], + fontSize: 15 + ), + ), + Container( + height: MediaQuery.of(context).size.height/3, + decoration: BoxDecoration( + image:DecorationImage(image: AssetImage('assets/gradient_japanese_temple.jpg')) + ), + ), + SizedBox(height: 20.0,), + MaterialButton( + minWidth: double.infinity, + height:60, + onPressed: (){ + Get.toNamed(AppPages.LOGIN); + }, + color: Colors.indigoAccent[400], + shape: RoundedRectangleBorder( + side: BorderSide( + color: Colors.black, + ), + borderRadius: BorderRadius.circular(40) + ), + child: Text("ログイン",style: TextStyle( + fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70 + + ), + ), + ), + SizedBox(height: 15.0,), + + MaterialButton( + minWidth: double.infinity, + height:60, + onPressed: (){ + Get.toNamed(AppPages.REGISTER); + }, + color: Colors.redAccent, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40) + ), + child: Text("サインアップ",style: TextStyle( + fontWeight: FontWeight.w600,fontSize: 16, + + ),), + ), + + ], + ) + ], + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/pages/login/login_page.dart b/lib/pages/login/login_page.dart new file mode 100644 index 0000000..039b281 --- /dev/null +++ b/lib/pages/login/login_page.dart @@ -0,0 +1,170 @@ + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; +import 'package:rogapp/routes/app_pages.dart'; + +class LoginPage extends StatelessWidget { + + final IndexController indexController = Get.find(); + + TextEditingController emailController = TextEditingController(); + TextEditingController passwordController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: Colors.white, + appBar: AppBar( + elevation: 0, + brightness: Brightness.light, + backgroundColor: Colors.white, + leading: + IconButton( onPressed: (){ + Navigator.pop(context); + },icon:Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)), + ), + body: Container( + height: MediaQuery.of(context).size.height, + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + children: [ + Column( + children: [ + Text ("ログイン", style: TextStyle( + fontSize: 30, + fontWeight: FontWeight.bold, + ),), + SizedBox(height: 20,), + Text("お帰りなさい !資格情報を使用してログインします",style: TextStyle( + fontSize: 15, + color: Colors.grey[700], + ),), + SizedBox(height: 30,) + ], + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 40 + ), + child: Column( + children: [ + makeInput(label: "Eメール", controller: emailController), + makeInput(label: "パスワード", controller: passwordController, obsureText: true), + ], + ), + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 40), + child: Container( + 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( + minWidth: double.infinity, + height:60, + onPressed: (){ + + }, + color: Colors.grey[400], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40) + ), + child: CircularProgressIndicator(), + ) : + MaterialButton( + minWidth: double.infinity, + height:60, + onPressed: (){ + if(emailController.text.isEmpty || passwordController.text.isEmpty){ + Get.snackbar("No values", "Email and password required"); + return; + } + indexController.is_loading.value = true; + indexController.login(emailController.text, passwordController.text, context); + }, + color: Colors.indigoAccent[400], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40) + ), + child: Text("ログイン",style: TextStyle( + fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70 + ), + ), + ) + ), + ), + ) + ), + SizedBox(height: 20,), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Flexible( + child: Text("アカウントをお持ちではありませんか?", style: TextStyle( + overflow: TextOverflow.ellipsis, + ),), + ), + TextButton( + onPressed: (){ + Get.toNamed(AppPages.REGISTER); + }, + child: Text("サインアップ",style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 18 + ),), + ), + ], + ) + ], + + ), + ], + ), + ), + ); + } +} + +Widget makeInput({label, required TextEditingController controller, obsureText = false}){ + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(label,style:TextStyle( + fontSize: 15, + fontWeight: FontWeight.w400, + color: Colors.black87 + ),), + SizedBox(height: 5,), + TextField( + controller: controller, + obscureText: obsureText, + decoration: InputDecoration( + contentPadding: EdgeInsets.symmetric(vertical: 0,horizontal: 10), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: (Colors.grey[400])!, + ), + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: (Colors.grey[400])! + ), + ), + ), + ), + SizedBox(height: 30.0,) + ], + ); +} diff --git a/lib/pages/map/map_binding_t.dart b/lib/pages/map/map_binding_t.dart deleted file mode 100644 index 97eda49..0000000 --- a/lib/pages/map/map_binding_t.dart +++ /dev/null @@ -1,14 +0,0 @@ -// import 'package:flutter_map/flutter_map.dart'; -// import 'package:get/get_core/src/get_main.dart'; -// import 'package:get/get_instance/src/bindings_interface.dart'; -// import 'package:get/get_instance/src/extension_instance.dart'; -// import 'package:rogapp/pages/home/home_controller.dart'; - - -// class MapBinding extends Bindings { -// @override -// void dependencies() { -// Get.put(HomeController()); -// Get.put(MapController()); -// } -// } diff --git a/lib/pages/map/map_controller_t.dart b/lib/pages/map/map_controller_t.dart deleted file mode 100644 index e69de29..0000000 diff --git a/lib/pages/map/map_page_t.dart b/lib/pages/map/map_page_t.dart deleted file mode 100644 index 6da81a2..0000000 --- a/lib/pages/map/map_page_t.dart +++ /dev/null @@ -1,181 +0,0 @@ -// import 'package:flutter/material.dart'; -// import 'package:flutter/rendering.dart'; -// import 'package:flutter_breadcrumb/flutter_breadcrumb.dart'; -// import 'package:flutter_map/plugin_api.dart'; -// import 'package:flutter_map_location_marker/flutter_map_location_marker.dart'; -// import 'package:geojson/geojson.dart'; -// import 'package:get/get.dart'; -// import 'package:get/get_state_manager/get_state_manager.dart'; -// import 'package:latlong2/latlong.dart'; -// import 'package:rogapp/pages/drawer/drawer_page.dart'; -// import 'package:rogapp/pages/home/home_controller.dart'; -// import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart'; -// import 'package:rogapp/routes/app_pages.dart'; -// import 'package:rogapp/widgets/base_layer_widget.dart'; -// import 'package:rogapp/widgets/bottom_sheet_widget.dart'; -// import 'package:rogapp/widgets/perfecture_widget.dart'; - - -// class MapPage extends GetView { -// MapPage({ Key? key }) : super(key: key); - -// final HomeController homeController = Get.find(); -// final MapController mapController = MapController(); - - -// Widget getBreadCurms(){ -// return Obx(() => -// homeController.perfectures.length > 0 ? -// BreadCrumb.builder( -// itemCount: homeController.perfectures.length, -// builder: (index) { -// return BreadCrumbItem( -// content: PerfectureWidget(homeController: homeController, mapController: mapController) //Text('Item$index') -// ); -// }, -// divider: Icon(Icons.chevron_right), -// ) : -// Container(width: 0, height: 0,), -// ); -// } - - -// @override -// Widget build(BuildContext context) { - -// final PopupController _popupController = PopupController(); - -// return Scaffold( -// drawer: DrawerPage(), -// appBar: AppBar( -// title: Text("app_title".tr), -// actions: [ -// IconButton( -// icon: const Icon(Icons.map), -// onPressed: () => {print("action")}, -// ) - -// ], -// ), -// bottomNavigationBar: BottomAppBar( -// child: new Row( -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// Expanded(child: IconButton(icon: Icon(Icons.camera_enhance), onPressed: (){},),), -// Expanded(child: new Text('')), -// Expanded(child: IconButton(icon: Icon(Icons.travel_explore), onPressed: (){}),), -// ], -// ), -// ), -// floatingActionButton: new FloatingActionButton( -// onPressed: (){ -// Get.toNamed(AppPages.INITIAL, arguments: [mapController]); -// }, -// tooltip: 'Increment', -// child: new Icon(Icons.document_scanner), -// elevation: 4.0, -// ), -// floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, -// body: SafeArea( -// child: Column( -// children: [ -// Container( -// padding: EdgeInsets.symmetric(horizontal: 16.0), -// alignment: Alignment.centerLeft, -// height: 50.0, -// child: SingleChildScrollView( -// scrollDirection: Axis.horizontal, -// child: -// getBreadCurms(), -// ), -// ), -// Expanded( -// child: Obx(() => -// Stack( -// children: [ -// FlutterMap( -// mapController: mapController, -// options: MapOptions( - -// //center: LatLng(37.15319600454702, 139.58765950528198), -// bounds: homeController.currentBound.length > 0 ? homeController.currentBound[0]: LatLngBounds.fromPoints([LatLng(37.15319600454702, 139.58765950528198)]), -// zoom: 6, -// maxZoom: 20, -// plugins: [ -// MarkerClusterPlugin(), -// ], -// onTap: (_, __) => -// _popupController -// .hideAllPopups(), // Hide popup when the map is tapped. -// ), -// children: [ -// BaseLayer(), -// LocationMarkerLayerWidget(), -// homeController.locations.length > 0 ? -// MarkerClusterLayerWidget( -// options: MarkerClusterLayerOptions( -// spiderfyCircleRadius: 80, -// spiderfySpiralDistanceMultiplier: 2, -// circleSpiralSwitchover: 12, -// maxClusterRadius: 20, -// rotate: true, -// onMarkerTap: (marker){ -// GeoJsonFeature? fs = homeController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude); -// print(fs); -// if(fs != null){ -// if(homeController.currentFeature.length > 0) { -// homeController.currentFeature.clear(); -// } -// homeController.currentFeature.add(fs); - -// showModalBottomSheet(context: context, isScrollControlled: true, -// builder:((context) => BottomSheetWidget()) -// ); -// } - -// }, - -// size: Size(40, 40), -// anchor: AnchorPos.align(AnchorAlign.center), -// fitBoundsOptions: const FitBoundsOptions( -// padding: EdgeInsets.all(50), -// maxZoom: 265, -// ), -// markers:homeController.locations[0].collection.map((i) { -// GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint; -// return Marker( -// anchorPos: AnchorPos.align(AnchorAlign.center), -// height: 70.0, -// width: 70.0, -// point: LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude), -// builder: (ctx) => Icon(Icons.pin_drop), -// ); -// }).toList(), -// builder: (context, markers) { -// return Container( -// decoration: BoxDecoration( -// borderRadius: BorderRadius.circular(20.0), -// color: Colors.blue), -// child: Center( -// child: Text( -// markers.length.toString(), -// style: TextStyle(color: Colors.white), -// ), -// ), -// ); -// }, -// ), -// ): Container(height:0,width: 0), -// ], -// ) -// ], -// ) -// ), -// ), -// ], -// ), -// ), -// ); -// } -// } - diff --git a/lib/pages/register/register_page.dart b/lib/pages/register/register_page.dart new file mode 100644 index 0000000..ba64e17 --- /dev/null +++ b/lib/pages/register/register_page.dart @@ -0,0 +1,163 @@ + + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; +import 'package:rogapp/routes/app_pages.dart'; + +class RegisterPage extends StatelessWidget { + + final IndexController indexController = Get.find(); + + TextEditingController emailController = TextEditingController(); + TextEditingController passwordController = TextEditingController(); + TextEditingController confirmPasswordController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: Colors.white, + appBar: AppBar( + elevation: 0, + brightness: Brightness.light, + backgroundColor: Colors.white, + leading: + IconButton( onPressed: (){ + Navigator.pop(context); + },icon:Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)), + ), + body: SafeArea( + child: SingleChildScrollView( + child: Container( + height: MediaQuery.of(context).size.height, + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Text ("サインアップ", style: TextStyle( + fontSize: 30, + fontWeight: FontWeight.bold, + ),), + SizedBox(height: 20,), + Text("アカウントを作成し、無料です",style: TextStyle( + fontSize: 15, + color: Colors.grey[700], + ),), + SizedBox(height: 30,) + ], + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 40 + ), + child: Column( + children: [ + makeInput(label: "Eメール", controller: emailController), + makeInput(label: "パスワード", controller: passwordController,obsureText: true), + makeInput(label: "パスワードを認証する", controller: confirmPasswordController,obsureText: true) + ], + ), + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 40), + child: Container( + 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: MaterialButton( + minWidth: double.infinity, + height:60, + onPressed: (){ + if(passwordController.text != confirmPasswordController.text){ + Get.snackbar("No match", "Passwords does not match"); + } + if(emailController.text.isEmpty || passwordController.text.isEmpty){ + Get.snackbar("No values", "Email and password required"); + return; + } + indexController.is_loading.value = true; + indexController.register(emailController.text, passwordController.text, context); + }, + color: Colors.redAccent, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40) + ), + child: Text("サインアップ",style: TextStyle( + fontWeight: FontWeight.w600,fontSize: 16, + + ),), + ), + ), + ), + SizedBox(height: 20,), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Flexible(child: Text("すでにアカウントをお持ちですか?")), + TextButton( + onPressed: (){ + Get.toNamed(AppPages.LOGIN); + }, + child: Text("ログイン",style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 18 + ),), + ), + ], + ) + ], + + ), + ], + ), + ), + ), + ), + ); + } +} + +Widget makeInput({label, required TextEditingController controller, obsureText = false}){ + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(label,style:TextStyle( + fontSize: 15, + fontWeight: FontWeight.w400, + color: Colors.black87 + ),), + SizedBox(height: 5,), + TextField( + controller: controller, + obscureText: obsureText, + decoration: InputDecoration( + contentPadding: EdgeInsets.symmetric(vertical: 0,horizontal: 10), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: (Colors.grey[400])!, + ), + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: (Colors.grey[400])! + ), + ), + ), + ), + SizedBox(height: 30,) + + ], + ); +} diff --git a/lib/routes/app_pages.dart b/lib/routes/app_pages.dart index 25ba30f..9b17c6b 100644 --- a/lib/routes/app_pages.dart +++ b/lib/routes/app_pages.dart @@ -1,6 +1,11 @@ import 'package:get/get_navigation/src/routes/get_route.dart'; -import 'package:rogapp/index/index_binding.dart'; -import 'package:rogapp/index/index_page.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_page.dart'; +import 'package:rogapp/pages/landing/landing_page.dart'; +import 'package:rogapp/pages/login/login_page.dart'; +import 'package:rogapp/pages/register/register_page.dart'; import 'package:rogapp/spa/spa_binding.dart'; import 'package:rogapp/spa/spa_page.dart'; @@ -12,6 +17,10 @@ class AppPages { static const INITIAL = Routes.INDEX; // ignore: constant_identifier_names static const SPA = Routes.SPA; + static const LANDING = Routes.LANDING; + static const LOGIN = Routes.LOGIN; + static const REGISTER = Routes.REGISTER; + static const TRAVEL = Routes.TRAVEL; static final routes = [ // GetPage( @@ -33,6 +42,26 @@ class AppPages { name: Routes.SPA, page: () => const SpaPage(), binding: SpaBinding(), + ), + GetPage( + name: Routes.LANDING, + page: () => LandingPage(), + //binding: SpaBinding(), + ), + GetPage( + name: Routes.LOGIN, + page: () => LoginPage(), + //binding: SpaBinding(), + ), + GetPage( + name: Routes.REGISTER, + page: () => RegisterPage(), + //binding: SpaBinding(), + ), + GetPage( + name: Routes.TRAVEL, + page: () => DestinationPage(), + binding: DestinationBinding(), ) ]; } \ No newline at end of file diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index 7412dda..5d30d0e 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -8,4 +8,8 @@ abstract class Routes { static const INDEX = '/'; // ignore: constant_identifier_names static const SPA = '/spa'; + static const LANDING = '/landing'; + static const LOGIN = '/login'; + static const REGISTER = '/register'; + static const TRAVEL = '/travel'; } diff --git a/lib/services/action_service.dart b/lib/services/action_service.dart new file mode 100644 index 0000000..86c941b --- /dev/null +++ b/lib/services/action_service.dart @@ -0,0 +1,43 @@ +import 'dart:convert'; +import 'package:http/http.dart' as http; + + +class ActionService{ + + static Future> makeAction(int user_id, int location_id, bool wanttogo, bool like, bool checkin) async { + Map cats = {}; + 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: { + 'Content-Type': 'application/json; charset=UTF-8', + } + ); + + if (response.statusCode == 200) { + cats = json.decode(utf8.decode(response.bodyBytes)); + } + return cats; + } + + + static Future?> userAction(int user_id, int location_id) async { + List cats = []; + 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', + }, + ); + + if (response.statusCode == 200) { + + cats = json.decode(utf8.decode(response.bodyBytes)); + } + return cats; + } + + + +} + diff --git a/lib/services/auth_service.dart b/lib/services/auth_service.dart new file mode 100644 index 0000000..4eb3727 --- /dev/null +++ b/lib/services/auth_service.dart @@ -0,0 +1,53 @@ +import 'dart:convert'; +import 'package:http/http.dart' as http; + + +class AuthService{ + + static Future> login(String email, String password) async { + Map cats = {}; + String url = 'http://localhost:8100/api/login/'; + final http.Response response = await http.post( + Uri.parse(url), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + body: jsonEncode({ + 'email': email, + 'password': password + }), + ); + + if (response.statusCode == 200) { + cats = json.decode(utf8.decode(response.bodyBytes)); + } + return cats; + } + + + static Future> register(String email, String password) async { + Map cats = {}; + String url = 'http://localhost:8100/api/register/'; + final http.Response response = await http.post( + Uri.parse(url), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + body: jsonEncode({ + 'email': email, + 'password': password + }), + ); + + 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 new file mode 100644 index 0000000..8be7fb0 --- /dev/null +++ b/lib/services/cat_service.dart @@ -0,0 +1,28 @@ +import 'dart:convert'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; + + +class CatService{ + + static Future?> loadCats() async { + List cats = []; + String url = 'http://localhost:8100/api/cats/'; + 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/destination_service.dart b/lib/services/destination_service.dart new file mode 100644 index 0000000..b0ec255 --- /dev/null +++ b/lib/services/destination_service.dart @@ -0,0 +1,41 @@ +import 'dart:convert'; +import 'package:http/http.dart' as http; + + +class DestinationService{ + + static Future> getDestinations(int user_id) async { + List cats = []; + String url = "http://localhost:8100/api/destinations/?user_id=${user_id}"; + final http.Response 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; + } + + static Future updateOrder(int action_id, int order, String dir) async { + int cats = 0; + 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: { + '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/location_line_service.dart b/lib/services/location_line_service.dart index a5adc70..68309cb 100644 --- a/lib/services/location_line_service.dart +++ b/lib/services/location_line_service.dart @@ -7,7 +7,7 @@ class LocationLineService{ final geo = GeoJson(); GeoJsonFeature? fs; - 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..59e4d56 100644 --- a/lib/services/location_polygon_service.dart +++ b/lib/services/location_polygon_service.dart @@ -7,7 +7,7 @@ class LocationPolygonervice{ final geo = GeoJson(); GeoJsonFeature? fs; - 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 c8b80de..3114d18 100644 --- a/lib/services/location_service.dart +++ b/lib/services/location_service.dart @@ -6,7 +6,7 @@ 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://localhost:8100/api/location/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -20,8 +20,15 @@ class LocationService{ return null; } - static Future loadLocationsFor(String perfecture) async { - String url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture; + static Future loadLocationsFor(String perfecture, String cat) async { + String url = ""; + if(cat.isNotEmpty){ + url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat; + } + else{ + url = 'http://localhost:8100/api/inperf/?perf=' + perfecture; + } + //String url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -37,8 +44,14 @@ class LocationService{ } - static Future loadLocationsSubFor(String subperfecture) async { - String url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture; + static Future loadLocationsSubFor(String subperfecture, String cat) async { + String url = ""; + if(cat.isNotEmpty){ + url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat; + } + else{ + url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture; + } final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/services/perfecture_service.dart b/lib/services/perfecture_service.dart index 635ddcf..ceefdd5 100644 --- a/lib/services/perfecture_service.dart +++ b/lib/services/perfecture_service.dart @@ -6,7 +6,7 @@ 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/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -22,7 +22,7 @@ class PerfectureService{ static Future?> loadSubPerfectures(String sub) async { List perfs = []; - String url = 'http://container.intranet.sumasen.net:8100/api/subperfinmain/?perf=' + sub; + String url = 'http://localhost:8100/api/subperfinmain/?perf=' + sub; //String url = 'http://container.intranet.sumasen.net:8100/api/insubperf/?perf=' + sub; final response = await http.get(Uri.parse(url), headers: { @@ -40,7 +40,7 @@ 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; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -57,7 +57,7 @@ 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; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/utils/string_values.dart b/lib/utils/string_values.dart index 66ed71a..f3c77aa 100644 --- a/lib/utils/string_values.dart +++ b/lib/utils/string_values.dart @@ -35,6 +35,8 @@ class StringValues extends Translations{ 'telephone':'電話', 'how_nice':'いいね', 'want_to_go': '行きたい', + 'like': 'お気に入り', + 'checkin': 'チェックイン', 'schedule_point': '予定地点', 'login': 'ログインする', 'change_password': 'パスワード変更', diff --git a/lib/widgets/bottom_sheet_widget.dart b/lib/widgets/bottom_sheet_widget.dart index 081c52d..15a1bc9 100644 --- a/lib/widgets/bottom_sheet_widget.dart +++ b/lib/widgets/bottom_sheet_widget.dart @@ -1,7 +1,10 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:geojson/geojson.dart'; import 'package:get/get.dart'; -import 'package:rogapp/index/index_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 BottomSheetWidget extends StatelessWidget { @@ -22,20 +25,6 @@ class BottomSheetWidget extends StatelessWidget { if (!await launch(url)) throw 'Could not launch $url'; } - // Widget getAttrib(String name){ - // print("calling ..."); - // if(homeController.currentFeature[0].properties!["phone"] == null || homeController.currentFeature[0].properties!["phone"] == ""){ - // return Container(height: 0, width: 0,); - // } - // else { - // return Obx(() => - // Text(homeController.currentFeature[0].properties!["phone"] ?? '', - // style: TextStyle(color: Colors.blue,), - // overflow: TextOverflow.ellipsis,) - // ); - // } - // } - @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -213,22 +202,125 @@ class BottomSheetWidget extends StatelessWidget { ], ), SizedBox(height: 20.0,), + Obx(() => + indexController.currentAction.isNotEmpty ? Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ + indexController.currentAction[0][0]["wanttogo"] == false ? + ElevatedButton( + onPressed: (){ + if(indexController.currentAction.isNotEmpty){ + print(indexController.currentAction[0]); + indexController.currentAction[0][0]["wanttogo"] = true; + Map temp = Map.from(indexController.currentAction[0][0]); + indexController.currentAction.clear(); + print("---temp---${temp}"); + indexController.currentAction.add([temp]); + } + indexController.makeAction(context); + }, + child: Text("want_to_go".tr) + ) : ElevatedButton( - onPressed: (){}, - child: Text("schedule_point".tr) + onPressed: (){ + if(indexController.currentAction.isNotEmpty){ + print(indexController.currentAction[0]); + indexController.currentAction[0][0]["wanttogo"] = false; + Map temp = Map.from(indexController.currentAction[0][0]); + indexController.currentAction.clear(); + print("---temp---${temp}"); + indexController.currentAction.add([temp]); + } + indexController.makeAction(context); + }, + + child: IconButton( + icon: Icon(Icons.favorite, color: Colors.red, semanticLabel: "want_to_go".tr,), onPressed: () { + + }, + + ) ), + indexController.currentAction[0][0]["like"] == false ? + ElevatedButton( + onPressed: (){ + if(indexController.currentAction.isNotEmpty){ + print(indexController.currentAction[0]); + indexController.currentAction[0][0]["like"] = true; + Map temp = Map.from(indexController.currentAction[0][0]); + indexController.currentAction.clear(); + print("---temp---${temp}"); + indexController.currentAction.add([temp]); + } + indexController.makeAction(context); + }, + child: Text("like".tr) + ) : ElevatedButton( - onPressed: (){}, - child: Text("schedule_point".tr) + onPressed: (){ + if(indexController.currentAction.isNotEmpty){ + print(indexController.currentAction[0]); + indexController.currentAction[0][0]["like"] = false; + Map temp = Map.from(indexController.currentAction[0][0]); + indexController.currentAction.clear(); + print("---temp---${temp}"); + indexController.currentAction.add([temp]); + } + indexController.makeAction(context); + }, + + child: IconButton( + icon: Icon(Icons.favorite, color: Colors.red, semanticLabel: "like".tr,), onPressed: () { + + }, + + ) ), + 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) + ) : ElevatedButton( - onPressed: (){}, - child: Text("schedule_point".tr) + onPressed: (){ + if(indexController.currentAction.isNotEmpty){ + print(indexController.currentAction[0]); + indexController.currentAction[0][0]["checkin"] = false; + Map temp = Map.from(indexController.currentAction[0][0]); + indexController.currentAction.clear(); + print("---temp---${temp}"); + indexController.currentAction.add([temp]); + } + indexController.makeAction(context); + }, + + child: Icon( + Icons.favorite, color: Colors.red) + + , ) ], + ): Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + onPressed: (){ + Get.toNamed(AppPages.LOGIN); + }, + child: Flexible(child: Text("その他のオプションについてはログインしてください"))) + ], + ), ), Row( children: [ diff --git a/lib/widgets/bread_crum_widget.dart b/lib/widgets/bread_crum_widget.dart index 8f12522..56e6ced 100644 --- a/lib/widgets/bread_crum_widget.dart +++ b/lib/widgets/bread_crum_widget.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:flutter_map/flutter_map.dart'; import 'package:get/get.dart'; import 'package:flutter_breadcrumb/flutter_breadcrumb.dart'; -import 'package:rogapp/index/index_controller.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/widgets/perfecture_widget.dart'; class BreadCrumbWidget extends StatelessWidget { diff --git a/lib/widgets/cat_widget.dart b/lib/widgets/cat_widget.dart new file mode 100644 index 0000000..9fea7da --- /dev/null +++ b/lib/widgets/cat_widget.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; +import 'package:rogapp/services/location_service.dart'; + +class CatWidget extends StatefulWidget { + CatWidget({ Key? key, required this.indexController, }) : super(key: key); + + IndexController indexController; + + @override + State createState() => _CatWidgetState(); +} + +class _CatWidgetState extends State { + String defaultValue = "---"; + + @override + Widget build(BuildContext context) { + return + PopupMenuButton( + onSelected: (value) { + widget.indexController.currentCat.clear(); + widget.indexController.currentCat.add(value.toString()); + widget.indexController.refreshLocationForCat(); + setState(() { + print(value); + defaultValue = value.toString(); + }); + }, + itemBuilder: (BuildContext context){ + List itms = []; + for(dynamic d in widget.indexController.cats[0]){ + PopupMenuItem itm = PopupMenuItem(child: Text(d['category'].toString()), value: d['category'].toString()); + itms.add(itm); + } + return itms; + } + + ); + } +} + + +// widget.indexController.cats.map((e) => +// PopupMenuItem( +// value: defaultValue, +// child: Text(e[0]['category'].toString()), +// ) +// ).toList(), \ No newline at end of file diff --git a/lib/widgets/list_widget.dart b/lib/widgets/list_widget.dart index fe9712a..d5b9d2d 100644 --- a/lib/widgets/list_widget.dart +++ b/lib/widgets/list_widget.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:geojson/geojson.dart'; import 'package:get/get.dart'; -import 'package:rogapp/index/index_controller.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/widgets/bottom_sheet_widget.dart'; class ListWidget extends StatelessWidget { diff --git a/lib/widgets/map_widget.dart b/lib/widgets/map_widget.dart index 19ad5f4..e53c303 100644 --- a/lib/widgets/map_widget.dart +++ b/lib/widgets/map_widget.dart @@ -6,7 +6,7 @@ import 'package:geojson/geojson.dart'; import 'package:get/get.dart'; import 'package:get/get_state_manager/get_state_manager.dart'; import 'package:latlong2/latlong.dart'; -import 'package:rogapp/index/index_controller.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/widgets/base_layer_widget.dart'; import 'package:rogapp/widgets/bottom_sheet_widget.dart'; @@ -57,6 +57,7 @@ class MapWidget extends StatelessWidget { indexController.currentFeature.clear(); } indexController.currentFeature.add(fs); + indexController.getAction(); showModalBottomSheet(context: context, isScrollControlled: true, builder:((context) => BottomSheetWidget()) diff --git a/lib/widgets/perfecture_widget.dart b/lib/widgets/perfecture_widget.dart index 1a09c81..74f8d1e 100644 --- a/lib/widgets/perfecture_widget.dart +++ b/lib/widgets/perfecture_widget.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:get/get.dart'; -import 'package:rogapp/index/index_controller.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; class PerfectureWidget extends StatefulWidget { @@ -18,7 +18,7 @@ class PerfectureWidget extends StatefulWidget { } class _PerfectureWidgetState extends State { - String dropdownValue = "9"; + List> getDropdownItems() { List> dropDownItems = []; @@ -58,7 +58,7 @@ class _PerfectureWidgetState extends State { Row( children: [ DropdownButton( - value: dropdownValue, + value: widget.indexController.dropdownValue, icon: const Icon(Icons.arrow_downward), elevation: 16, style: const TextStyle(color: Colors.deepPurple), @@ -69,7 +69,7 @@ class _PerfectureWidgetState extends State { onChanged: (String? newValue) { //setState(() { if(newValue != null){ - dropdownValue = newValue; + widget.indexController.dropdownValue = newValue; widget.indexController.populateForPerf(newValue, widget.mapController); } //}); diff --git a/pubspec.lock b/pubspec.lock index e3640b0..ff33a18 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -574,6 +574,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.8" + timeline_tile: + dependency: "direct main" + description: + name: timeline_tile + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" transparent_image: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index b918068..68d31e8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -60,6 +60,7 @@ dependencies: geojson: ^1.0.0 url_launcher: ^6.0.20 flutter_breadcrumb: ^1.0.1 + timeline_tile: ^2.0.0 dev_dependencies: @@ -87,6 +88,7 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - assets/images/empty_image.png + - assets/gradient_japanese_temple.jpg # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see