fixed state
This commit is contained in:
@ -9,6 +9,21 @@ import 'package:rogapp/utils/string_values.dart';
|
|||||||
import 'package:shared_preferences/shared_preferences.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 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 main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
@ -27,7 +42,6 @@ void main() async {
|
|||||||
key: 'behaviour',
|
key: 'behaviour',
|
||||||
value: 'cacheFirst',
|
value: 'cacheFirst',
|
||||||
);
|
);
|
||||||
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,20 +69,13 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveGameState() async {
|
// void saveGameState() async {
|
||||||
DestinationController destinationController = Get.find<DestinationController>();
|
// DestinationController destinationController = Get.find<DestinationController>();
|
||||||
SharedPreferences pref = await SharedPreferences.getInstance();
|
// SharedPreferences pref = await SharedPreferences.getInstance();
|
||||||
pref.setBool("is_in_rog", destinationController.is_in_rog.value);
|
// pref.setBool("is_in_rog", destinationController.is_in_rog.value);
|
||||||
pref.setBool("rogaining_counted", destinationController.rogaining_counted.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>();
|
DestinationController destinationController = Get.find<DestinationController>();
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:rogapp/main.dart';
|
||||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
|
|
||||||
class DestinationBinding extends Bindings {
|
class DestinationBinding extends Bindings {
|
||||||
@override
|
@override
|
||||||
void dependencies() {
|
void dependencies() {
|
||||||
Get.put<DestinationController>(DestinationController());
|
Get.put<DestinationController>(DestinationController());
|
||||||
|
restoreGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import 'package:geolocator/geolocator.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
|
import 'package:rogapp/main.dart';
|
||||||
import 'package:rogapp/model/destination.dart';
|
import 'package:rogapp/model/destination.dart';
|
||||||
import 'package:rogapp/pages/camera/camera_page.dart';
|
import 'package:rogapp/pages/camera/camera_page.dart';
|
||||||
import 'package:rogapp/pages/index/index_controller.dart';
|
import 'package:rogapp/pages/index/index_controller.dart';
|
||||||
@ -109,9 +110,10 @@ class DestinationController extends GetxController {
|
|||||||
|
|
||||||
void startTimerLocation(GeoJsonFeature fs, double distance) {
|
void startTimerLocation(GeoJsonFeature fs, double distance) {
|
||||||
print("---- in startTimer ----");
|
print("---- in startTimer ----");
|
||||||
|
print("---- is in rog is ${is_in_rog} ----");
|
||||||
//skip_gps = true;
|
//skip_gps = true;
|
||||||
double checkinRadious = fs.properties!['checkin_radius'] ?? double.infinity;
|
double checkinRadious = fs.properties!['checkin_radius'] ?? double.infinity;
|
||||||
if (checkinRadious >= distance) {
|
//if (checkinRadious >= distance) {
|
||||||
indexController.currentFeature.clear();
|
indexController.currentFeature.clear();
|
||||||
Destination d = festuretoDestination(fs);
|
Destination d = festuretoDestination(fs);
|
||||||
print("----- destination lenght is ${destinations.length} -----");
|
print("----- destination lenght is ${destinations.length} -----");
|
||||||
@ -124,7 +126,7 @@ class DestinationController extends GetxController {
|
|||||||
indexController.currentFeature.add(fs);
|
indexController.currentFeature.add(fs);
|
||||||
print("---- before calling startTimer ----");
|
print("---- before calling startTimer ----");
|
||||||
startTimer(d, distance);
|
startTimer(d, distance);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startTimer(Destination d, double distance) async {
|
void startTimer(Destination d, double distance) async {
|
||||||
@ -337,6 +339,8 @@ class DestinationController extends GetxController {
|
|||||||
is_gps_selected.value = true;
|
is_gps_selected.value = true;
|
||||||
skip_gps = false;
|
skip_gps = false;
|
||||||
|
|
||||||
|
saveGameState();
|
||||||
|
|
||||||
_start = 0;
|
_start = 0;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
rogaining_counted.value = false;
|
rogaining_counted.value = false;
|
||||||
@ -365,13 +369,16 @@ class DestinationController extends GetxController {
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => CameraCamera(
|
builder: (_) => CameraCamera(
|
||||||
|
resolutionPreset: ResolutionPreset.medium,
|
||||||
onFile: (file) {
|
onFile: (file) {
|
||||||
photos.add(file);
|
photos.add(file);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
print("----image file is : $file----");
|
print("----image file is : $file----");
|
||||||
//setState(() {});
|
//setState(() {});
|
||||||
},
|
},
|
||||||
)));
|
)
|
||||||
|
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void getRoutePoints() {
|
void getRoutePoints() {
|
||||||
@ -408,6 +415,7 @@ class DestinationController extends GetxController {
|
|||||||
} else {
|
} else {
|
||||||
print("--- hidden loc ${d.hidden_location} ----");
|
print("--- hidden loc ${d.hidden_location} ----");
|
||||||
// ask for checkin
|
// ask for checkin
|
||||||
|
print("is rog ---- ${is_in_rog.value} ----");
|
||||||
if (d.hidden_location != null &&
|
if (d.hidden_location != null &&
|
||||||
d.hidden_location == 0 &&
|
d.hidden_location == 0 &&
|
||||||
is_in_rog.value == true &&
|
is_in_rog.value == true &&
|
||||||
@ -425,7 +433,7 @@ class DestinationController extends GetxController {
|
|||||||
destination: d,
|
destination: d,
|
||||||
))).whenComplete(() {
|
))).whenComplete(() {
|
||||||
skip_gps = false;
|
skip_gps = false;
|
||||||
rogaining_counted.value = true;
|
//rogaining_counted.value = true;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
is_in_checkin.value = false;
|
is_in_checkin.value = false;
|
||||||
});
|
});
|
||||||
@ -497,6 +505,8 @@ class DestinationController extends GetxController {
|
|||||||
makeCheckin(df, true, "");
|
makeCheckin(df, true, "");
|
||||||
}
|
}
|
||||||
is_in_rog.value = true;
|
is_in_rog.value = true;
|
||||||
|
|
||||||
|
saveGameState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeCheckin(
|
void makeCheckin(
|
||||||
@ -514,7 +524,7 @@ class DestinationController extends GetxController {
|
|||||||
|
|
||||||
await GallerySaver.saveImage(imageurl);
|
await GallerySaver.saveImage(imageurl);
|
||||||
|
|
||||||
PopulateDestinations();
|
//PopulateDestinations();
|
||||||
|
|
||||||
/// post to NATNAT
|
/// post to NATNAT
|
||||||
if (indexController.currentUser.isNotEmpty) {
|
if (indexController.currentUser.isNotEmpty) {
|
||||||
@ -622,6 +632,8 @@ class DestinationController extends GetxController {
|
|||||||
// Start a new timer that fires every 3 seconds
|
// Start a new timer that fires every 3 seconds
|
||||||
_timer = Timer.periodic(Duration(seconds: 3), (timer) async {
|
_timer = Timer.periodic(Duration(seconds: 3), (timer) async {
|
||||||
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
||||||
|
current_lat = position.latitude;
|
||||||
|
current_lon = position.longitude;
|
||||||
|
|
||||||
if (is_gps_selected.value) {
|
if (is_gps_selected.value) {
|
||||||
double czoom = indexController.rogMapController.zoom;
|
double czoom = indexController.rogMapController.zoom;
|
||||||
|
|||||||
@ -65,8 +65,14 @@ class IndexPage extends GetView<IndexController> {
|
|||||||
),
|
),
|
||||||
bottomNavigationBar: BottomAppBar(
|
bottomNavigationBar: BottomAppBar(
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
Obx(() =>
|
||||||
|
destinationController.is_in_rog.value == true ?
|
||||||
|
IconButton(onPressed: (){}, icon: Icon(Icons.run_circle, size: 44, color: Colors.green,))
|
||||||
|
:
|
||||||
|
IconButton(onPressed: (){}, icon: Icon(Icons.run_circle, size: 44, color: Colors.black12,)),
|
||||||
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
|
const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
|
||||||
|
|||||||
@ -3,6 +3,8 @@ import 'package:geojson/geojson.dart';
|
|||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
import 'package:latlong2/latlong.dart';
|
||||||
|
import 'package:rogapp/main.dart';
|
||||||
import 'package:rogapp/model/destination.dart';
|
import 'package:rogapp/model/destination.dart';
|
||||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
import 'package:rogapp/pages/index/index_controller.dart';
|
import 'package:rogapp/pages/index/index_controller.dart';
|
||||||
@ -242,6 +244,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
destinationController.current_lon,
|
destinationController.current_lon,
|
||||||
indexController
|
indexController
|
||||||
.currentDestinationFeature[0].location_id!);
|
.currentDestinationFeature[0].location_id!);
|
||||||
|
saveGameState();
|
||||||
ExternalService()
|
ExternalService()
|
||||||
.StartRogaining()
|
.StartRogaining()
|
||||||
.then((value) => Get.back());
|
.then((value) => Get.back());
|
||||||
@ -368,6 +371,13 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
|
|
||||||
// show add location details
|
// show add location details
|
||||||
SingleChildScrollView detailsSheet(BuildContext context) {
|
SingleChildScrollView detailsSheet(BuildContext context) {
|
||||||
|
|
||||||
|
Destination _cdest = destinationController.festuretoDestination(
|
||||||
|
indexController.currentFeature[0]);
|
||||||
|
var distance = const Distance();
|
||||||
|
double _distance_to_dest = distance.as(LengthUnit.Meter, LatLng(destinationController.current_lat, destinationController.current_lon), LatLng(_cdest.lat!, _cdest.lon!));
|
||||||
|
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@ -445,6 +455,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
indexController
|
indexController
|
||||||
.currentDestinationFeature[0]
|
.currentDestinationFeature[0]
|
||||||
.location_id!);
|
.location_id!);
|
||||||
|
saveGameState();
|
||||||
ExternalService()
|
ExternalService()
|
||||||
.StartRogaining()
|
.StartRogaining()
|
||||||
.then((value) => Get.back());
|
.then((value) => Get.back());
|
||||||
@ -535,6 +546,10 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 10,
|
width: 10,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
|
// forced start / checkin
|
||||||
|
_distance_to_dest <= 100 ?
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
@ -550,6 +565,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
destinationController.current_lat,
|
destinationController.current_lat,
|
||||||
destinationController.current_lon,
|
destinationController.current_lon,
|
||||||
dd.location_id!);
|
dd.location_id!);
|
||||||
|
saveGameState();
|
||||||
ExternalService()
|
ExternalService()
|
||||||
.StartRogaining()
|
.StartRogaining()
|
||||||
.then((value) => Get.back());
|
.then((value) => Get.back());
|
||||||
@ -569,7 +585,10 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
.onSecondary))),
|
.onSecondary))):
|
||||||
|
|
||||||
|
Container()
|
||||||
|
,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
@ -69,7 +69,7 @@ dependencies:
|
|||||||
flutter_launcher_icons: ^0.13.1
|
flutter_launcher_icons: ^0.13.1
|
||||||
rename: ^2.0.1
|
rename: ^2.0.1
|
||||||
circular_menu: ^2.0.1
|
circular_menu: ^2.0.1
|
||||||
camera_camera: ^3.0.0-dev
|
camera_camera: ^3.0.0
|
||||||
intl: ^0.18.1
|
intl: ^0.18.1
|
||||||
modal_bottom_sheet: ^3.0.0-pre
|
modal_bottom_sheet: ^3.0.0-pre
|
||||||
connectivity_plus: ^4.0.2
|
connectivity_plus: ^4.0.2
|
||||||
@ -78,6 +78,7 @@ dependencies:
|
|||||||
gallery_saver: ^2.3.2
|
gallery_saver: ^2.3.2
|
||||||
flutter_riverpod: ^2.4.0
|
flutter_riverpod: ^2.4.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
flutter_icons:
|
flutter_icons:
|
||||||
android: true
|
android: true
|
||||||
|
|||||||
Reference in New Issue
Block a user