1092 lines
50 KiB
Dart
1092 lines
50 KiB
Dart
import 'dart:ffi';
|
|
import 'dart:ui' as ui;
|
|
import 'package:flutter/material.dart';
|
|
import 'package:geojson/geojson.dart';
|
|
import 'package:geolocator/geolocator.dart';
|
|
import 'package:get/get.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/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';
|
|
import 'package:rogapp/services/external_service.dart';
|
|
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(
|
|
{this.isAlreadyCheckedIn = false, Key? key, required this.destination})
|
|
: super(key: key);
|
|
|
|
final IndexController indexController = Get.find<IndexController>();
|
|
final DestinationController destinationController =
|
|
Get.find<DestinationController>();
|
|
final Destination destination;
|
|
final bool isAlreadyCheckedIn;
|
|
|
|
Image getImage() {
|
|
String serverUrl = ConstValues.currentServer();
|
|
if (indexController.rogMode == 1) {
|
|
//print("----- rogaining mode 1");
|
|
if (indexController.currentDestinationFeature.isEmpty ||
|
|
indexController.currentDestinationFeature[0].photos! == "") {
|
|
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
|
} else {
|
|
//print("@@@@@@@@@@@@@ rog mode -------------------- ${indexController.currentDestinationFeature[0].photos} @@@@@@@@@@@");
|
|
String photo = indexController.currentDestinationFeature[0].photos!;
|
|
if (photo.contains('http')) {
|
|
return Image(
|
|
image: NetworkImage(
|
|
indexController.currentDestinationFeature[0].photos!,
|
|
),
|
|
errorBuilder: (BuildContext context, Object exception,
|
|
StackTrace? stackTrace) {
|
|
return Image.asset("assets/images/empty_image.png");
|
|
},
|
|
);
|
|
} else {
|
|
return Image(
|
|
image: NetworkImage(
|
|
'$serverUrl/media/compressed/${indexController.currentDestinationFeature[0].photos!}',
|
|
),
|
|
errorBuilder: (BuildContext context, Object exception,
|
|
StackTrace? stackTrace) {
|
|
return Image.asset("assets/images/empty_image.png");
|
|
},
|
|
);
|
|
}
|
|
}
|
|
} else {
|
|
GeoJsonFeature<dynamic> gf = indexController.currentFeature[0];
|
|
print("=== photo sss ${gf.properties!["photos"]}");
|
|
if (gf.properties!["photos"] == null || gf.properties!["photos"] == "") {
|
|
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
|
} else {
|
|
String photo = gf.properties!["photos"];
|
|
if (photo.contains('http')) {
|
|
return Image(
|
|
image: NetworkImage(
|
|
gf.properties!["photos"],
|
|
),
|
|
errorBuilder: (BuildContext context, Object exception,
|
|
StackTrace? stackTrace) {
|
|
return Image.asset("assets/images/empty_image.png");
|
|
},
|
|
);
|
|
} else {
|
|
String imageUrl = Uri.encodeFull(
|
|
'$serverUrl/media/compressed/${gf.properties!["photos"]}');
|
|
return Image(
|
|
image: NetworkImage(
|
|
imageUrl,
|
|
),
|
|
errorBuilder: (BuildContext context, Object exception,
|
|
StackTrace? stackTrace) {
|
|
return Image.asset("assets/images/empty_image.png");
|
|
},
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void _launchURL(url) async {
|
|
if (!await launchUrl(url)) throw 'Could not launch $url';
|
|
}
|
|
|
|
bool isInDestination(String locationid) {
|
|
int lid = int.parse(locationid);
|
|
if (destinationController.destinations
|
|
.where((element) => element.location_id == lid)
|
|
.isNotEmpty) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
destinationController.skipGps = true;
|
|
// print('--- c use --- ${indexController.currentUser[0].values}');
|
|
// print('---- rog_mode ----- ${indexController.rogMode.value} -----');
|
|
// return indexController.rogMode.value == 0
|
|
// ? detailsSheet(context)
|
|
// : destinationSheet(context);
|
|
return detailsSheet(context);
|
|
}
|
|
|
|
// Show destination detais
|
|
// 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),
|
|
|
|
// // FutureBuilder<Widget>(
|
|
// // future: wantToGo(context),
|
|
// // builder: (context, snapshot) {
|
|
// // return Container(
|
|
// // child: snapshot.data,
|
|
// // );
|
|
// // },
|
|
// // ),
|
|
|
|
// // ),
|
|
// 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
|
|
SingleChildScrollView detailsSheet(BuildContext context) {
|
|
Destination cdest = destinationController
|
|
.festuretoDestination(indexController.currentFeature[0]);
|
|
var distance = const Distance();
|
|
double distanceToDest = distance.as(
|
|
LengthUnit.Meter,
|
|
LatLng(
|
|
destinationController.currentLat, destinationController.currentLon),
|
|
LatLng(cdest.lat!, cdest.lon!));
|
|
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
MaterialButton(
|
|
onPressed: () {
|
|
Get.back();
|
|
//indexController.makePrevious(indexController.currentFeature[0]);
|
|
},
|
|
color: Colors.blue,
|
|
textColor: Colors.white,
|
|
padding: const EdgeInsets.all(16),
|
|
shape: const CircleBorder(),
|
|
child: const Icon(
|
|
Icons.arrow_back_ios,
|
|
//Icons.arrow_back_ios,
|
|
size: 14,
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
child: Obx(() => Text(
|
|
"${TextUtils.getDisplayTextFeture(indexController.currentFeature[0])} : ${indexController.currentFeature[0].properties!["location_name"]}",
|
|
// indexController
|
|
// .currentFeature[0].properties!["location_name"],
|
|
style: const TextStyle(
|
|
fontSize: 15.0,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
)),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: SizedBox(
|
|
height: 260.0,
|
|
child: Obx(() => getImage()),
|
|
)),
|
|
],
|
|
),
|
|
Obx(() => Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
// Obx(
|
|
// () => indexController
|
|
// .currentDestinationFeature.isNotEmpty &&
|
|
// indexController
|
|
// .currentDestinationFeature[0].cp ==
|
|
// -1 &&
|
|
// indexController.currentDestinationFeature[0]
|
|
// .checkedin ==
|
|
// false &&
|
|
// destinationController.isAtStart.value == true
|
|
// ? ElevatedButton(
|
|
// onPressed: () async {
|
|
// await destinationController
|
|
// .resetRogaining();
|
|
// //print("~~~~ start button ~~~~");
|
|
// 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(),
|
|
// ),
|
|
|
|
destinationController.rogainingCounted.value == true &&
|
|
destination.cp == -1
|
|
? ElevatedButton(
|
|
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 {
|
|
await destinationController
|
|
.removeCheckin(destination.cp!.toInt());
|
|
destinationController
|
|
.deleteDestination(destination);
|
|
Get.back();
|
|
},
|
|
child: const Text("チェックイン取消"))
|
|
: Container(),
|
|
|
|
// Obx(
|
|
// () => destinationController.rogainingCounted.value ==
|
|
// false &&
|
|
// destination.cp == -1 &&
|
|
// destinationController.distanceToStart() <= 500
|
|
// ? ElevatedButton(
|
|
// onPressed: () {
|
|
// Get.toNamed(AppPages.CAMERA_PAGE);
|
|
// Get.back();
|
|
// },
|
|
// child: Text(
|
|
// //goal
|
|
// indexController
|
|
// .currentDestinationFeature[
|
|
// 0]
|
|
// .checkedin !=
|
|
// null ||
|
|
// indexController
|
|
// .currentDestinationFeature[
|
|
// 0]
|
|
// .checkedin ==
|
|
// true
|
|
// ? "ロゲイニングを終える"
|
|
// : "間違った目的地 ..."))
|
|
// : Container(),
|
|
// ),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Theme.of(context)
|
|
.colorScheme
|
|
.onPrimaryContainer),
|
|
onPressed: () async {
|
|
Get.back();
|
|
//print("---- go to ----");
|
|
GeoJsonFeature<GeoJsonMultiPoint> mp =
|
|
indexController.currentFeature[0]
|
|
as GeoJsonFeature<GeoJsonMultiPoint>;
|
|
Position position =
|
|
await Geolocator.getCurrentPosition(
|
|
desiredAccuracy:
|
|
LocationAccuracy.bestForNavigation,
|
|
forceAndroidLocationManager: true);
|
|
//print("------- position -------- $position");
|
|
Destination ds = Destination(
|
|
lat: position.latitude,
|
|
lon: position.longitude);
|
|
|
|
Destination tp = Destination(
|
|
lat: mp.geometry!.geoSerie!.geoPoints[0]
|
|
.latitude,
|
|
lon: mp.geometry!.geoSerie!.geoPoints[0]
|
|
.longitude);
|
|
|
|
destinationController
|
|
.destinationMatrixFromCurrentPoint([ds, tp]);
|
|
},
|
|
child: Text(
|
|
"ここへ行く",
|
|
style: TextStyle(
|
|
color:
|
|
Theme.of(context).colorScheme.onPrimary),
|
|
)),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
|
|
// forced start / checkin
|
|
Obx(() => ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor:
|
|
Theme.of(context).colorScheme.secondary),
|
|
onPressed: () async {
|
|
//print("~~~~ manual checkin button ~~~~");
|
|
if (destination.cp == -1 &&
|
|
destinationController.isInRog.value ==
|
|
false &&
|
|
destinationController
|
|
.rogainingCounted.value ==
|
|
false) {
|
|
destinationController.isInRog.value = true;
|
|
destinationController.addToRogaining(
|
|
destinationController.currentLat,
|
|
destinationController.currentLon,
|
|
destination.location_id!);
|
|
saveGameState();
|
|
ExternalService()
|
|
.startRogaining()
|
|
.then((value) => Get.back());
|
|
} else {
|
|
if (destination.cp == -1) {
|
|
return;
|
|
}
|
|
Get.back();
|
|
await destinationController
|
|
.callforCheckin(destination);
|
|
}
|
|
},
|
|
child: Text(
|
|
destination.cp == -1 &&
|
|
destinationController.isInRog.value ==
|
|
false &&
|
|
destinationController
|
|
.rogainingCounted.value ==
|
|
false
|
|
? "ロゲ開始"
|
|
: destinationController.isInRog.value ==
|
|
true &&
|
|
destination.cp == -1
|
|
? "ゲーム中"
|
|
: isAlreadyCheckedIn == true
|
|
? "ゲーム中"
|
|
: "チェックイン",
|
|
style: TextStyle(
|
|
color: Theme.of(context)
|
|
.colorScheme
|
|
.onSecondary))))
|
|
// ElevatedButton(
|
|
// onPressed: () {}, child: const Text("ゲーム中")),
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
indexController.currentDestinationFeature
|
|
.isNotEmpty &&
|
|
destinationController.isInCheckin.value ==
|
|
true
|
|
? Container()
|
|
: FutureBuilder<Widget>(
|
|
future: wantToGo(context),
|
|
builder: (context, snapshot) {
|
|
return Container(
|
|
child: snapshot.data,
|
|
);
|
|
},
|
|
),
|
|
indexController.currentFeature[0]
|
|
.properties!["location_name"] !=
|
|
null &&
|
|
(indexController.currentFeature[0]
|
|
.properties!["location_name"]
|
|
as String)
|
|
.isNotEmpty
|
|
? Flexible(
|
|
child: Text(indexController
|
|
.currentFeature[0]
|
|
.properties!["location_name"]))
|
|
: const SizedBox(
|
|
width: 0.0,
|
|
height: 0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(
|
|
height: 8.0,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
const Icon(Icons.roundabout_left),
|
|
const SizedBox(
|
|
width: 8.0,
|
|
),
|
|
indexController.currentFeature[0]
|
|
.properties!["address"] !=
|
|
null &&
|
|
(indexController.currentFeature[0]
|
|
.properties!["address"] as String)
|
|
.isNotEmpty
|
|
? getDetails(
|
|
context,
|
|
"address".tr,
|
|
indexController.currentFeature[0]
|
|
.properties!["address"] ??
|
|
'')
|
|
: const SizedBox(
|
|
width: 0.0,
|
|
height: 0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
const Icon(Icons.phone),
|
|
const SizedBox(
|
|
width: 8.0,
|
|
),
|
|
indexController.currentFeature[0]
|
|
.properties!["phone"] !=
|
|
null &&
|
|
(indexController.currentFeature[0]
|
|
.properties!["phone"] as String)
|
|
.isNotEmpty
|
|
? getDetails(
|
|
context,
|
|
"telephone".tr,
|
|
indexController.currentFeature[0]
|
|
.properties!["phone"] ??
|
|
'')
|
|
: const SizedBox(
|
|
width: 0.0,
|
|
height: 0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
const Icon(Icons.email),
|
|
const SizedBox(
|
|
width: 8.0,
|
|
),
|
|
indexController.currentFeature[0]
|
|
.properties!["email"] !=
|
|
null &&
|
|
(indexController.currentFeature[0]
|
|
.properties!["email"] as String)
|
|
.isNotEmpty
|
|
? getDetails(
|
|
context,
|
|
"email".tr,
|
|
indexController.currentFeature[0]
|
|
.properties!["email"] ??
|
|
'')
|
|
: const SizedBox(
|
|
width: 0.0,
|
|
height: 0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
const Icon(Icons.language),
|
|
const SizedBox(
|
|
width: 8.0,
|
|
),
|
|
indexController.currentFeature[0]
|
|
.properties!["webcontents"] !=
|
|
null &&
|
|
(indexController.currentFeature[0]
|
|
.properties!["webcontents"] as String)
|
|
.isNotEmpty
|
|
? getDetails(
|
|
context,
|
|
"web".tr,
|
|
indexController.currentFeature[0]
|
|
.properties!["webcontents"] ??
|
|
'',
|
|
isurl: true)
|
|
: const SizedBox(
|
|
width: 0.0,
|
|
height: 0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
const SizedBox(
|
|
width: 8.0,
|
|
),
|
|
indexController.currentFeature[0]
|
|
.properties!["remark"] !=
|
|
null &&
|
|
(indexController.currentFeature[0]
|
|
.properties!["remark"] as String)
|
|
.isNotEmpty
|
|
? getDetails(
|
|
context,
|
|
"remarks".tr,
|
|
indexController.currentFeature[0]
|
|
.properties!["remark"] ??
|
|
'',
|
|
isurl: false)
|
|
: const SizedBox(
|
|
width: 0.0,
|
|
height: 0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// Text('${TextUtils.getDisplayText(indexController.currentFeature[0].properties!["cp"].toString())} - id: ${TextUtils.getDisplayText(indexController.currentFeature[0].properties!["checkin_point"].toString())}'),
|
|
],
|
|
),
|
|
)),
|
|
const SizedBox(
|
|
height: 60.0,
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<Widget> wantToGo(BuildContext context) async {
|
|
bool selected = false;
|
|
// print(
|
|
// '---target-- ${indexController.currentFeature[0].properties!["location_id"]}----');
|
|
for (Destination d in destinationController.destinations) {
|
|
//print('---- ${d.location_id.toString()} ----');
|
|
if (d.location_id ==
|
|
indexController.currentFeature[0].properties!["location_id"]) {
|
|
selected = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
DatabaseHelper db = DatabaseHelper.instance;
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
// indexController.rog_mode == 0 ?
|
|
// // IconButton(
|
|
// // icon: Icon(Icons.pin_drop_sharp, size: 32, color: _selected == true ? Colors.amber : Colors.blue,),
|
|
// // onPressed: (){
|
|
// // if(_selected){
|
|
// // // show remove from destination
|
|
// // Get.defaultDialog(
|
|
// // title: "本当にこのポイントを通過順から外しますか?",
|
|
// // middleText: "場所は目的地リストから削除されます",
|
|
// // backgroundColor: Colors.blue.shade300,
|
|
// // titleStyle: TextStyle(color: Colors.white),
|
|
// // middleTextStyle: TextStyle(color: Colors.white),
|
|
// // textConfirm: "はい",
|
|
// // textCancel: "いいえ",
|
|
// // cancelTextColor: Colors.white,
|
|
// // confirmTextColor: Colors.blue,
|
|
// // buttonColor: Colors.white,
|
|
// // barrierDismissible: false,
|
|
// // radius: 10,
|
|
// // content: Column(
|
|
// // children: [
|
|
// // ],
|
|
// // ),
|
|
// // onConfirm: (){
|
|
// // int _id = indexController.currentFeature[0].properties!["location_id"];
|
|
// // Destination? d = destinationController.destinationById(_id);
|
|
// // print('--- des id is : ${d} -----');
|
|
// // if(d != null) {
|
|
// // //print('--- des id is : ${d.location_id} -----');
|
|
// // destinationController.deleteDestination(d);
|
|
// // Get.back();
|
|
// // Get.back();
|
|
// // Get.snackbar("追加した", "場所が削除されました");
|
|
// // }
|
|
// // }
|
|
// // );
|
|
// // return;
|
|
// // }
|
|
// // // show add to destination
|
|
// // Get.defaultDialog(
|
|
// // title: "この場所を登録してもよろしいですか",
|
|
// // middleText: "ロケーションがロガニング リストに追加されます",
|
|
// // backgroundColor: Colors.blue.shade300,
|
|
// // titleStyle: TextStyle(color: Colors.white),
|
|
// // middleTextStyle: TextStyle(color: Colors.white),
|
|
// // textConfirm: "はい",
|
|
// // textCancel: "いいえ",
|
|
// // cancelTextColor: Colors.white,
|
|
// // confirmTextColor: Colors.blue,
|
|
// // buttonColor: Colors.white,
|
|
// // barrierDismissible: false,
|
|
// // radius: 10,
|
|
// // content: Column(
|
|
// // children: [
|
|
// // ],
|
|
// // ),
|
|
// // onConfirm: (){
|
|
// // GeoJsonMultiPoint mp = indexController.currentFeature[0].geometry as GeoJsonMultiPoint;
|
|
// // LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude, mp.geoSerie!.geoPoints[0].longitude);
|
|
|
|
// // print("----- want to go sub location is ---- ${indexController.currentFeature[0].properties!["sub_loc_id"]} -----");
|
|
|
|
// // Destination dest = Destination(
|
|
// // name: indexController.currentFeature[0].properties!["location_name"],
|
|
// // address: indexController.currentFeature[0].properties!["address"],
|
|
// // phone: indexController.currentFeature[0].properties!["phone"],
|
|
// // email: indexController.currentFeature[0].properties!["email"],
|
|
// // webcontents: indexController.currentFeature[0].properties!["webcontents"],
|
|
// // videos: indexController.currentFeature[0].properties!["videos"],
|
|
// // category: indexController.currentFeature[0].properties!["category"],
|
|
// // series: 1,
|
|
// // lat: pt.latitude,
|
|
// // lon: pt.longitude,
|
|
// // sub_loc_id: indexController.currentFeature[0].properties!["sub_loc_id"],
|
|
// // location_id: indexController.currentFeature[0].properties!["location_id"],
|
|
// // list_order: 1,
|
|
// // photos: indexController.currentFeature[0].properties!["photos"],
|
|
// // checkin_radious: indexController.currentFeature[0].properties!["checkin_radius"],
|
|
// // auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0,
|
|
// // cp: indexController.currentFeature[0].properties!["cp"],
|
|
// // checkin_point: indexController.currentFeature[0].properties!["checkin_point"],
|
|
// // buy_point: indexController.currentFeature[0].properties!["buy_point"],
|
|
// // selected: false,
|
|
// // checkedin: false,
|
|
// // hidden_location: indexController.currentFeature[0].properties!["hidden_location"] == true ?1 : 0
|
|
// // );
|
|
// // destinationController.addDestinations(dest);
|
|
// // Get.back();
|
|
// // Get.back();
|
|
// // Get.snackbar("追加した", "場所が追加されました");
|
|
// // }
|
|
// // );
|
|
|
|
// // },
|
|
// // ):
|
|
// // Container(),
|
|
const SizedBox(
|
|
width: 8.0,
|
|
),
|
|
Obx((() => indexController.rogMode.value == 1
|
|
? ElevatedButton(
|
|
onPressed: () async {
|
|
Destination dest =
|
|
indexController.currentDestinationFeature[0];
|
|
//print("~~~~ before checking button ~~~~");
|
|
//print("------ curent destination is ${dest!.checkedIn}-------");
|
|
destinationController.makeCheckin(
|
|
dest, !dest.checkedin!, "");
|
|
},
|
|
child: indexController
|
|
.currentDestinationFeature[0].checkedin ==
|
|
false
|
|
? const Text("チェックイン")
|
|
: const Text("チェックアウト"))
|
|
: Container())),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget getCheckin(BuildContext context) {
|
|
//print("------ currentAction ----- ${indexController.currentAction}-----");
|
|
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
indexController.currentAction[0][0]["checkin"] == false
|
|
? Column(
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
ElevatedButton(
|
|
child: const Text("Image"),
|
|
onPressed: () {
|
|
final ImagePicker picker = ImagePicker();
|
|
picker
|
|
.pickImage(source: ImageSource.camera)
|
|
.then((value) {
|
|
//print("----- image---- ${value!.path}");
|
|
});
|
|
},
|
|
)
|
|
],
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
if (indexController.currentAction.isNotEmpty) {
|
|
//print(indexController.currentAction[0]);
|
|
indexController.currentAction[0][0]["checkin"] =
|
|
true;
|
|
Map<String, dynamic> temp =
|
|
Map<String, dynamic>.from(
|
|
indexController.currentAction[0][0]);
|
|
indexController.currentAction.clear();
|
|
//print("---temp---${temp}");
|
|
indexController.currentAction.add([temp]);
|
|
}
|
|
},
|
|
child: Text("checkin".tr))
|
|
],
|
|
)
|
|
: ElevatedButton(
|
|
onPressed: () {
|
|
if (indexController.currentAction.isNotEmpty) {
|
|
//print(indexController.currentAction[0]);
|
|
indexController.currentAction[0][0]["checkin"] = false;
|
|
Map<String, dynamic> temp = Map<String, dynamic>.from(
|
|
indexController.currentAction[0][0]);
|
|
indexController.currentAction.clear();
|
|
//print("---temp---${temp}");
|
|
indexController.currentAction.add([temp]);
|
|
}
|
|
},
|
|
child: const Icon(Icons.favorite, color: Colors.red),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget getDetails(BuildContext context, String label, String text,
|
|
{bool isurl = false}) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(label),
|
|
const SizedBox(
|
|
width: 10.0,
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
if (isurl) {
|
|
if (indexController.rogMode.value == 0) {
|
|
_launchURL(indexController
|
|
.currentFeature[0].properties!["webcontents"]);
|
|
} else {
|
|
indexController.currentDestinationFeature[0].webcontents;
|
|
}
|
|
}
|
|
},
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width -
|
|
(MediaQuery.of(context).size.width * 0.35),
|
|
child: Text(
|
|
text,
|
|
textAlign: TextAlign.justify,
|
|
style: TextStyle(
|
|
color: isurl ? Colors.blue : Colors.black,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|