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

View File

@ -376,7 +376,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = D5SL68ATB9;
DEVELOPMENT_TEAM = ECMVJVB7LV;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
@ -506,7 +506,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = D5SL68ATB9;
DEVELOPMENT_TEAM = ECMVJVB7LV;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
@ -530,7 +530,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = D5SL68ATB9;
DEVELOPMENT_TEAM = ECMVJVB7LV;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
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/routes/app_pages.dart';
import 'package:rogapp/utils/string_values.dart';
import 'package:shared_preferences/shared_preferences.dart';
// import 'package:is_lock_screen/is_lock_screen.dart';
void main() async {
@ -54,11 +55,27 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
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) {
DestinationController destinationController = Get.find<DestinationController>();
switch (state) {
case AppLifecycleState.resumed:
print("RESUMED");
DestinationController destinationController = Get.find<DestinationController>();
restoreGame();
if(destinationController.positionStream == null){
destinationController.startGPSTimer();
}
@ -68,12 +85,15 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
break;
case AppLifecycleState.paused:
print("PAUSED");
saveGameState();
break;
case AppLifecycleState.detached:
print("DETACHED");
saveGameState();
break;
case AppLifecycleState.hidden:
print("DETACHED");
saveGameState();
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) {
indexController.currentFeature.clear();
Destination d = festuretoDestination(fs);
for (Destination de in destinations) {
if (de.location_id == d.location_id) {
d = de;
break;
}
}
print("----- destination lenght is ${destinations.length} -----");
// for (Destination de in destinations) {
// if (de.location_id == d.location_id) {
// d = de;
// break;
// }
// }
indexController.currentFeature.add(fs);
print("---- before calling startTimer ----");
startTimer(d, distance);
@ -130,9 +131,13 @@ class DestinationController extends GetxController {
print("=== passed dest is ${d.location_id} ${d.checkedin} ====");
skip_gps = true;
print("---- in startTimer ----");
DatabaseHelper db = DatabaseHelper.instance;
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
double checkinRadious = d.checkin_radious ?? double.infinity;
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;
//make current destination
print("---- checkin_radious $checkinRadious ----");
@ -165,8 +170,6 @@ class DestinationController extends GetxController {
return;
}
DatabaseHelper db = DatabaseHelper.instance;
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
if (ds.isEmpty) {
print("----- in location popup cp - ${d.cp}----");
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) {
print("--- skip_gps ---- $skip_gps----");
for (final d in destinations) {
print("--- check checkin for--loc_id- ${d.sub_loc_id}----");
// for (final d in destinations) {
// print("--- check checkin for--loc_id- ${d.sub_loc_id}----");
double lat = d.lat!;
double lon = d.lon!;
LatLng p = LatLng(lat, lon);
getDestinationForLatLong(lat, lon).then((value) {
var distance = const Distance();
double dist =
distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln));
//double checkin_radious = value!.checkin_radious ?? double.infinity;
//bool auto_checkin = value.auto_checkin == 0 ? false : true;
//bool location_already_checked_id = d.checkedin ?? false;
// double lat = d.lat!;
// double lon = d.lon!;
// LatLng p = LatLng(lat, lon);
// getDestinationForLatLong(lat, lon).then((value) {
// var distance = const Distance();
// double dist =
// distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln));
// //double checkin_radious = value!.checkin_radious ?? double.infinity;
// //bool auto_checkin = value.auto_checkin == 0 ? false : true;
// //bool location_already_checked_id = d.checkedin ?? false;
// print("-----rogaining_counted---${rogaining_counted.value}-----");
// print("-----is_in_rog---${is_in_rog}-----");
// print("-----dist is ---${dist}-----");
//print("----- ${indexController.currentUser} ----");
// // print("-----rogaining_counted---${rogaining_counted.value}-----");
// // print("-----is_in_rog---${is_in_rog}-----");
// // print("-----dist is ---${dist}-----");
// //print("----- ${indexController.currentUser} ----");
if (dist <= 250 && skip_gps == false) {
//near a destination
print("---- time with ${d.location_id} ----");
startTimer(d, dist);
}
});
}
// if (dist <= 250 && skip_gps == false) {
// //near a destination
// print("---- time with ${d.location_id} ----");
// startTimer(d, dist);
// }
// });
// }
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"
source: hosted
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:
dependency: "direct dev"
description: flutter
@ -1080,6 +1088,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.1"
riverpod:
dependency: transitive
description:
name: riverpod
sha256: a600120d6f213a9922860eea1abc32597436edd5b2c4e73b91410f8c2af67d22
url: "https://pub.dev"
source: hosted
version: "2.4.0"
sanitize_html:
dependency: transitive
description:
@ -1189,6 +1205,14 @@ packages:
url: "https://pub.dev"
source: hosted
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:
dependency: transitive
description:

View File

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