integrated with previous

This commit is contained in:
Mohamed Nouffer
2023-06-09 15:55:59 +05:30
parent a358f65853
commit 2cd685b65e
23 changed files with 1950 additions and 397 deletions

View File

@ -1,6 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:geojson/geojson.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
@ -9,11 +7,13 @@ import 'package:image_picker/image_picker.dart';
import 'package:latlong2/latlong.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.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/model/location_response.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/screens/auth/controller/auth_controller.dart';
import 'package:rogapp/screens/home/home_controller.dart';
import 'package:rogapp/screens/home/location_controller.dart';
import 'package:rogapp/services/external_service.dart';
import 'package:rogapp/utils/checkin_db_helper.dart';
import 'package:rogapp/utils/const.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'package:rogapp/utils/text_util.dart';
@ -23,23 +23,26 @@ import 'package:url_launcher/url_launcher.dart';
class BottomSheetNew extends GetView<BottomSheetController> {
BottomSheetNew({ Key? key }) : super(key: key);
final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>();
//final IndexController indexController = Get.find<IndexController>();
//final DestinationController destinationController = Get.find<DestinationController>();
HomeController homeController = Get.find<HomeController>();
LocationController locationController = Get.find<LocationController>();
AuthController authController = Get.find<AuthController>();
CheckinDBHelper checkinDBHelper = CheckinDBHelper.instance;
Image getImage(){
String server_url = ConstValues.currentServer();
if(indexController.rog_mode == 1){
//print("----- rogaining mode 1");
if(indexController.currentDestinationFeature.length <= 0 || indexController.currentDestinationFeature[0].photos! == ""){
if(homeController.currentFeature.isEmpty || homeController.currentFeature[0].properties!.photos == ""){
return Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
//print("@@@@@@@@@@@@@ rog mode -------------------- ${indexController.currentDestinationFeature[0].photos} @@@@@@@@@@@");
String _photo = indexController.currentDestinationFeature[0].photos!;
String _photo = homeController.currentFeature[0].properties!.photos!;
if(_photo.contains('http')){
return Image(image: NetworkImage(
indexController.currentDestinationFeature[0].photos!,
homeController.currentFeature[0].properties!.photos!,
),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
@ -48,7 +51,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
}
else {
return Image(image: NetworkImage(
'${server_url}/media/compressed/' + indexController.currentDestinationFeature[0].photos!,
'${server_url}/media/compressed/' + homeController.currentFeature[0].properties!.photos!,
),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
@ -56,64 +59,31 @@ class BottomSheetNew extends GetView<BottomSheetController> {
);
}
}
}
else{
GeoJsonFeature<dynamic> gf = indexController.currentFeature[0];
if(gf!.properties!["photos"] == null || gf.properties!["photos"] == ""){
return 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 {
return Image(image: NetworkImage(
'${server_url}/media/compressed/' + gf.properties!["photos"],
),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
}
}
}
void _launchURL(url) async {
if (!await launch(url)) throw 'Could not launch $url';
}
bool isInDestination(String locationid){
int lid = int.parse(locationid);
if(destinationController.destinations.where((element) => element.location_id == lid).length > 0){
return true;
}
else{
return false;
}
}
// bool isInDestination(String locationid){
// int lid = int.parse(locationid);
// if(destinationController.destinations.where((element) => element.location_id == lid).length > 0){
// return true;
// }
// else{
// return false;
// }
// }
@override
Widget build(BuildContext context) {
destinationController.skip_gps = true;
print('---- rog_mode ----- ${indexController.rog_mode} -----');
return indexController.rog_mode == 0 ? detailsSheet(context) : destinationSheet(context);
locationController.skip_gps = true;
return destinationSheet(context);
}
// Show destination detais
SingleChildScrollView destinationSheet(BuildContext context) {
print('---- currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} -----');
return SingleChildScrollView(
child: Column(
@ -141,14 +111,14 @@ class BottomSheetNew extends GetView<BottomSheetController> {
child: Container(
alignment: Alignment.center,
child: Obx(() =>
indexController.currentUser.length > 0 ?
Text("${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${indexController.currentDestinationFeature[0].name!}", style: TextStyle(
authController.authList.isNotEmpty ?
Text("${TextUtils.getDisplayText(homeController.currentFeature[0])} : ${TextUtils.getDisplayText(homeController.currentFeature[0])} : ${homeController.currentFeature[0].properties!.location_name}", style: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
)
:
Text("${indexController.currentDestinationFeature[0].name!}", style: TextStyle(
Text("${homeController.currentFeature[0].properties!.location_name}", style: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
@ -174,38 +144,48 @@ class BottomSheetNew extends GetView<BottomSheetController> {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Obx(() =>
indexController.currentDestinationFeature.isNotEmpty && destinationController.is_in_checkin.value == true && destinationController.is_at_start.value == false ?
homeController.currentBound.isNotEmpty && locationController.is_in_checkin.value == true && locationController.is_at_start.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.skip_gps = false;
destinationController.is_photo_shoot.value = true;
onPressed: () async {
final _locId = homeController.currentFeature[0].location_id;
final _exist = await checkinDBHelper.exists(_locId!);
if(_exist){
if(homeController.currentFeature[0].properties!.hidden_location == 0){
locationController.skip_gps = false;
locationController.is_photo_shoot.value = true;
Get.back();
}
else{
destinationController.makeCheckin(indexController.currentDestinationFeature[0], true, "");
if(indexController.currentDestinationFeature[0].cp != -1){
destinationController.rogaining_counted.value =true;
locationController.makeCheckin(homeController.currentFeature[0], true, "");
if(homeController.currentFeature[0].properties!.cp != -1){
locationController.rogaining_counted.value =true;
}
}
}
else{
destinationController.makeCheckin(indexController.currentDestinationFeature[0], false, "");
locationController.makeCheckin(homeController.currentFeature[0], false, "");
}
//Get.back();
},
child: Text(
//Checkin
indexController.currentDestinationFeature[0].checkedin == null || indexController.currentDestinationFeature[0].checkedin == false ?
"チェックイン"
:
"チェックアウト"
)
child: FutureBuilder<bool>(
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot){
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator(); // return a circular progress indicator while waiting
} else {
if (snapshot.hasError)
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
else
return snapshot.data! ?
const Text("チェックイン") : // Widget to show if locationId exists
const Text("チェックアウト");
}
},
),
),
],
)
@ -213,19 +193,28 @@ class BottomSheetNew extends GetView<BottomSheetController> {
Container(),
),
Obx(() =>
destinationController.is_at_start.value == true ?
locationController.is_at_start.value == true ?
ElevatedButton(
onPressed: (){
destinationController.is_in_rog.value = true;
destinationController.addToRogaining(destinationController.current_lat, destinationController.current_lon, indexController.currentDestinationFeature[0].location_id!);
locationController.is_in_rog.value = true;
locationController.addToRogaining(locationController.current_lat, locationController.current_lon, homeController.currentFeature[0].location_id!);
ExternalService().StartRogaining().then((value) => Get.back());
},
child: Text(
// start
indexController.currentDestinationFeature[0].checkedin != null || indexController.currentDestinationFeature[0].checkedin == true ?
"ロゲイニングを開始"
:
"間違った目的地..."
child:
FutureBuilder<bool>(
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
builder: (context, snapshot){
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator(); // return a circular progress indicator while waiting
} else {
if (snapshot.hasError)
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
else
return snapshot.data! ?
const Text("ロゲイニングを開始") : // Widget to show if locationId exists
const Text("間違った目的地...");
}
},
)
)
:
@ -233,18 +222,27 @@ class BottomSheetNew extends GetView<BottomSheetController> {
),
Obx(() =>
destinationController.is_at_goal.value == true && destinationController.rogaining_counted ==true ?
locationController.is_at_goal.value == true && locationController.rogaining_counted ==true ?
ElevatedButton(
onPressed: (){
Get.toNamed(AppPages.CAMERA_PAGE);
Get.back();
},
child: Text(
//goal
indexController.currentDestinationFeature[0].checkedin != null || indexController.currentDestinationFeature[0].checkedin == true ?
"ロゲイニングを終える"
:
"間違った目的地 ..."
child:
FutureBuilder<bool>(
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
builder: (context, snapshot){
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator(); // return a circular progress indicator while waiting
} else {
if (snapshot.hasError)
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
else
return snapshot.data! ?
const Text("ロゲイニングを終える") : // Widget to show if locationId exists
const Text("間違った目的地 ...");
}
},
)
)
:
@ -254,32 +252,32 @@ class BottomSheetNew extends GetView<BottomSheetController> {
],
),
Obx(() =>
indexController.currentDestinationFeature[0].address != null && indexController.currentDestinationFeature[0].address!.isNotEmpty ?
getDetails(context, "address".tr, indexController.currentDestinationFeature[0].address! ?? '')
homeController.currentFeature[0].properties!.address != null ?
getDetails(context, "address".tr, homeController.currentFeature[0].properties!.address! ?? '')
:
Container(width: 0.0, height: 0,),
),
Obx(() =>
indexController.currentDestinationFeature[0].phone != null && indexController.currentDestinationFeature[0].phone!.isNotEmpty ?
getDetails(context, "telephone".tr, indexController.currentDestinationFeature[0].phone! ?? '')
homeController.currentFeature[0].properties!.phone != null ?
getDetails(context, "telephone".tr, homeController.currentFeature[0].properties!.phone! ?? '')
:
Container(width: 0.0, height: 0,),
),
Obx(() =>
indexController.currentDestinationFeature[0].email != null && indexController.currentDestinationFeature[0].email!.isNotEmpty ?
getDetails(context, "email".tr, indexController.currentDestinationFeature[0].email! ?? '')
homeController.currentFeature[0].properties!.email != null ?
getDetails(context, "email".tr, homeController.currentFeature[0].properties!.email! ?? '')
:
Container(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)
homeController.currentFeature[0].properties!.webcontents != null ?
getDetails(context, "web".tr, homeController.currentFeature[0].properties!.webcontents! ?? '', isurl: true)
:
Container(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)
homeController.currentFeature[0].properties!.videos != null ?
getDetails(context, "video".tr, homeController.currentFeature[0].properties!.videos! ?? '', isurl: true)
:
Container(width: 0.0, height: 0,),
),
@ -333,7 +331,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
child: Container(
alignment: Alignment.center,
child: Obx(() =>
Text(indexController.currentFeature[0].properties!["location_name"], style: TextStyle(
Text(homeController.currentFeature[0].properties!.location_name!, style: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
@ -364,38 +362,60 @@ class BottomSheetNew extends GetView<BottomSheetController> {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Obx(() =>
indexController.currentDestinationFeature.isNotEmpty && indexController.currentDestinationFeature[0].cp == -1 && indexController.currentDestinationFeature[0].checkedin == false && destinationController.is_at_start.value == true ?
ElevatedButton(
onPressed: (){
destinationController.is_in_rog.value = true;
destinationController.addToRogaining(destinationController.current_lat, destinationController.current_lon, indexController.currentDestinationFeature[0].location_id!);
ExternalService().StartRogaining().then((value) => Get.back());
},
child: Text(
// start
indexController.currentDestinationFeature[0].checkedin != null || indexController.currentDestinationFeature[0].checkedin == true ?
"ロゲイニングを開始"
:
"間違った目的地..."
)
)
:
Container(),
FutureBuilder<bool>(
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
builder: (context, snapshot){
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator(); // return a circular progress indicator while waiting
} else {
if (snapshot.hasError)
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
else
if(homeController.currentFeature[0].properties!.cp == -1 && locationController.is_at_start.value ==true){
return ElevatedButton(
onPressed: (){
locationController.is_in_rog.value = true;
locationController.addToRogaining(locationController.current_lat, locationController.current_lon, homeController.currentFeature[0].location_id!);
ExternalService().StartRogaining().then((value) => Get.back());
},
child: Text(
// start
snapshot.data! == true ?
"ロゲイニングを開始"
:
"間違った目的地..."
)
);
}
else {
return Container();
}
}
},
)
),
Obx(() =>
destinationController.is_at_goal.value == true && destinationController.rogaining_counted ==true ?
locationController.is_at_goal.value == true && locationController.rogaining_counted ==true ?
ElevatedButton(
onPressed: (){
Get.toNamed(AppPages.CAMERA_PAGE);
Get.back();
},
child: Text(
//goal
indexController.currentDestinationFeature[0].checkedin != null || indexController.currentDestinationFeature[0].checkedin == true ?
"ロゲイニングを終える"
:
"間違った目的地 ..."
child:
FutureBuilder<bool>(
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
builder: (context, snapshot){
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator(); // return a circular progress indicator while waiting
} else {
if (snapshot.hasError)
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
else
return snapshot.data! ?
const Text("ロゲイニングを終える") : // Widget to show if locationId exists
const Text("間違った目的地 ...");
}
},
)
)
:
@ -409,41 +429,56 @@ class BottomSheetNew extends GetView<BottomSheetController> {
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
indexController.currentDestinationFeature.isNotEmpty && destinationController.is_in_checkin.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"]))
:
Container(width: 0.0, height: 0,),
FutureBuilder<bool>(
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
builder: (context, snapshot){
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator(); // return a circular progress indicator while waiting
} else {
if (snapshot.hasError)
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
else{
if(snapshot.data == true){
return Container();
}
else{
return 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"]))
// :
// Container(width: 0.0, height: 0,),
],
),
),
ElevatedButton(
onPressed:() async {
GeoJsonFeature<GeoJsonMultiPoint> mp = indexController.currentFeature[0] as GeoJsonFeature<GeoJsonMultiPoint>;
Feature mp = homeController.currentFeature[0];
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
Destination ds = Destination(
lat: position.latitude,
lon: position.longitude
Feature ds = Feature(
latitude: position.latitude,
longitude: position.longitude
);
Destination tp = Destination(
lat: mp.geometry!.geoSerie!.geoPoints[0].latitude,
lon: mp.geometry!.geoSerie!.geoPoints[0].longitude
Feature tp = Feature(
latitude: mp.latitude,
longitude: mp.longitude
);
Get.back();
destinationController.destinationMatrixFromCurrentPoint([ds, tp]);
locationController.destinationMatrixFromCurrentPoint([ds, tp]);
},
child:Text("ここへ行く")),
],
@ -455,8 +490,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
children: [
Icon(Icons.roundabout_left),
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"] ?? '')
homeController.currentFeature[0].properties!.address != null && homeController.currentFeature[0].properties!.address!.isNotEmpty ?
getDetails(context, "address".tr, homeController.currentFeature[0].properties!.address ?? '')
:
Container(width: 0.0, height: 0,),
],
@ -468,8 +503,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
children: [
Icon(Icons.phone),
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"] ?? '')
homeController.currentFeature[0].properties!.phone != null && homeController.currentFeature[0].properties!.phone!.isNotEmpty ?
getDetails(context, "telephone".tr, homeController.currentFeature[0].properties!.phone ?? '')
:
Container(width: 0.0, height: 0,),
],
@ -481,8 +516,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
children: [
Icon(Icons.email),
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"] ?? '')
homeController.currentFeature[0].properties!.email != null && homeController.currentFeature[0].properties!.email!.isNotEmpty ?
getDetails(context, "email".tr, homeController.currentFeature[0].properties!.email ?? '')
:
Container(width: 0.0, height: 0,),
],
@ -494,8 +529,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
children: [
Icon(Icons.language),
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)
homeController.currentFeature[0].properties!.webcontents != null && homeController.currentFeature[0].properties!.webcontents!.isNotEmpty ?
getDetails(context, "web".tr, homeController.currentFeature[0].properties!.webcontents ?? '', isurl: true)
:
Container(width: 0.0, height: 0,),
],
@ -506,8 +541,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
child: Row(
children: [
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)
homeController.currentFeature[0].properties!.remark != null && homeController.currentFeature[0].properties!.remark!.isNotEmpty ?
getDetails(context, "remarks".tr, homeController.currentFeature[0].properties!.remark ?? '', isurl: false)
:
Container(width: 0.0, height: 0,),
],
@ -528,16 +563,10 @@ class BottomSheetNew extends GetView<BottomSheetController> {
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;
}
}
bool _selected = await checkinDBHelper.exists(homeController.currentFeature[0].location_id!);
DatabaseHelper db = DatabaseHelper.instance;
return
@ -547,196 +576,108 @@ class BottomSheetNew extends GetView<BottomSheetController> {
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(),
SizedBox(width: 8.0,) ,
Obx((() =>
indexController.rog_mode == 1 ?
ElevatedButton(
ElevatedButton(
onPressed: () async {
Destination dest = indexController.currentDestinationFeature[0]!;
Feature dest = homeController.currentFeature[0];
//print("------ curent destination is ${dest!.checkedIn}-------");
if(dest != null){
//print("------ curent destination is ${dest!.checkedin}-------::::::::::");
destinationController.makeCheckin(dest, !dest.checkedin!, "");
bool checkin = await checkinDBHelper.exists(homeController.currentFeature[0].location_id!);
locationController.makeCheckin(dest, checkin, "");
}
},
child: indexController.currentDestinationFeature[0].checkedin == false ?
Text("チェックイン")
:
Text("チェックアウト")
):
Container()
)
),
child:
FutureBuilder<bool>(
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
builder: (context, snapshot){
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
}else {
if (snapshot.hasError)
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
else
return snapshot.data! ?
const Text("チェックイン") : // Widget to show if locationId exists
const Text("チェックアウト");
}
},
)
)
],
),
],
);
}
Widget getCheckin(BuildContext context){
// Widget getCheckin(BuildContext context){
//print("------ currentAction ----- ${indexController.currentAction}-----");
// //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: 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]);
}
indexController.makeAction(context);
},
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]);
}
indexController.makeAction(context);
},
// 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: Text("Image"), onPressed: (){
// final ImagePicker _picker = ImagePicker();
// _picker.pickImage(source: ImageSource.camera).then((value){
// //print("----- image---- ${value!.path}");
// });
// },
// )
// ],
// ),
// ElevatedButton(
// onPressed: (){},
// //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]);
// // }
// // indexController.makeAction(context);
// // },
// child: Text("checkin".tr)
// )
// ],
// )
// :
// ElevatedButton(
// onPressed: (){},
// // 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]);
// // }
// // indexController.makeAction(context);
// // },
child: Icon(
Icons.favorite, color: Colors.red)
// child: Icon(
// Icons.favorite, color: Colors.red)
,
)
],
)
],
);
}
// ,
// )
// ],
// )
// ],
// );
// }
@ -749,13 +690,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
InkWell(
onTap: (){
if(isurl){
if(indexController.rog_mode == 0){
_launchURL(indexController.currentFeature[0].properties!["webcontents"]);
}
else {
indexController.currentDestinationFeature[0].webcontents;
}
_launchURL(homeController.currentFeature[0].properties!.webcontents);
}
},
child: Container(