不明
This commit is contained in:
@ -11,6 +11,7 @@ import 'package:rogapp/pages/settings/settings_controller.dart';
|
||||
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
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/location_controller.dart';
|
||||
import 'package:rogapp/utils/string_values.dart';
|
||||
@ -25,6 +26,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
Map<String, dynamic> deviceInfo = {};
|
||||
|
||||
/*
|
||||
void saveGameState() async {
|
||||
DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
@ -34,7 +36,22 @@ void saveGameState() async {
|
||||
"rogaining_counted", destinationController.rogainingCounted.value);
|
||||
pref.setBool("ready_for_goal", DestinationController.ready_for_goal);
|
||||
}
|
||||
*/
|
||||
|
||||
// 現在のユーザーのIDも一緒に保存するようにします。
|
||||
void saveGameState() async {
|
||||
DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
IndexController indexController = Get.find<IndexController>();
|
||||
SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
pref.setInt("user_id", indexController.currentUser[0]["user"]["id"]);
|
||||
pref.setBool("is_in_rog", destinationController.isInRog.value);
|
||||
pref.setBool(
|
||||
"rogaining_counted", destinationController.rogainingCounted.value);
|
||||
pref.setBool("ready_for_goal", DestinationController.ready_for_goal);
|
||||
}
|
||||
|
||||
/*
|
||||
void restoreGame() async {
|
||||
SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
DestinationController destinationController =
|
||||
@ -48,6 +65,24 @@ void restoreGame() async {
|
||||
//print(
|
||||
// "--restored -- destinationController.isInRog.value ${pref.getBool("is_in_rog")} -- ${pref.getBool("rogaining_counted")}");
|
||||
}
|
||||
*/
|
||||
|
||||
void restoreGame() async {
|
||||
SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
IndexController indexController = Get.find<IndexController>();
|
||||
int? savedUserId = pref.getInt("user_id");
|
||||
if (indexController.currentUser.isNotEmpty &&
|
||||
indexController.currentUser[0]["user"]["id"] == savedUserId) {
|
||||
DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
destinationController.skipGps = false;
|
||||
destinationController.isInRog.value = pref.getBool("is_in_rog") ?? false;
|
||||
destinationController.rogainingCounted.value =
|
||||
pref.getBool("rogaining_counted") ?? false;
|
||||
DestinationController.ready_for_goal =
|
||||
pref.getBool("ready_for_goal") ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
Reference in New Issue
Block a user