update to add resume app from sleep
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
|
||||
import 'package:flutter_map/plugin_api.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
|
||||
class IndexBinding extends Bindings {
|
||||
|
||||
@ -124,7 +124,7 @@ class IndexController extends GetxController {
|
||||
void onInit() {
|
||||
_ever = ever(rog_mode, (_) => print("$_ has been changed (ever)"));
|
||||
|
||||
if(perfectures.length == 0){
|
||||
if(perfectures.isEmpty){
|
||||
PerfectureService.loadPerfectures().then((value){
|
||||
perfectures.add(value);
|
||||
loadAreaFor("9");
|
||||
@ -193,7 +193,7 @@ List<LatLng> getLocationsList(){
|
||||
|
||||
void login(String email, String password, BuildContext context){
|
||||
AuthService.login(email, password).then((value){
|
||||
print("------- logged in user details ######## ${value} ###### --------");
|
||||
print("------- logged in user details ######## $value ###### --------");
|
||||
if(value.isNotEmpty){
|
||||
currentUser.clear();
|
||||
currentUser.add(value);
|
||||
@ -206,7 +206,7 @@ void login(String email, String password, BuildContext context){
|
||||
getAction();
|
||||
}
|
||||
|
||||
if(currentUser.length > 0){
|
||||
if(currentUser.isNotEmpty){
|
||||
rog_mode.value = 0 ;
|
||||
}
|
||||
else{
|
||||
@ -225,9 +225,9 @@ void login(String email, String password, BuildContext context){
|
||||
Get.snackbar(
|
||||
"Failed",
|
||||
"User login failed, please try again.",
|
||||
icon: Icon(Icons.error, size: 40.0, color: Colors.blue),
|
||||
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: Duration(milliseconds: 800),
|
||||
duration: const Duration(milliseconds: 800),
|
||||
backgroundColor: Colors.yellow,
|
||||
//icon:Image(image:AssetImage("assets/images/dora.png"))
|
||||
);
|
||||
@ -240,7 +240,7 @@ void login(String email, String password, BuildContext context){
|
||||
String _token = currentUser[0]['token'];
|
||||
//print("------- change password ######## ${currentUser[0]['token']} ###### --------");
|
||||
AuthService.changePassword(oldpassword, newpassword, _token).then((value){
|
||||
print("------- change password ######## ${value} ###### --------");
|
||||
print("------- change password ######## $value ###### --------");
|
||||
if(value.isNotEmpty){
|
||||
is_loading.value = false;
|
||||
Navigator.pop(context);
|
||||
@ -254,9 +254,9 @@ void login(String email, String password, BuildContext context){
|
||||
Get.snackbar(
|
||||
'failed'.tr,
|
||||
'password_change_failed_please_try_again'.tr,
|
||||
icon: Icon(Icons.error, size: 40.0, color: Colors.blue),
|
||||
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: Duration(milliseconds: 800),
|
||||
duration: const Duration(milliseconds: 800),
|
||||
backgroundColor: Colors.yellow,
|
||||
//icon:Image(image:AssetImage("assets/images/dora.png"))
|
||||
);
|
||||
@ -271,9 +271,7 @@ void login(String email, String password, BuildContext context){
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
db.deleteAllDestinations().then((value){
|
||||
DestinationController destinationController = Get.find<DestinationController>();
|
||||
if(destinationController != null){
|
||||
destinationController.PopulateDestinations();
|
||||
}
|
||||
destinationController.PopulateDestinations();
|
||||
});
|
||||
currentUser.clear();
|
||||
cats.clear();
|
||||
@ -293,9 +291,9 @@ void login(String email, String password, BuildContext context){
|
||||
Get.snackbar(
|
||||
'failed'.tr,
|
||||
'user_registration_failed_please_try_again'.tr,
|
||||
icon: Icon(Icons.error, size: 40.0, color: Colors.blue),
|
||||
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: Duration(milliseconds: 800),
|
||||
duration: const Duration(milliseconds: 800),
|
||||
backgroundColor: Colors.yellow,
|
||||
//icon:Image(image:AssetImage("assets/images/dora.png"))
|
||||
);
|
||||
@ -304,13 +302,13 @@ void login(String email, String password, BuildContext context){
|
||||
}
|
||||
|
||||
void makeAction(BuildContext context){
|
||||
int user_id = currentUser[0]["user"]["id"] as int;
|
||||
int location_id = currentFeature[0].properties!["location_id"] as int;
|
||||
int userId = currentUser[0]["user"]["id"] as int;
|
||||
int locationId = 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"];
|
||||
if(user_id > 0){
|
||||
ActionService.makeAction(user_id, location_id, wanttogo, like, checkin).then((value){
|
||||
if(userId > 0){
|
||||
ActionService.makeAction(userId, locationId, wanttogo, like, checkin).then((value){
|
||||
});
|
||||
}
|
||||
|
||||
@ -318,7 +316,7 @@ void login(String email, String password, BuildContext context){
|
||||
|
||||
String getCatText(){
|
||||
String _cat = 'all'.tr;
|
||||
if(currentUser.length > 0){
|
||||
if(currentUser.isNotEmpty){
|
||||
Map<String, dynamic> _urs = currentUser[0];
|
||||
print('-- is_rogaining :-- ${_urs['user']['is_rogaining']} ------');
|
||||
if(_urs['user']['is_rogaining'] == true){
|
||||
@ -333,8 +331,8 @@ void login(String email, String password, BuildContext context){
|
||||
|
||||
void loadCatsv2(){
|
||||
dynamic initVal = {'category':getCatText()};
|
||||
LatLngBounds bounds = mapController!.bounds!;
|
||||
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
|
||||
LatLngBounds bounds = mapController.bounds!;
|
||||
if(bounds.southWest != null && bounds.northEast != null ){
|
||||
CatService.loadCats(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude).then((value) {
|
||||
cats.clear();
|
||||
cats.add(initVal);
|
||||
@ -349,8 +347,8 @@ void login(String email, String password, BuildContext context){
|
||||
|
||||
void loadCatForCity(String city){
|
||||
dynamic initVal = {'category':getCatText()};
|
||||
LatLngBounds bounds = mapController!.bounds!;
|
||||
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
|
||||
LatLngBounds bounds = mapController.bounds!;
|
||||
if(bounds.southWest != null && bounds.northEast != null ){
|
||||
CatService.loadCatByCity(city).then((value) {
|
||||
cats.clear();
|
||||
cats.add(initVal);
|
||||
@ -395,12 +393,12 @@ void login(String email, String password, BuildContext context){
|
||||
}
|
||||
|
||||
void loadUserDetails(){
|
||||
if(currentUser.length > 0){
|
||||
int user_id = currentUser[0]["user"]["id"] as int;
|
||||
AuthService.UserDetails(user_id).then((value){
|
||||
print("--------- user details ----- ${value}");
|
||||
if(currentUser.isNotEmpty){
|
||||
int userId = currentUser[0]["user"]["id"] as int;
|
||||
AuthService.UserDetails(userId).then((value){
|
||||
print("--------- user details ----- $value");
|
||||
if(value != null && value.isNotEmpty){
|
||||
bool paid = value![0]["paid"] as bool;
|
||||
bool paid = value[0]["paid"] as bool;
|
||||
if(paid){
|
||||
loadCustomAreas();
|
||||
}
|
||||
@ -413,7 +411,7 @@ void login(String email, String password, BuildContext context){
|
||||
void loadCustomAreas(){
|
||||
customAreas.clear();
|
||||
PerfectureService.loadCustomAreas().then((value){
|
||||
print("--- loading custom areas ${value}");
|
||||
print("--- loading custom areas $value");
|
||||
customAreas.add(value);
|
||||
});
|
||||
}
|
||||
@ -431,7 +429,7 @@ void login(String email, String password, BuildContext context){
|
||||
|
||||
String getSubInitialVal(){
|
||||
int min = 0;
|
||||
if(subPerfs.length > 0){
|
||||
if(subPerfs.isNotEmpty){
|
||||
min = int.parse(subPerfs[0][0]['id'].toString());
|
||||
for(var sub in subPerfs[0]){
|
||||
int x = int.parse(sub['id'].toString()); // as int;
|
||||
@ -471,16 +469,16 @@ void login(String email, String password, BuildContext context){
|
||||
if(currentCat.isNotEmpty && currentCat[0] == "-all-"){
|
||||
cat = "";
|
||||
}
|
||||
print("----- ${customarea}");
|
||||
print("----- $customarea");
|
||||
LocationService.loadCustomLocations(customarea, cat).then((value){
|
||||
locations.clear();
|
||||
locations.add(value!);
|
||||
List<LatLng> locs = getLocationsList();
|
||||
LatLngBounds bounds = boundsFromLatLngList(locs);
|
||||
mapController!.fitBounds(bounds);
|
||||
mapController.fitBounds(bounds);
|
||||
setBound(bounds);
|
||||
Future.delayed(Duration(microseconds: 400), () {
|
||||
mapController!.fitBounds(bounds);
|
||||
Future.delayed(const Duration(microseconds: 400), () {
|
||||
mapController.fitBounds(bounds);
|
||||
});
|
||||
|
||||
});
|
||||
@ -495,33 +493,33 @@ void login(String email, String password, BuildContext context){
|
||||
if(currentCat.isNotEmpty && currentCat[0] == "-all-"){
|
||||
cat = "";
|
||||
}
|
||||
LatLngBounds bounds = mapController!.bounds!;
|
||||
LatLngBounds bounds = mapController.bounds!;
|
||||
currentBound.clear();
|
||||
currentBound.add(bounds);
|
||||
//print(currentCat);
|
||||
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
|
||||
if(bounds.southWest != null && bounds.northEast != null ){
|
||||
LocationService.loadLocationsBound(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude, cat).then((value){
|
||||
//print("---value length ------ ${value!.collection.length}");
|
||||
if(value == null){
|
||||
return;
|
||||
}
|
||||
if(value != null && value.collection.isEmpty){
|
||||
if(value.collection.isEmpty){
|
||||
if(showPopup == false) {
|
||||
return;
|
||||
}
|
||||
Get.snackbar(
|
||||
"Too many Points",
|
||||
"please zoom in",
|
||||
icon: Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
|
||||
icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: Duration(milliseconds: 800),
|
||||
duration: const Duration(milliseconds: 800),
|
||||
backgroundColor: Colors.yellow,
|
||||
//icon:Image(image:AssetImage("assets/images/dora.png"))
|
||||
);
|
||||
showPopup = false;
|
||||
//Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",));
|
||||
}
|
||||
if(value != null && value.collection.isNotEmpty){
|
||||
if(value.collection.isNotEmpty){
|
||||
//print("---- added---");
|
||||
locations.add(value);
|
||||
loadCatsv2();
|
||||
@ -542,7 +540,7 @@ void login(String email, String password, BuildContext context){
|
||||
LatLng lat1 = LatLng(value![1], value[0]);
|
||||
LatLng lat2 = LatLng(value[3], value[2]);
|
||||
LatLngBounds bound = LatLngBounds(lat1, lat2);
|
||||
mapController!.fitBounds(bound);
|
||||
mapController.fitBounds(bound);
|
||||
setBound(bound);
|
||||
});
|
||||
|
||||
@ -556,7 +554,7 @@ void login(String email, String password, BuildContext context){
|
||||
LatLng lat1 = LatLng(value![1], value[0]);
|
||||
LatLng lat2 = LatLng(value[3], value[2]);
|
||||
LatLngBounds bound = LatLngBounds(lat1, lat2);
|
||||
mapController!.fitBounds(bound);
|
||||
mapController.fitBounds(bound);
|
||||
setBound(bound);
|
||||
});
|
||||
|
||||
@ -586,7 +584,7 @@ void login(String email, String password, BuildContext context){
|
||||
|
||||
|
||||
GeoJsonFeature? getFeatureForLatLong(double lat, double long){
|
||||
if(locations.length > 0){
|
||||
if(locations.isNotEmpty){
|
||||
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){
|
||||
@ -594,25 +592,26 @@ void login(String email, String password, BuildContext context){
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void getAction(){
|
||||
//print(currentUser[0]["user"]["id"]);
|
||||
//print(currentFeature[0].properties!["location_id"]);
|
||||
if(currentUser.length == 0){
|
||||
if(currentUser.isEmpty){
|
||||
return;
|
||||
}
|
||||
int user_id = currentUser[0]["user"]["id"] as int;
|
||||
int userId = currentUser[0]["user"]["id"] as int;
|
||||
print("---- loc id ${currentFeature[0].properties}");
|
||||
int location_id = currentFeature[0].properties!["location_id"] as int;
|
||||
ActionService.userAction(user_id, location_id).then((value){
|
||||
print("------${value}");
|
||||
if(value != null && value.length > 0){
|
||||
int locationId = currentFeature[0].properties!["location_id"] as int;
|
||||
ActionService.userAction(userId, locationId).then((value){
|
||||
print("------$value");
|
||||
if(value != null && value.isNotEmpty){
|
||||
currentAction.clear();
|
||||
currentAction.add(value);
|
||||
print("------${currentAction[0]}");
|
||||
}else{
|
||||
List<dynamic> initval = [{"user": user_id, "location": location_id, "wanttogo": false, "like": false, "checkin": false}];
|
||||
List<dynamic> initval = [{"user": userId, "location": locationId, "wanttogo": false, "like": false, "checkin": false}];
|
||||
currentAction.clear();
|
||||
currentAction.add(initval);
|
||||
}
|
||||
@ -632,15 +631,15 @@ void login(String email, String password, BuildContext context){
|
||||
|
||||
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){
|
||||
if(currentFeature.isNotEmpty){
|
||||
currentFeature.clear();
|
||||
}
|
||||
if(i >= locations[0].collection.length - 1 ){
|
||||
currentFeature.add(locations[0].collection[0] as GeoJsonFeature);
|
||||
currentFeature.add(locations[0].collection[0]);
|
||||
getAction();
|
||||
}
|
||||
else{
|
||||
currentFeature.add(locations[0].collection[i + 1] as GeoJsonFeature);
|
||||
currentFeature.add(locations[0].collection[i + 1]);
|
||||
getAction();
|
||||
}
|
||||
}
|
||||
@ -665,15 +664,15 @@ void login(String email, String password, BuildContext context){
|
||||
|
||||
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){
|
||||
if(currentFeature.isNotEmpty){
|
||||
currentFeature.clear();
|
||||
}
|
||||
if(i == 0 ){
|
||||
currentFeature.add(locations[0].collection[locations[0].collection.length -1] as GeoJsonFeature);
|
||||
currentFeature.add(locations[0].collection[locations[0].collection.length -1]);
|
||||
getAction();
|
||||
}
|
||||
else{
|
||||
currentFeature.add(locations[0].collection[i - 1] as GeoJsonFeature);
|
||||
currentFeature.add(locations[0].collection[i - 1]);
|
||||
getAction();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,13 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/drawer/drawer_page.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/maxtrix_service.dart';
|
||||
import 'package:rogapp/utils/database_helper.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';
|
||||
|
||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
|
||||
class IndexPage extends GetView<IndexController> {
|
||||
IndexPage({Key? key}) : super(key: key);
|
||||
@ -43,7 +36,7 @@ class IndexPage extends GetView<IndexController> {
|
||||
onPressed: (){
|
||||
destinationController.fixMapBound();
|
||||
},
|
||||
icon: Icon(Icons.refresh)
|
||||
icon: const Icon(Icons.refresh)
|
||||
),
|
||||
InkWell(
|
||||
onTap: (){
|
||||
@ -76,7 +69,7 @@ class IndexPage extends GetView<IndexController> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
|
||||
child: InkWell(
|
||||
child: Image(image: AssetImage('assets/images/route3_off.png'), width: 35, height: 35,),
|
||||
child: const Image(image: AssetImage('assets/images/route3_off.png'), width: 35, height: 35,),
|
||||
onTap: (){
|
||||
//indexController.switchPage(AppPages.TRAVEL);
|
||||
},
|
||||
@ -85,7 +78,7 @@ class IndexPage extends GetView<IndexController> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
|
||||
child: InkWell(
|
||||
child: Image(image: AssetImage('assets/images/route2_on.png'),width: 35, height: 35,),
|
||||
child: const Image(image: AssetImage('assets/images/route2_on.png'),width: 35, height: 35,),
|
||||
onTap: (){
|
||||
//indexController.switchPage(AppPages.TRAVEL);
|
||||
},
|
||||
@ -108,9 +101,9 @@ class IndexPage extends GetView<IndexController> {
|
||||
tooltip: 'Increment',
|
||||
child: Obx(() =>
|
||||
indexController.mode == 0 ?
|
||||
Image(image: AssetImage('assets/images/list2.png'))
|
||||
const Image(image: AssetImage('assets/images/list2.png'))
|
||||
:
|
||||
Image(image: AssetImage('assets/images/map.png')),
|
||||
const Image(image: AssetImage('assets/images/map.png')),
|
||||
),
|
||||
elevation: 4.0,
|
||||
),
|
||||
@ -168,7 +161,7 @@ class IndexPage extends GetView<IndexController> {
|
||||
child: Obx(() =>
|
||||
indexController.mode == 0 ?
|
||||
MapWidget() :
|
||||
ListWidget(),
|
||||
const ListWidget(),
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user