update status

This commit is contained in:
Mohamed Nouffer
2023-09-08 21:19:12 +05:30
parent 720dd149a9
commit 6f3249631f
8 changed files with 135 additions and 36 deletions

View File

@ -12,6 +12,8 @@ PODS:
- FMDB (2.7.5): - FMDB (2.7.5):
- FMDB/standard (= 2.7.5) - FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5) - FMDB/standard (2.7.5)
- gallery_saver (0.0.1):
- Flutter
- geolocator_apple (1.2.0): - geolocator_apple (1.2.0):
- Flutter - Flutter
- google_maps_flutter_ios (0.0.1): - google_maps_flutter_ios (0.0.1):
@ -47,6 +49,7 @@ DEPENDENCIES:
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- flutter_compass (from `.symlinks/plugins/flutter_compass/ios`) - flutter_compass (from `.symlinks/plugins/flutter_compass/ios`)
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- gallery_saver (from `.symlinks/plugins/gallery_saver/ios`)
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`) - geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`)
- google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`) - google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
@ -74,6 +77,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_compass/ios" :path: ".symlinks/plugins/flutter_compass/ios"
flutter_keyboard_visibility: flutter_keyboard_visibility:
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios" :path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
gallery_saver:
:path: ".symlinks/plugins/gallery_saver/ios"
geolocator_apple: geolocator_apple:
:path: ".symlinks/plugins/geolocator_apple/ios" :path: ".symlinks/plugins/geolocator_apple/ios"
google_maps_flutter_ios: google_maps_flutter_ios:
@ -100,6 +105,7 @@ SPEC CHECKSUMS:
flutter_compass: cbbd285cea1584c7ac9c4e0c3e1f17cbea55e855 flutter_compass: cbbd285cea1584c7ac9c4e0c3e1f17cbea55e855
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069 flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
gallery_saver: 9fc173c9f4fcc48af53b2a9ebea1b643255be542
geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401 geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401
google_maps_flutter_ios: abdac20d6ce8931f6ebc5f46616df241bfaa2cfd google_maps_flutter_ios: abdac20d6ce8931f6ebc5f46616df241bfaa2cfd
GoogleMaps: 025272d5876d3b32604e5c080dc25eaf68764693 GoogleMaps: 025272d5876d3b32604e5c080dc25eaf68764693

View File

@ -376,7 +376,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = D5SL68ATB9; DEVELOPMENT_TEAM = ECMVJVB7LV;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
@ -506,7 +506,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = D5SL68ATB9; DEVELOPMENT_TEAM = ECMVJVB7LV;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
@ -530,7 +530,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = D5SL68ATB9; DEVELOPMENT_TEAM = ECMVJVB7LV;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;

View File

@ -6,6 +6,7 @@ import 'package:rogapp/pages/index/index_binding.dart';
import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart'; import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/utils/string_values.dart'; import 'package:rogapp/utils/string_values.dart';
import 'package:shared_preferences/shared_preferences.dart';
// import 'package:is_lock_screen/is_lock_screen.dart'; // import 'package:is_lock_screen/is_lock_screen.dart';
void main() async { void main() async {
@ -54,11 +55,27 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
super.dispose(); super.dispose();
} }
void saveGameState() async {
DestinationController destinationController = Get.find<DestinationController>();
SharedPreferences pref = await SharedPreferences.getInstance();
pref.setBool("is_in_rog", destinationController.is_in_rog.value);
pref.setBool("rogaining_counted", destinationController.rogaining_counted.value);
}
void restoreGame() async{
SharedPreferences pref = await SharedPreferences.getInstance();
DestinationController destinationController = Get.find<DestinationController>();
destinationController.skip_gps = false;
destinationController.is_in_rog.value = pref.getBool("is_in_rog") ?? false;
destinationController.rogaining_counted.value = pref.getBool("rogaining_counted") ?? false;
}
void didChangeAppLifecycleState(AppLifecycleState state) { void didChangeAppLifecycleState(AppLifecycleState state) {
DestinationController destinationController = Get.find<DestinationController>();
switch (state) { switch (state) {
case AppLifecycleState.resumed: case AppLifecycleState.resumed:
print("RESUMED"); print("RESUMED");
DestinationController destinationController = Get.find<DestinationController>(); restoreGame();
if(destinationController.positionStream == null){ if(destinationController.positionStream == null){
destinationController.startGPSTimer(); destinationController.startGPSTimer();
} }
@ -68,12 +85,15 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
break; break;
case AppLifecycleState.paused: case AppLifecycleState.paused:
print("PAUSED"); print("PAUSED");
saveGameState();
break; break;
case AppLifecycleState.detached: case AppLifecycleState.detached:
print("DETACHED"); print("DETACHED");
saveGameState();
break; break;
case AppLifecycleState.hidden: case AppLifecycleState.hidden:
print("DETACHED"); print("DETACHED");
saveGameState();
break; break;
} }
} }

View File

@ -0,0 +1,18 @@
enum LocationState {
noGps,
notInCheckin,
withinCheckin
}
enum GameState {
notStarted,
startedNotCounted,
startedCounted,
nodeGoal
}
class GameInstanceState{
LocationState locationState = LocationState.noGps;
GameState gameState = GameState.notStarted;
}

View File

@ -114,12 +114,13 @@ class DestinationController extends GetxController {
if (checkinRadious >= distance) { if (checkinRadious >= distance) {
indexController.currentFeature.clear(); indexController.currentFeature.clear();
Destination d = festuretoDestination(fs); Destination d = festuretoDestination(fs);
for (Destination de in destinations) { print("----- destination lenght is ${destinations.length} -----");
if (de.location_id == d.location_id) { // for (Destination de in destinations) {
d = de; // if (de.location_id == d.location_id) {
break; // d = de;
} // break;
} // }
// }
indexController.currentFeature.add(fs); indexController.currentFeature.add(fs);
print("---- before calling startTimer ----"); print("---- before calling startTimer ----");
startTimer(d, distance); startTimer(d, distance);
@ -130,9 +131,13 @@ class DestinationController extends GetxController {
print("=== passed dest is ${d.location_id} ${d.checkedin} ===="); print("=== passed dest is ${d.location_id} ${d.checkedin} ====");
skip_gps = true; skip_gps = true;
print("---- in startTimer ----"); print("---- in startTimer ----");
DatabaseHelper db = DatabaseHelper.instance;
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
double checkinRadious = d.checkin_radious ?? double.infinity; double checkinRadious = d.checkin_radious ?? double.infinity;
bool autoCheckin = d.auto_checkin == 0 ? false : true; bool autoCheckin = d.auto_checkin == 0 ? false : true;
bool locationAlreadyCheckedIn = d.checkedin ?? false; bool locationAlreadyCheckedIn = ds.length > 0 && ds[0].checkedin == true ? true : false;
bool isuserLoggedIn = indexController.currentUser.isNotEmpty ? true : false; bool isuserLoggedIn = indexController.currentUser.isNotEmpty ? true : false;
//make current destination //make current destination
print("---- checkin_radious $checkinRadious ----"); print("---- checkin_radious $checkinRadious ----");
@ -165,8 +170,6 @@ class DestinationController extends GetxController {
return; return;
} }
DatabaseHelper db = DatabaseHelper.instance;
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
if (ds.isEmpty) { if (ds.isEmpty) {
print("----- in location popup cp - ${d.cp}----"); print("----- in location popup cp - ${d.cp}----");
if (d.cp == -1 && DateTime.now().difference(last_goal_at).inHours >= 24) { if (d.cp == -1 && DateTime.now().difference(last_goal_at).inHours >= 24) {
@ -435,32 +438,32 @@ class DestinationController extends GetxController {
void checkForCheckin(double la, double ln) { void checkForCheckin(double la, double ln) {
print("--- skip_gps ---- $skip_gps----"); print("--- skip_gps ---- $skip_gps----");
for (final d in destinations) { // for (final d in destinations) {
print("--- check checkin for--loc_id- ${d.sub_loc_id}----"); // print("--- check checkin for--loc_id- ${d.sub_loc_id}----");
double lat = d.lat!; // double lat = d.lat!;
double lon = d.lon!; // double lon = d.lon!;
LatLng p = LatLng(lat, lon); // LatLng p = LatLng(lat, lon);
getDestinationForLatLong(lat, lon).then((value) { // getDestinationForLatLong(lat, lon).then((value) {
var distance = const Distance(); // var distance = const Distance();
double dist = // double dist =
distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln)); // distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln));
//double checkin_radious = value!.checkin_radious ?? double.infinity; // //double checkin_radious = value!.checkin_radious ?? double.infinity;
//bool auto_checkin = value.auto_checkin == 0 ? false : true; // //bool auto_checkin = value.auto_checkin == 0 ? false : true;
//bool location_already_checked_id = d.checkedin ?? false; // //bool location_already_checked_id = d.checkedin ?? false;
// print("-----rogaining_counted---${rogaining_counted.value}-----"); // // print("-----rogaining_counted---${rogaining_counted.value}-----");
// print("-----is_in_rog---${is_in_rog}-----"); // // print("-----is_in_rog---${is_in_rog}-----");
// print("-----dist is ---${dist}-----"); // // print("-----dist is ---${dist}-----");
//print("----- ${indexController.currentUser} ----"); // //print("----- ${indexController.currentUser} ----");
if (dist <= 250 && skip_gps == false) { // if (dist <= 250 && skip_gps == false) {
//near a destination // //near a destination
print("---- time with ${d.location_id} ----"); // print("---- time with ${d.location_id} ----");
startTimer(d, dist); // startTimer(d, dist);
} // }
}); // });
} // }
if (indexController.locations.isEmpty) return; if (indexController.locations.isEmpty) return;

View File

@ -0,0 +1,27 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:rogapp/model/game_instance_state.dart';
final gameStateNotifierProvider = StateNotifierProvider<GameStaticState, GameInstanceState>((ref) {
return GameStaticState();
});
class GameStaticState extends StateNotifier<GameInstanceState>{
GameStaticState(): super(GameInstanceState());
@override
GameInstanceState get state => super.state;
void startGame(GameInstanceState gi){
state = gi;
}
void doCheckin(){
}
void makeGoal(){
}
}

View File

@ -414,6 +414,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
flutter_riverpod:
dependency: "direct main"
description:
name: flutter_riverpod
sha256: "1bd39b04f1bcd217a969589777ca6bd642d116e3e5de65c3e6a8e8bdd8b178ec"
url: "https://pub.dev"
source: hosted
version: "2.4.0"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -1080,6 +1088,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
riverpod:
dependency: transitive
description:
name: riverpod
sha256: a600120d6f213a9922860eea1abc32597436edd5b2c4e73b91410f8c2af67d22
url: "https://pub.dev"
source: hosted
version: "2.4.0"
sanitize_html: sanitize_html:
dependency: transitive dependency: transitive
description: description:
@ -1189,6 +1205,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.11.0" version: "1.11.0"
state_notifier:
dependency: transitive
description:
name: state_notifier
sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb
url: "https://pub.dev"
source: hosted
version: "1.0.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:

View File

@ -76,6 +76,7 @@ dependencies:
flutter_map_tile_caching: ^8.0.1 flutter_map_tile_caching: ^8.0.1
shared_preferences: ^2.0.15 shared_preferences: ^2.0.15
gallery_saver: ^2.3.2 gallery_saver: ^2.3.2
flutter_riverpod: ^2.4.0
flutter_icons: flutter_icons: