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

@ -1,5 +1,5 @@
import 'dart:ffi';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:geojson/geojson.dart';
import 'package:geolocator/geolocator.dart';
@ -8,6 +8,7 @@ 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/pages/camera/camera_page.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.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/text_util.dart';
import 'package:rogapp/widgets/bottom_sheet_controller.dart';
import 'package:sqflite/sqflite.dart';
import 'package:url_launcher/url_launcher.dart';
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 DestinationController destinationController =
Get.find<DestinationController>();
Destination destination;
final Destination destination;
final bool isAlreadyCheckedIn;
Image getImage() {
String serverUrl = ConstValues.currentServer();
@ -116,258 +121,265 @@ class BottomSheetNew extends GetView<BottomSheetController> {
}
// Show destination detais
SingleChildScrollView destinationSheet(BuildContext context) {
// print(
// '---- currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} -----');
// SingleChildScrollView destinationSheet(BuildContext context) {
// // print(
// // '---- currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} -----');
return SingleChildScrollView(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
MaterialButton(
onPressed: () {
Get.back();
//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),
// return SingleChildScrollView(
// child: Column(
// children: [
// Padding(
// padding: const EdgeInsets.all(8.0),
// child: Row(
// children: [
// MaterialButton(
// onPressed: () {
// Get.back();
// //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,
// );
// },
// ),
// // 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
@ -486,12 +498,35 @@ class BottomSheetNew extends GetView<BottomSheetController> {
destination.cp == -1 &&
destinationController.distanceToStart() <= 500
? ElevatedButton(
onPressed: () {
Get.toNamed(AppPages.CAMERA_PAGE);
Get.back();
onPressed: () async {
destinationController.isAtGoal.value = true;
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("ロゲイニングを終える"))
: Container(),
//remove checkin
isAlreadyCheckedIn == true && destination.cp != -1
? ElevatedButton(
onPressed: () async {
destinationController
.deleteDestination(destination);
Get.back();
},
child: const Text("チェックイン取消"))
: Container(),
// Obx(
// () => destinationController.rogainingCounted.value ==
@ -568,6 +603,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
distanceToDest <=
destinationController
.getForcedChckinDistance(destination) &&
destinationController.isInRog.value == false &&
// destinationController.isInCheckin.value ==
// true &&
destinationController.rogainingCounted.value ==
@ -607,7 +643,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
color: Theme.of(context)
.colorScheme
.onSecondary)))
: Container(),
: ElevatedButton(
onPressed: () {}, child: const Text("ゲーム中")),
],
),
Row(