update for get listview update
This commit is contained in:
@ -21,6 +21,7 @@ class DestinationController extends GetxController {
|
||||
|
||||
late LocationSettings locationSettings;
|
||||
|
||||
var destinationCount = 0.obs;
|
||||
List<dynamic> destinations = <dynamic>[].obs;
|
||||
List<Map<String, dynamic>> destination_index_data = <Map<String, dynamic>>[].obs;
|
||||
|
||||
@ -101,58 +102,57 @@ class DestinationController extends GetxController {
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
PopulateDestinations();
|
||||
|
||||
print("------ in iniit");
|
||||
|
||||
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
locationSettings = AndroidSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
distanceFilter: 30,
|
||||
forceLocationManager: true,
|
||||
intervalDuration: const Duration(seconds: 10),
|
||||
//(Optional) Set foreground notification config to keep the app alive
|
||||
//when going to the background
|
||||
foregroundNotificationConfig: const ForegroundNotificationConfig(
|
||||
notificationText:
|
||||
"Example app will continue to receive your location even when you aren't using it",
|
||||
notificationTitle: "Running in Background",
|
||||
enableWakeLock: true,
|
||||
)
|
||||
);
|
||||
} else if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
locationSettings = AppleSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
activityType: ActivityType.fitness,
|
||||
distanceFilter: 1,
|
||||
pauseLocationUpdatesAutomatically: false,
|
||||
// Only set to true if our app will be started up in the background.
|
||||
showBackgroundLocationIndicator: true
|
||||
);
|
||||
} else {
|
||||
locationSettings = LocationSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
distanceFilter: 30,
|
||||
);
|
||||
}
|
||||
// if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
// locationSettings = AndroidSettings(
|
||||
// accuracy: LocationAccuracy.high,
|
||||
// distanceFilter: 30,
|
||||
// forceLocationManager: true,
|
||||
// intervalDuration: const Duration(seconds: 10),
|
||||
// //(Optional) Set foreground notification config to keep the app alive
|
||||
// //when going to the background
|
||||
// foregroundNotificationConfig: const ForegroundNotificationConfig(
|
||||
// notificationText:
|
||||
// "Example app will continue to receive your location even when you aren't using it",
|
||||
// notificationTitle: "Running in Background",
|
||||
// enableWakeLock: true,
|
||||
// )
|
||||
// );
|
||||
// } else if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
// locationSettings = AppleSettings(
|
||||
// accuracy: LocationAccuracy.high,
|
||||
// activityType: ActivityType.fitness,
|
||||
// distanceFilter: 1,
|
||||
// pauseLocationUpdatesAutomatically: false,
|
||||
// // Only set to true if our app will be started up in the background.
|
||||
// showBackgroundLocationIndicator: true
|
||||
// );
|
||||
// } else {
|
||||
// locationSettings = LocationSettings(
|
||||
// accuracy: LocationAccuracy.high,
|
||||
// distanceFilter: 30,
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
|
||||
(Position? position) {
|
||||
if(isSelected[0]){
|
||||
String user_id = indexController.currentUser[0]["user"]["id"].toString();
|
||||
TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){
|
||||
//checkForCheckin(position!.latitude, position.longitude);
|
||||
});
|
||||
// StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
|
||||
// (Position? position) {
|
||||
// if(isSelected[0]){
|
||||
// String user_id = indexController.currentUser[0]["user"]["id"].toString();
|
||||
// TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){
|
||||
// //checkForCheckin(position!.latitude, position.longitude);
|
||||
// });
|
||||
|
||||
}
|
||||
print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}');
|
||||
});
|
||||
// }
|
||||
// print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}');
|
||||
// });
|
||||
|
||||
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void deleteDestination(int index){
|
||||
@ -165,18 +165,20 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
|
||||
void PopulateDestinations(){
|
||||
print("--------- populsting destinations -----------");
|
||||
if(indexController.currentUser.isNotEmpty){
|
||||
int user_id = indexController.currentUser[0]["user"]["id"];
|
||||
print(user_id);
|
||||
DestinationService.getDestinations(user_id).then((value){
|
||||
destinations.clear();
|
||||
destinations = value;
|
||||
destinationCount.value = 0;
|
||||
destinationCount.value = destinations.length;
|
||||
|
||||
MatrixService.getDestinations(value).then((mat){
|
||||
print(mat);
|
||||
matrix = mat;
|
||||
|
||||
destinations.clear();
|
||||
destinations = value;
|
||||
|
||||
});
|
||||
|
||||
//var val = value[2]["location"]["id"];
|
||||
|
||||
@ -49,6 +49,7 @@ class _DestinationPageState extends State<DestinationPage> {
|
||||
@override
|
||||
void initState() {
|
||||
destinationController.context = context;
|
||||
destinationController.PopulateDestinations();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
@ -164,7 +164,15 @@ void login(String email, String password, BuildContext context){
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
}else{
|
||||
is_loading.value = false;
|
||||
Get.snackbar("Failed", "User login failed, please try again.");
|
||||
Get.snackbar(
|
||||
"Failed",
|
||||
"User login failed, please try again.",
|
||||
icon: Icon(Icons.error, size: 40.0, color: Colors.blue),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: Duration(milliseconds: 800),
|
||||
backgroundColor: Colors.yellow,
|
||||
//icon:Image(image:AssetImage("assets/images/dora.png"))
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
@ -181,7 +189,15 @@ void login(String email, String password, BuildContext context){
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
}else{
|
||||
is_loading.value = false;
|
||||
Get.snackbar("Failed", "User registration failed, please try again.");
|
||||
Get.snackbar(
|
||||
"Failed",
|
||||
"User registration failed, please try again.",
|
||||
icon: Icon(Icons.error, size: 40.0, color: Colors.blue),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: Duration(milliseconds: 800),
|
||||
backgroundColor: Colors.yellow,
|
||||
//icon:Image(image:AssetImage("assets/images/dora.png"))
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -331,6 +347,8 @@ void login(String email, String password, BuildContext context){
|
||||
void loadLocationsBound(){
|
||||
String cat = currentCat.isNotEmpty ? currentCat[0] : "";
|
||||
LatLngBounds bounds = mapController!.bounds!;
|
||||
currentBound.clear();
|
||||
currentBound.add(bounds);
|
||||
//print(currentCat);
|
||||
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != 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){
|
||||
@ -338,20 +356,21 @@ void login(String email, String password, BuildContext context){
|
||||
if(value == null){
|
||||
return;
|
||||
}
|
||||
locations.clear();
|
||||
if(value != null && value.collection.isEmpty){
|
||||
Get.snackbar(
|
||||
"Too many Points",
|
||||
"please zoom in",
|
||||
icon: Icon(Icons.person, color: Colors.white),
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
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"))
|
||||
);
|
||||
//Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",));
|
||||
}
|
||||
if(value != null && value.collection.isNotEmpty){
|
||||
//print("---- added---");
|
||||
locations.clear();
|
||||
locations.add(value);
|
||||
loadCatsv2();
|
||||
}
|
||||
|
||||
@ -89,7 +89,15 @@ class LoginPage extends StatelessWidget {
|
||||
height:60,
|
||||
onPressed: (){
|
||||
if(emailController.text.isEmpty || passwordController.text.isEmpty){
|
||||
Get.snackbar("No values", "Email and password required");
|
||||
Get.snackbar(
|
||||
"No values",
|
||||
"Email and password required",
|
||||
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;
|
||||
|
||||
@ -82,10 +82,26 @@ class RegisterPage extends StatelessWidget {
|
||||
height:60,
|
||||
onPressed: (){
|
||||
if(passwordController.text != confirmPasswordController.text){
|
||||
Get.snackbar("No match", "Passwords does not match");
|
||||
Get.snackbar(
|
||||
"No match",
|
||||
"Passwords does not match",
|
||||
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"))
|
||||
);
|
||||
}
|
||||
if(emailController.text.isEmpty || passwordController.text.isEmpty){
|
||||
Get.snackbar("No values", "Email and password required");
|
||||
Get.snackbar(
|
||||
"No values",
|
||||
"Email and password required",
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user