fixed issues for release

This commit is contained in:
2023-11-21 22:43:28 +05:30
parent acc03f8e2b
commit 8a1e5b1ca8
5 changed files with 324 additions and 276 deletions

View File

@ -25,6 +25,8 @@ void restoreGame() async {
destinationController.isInRog.value = pref.getBool("is_in_rog") ?? false; destinationController.isInRog.value = pref.getBool("is_in_rog") ?? false;
destinationController.rogainingCounted.value = destinationController.rogainingCounted.value =
pref.getBool("rogaining_counted") ?? false; pref.getBool("rogaining_counted") ?? false;
print(
"--restored -- destinationController.isInRog.value ${pref.getBool("is_in_rog")} -- ${pref.getBool("rogaining_counted")}");
} }
void main() async { void main() async {
@ -61,6 +63,9 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
if (context.mounted) {
restoreGame();
}
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
} }
@ -83,22 +88,22 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
Get.find<DestinationController>(); Get.find<DestinationController>();
switch (state) { switch (state) {
case AppLifecycleState.resumed: case AppLifecycleState.resumed:
//print("RESUMED"); print("RESUMED");
restoreGame(); restoreGame();
break; break;
case AppLifecycleState.inactive: case AppLifecycleState.inactive:
//print("INACTIVE"); print("INACTIVE");
break; break;
case AppLifecycleState.paused: case AppLifecycleState.paused:
//print("PAUSED"); print("PAUSED");
saveGameState(); saveGameState();
break; break;
case AppLifecycleState.detached: case AppLifecycleState.detached:
//print("DETACHED"); print("DETACHED");
saveGameState(); saveGameState();
break; break;
case AppLifecycleState.hidden: case AppLifecycleState.hidden:
//print("DETACHED"); print("DETACHED");
saveGameState(); saveGameState();
break; break;
} }

View File

@ -675,13 +675,13 @@ class DestinationController extends GetxController {
Destination des = festuretoDestination(gfs); Destination des = festuretoDestination(gfs);
//print("=== gfs == ${des.toMap()}"); print("=== gfs == ${des.toMap()}");
double distanceToDest = double.infinity; double distanceToDest = double.infinity;
var distance = const Distance(); var distance = const Distance();
distanceToDest = distance.as(LengthUnit.Meter, distanceToDest = distance.as(LengthUnit.Meter,
LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!)); LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!));
//print("==== dist==${distanceToDest}"); print("==== dist==${distanceToDest}");
return distanceToDest; return distanceToDest;
} }
@ -936,6 +936,9 @@ class DestinationController extends GetxController {
//print("-----populated----- ${d.toMap()}"); //print("-----populated----- ${d.toMap()}");
destinations.add(d); destinations.add(d);
} }
if (destinations.isEmpty) {
rogainingCounted.value = false;
}
// destinationCount.value = 0; // destinationCount.value = 0;
//print( //print(
// "------ destination controller destinationcount-------- $destinationCount-------- :::::"); // "------ destination controller destinationcount-------- $destinationCount-------- :::::");

View File

