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,
textColor: Colors.white,
padding: const EdgeInsets.all(16),
shape: const CircleBorder(),
child: const Icon(
Icons.arrow_back_ios,
size: 14,
),
),
Expanded(
child: Container(
alignment: Alignment.center,
child: Obx(() => indexController.currentUser.isNotEmpty
? Text(
"${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${indexController.currentDestinationFeature[0].name!}",
style: const TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
)
: Text(
indexController.currentDestinationFeature[0].name!,
style: const TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
)),
),
),
],
),
),
Row(
children: [
Expanded(
child: SizedBox(
height: 260.0,
child: Obx(() => getImage()),
)),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Obx(
() => indexController.currentDestinationFeature.isNotEmpty &&
destinationController.isInCheckin.value == true &&
destinationController.isAtStart.value == false
? Row(
children: [
ElevatedButton(
onPressed: () {
if (indexController.currentDestinationFeature[0]
.checkedin ==
null ||
indexController.currentDestinationFeature[0]
.checkedin ==
false) {
if (indexController
.currentDestinationFeature[0]
.hidden_location ==
0) {
destinationController.skipGps = false;
destinationController.isPhotoShoot.value =
true;
Get.back();
} else {
destinationController.makeCheckin(
indexController
.currentDestinationFeature[0],
true,
"");
if (indexController
.currentDestinationFeature[0].cp !=
-1) {
destinationController
.rogainingCounted.value = true;
}
}
} else {
destinationController.makeCheckin(
indexController
.currentDestinationFeature[0],
false,
"");
}
//Get.back();
},
child: Text(
//Checkin
indexController.currentDestinationFeature[0]
.checkedin ==
null ||
indexController
.currentDestinationFeature[0]
.checkedin ==
false
? "チェックイン"
: "チェックアウト")),
],
)
: Container(),
),
Obx(
() => destinationController.isAtStart.value == true
? ElevatedButton(
onPressed: () {
destinationController.isInRog.value = true;
destinationController.addToRogaining(
destinationController.currentLat,
destinationController.currentLon,
indexController
.currentDestinationFeature[0].location_id!);
saveGameState();
ExternalService()
.startRogaining()
.then((value) => Get.back());
},
child: Text(
// start
indexController.currentDestinationFeature[0]
.checkedin !=
null ||
indexController.currentDestinationFeature[0]
.checkedin ==
true
? "ロゲイニングを開始"
: "間違った目的地..."))
: Container(),
),
Obx(
() => destinationController.isAtGoal.value == true &&
destinationController.rogainingCounted.value == true
? ElevatedButton(
onPressed: () {
Get.toNamed(AppPages.CAMERA_PAGE);
Get.back();
},
child: Text(
//goal
indexController.currentDestinationFeature[0]
.checkedin !=
null ||
indexController.currentDestinationFeature[0]
.checkedin ==
true
? "ロゲイニングを終える"
: "間違った目的地 ..."))
: Container(),
),
],
),
Obx(
() => indexController.currentDestinationFeature[0].address !=
null &&
indexController
.currentDestinationFeature[0].address!.isNotEmpty
? getDetails(context, "address".tr,
indexController.currentDestinationFeature[0].address! ?? '')
: const SizedBox(
width: 0.0,
height: 0,
),
),
Obx(
() => indexController.currentDestinationFeature[0].phone != null &&
indexController
.currentDestinationFeature[0].phone!.isNotEmpty
? getDetails(context, "telephone".tr,
indexController.currentDestinationFeature[0].phone! ?? '')
: const SizedBox(
width: 0.0,
height: 0,
),
),
Obx(
() => indexController.currentDestinationFeature[0].email != null &&
indexController
.currentDestinationFeature[0].email!.isNotEmpty
? getDetails(context, "email".tr,
indexController.currentDestinationFeature[0].email! ?? '')
: const SizedBox(
width: 0.0,
height: 0,
),
),
Obx(
() => indexController.currentDestinationFeature[0].webcontents !=
null &&
indexController
.currentDestinationFeature[0].webcontents!.isNotEmpty
? getDetails(
context,
"web".tr,
indexController.currentDestinationFeature[0].webcontents! ??
'',
isurl: true)
: const SizedBox(
width: 0.0,
height: 0,
),
),
Obx(
() => indexController.currentDestinationFeature[0].videos != null &&
indexController
.currentDestinationFeature[0].videos!.isNotEmpty
? getDetails(context, "video".tr,
indexController.currentDestinationFeature[0].videos! ?? '',
isurl: true)
: const SizedBox(
width: 0.0,
height: 0,
),
),
const SizedBox(
height: 20.0,
),
// Obx(() =>
// //wantToGo(context),
// FutureBuilder<Widget>(
// future: wantToGo(context),
// builder: (context, snapshot) {
// return Container(
// child: snapshot.data,
// );
// }, // },
// color: Colors.blue,
// textColor: Colors.white,
// padding: const EdgeInsets.all(16),
// shape: const CircleBorder(),
// child: const Icon(
// Icons.arrow_back_ios,
// size: 14,
// ), // ),
// ),
// Expanded(
// child: Container(
// alignment: Alignment.center,
// child: Obx(() => indexController.currentUser.isNotEmpty
// ? Text(
// "${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${indexController.currentDestinationFeature[0].name!}",
// style: const TextStyle(
// fontSize: 15.0,
// fontWeight: FontWeight.bold,
// ),
// )
// : Text(
// indexController.currentDestinationFeature[0].name!,
// style: const TextStyle(
// fontSize: 15.0,
// fontWeight: FontWeight.bold,
// ),
// )),
// ),
// ),
// ],
// ),
// ),
// Row(
// children: [
// Expanded(
// child: SizedBox(
// height: 260.0,
// child: Obx(() => getImage()),
// )),
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// children: [
// Obx(
// () => indexController.currentDestinationFeature.isNotEmpty &&
// destinationController.isInCheckin.value == true &&
// destinationController.isAtStart.value == false
// ? Row(
// children: [
// ElevatedButton(
// onPressed: () {
// if (indexController.currentDestinationFeature[0]
// .checkedin ==
// null ||
// indexController.currentDestinationFeature[0]
// .checkedin ==
// false) {
// if (indexController
// .currentDestinationFeature[0]
// .hidden_location ==
// 0) {
// destinationController.skipGps = false;
// destinationController.isPhotoShoot.value =
// true;
// Get.back();
// } else {
// destinationController.makeCheckin(
// indexController
// .currentDestinationFeature[0],
// true,
// "");
// if (indexController
// .currentDestinationFeature[0].cp !=
// -1) {
// destinationController
// .rogainingCounted.value = true;
// }
// }
// } else {
// destinationController.makeCheckin(
// indexController
// .currentDestinationFeature[0],
// false,
// "");
// }
// //Get.back();
// },
// child: Text(
// //Checkin
// indexController.currentDestinationFeature[0]
// .checkedin ==
// null ||
// indexController
// .currentDestinationFeature[0]
// .checkedin ==
// false
// ? "チェックイン"
// : "チェックアウト")),
// ],
// )
// : Container(),
// ),
// Obx(
// () => destinationController.isAtStart.value == true
// ? ElevatedButton(
// onPressed: () {
// destinationController.isInRog.value = true;
// destinationController.addToRogaining(
// destinationController.currentLat,
// destinationController.currentLon,
// indexController
// .currentDestinationFeature[0].location_id!);
// saveGameState();
// ExternalService()
// .startRogaining()
// .then((value) => Get.back());
// },
// child: Text(
// // start
// indexController.currentDestinationFeature[0]
// .checkedin !=
// null ||
// indexController.currentDestinationFeature[0]
// .checkedin ==
// true
// ? "ロゲイニングを開始"
// : "間違った目的地..."))
// : Container(),
// ),
// Obx(
// () => destinationController.isAtGoal.value == true &&
// destinationController.rogainingCounted.value == true
// ? ElevatedButton(
// onPressed: () {
// Get.toNamed(AppPages.CAMERA_PAGE);
// Get.back();
// },
// child: Text(
// //goal
// indexController.currentDestinationFeature[0]
// .checkedin !=
// null ||
// indexController.currentDestinationFeature[0]
// .checkedin ==
// true
// ? "ロゲイニングを終える"
// : "間違った目的地 ..."))
// : Container(),
// ),
// ],
// ),
// Obx(
// () => indexController.currentDestinationFeature[0].address !=
// null &&
// indexController
// .currentDestinationFeature[0].address!.isNotEmpty
// ? getDetails(context, "address".tr,
// indexController.currentDestinationFeature[0].address! ?? '')
// : const SizedBox(
// width: 0.0,
// height: 0,
// ),
// ),
// Obx(
// () => indexController.currentDestinationFeature[0].phone != null &&
// indexController
// .currentDestinationFeature[0].phone!.isNotEmpty
// ? getDetails(context, "telephone".tr,
// indexController.currentDestinationFeature[0].phone! ?? '')
// : const SizedBox(
// width: 0.0,
// height: 0,
// ),
// ),
// Obx(
// () => indexController.currentDestinationFeature[0].email != null &&
// indexController
// .currentDestinationFeature[0].email!.isNotEmpty
// ? getDetails(context, "email".tr,
// indexController.currentDestinationFeature[0].email! ?? '')
// : const SizedBox(
// width: 0.0,
// height: 0,
// ),
// ),
// Obx(
// () => indexController.currentDestinationFeature[0].webcontents !=
// null &&
// indexController
// .currentDestinationFeature[0].webcontents!.isNotEmpty
// ? getDetails(
// context,
// "web".tr,
// indexController.currentDestinationFeature[0].webcontents! ??
// '',
// isurl: true)
// : const SizedBox(
// width: 0.0,
// height: 0,
// ),
// ),
// Obx(
// () => indexController.currentDestinationFeature[0].videos != null &&
// indexController
// .currentDestinationFeature[0].videos!.isNotEmpty
// ? getDetails(context, "video".tr,
// indexController.currentDestinationFeature[0].videos! ?? '',
// isurl: true)
// : const SizedBox(
// width: 0.0,
// height: 0,
// ),
// ),
// const SizedBox(
// height: 20.0,
// ),
// // Obx(() =>
// // //wantToGo(context),
// // FutureBuilder<Widget>(
// // future: wantToGo(context),
// // builder: (context, snapshot) {
// // return Container(
// // child: snapshot.data,
// // );
// // },
// // ),
// // ),
// const SizedBox(
// height: 60.0,
// )
// ],
// ), // ),
const SizedBox( // );
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,19 +44,21 @@ class MapWidget extends StatelessWidget {
Destination des = destinationController.festuretoDestination(fs); Destination des = destinationController.festuretoDestination(fs);
DatabaseHelper db = DatabaseHelper.instance;
db.getDestinationByLatLon(des.lat!, des.lon!).then((value) {
showModalBottomSheet( showModalBottomSheet(
constraints: constraints: BoxConstraints.loose(
BoxConstraints.loose(Size(Get.width, Get.height * 0.85)), Size(Get.width, Get.height * 0.85)),
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
isDismissible: true, isDismissible: true,
builder: ((context) => BottomSheetNew( builder: ((context) => BottomSheetNew(
destination: des, destination: des, isAlreadyCheckedIn: value.isNotEmpty))
))
//builder:((context) => BottomSheetWidget()) //builder:((context) => BottomSheetWidget())
).whenComplete(() { ).whenComplete(() {
destinationController.skipGps = false; destinationController.skipGps = false;
}); });
});
} }
}, },
child: Container( child: Container(

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"