diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index 66c30ad..13a5101 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -6,6 +6,7 @@ import 'dart:io'; import 'package:camera_camera/camera_camera.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_map/flutter_map.dart'; import 'package:geojson/geojson.dart'; import 'package:geolocator/geolocator.dart'; import 'package:get/get.dart'; @@ -19,7 +20,10 @@ import 'package:rogapp/routes/app_pages.dart'; import 'package:rogapp/services/action_service.dart'; import 'package:rogapp/services/destination_service.dart'; import 'package:rogapp/services/external_service.dart'; +import 'package:rogapp/services/location_line_service.dart'; +import 'package:rogapp/services/location_service.dart'; import 'package:rogapp/services/maxtrix_service.dart'; +import 'package:rogapp/services/perfecture_service.dart'; import 'package:rogapp/services/reacking_service.dart'; import 'package:rogapp/utils/database_helper.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart'; @@ -434,6 +438,7 @@ class DestinationController extends GetxController { @override void onInit() async { + checkPermission(); PopulateDestinations(); @@ -505,6 +510,33 @@ class DestinationController extends GetxController { } + @override + void onReady() { + Get.toNamed(AppPages.LOGIN)!.then((value){ + if(indexController.currentUser.length > 0) { + Get.toNamed(AppPages.INITIAL); + LocationService.getLocationsExt().then((value) { + if(value != null){ + print("--- loc ext is - ${value} ----"); + LatLngBounds bnds = LatLngBounds(LatLng(value[1], value[0]), LatLng(value[3], value[2])); + print("--- bnds is - ${bnds} ----"); + indexController.mapController!.fitBounds(bnds); //.centerZoomFitBounds(bnds); + } + }); + } + else { + Get.toNamed(AppPages.TRAVEL); + PerfectureService.getSubExt("9").then((value){ + if(value != null){ + LatLngBounds bnds = LatLngBounds(LatLng(value[1], value[0]), LatLng(value[3], value[2])); + indexController.mapController!.fitBounds(bnds); //.centerZoomFitBounds(bnds); + } + }); + } + }); + super.onReady(); + } + void connectionChanged(String val) { print('----- %%%%%%%%%%%%%%%%%%%%% ----- ${val}'); Map _res = {}; diff --git a/lib/pages/index/index_controller.dart b/lib/pages/index/index_controller.dart index ac40b5f..92cab90 100644 --- a/lib/pages/index/index_controller.dart +++ b/lib/pages/index/index_controller.dart @@ -119,7 +119,6 @@ class IndexController extends GetxController { @override void onInit() { - _ever = ever(rog_mode, (_) => print("$_ has been changed (ever)")); if(perfectures.length == 0){ @@ -194,23 +193,31 @@ void login(String email, String password, BuildContext context){ AuthService.login(email, password).then((value){ print("------- logged in user details ######## ${value} ###### --------"); if(value.isNotEmpty){ - currentUser.clear(); - currentUser.add(value); - is_loading.value = false; - Navigator.pop(context); - loadUserDetails(); - loadLocationsBound(); - cats.clear(); - if(currentFeature.isNotEmpty){ - getAction(); - } - if(rog_mode.value == 1){ - switchPage(AppPages.TRAVEL); - } - else{ - switchPage(AppPages.INITIAL); - } - //Get.toNamed(AppPages.INITIAL); + currentUser.clear(); + currentUser.add(value); + is_loading.value = false; + Navigator.pop(context); + loadUserDetails(); + loadLocationsBound(); + cats.clear(); + if(currentFeature.isNotEmpty){ + getAction(); + } + + if(currentUser.length > 0){ + rog_mode.value = 0 ; + } + else{ + rog_mode.value = 1; + } + + if(rog_mode.value == 1){ + switchPage(AppPages.TRAVEL); + } + else{ + switchPage(AppPages.INITIAL); + } + //Get.toNamed(AppPages.INITIAL); }else{ is_loading.value = false; Get.snackbar( @@ -390,9 +397,11 @@ void login(String email, String password, BuildContext context){ 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(); + if(value != null && value.isNotEmpty){ + bool paid = value![0]["paid"] as bool; + if(paid){ + loadCustomAreas(); + } } }); } diff --git a/lib/pages/login/login_page.dart b/lib/pages/login/login_page.dart index bef5ff9..d37413a 100644 --- a/lib/pages/login/login_page.dart +++ b/lib/pages/login/login_page.dart @@ -81,7 +81,7 @@ class LoginPage extends StatelessWidget { children: [ MaterialButton( minWidth: double.infinity, - height:60, + height:40, onPressed: (){ if(emailController.text.isEmpty || passwordController.text.isEmpty){ Get.snackbar( @@ -107,10 +107,10 @@ class LoginPage extends StatelessWidget { ), ), ), - SizedBox(height: 10.0,), + SizedBox(height: 19.0,), MaterialButton( minWidth: double.infinity, - height:60, + height:40, onPressed: (){ Get.toNamed(AppPages.REGISTER); }, @@ -122,7 +122,23 @@ class LoginPage extends StatelessWidget { fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70 ), ), - ) + ), + SizedBox(height: 19.0,), + MaterialButton( + minWidth: double.infinity, + height:40, + onPressed: (){ + Get.back(); + }, + color: Colors.grey, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40) + ), + child: Text("cancel".tr,style: TextStyle( + fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70 + ), + ), + ), ], ) ), diff --git a/lib/pages/login_popup/login_popup_page.dart b/lib/pages/login_popup/login_popup_page.dart new file mode 100644 index 0000000..5224c89 --- /dev/null +++ b/lib/pages/login_popup/login_popup_page.dart @@ -0,0 +1,210 @@ +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 LoginPopupPage extends StatelessWidget { + LoginPopupPage({Key? key}) : super(key: key); + + 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: + indexController.currentUser.length == 0 ? + Container( + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Column( + children: [ + Column( + children: [ + Container( + height: MediaQuery.of(context).size.height/5, + decoration: BoxDecoration( + image:DecorationImage(image: AssetImage('assets/images/login_image.jpg')) + ), + ), + SizedBox(height: 5,), + + ], + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 40 + ), + child: Column( + children: [ + makeInput(label: "email".tr, controller: emailController), + makeInput(label: "password".tr, 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), + ), + 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(), + ) : + Column( + children: [ + MaterialButton( + minWidth: double.infinity, + height:60, + onPressed: (){ + if(emailController.text.isEmpty || passwordController.text.isEmpty){ + Get.snackbar( + "no_values".tr, + "email_and_password_required".tr, + icon: Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue), + snackPosition: SnackPosition.TOP, + duration: Duration(milliseconds: 800), + backgroundColor: Colors.yellow, + //icon:Image(image:AssetImage("assets/images/dora.png")) + ); + 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: 19.0,), + MaterialButton( + minWidth: double.infinity, + height:50, + onPressed: (){ + Get.toNamed(AppPages.REGISTER); + }, + color: Colors.redAccent, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40) + ), + child: Text("sign_up".tr,style: TextStyle( + fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70 + ), + ), + ), + SizedBox(height: 19.0,), + MaterialButton( + minWidth: double.infinity, + height:50, + onPressed: (){ + Get.toNamed(AppPages.TRAVEL); + }, + color: Colors.grey, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40) + ), + child: Text("cancel".tr,style: TextStyle( + fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70 + ), + ), + ) + ], + ) + ), + ), + ) + ), + SizedBox(height: 20,), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Flexible( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text("rogaining_user_need_tosign_up".tr, style: TextStyle( + overflow: TextOverflow.ellipsis, + ),), + ), + ), + ], + ) + ], + + ), + ], + ), + ): + Container( + child: TextButton( + onPressed: (){ + indexController.currentUser.clear(); + }, + child: Text("Already Logged in, Click to logout"), + ), + ) + , + ); + } +} + +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/services/location_service.dart b/lib/services/location_service.dart index cf28504..eca01dc 100644 --- a/lib/services/location_service.dart +++ b/lib/services/location_service.dart @@ -76,6 +76,24 @@ class LocationService{ return null; } + static Future?> getLocationsExt() async { + List ext = []; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/locsext/'; + //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', + }, + ); + + if (response.statusCode == 200) { + + ext = json.decode(utf8.decode(response.bodyBytes)); + } + return ext; + } + static Future loadLocationsSubFor(String subperfecture, String cat) async { final IndexController indexController = Get.find();