@ -1,5 +1,5 @@
import 'dart:ffi'; import 'dart:ffi';
import 'dart:ui' as ui;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geojson/geojson.dart'; import 'package:geojson/geojson.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
@ -8,6 +8,7 @@ import 'package:image_picker/image_picker.dart';
import 'package:latlong2/latlong.dart'; import 'package:latlong2/latlong.dart';
import 'package:rogapp/main.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/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';
import 'package:rogapp/routes/app_pages.dart'; import 'package:rogapp/routes/app_pages.dart';
@ -16,15 +17,19 @@ import 'package:rogapp/utils/const.dart';
import 'package:rogapp/utils/database_helper.dart'; import 'package:rogapp/utils/database_helper.dart';
import 'package:rogapp/utils/text_util.dart'; import 'package:rogapp/utils/text_util.dart';
import 'package:rogapp/widgets/bottom_sheet_controller.dart'; import 'package:rogapp/widgets/bottom_sheet_controller.dart';
import 'package:sqflite/sqflite.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class BottomSheetNew extends GetView<BottomSheetController> { class BottomSheetNew extends GetView<BottomSheetController> {
BottomSheetNew({Key? key, required this.destination}) : super(key: key); BottomSheetNew(
{this.isAlreadyCheckedIn = false, Key? key, required this.destination})
: super(key: key);
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = final DestinationController destinationController =
Get.find<DestinationController>(); Get.find<DestinationController>();
Destination destination; final Destination destination;
final bool isAlreadyCheckedIn;
Image getImage() { Image getImage() {
String serverUrl = ConstValues.currentServer(); String serverUrl = ConstValues.currentServer();
@ -116,258 +121,265 @@ class BottomSheetNew extends GetView<BottomSheetController> {
} }
// Show destination detais // Show destination detais
SingleChildScrollView destinationSheet(BuildContext context) { // SingleChildScrollView destinationSheet(BuildContext context) {
// print( // // print(
// '---- currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} -----'); // // '---- currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} -----');
return SingleChildScrollView( // return SingleChildScrollView(
child: Column( // child: Column(
children: [ // children: [
Padding( // Padding(
padding: const EdgeInsets.all(8.0), // padding: const EdgeInsets.all(8.0),
child: Row( // child: Row(
children: [ // children: [
MaterialButton( // MaterialButton(
onPressed: () { // onPressed: () {
Get.back(); // Get.back();
//destinationController.makePrevious(indexController.currentDestinationFeature[0]); // //destinationController.makePrevious(indexController.currentDestinationFeature[0]);
}, // },
color: Colors.blue, // color: Colors.blue,
textColor: Colors.white, // textColor: Colors.white,
padding: const EdgeInsets.all(16), // padding: const EdgeInsets.all(16),
shape: const CircleBorder(), // shape: const CircleBorder(),
child: const Icon( // child: const Icon(
Icons.arrow_back_ios, // Icons.arrow_back_ios,
size: 14, // size: 14,
), // ),
), // ),
Expanded( // Expanded(
child: Container( // child: Container(
alignment: Alignment.center, // alignment: Alignment.center,
child: Obx(() => indexController.currentUser.isNotEmpty // child: Obx(() => indexController.currentUser.isNotEmpty
? Text( // ? Text(
"${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${indexController.currentDestinationFeature[0].name!}", // "${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${indexController.currentDestinationFeature[0].name!}",
style: const TextStyle( // style: const TextStyle(
fontSize: 15.0, // fontSize: 15.0,
fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
), // ),
) // )
: Text( // : Text(
indexController.currentDestinationFeature[0].name!, // indexController.currentDestinationFeature[0].name!,
style: const TextStyle( // style: const TextStyle(
fontSize: 15.0, // fontSize: 15.0,
fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
), // ),
)), // )),
), // ),
), // ),
], // ],
), // ),
), // ),
Row( // Row(
children: [ // children: [
Expanded( // Expanded(
child: SizedBox( // child: SizedBox(
height: 260.0, // height: 260.0,
child: Obx(() => getImage()), // child: Obx(() => getImage()),
)), // )),
], // ],
), // ),
Row( // Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, // mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ // children: [
Obx( // Obx(
() => indexController.currentDestinationFeature.isNotEmpty && // () => indexController.currentDestinationFeature.isNotEmpty &&
destinationController.isInCheckin.value == true && // destinationController.isInCheckin.value == true &&
destinationController.isAtStart.value == false // destinationController.isAtStart.value == false
? Row( // ? Row(
children: [ // children: [
ElevatedButton( // ElevatedButton(
onPressed: () { // onPressed: () {
if (indexController.currentDestinationFeature[0] // if (indexController.currentDestinationFeature[0]
.checkedin == // .checkedin ==
null || // null ||
indexController.currentDestinationFeature[0] // indexController.currentDestinationFeature[0]
.checkedin == // .checkedin ==
false) { // false) {
if (indexController // if (indexController
.currentDestinationFeature[0] // .currentDestinationFeature[0]
.hidden_location == // .hidden_location ==
0) { // 0) {
destinationController.skipGps = false; // destinationController.skipGps = false;
destinationController.isPhotoShoot.value = // destinationController.isPhotoShoot.value =
true; // true;
Get.back(); // Get.back();
} else { // } else {
destinationController.makeCheckin( // destinationController.makeCheckin(
indexController // indexController
.currentDestinationFeature[0], // .currentDestinationFeature[0],
true, // true,
""); // "");
if (indexController // if (indexController
.currentDestinationFeature[0].cp != // .currentDestinationFeature[0].cp !=
-1) { // -1) {
destinationController // destinationController
.rogainingCounted.value = true; // .rogainingCounted.value = true;
} // }
} // }
} else { // } else {
destinationController.makeCheckin( // destinationController.makeCheckin(
indexController // indexController
.currentDestinationFeature[0], // .currentDestinationFeature[0],
false, // false,
""); // "");
} // }
//Get.back(); // //Get.back();
}, // },
child: Text( // child: Text(
//Checkin // //Checkin
indexController.currentDestinationFeature[0] // indexController.currentDestinationFeature[0]
.checkedin == // .checkedin ==
null || // null ||
indexController // indexController
.currentDestinationFeature[0] // .currentDestinationFeature[0]
.checkedin == // .checkedin ==
false // false
? "チェックイン" // ? "チェックイン"
: "チェックアウト")), // : "チェックアウト")),
], // ],
) // )
: Container(), // : Container(),
), // ),
Obx( // Obx(
() => destinationController.isAtStart.value == true // () => destinationController.isAtStart.value == true
? ElevatedButton( // ? ElevatedButton(
onPressed: () { // onPressed: () {
destinationController.isInRog.value = true; // destinationController.isInRog.value = true;
destinationController.addToRogaining( // destinationController.addToRogaining(
destinationController.currentLat, // destinationController.currentLat,
destinationController.currentLon, // destinationController.currentLon,
indexController // indexController
.currentDestinationFeature[0].location_id!); // .currentDestinationFeature[0].location_id!);
saveGameState(); // saveGameState();
ExternalService() // ExternalService()
.startRogaining() // .startRogaining()
.then((value) => Get.back()); // .then((value) => Get.back());
}, // },
child: Text( // child: Text(
// start // // start
indexController.currentDestinationFeature[0] // indexController.currentDestinationFeature[0]
.checkedin != // .checkedin !=
null || // null ||
indexController.currentDestinationFeature[0] // indexController.currentDestinationFeature[0]
.checkedin == // .checkedin ==
true // true
? "ロゲイニングを開始" // ? "ロゲイニングを開始"
: "間違った目的地...")) // : "間違った目的地..."))
: Container(), // : Container(),
), // ),
Obx( // Obx(
() => destinationController.isAtGoal.value == true && // () => destinationController.isAtGoal.value == true &&
destinationController.rogainingCounted.value == true // destinationController.rogainingCounted.value == true
? ElevatedButton( // ? ElevatedButton(
onPressed: () { // onPressed: () {
Get.toNamed(AppPages.CAMERA_PAGE); // Get.toNamed(AppPages.CAMERA_PAGE);
Get.back(); // Get.back();
}, // },
child: Text( // child: Text(
//goal // //goal
indexController.currentDestinationFeature[0] // indexController.currentDestinationFeature[0]
.checkedin != // .checkedin !=
null || // null ||
indexController.currentDestinationFeature[0] // indexController.currentDestinationFeature[0]
.checkedin == // .checkedin ==
true // true
? "ロゲイニングを終える" // ? "ロゲイニングを終える"
: "間違った目的地 ...")) // : "間違った目的地 ..."))
: Container(), // : Container(),
), // ),
], // ],
), // ),
Obx( // Obx(
() => indexController.currentDestinationFeature[0].address != // () => indexController.currentDestinationFeature[0].address !=
null && // null &&
indexController // indexController
.currentDestinationFeature[0].address!.isNotEmpty // .currentDestinationFeature[0].address!.isNotEmpty
? getDetails(context, "address".tr, // ? getDetails(context, "address".tr,
indexController.currentDestinationFeature[0].address! ?? '') // indexController.currentDestinationFeature[0].address! ?? '')
: const SizedBox( // : const SizedBox(
width: 0.0, // width: 0.0,
height: 0, // height: 0,
), // ),
), // ),
Obx( // Obx(
() => indexController.currentDestinationFeature[0].phone != null && // () => indexController.currentDestinationFeature[0].phone != null &&
indexController // indexController
.currentDestinationFeature[0].phone!.isNotEmpty // .currentDestinationFeature[0].phone!.isNotEmpty
? getDetails(context, "telephone".tr, // ? getDetails(context, "telephone".tr,
indexController.currentDestinationFeature[0].phone! ?? '') // indexController.currentDestinationFeature[0].phone! ?? '')
: const SizedBox( // : const SizedBox(
width: 0.0, // width: 0.0,
height: 0, // height: 0,
), // ),
), // ),
Obx( // Obx(
() => indexController.currentDestinationFeature[0].email != null && // () => indexController.currentDestinationFeature[0].email != null &&
indexController // indexController
.currentDestinationFeature[0].email!.isNotEmpty // .currentDestinationFeature[0].email!.isNotEmpty
? getDetails(context, "email".tr, // ? getDetails(context, "email".tr,
indexController.currentDestinationFeature[0].email! ?? '') // indexController.currentDestinationFeature[0].email! ?? '')
: const SizedBox( // : const SizedBox(
width: 0.0, // width: 0.0,
height: 0, // height: 0,
), // ),
), // ),
Obx( // Obx(
() => indexController.currentDestinationFeature[0].webcontents != // () => indexController.currentDestinationFeature[0].webcontents !=
null && // null &&
indexController // indexController
.currentDestinationFeature[0].webcontents!.isNotEmpty // .currentDestinationFeature[0].webcontents!.isNotEmpty
? getDetails( // ? getDetails(
context, // context,
"web".tr, // "web".tr,
indexController.currentDestinationFeature[0].webcontents! ?? // indexController.currentDestinationFeature[0].webcontents! ??
'', // '',
isurl: true) // isurl: true)
: const SizedBox( // : const SizedBox(
width: 0.0, // width: 0.0,
height: 0, // height: 0,
), // ),
), // ),
Obx( // Obx(
() => indexController.currentDestinationFeature[0].videos != null && // () => indexController.currentDestinationFeature[0].videos != null &&
indexController // indexController
.currentDestinationFeature[0].videos!.isNotEmpty // .currentDestinationFeature[0].videos!.isNotEmpty
? getDetails(context, "video".tr, // ? getDetails(context, "video".tr,
indexController.currentDestinationFeature[0].videos! ?? '', // indexController.currentDestinationFeature[0].videos! ?? '',
isurl: true) // isurl: true)
: const SizedBox( // : const SizedBox(
width: 0.0, // width: 0.0,
height: 0, // height: 0,
), // ),
), // ),
const SizedBox( // const SizedBox(
height: 20.0, // height: 20.0,
), // ),
// Obx(() => // // Obx(() =>
// //wantToGo(context), // // //wantToGo(context),
// FutureBuilder<Widget>( // // FutureBuilder<Widget>(
// future: wantToGo(context), // // future: wantToGo(context),
// builder: (context, snapshot) { // // builder: (context, snapshot) {
// return Container( // // return Container(
// child: snapshot.data, // // child: snapshot.data,
// ); // // );
// }, // // },
// ), // // ),
// ), // // ),
const SizedBox( // const SizedBox(
height: 60.0, // height: 60.0,
) // )
], // ],
), // ),
); // );
// }
Future<bool> isDestinationCheckedIn(Destination d) async {
DatabaseHelper db = DatabaseHelper.instance;
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
return ds.isNotEmpty;
} }
// show add location details // show add location details
@ -486,12 +498,35 @@ class BottomSheetNew extends GetView<BottomSheetController> {
destination.cp == -1 && destination.cp == -1 &&
destinationController.distanceToStart() <= 500 destinationController.distanceToStart() <= 500
? ElevatedButton( ? ElevatedButton(
onPressed: () { onPressed: () async {
Get.toNamed(AppPages.CAMERA_PAGE); destinationController.isAtGoal.value = true;
Get.back(); destinationController.photos.clear();
await showModalBottomSheet(
constraints: BoxConstraints.loose(ui.Size(
Get.width, Get.height * 0.75)),
context: Get.context!,
isScrollControlled: true,
builder: ((context) => CameraPage(
destination: destination,
))).whenComplete(() {
destinationController.skipGps = false;
destinationController.chekcs = 0;
destinationController.isAtGoal.value =
false;
});
}, },
child: Text("ロゲイニングを終える")) child: Text("ロゲイニングを終える"))
: Container(), : Container(),
//remove checkin
isAlreadyCheckedIn == true && destination.cp != -1
? ElevatedButton(
onPressed: () async {
destinationController
.deleteDestination(destination);
Get.back();
},
child: const Text("チェックイン取消"))
: Container(),
// Obx( // Obx(
// () => destinationController.rogainingCounted.value == // () => destinationController.rogainingCounted.value ==
@ -568,6 +603,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
distanceToDest <= distanceToDest <=
destinationController destinationController
.getForcedChckinDistance(destination) && .getForcedChckinDistance(destination) &&
destinationController.isInRog.value == false &&
// destinationController.isInCheckin.value == // destinationController.isInCheckin.value ==
// true && // true &&
destinationController.rogainingCounted.value == destinationController.rogainingCounted.value ==
@ -607,7 +643,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
color: Theme.of(context) color: Theme.of(context)
.colorScheme .colorScheme
.onSecondary))) .onSecondary)))
: Container(), : ElevatedButton(
onPressed: () {}, child: const Text("ゲーム中")),
], ],
), ),
Row( Row(

View File

@ -10,6 +10,7 @@ import 'package:latlong2/latlong.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';
import 'package:rogapp/utils/database_helper.dart';
import 'package:rogapp/utils/text_util.dart'; import 'package:rogapp/utils/text_util.dart';
import 'package:rogapp/widgets/base_layer_widget.dart'; import 'package:rogapp/widgets/base_layer_widget.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart';
@ -43,18 +44,20 @@ class MapWidget extends StatelessWidget {
Destination des = destinationController.festuretoDestination(fs); Destination des = destinationController.festuretoDestination(fs);
showModalBottomSheet( DatabaseHelper db = DatabaseHelper.instance;
constraints: db.getDestinationByLatLon(des.lat!, des.lon!).then((value) {
BoxConstraints.loose(Size(Get.width, Get.height * 0.85)), showModalBottomSheet(
context: context, constraints: BoxConstraints.loose(
isScrollControlled: true, Size(Get.width, Get.height * 0.85)),
isDismissible: true, context: context,
builder: ((context) => BottomSheetNew( isScrollControlled: true,
destination: des, isDismissible: true,
)) builder: ((context) => BottomSheetNew(
//builder:((context) => BottomSheetWidget()) destination: des, isAlreadyCheckedIn: value.isNotEmpty))
).whenComplete(() { //builder:((context) => BottomSheetWidget())
destinationController.skipGps = false; ).whenComplete(() {
destinationController.skipGps = false;
});
}); });
} }
}, },

View File

@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.24+24 version: 1.0.25+25
environment: environment:
sdk: ">=3.1.0 <4.0.0" sdk: ">=3.1.0 <4.0.0"