update to server location popup

This commit is contained in:
Mohamed Nouffer
2022-10-30 21:43:29 +05:30
parent 2d9f7a9633
commit d16d97f64f
17 changed files with 700 additions and 241 deletions

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:geojson/geojson.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
@ -8,6 +9,7 @@ import 'package:rogapp/model/destination.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/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';
@ -21,6 +23,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
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! == ""){
@ -40,7 +43,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
}
else {
return Image(image: NetworkImage(
'http://container.intranet.sumasen.net:8100/media/' + indexController.currentDestinationFeature[0].photos!,
'${server_url}/media/compressed/' + indexController.currentDestinationFeature[0].photos!,
),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
@ -67,7 +70,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
}
else {
return Image(image: NetworkImage(
'http://container.intranet.sumasen.net:8100/media/' + gf.properties!["photos"],
'${server_url}/media/compressed/' + gf.properties!["photos"],
),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
@ -96,11 +99,15 @@ class BottomSheetNew extends GetView<BottomSheetController> {
@override
Widget build(BuildContext context) {
print('---- rog_mode ----- ${indexController.rog_mode} -----');
return indexController.rog_mode == 0 ? detailsSheet(context) : destinationSheet(context);
}
// Show destination detais
SingleChildScrollView destinationSheet(BuildContext context) {
print('---- currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} -----');
return SingleChildScrollView(
child: Column(
children: [
@ -156,6 +163,77 @@ class BottomSheetNew extends GetView<BottomSheetController> {
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Obx(() =>
indexController.currentDestinationFeature.isNotEmpty && destinationController.is_in_checkin.value == true ?
Row(
children: [
ElevatedButton(
onPressed: (){
if(indexController.currentDestinationFeature[0].checkedin == null || indexController.currentDestinationFeature[0].checkedin == false){
destinationController.makeCheckin(indexController.currentDestinationFeature[0], true);
if(indexController.currentDestinationFeature[0].cp != -1){
destinationController.rogaining_counted.value =true;
}
}
else{
destinationController.makeCheckin(indexController.currentDestinationFeature[0], false);
}
Get.back();
},
child: Text(
indexController.currentDestinationFeature[0].checkedin == null || indexController.currentDestinationFeature[0].checkedin == false ?
"Chekin"
:
"Checkput"
)
),
],
)
:
Container(),
),
Obx(() =>
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!);
Get.back();
},
child: Text(
indexController.currentDestinationFeature[0].checkedin != null || indexController.currentDestinationFeature[0].checkedin == true ?
"Start Rogaining"
:
"Wrong destination ..."
)
)
:
Container(),
),
Obx(() =>
destinationController.is_at_goal.value == true && destinationController.rogaining_counted ==true ?
ElevatedButton(
onPressed: (){
Get.toNamed(AppPages.CAMERA_PAGE);
Get.back();
},
child: Text(
indexController.currentDestinationFeature[0].checkedin != null || indexController.currentDestinationFeature[0].checkedin == true ?
"Finish Rogaining"
:
"Wrong destination ..."
)
)
:
Container(),
),
],
),
Obx(() =>
indexController.currentDestinationFeature[0].address != null && indexController.currentDestinationFeature[0].address!.isNotEmpty ?
getDetails(context, "address".tr, indexController.currentDestinationFeature[0].address! ?? '')
@ -187,19 +265,19 @@ class BottomSheetNew extends GetView<BottomSheetController> {
Container(width: 0.0, height: 0,),
),
SizedBox(height: 20.0,),
Obx(() =>
//wantToGo(context),
// 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,
// );
// },
// ),
),
// ),
SizedBox(height: 60.0,)
],
),
@ -440,6 +518,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
GeoJsonMultiPoint mp = indexController.currentFeature[0].geometry as GeoJsonMultiPoint;
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude, mp.geoSerie!.geoPoints[0].longitude);
//print("----- ${indexController.currentFeature[0].properties} -----");
Destination dest = Destination(
name: indexController.currentFeature[0].properties!["location_name"],
address: indexController.currentFeature[0].properties!["address"],
@ -454,13 +534,14 @@ class BottomSheetNew extends GetView<BottomSheetController> {
location_id: indexController.currentFeature[0].properties!["location_id"],
list_order: 1,
photos: indexController.currentFeature[0].properties!["photos"],
checkin_radious: indexController.currentFeature[0].properties!["checkin_radious"],
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
checkedin: false,
hidden_location: indexController.currentFeature[0].properties!["hidden_location"] == true ?1 : 0
);
destinationController.addDestinations(dest);
Get.back();
@ -589,13 +670,11 @@ class BottomSheetNew extends GetView<BottomSheetController> {
},
child: Container(
width: MediaQuery.of(context).size.width - 160,
child: Expanded(
child: Text(text,
style: TextStyle(
color: isurl ? Colors.blue : Colors.black,
),
child: Text(text,
style: TextStyle(
color: isurl ? Colors.blue : Colors.black,
),
),
),
),
),
],