Files
rog_app/lib/widgets/bottom_sheet_new.dart

527 lines
20 KiB
Dart
Raw Normal View History

2022-06-27 12:15:54 +05:30
import 'package:flutter/material.dart';
import 'package:geojson/geojson.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:image_picker/image_picker.dart';
2022-07-09 22:51:34 +05:30
import 'package:latlong2/latlong.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
2022-06-27 12:15:54 +05:30
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
2022-07-09 22:51:34 +05:30
import 'package:rogapp/utils/database_helper.dart';
2022-06-27 12:15:54 +05:30
import 'package:rogapp/widgets/bottom_sheet_controller.dart';
import 'package:url_launcher/url_launcher.dart';
class BottomSheetNew extends GetView<BottomSheetController> {
BottomSheetNew({ Key? key }) : super(key: key);
final IndexController indexController = Get.find<IndexController>();
2022-07-09 22:51:34 +05:30
final DestinationController destinationController = Get.find<DestinationController>();
2022-06-27 12:15:54 +05:30
2022-07-14 23:10:24 +05:30
Image getImage(){
if(indexController.rog_mode == 1){
if(indexController.currentDestinationFeature.length <= 0 || indexController.currentDestinationFeature[0].photos! == ""){
return Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
2022-07-25 19:56:32 +05:30
//print("@@@@@@@@@@@@@ rog mode -------------------- ${indexController.currentDestinationFeature[0].photos} @@@@@@@@@@@");
2022-07-14 23:10:24 +05:30
return Image(image: NetworkImage(
indexController.currentDestinationFeature[0].photos!,
),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
2022-06-27 12:15:54 +05:30
}
else{
2022-07-14 23:10:24 +05:30
GeoJsonFeature<dynamic> gf = indexController.currentFeature[0];
if(gf!.properties!["photos"] == null || gf.properties!["photos"] == ""){
return Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
return Image(image: NetworkImage(
gf.properties!["photos"],
),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
2022-06-27 12:15:54 +05:30
}
2022-07-14 23:10:24 +05:30
2022-06-27 12:15:54 +05:30
}
void _launchURL(url) async {
if (!await launch(url)) throw 'Could not launch $url';
}
2022-07-22 19:36:04 +05:30
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;
}
}
2022-06-27 12:15:54 +05:30
@override
Widget build(BuildContext context) {
2022-07-14 23:10:24 +05:30
return indexController.rog_mode == 0 ? detailsSheet(context) : destinationSheet(context);
}
2022-09-01 19:14:18 +05:30
// Show destination detais
2022-07-14 23:10:24 +05:30
SingleChildScrollView destinationSheet(BuildContext context) {
return SingleChildScrollView(
child: Column(
2022-06-27 12:15:54 +05:30
children: [
2022-07-14 23:10:24 +05:30
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Row(
children: [
MaterialButton(
onPressed: () {
2022-07-27 19:43:12 +05:30
destinationController.makePrevious(indexController.currentDestinationFeature[0]);
2022-07-14 23:10:24 +05:30
},
color: Colors.blue,
textColor: Colors.white,
child: Icon(
Icons.arrow_back_ios,
size: 14,
),
padding: EdgeInsets.all(16),
shape: CircleBorder(),
),
Expanded(
child: Container(
alignment: Alignment.center,
child: Obx(() =>
Text(indexController.currentDestinationFeature[0].name!, style: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
2022-06-27 12:15:54 +05:30
),
2022-07-14 23:10:24 +05:30
)
2022-06-27 12:15:54 +05:30
),
2022-07-14 23:10:24 +05:30
),
2022-06-27 12:15:54 +05:30
),
2022-07-14 23:10:24 +05:30
MaterialButton(
onPressed: () {
2022-07-27 19:43:12 +05:30
destinationController.makeNext(indexController.currentDestinationFeature[0]);
2022-07-14 23:10:24 +05:30
},
color: Colors.blue,
textColor: Colors.white,
child: Icon(
Icons.arrow_forward_ios,
size: 14,
),
padding: EdgeInsets.all(16),
shape: CircleBorder(),
2022-06-27 12:15:54 +05:30
),
],
),
2022-07-14 23:10:24 +05:30
),
),
Row(
children: [
Expanded(
child: SizedBox(
height: 260.0,
child: Obx(() => getImage()),
)
2022-06-27 12:15:54 +05:30
),
2022-07-14 23:10:24 +05:30
],
),
Obx(() =>
2022-09-01 19:14:18 +05:30
indexController.currentDestinationFeature[0].address != null && indexController.currentDestinationFeature[0].address!.isNotEmpty ?
2022-07-14 23:10:24 +05:30
getDetails(context, "address".tr, indexController.currentDestinationFeature[0].address! ?? '')
:
Container(width: 0.0, height: 0,),
),
Obx(() =>
2022-09-01 19:14:18 +05:30
indexController.currentDestinationFeature[0].phone != null && indexController.currentDestinationFeature[0].phone!.isNotEmpty ?
2022-07-14 23:10:24 +05:30
getDetails(context, "telephone".tr, indexController.currentDestinationFeature[0].phone! ?? '')
:
Container(width: 0.0, height: 0,),
),
Obx(() =>
2022-09-01 19:14:18 +05:30
indexController.currentDestinationFeature[0].email != null && indexController.currentDestinationFeature[0].email!.isNotEmpty ?
2022-07-14 23:10:24 +05:30
getDetails(context, "email".tr, indexController.currentDestinationFeature[0].email! ?? '')
:
Container(width: 0.0, height: 0,),
),
Obx(() =>
2022-09-01 19:14:18 +05:30
indexController.currentDestinationFeature[0].webcontents != null && indexController.currentDestinationFeature[0].webcontents!.isNotEmpty ?
2022-07-14 23:10:24 +05:30
getDetails(context, "web".tr, indexController.currentDestinationFeature[0].webcontents! ?? '', isurl: true)
:
Container(width: 0.0, height: 0,),
),
Obx(() =>
2022-09-01 19:14:18 +05:30
indexController.currentDestinationFeature[0].videos != null && indexController.currentDestinationFeature[0].videos!.isNotEmpty ?
2022-07-14 23:10:24 +05:30
getDetails(context, "video".tr, indexController.currentDestinationFeature[0].videos! ?? '', isurl: true)
:
Container(width: 0.0, height: 0,),
),
SizedBox(height: 20.0,),
Obx(() =>
//wantToGo(context),
FutureBuilder<Widget>(
future: wantToGo(context),
builder: (context, snapshot) {
return Container(
child: snapshot.data,
);
},
),
),
SizedBox(height: 60.0,)
],
),
);
}
2022-07-10 23:50:43 +05:30
2022-09-01 19:14:18 +05:30
// show add location details
2022-07-14 23:10:24 +05:30
SingleChildScrollView detailsSheet(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Row(
children: [
MaterialButton(
onPressed: () {
indexController.makePrevious(indexController.currentFeature[0]);
},
color: Colors.blue,
textColor: Colors.white,
child: Icon(
Icons.arrow_back_ios,
size: 14,
),
padding: EdgeInsets.all(16),
shape: CircleBorder(),
),
Expanded(
child: Container(
alignment: Alignment.center,
child: Obx(() =>
Text(indexController.currentFeature[0].properties!["location_name"], style: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
)
),
),
),
MaterialButton(
onPressed: () {
2022-07-25 19:56:32 +05:30
//print("----- next is ${indexController.currentFeature[0]} ------");
2022-07-14 23:10:24 +05:30
indexController.makeNext(indexController.currentFeature[0]);
},
color: Colors.blue,
textColor: Colors.white,
child: Icon(
Icons.arrow_forward_ios,
size: 14,
),
padding: EdgeInsets.all(16),
shape: CircleBorder(),
),
],
2022-07-10 23:50:43 +05:30
),
2022-07-14 23:10:24 +05:30
),
),
Row(
children: [
Expanded(
child: SizedBox(
height: 260.0,
child: Obx(() => getImage()),
)
2022-07-10 23:50:43 +05:30
),
2022-06-27 12:15:54 +05:30
],
2022-07-14 23:10:24 +05:30
),
2022-07-22 10:27:11 +05:30
Obx(() =>
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Row(
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
FutureBuilder<Widget>(
future: wantToGo(context),
builder: (context, snapshot) {
return Container(
child: snapshot.data,
);
},
),
2022-07-25 19:56:32 +05:30
indexController.currentFeature[0].properties!["location_name"] != null && (indexController.currentFeature[0].properties!["location_name"] as String).isNotEmpty ?
2022-07-22 10:27:11 +05:30
Flexible(child: Text(indexController.currentFeature[0].properties!["location_name"]))
:
Container(width: 0.0, height: 0,),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(Icons.thumb_up_alt_sharp),
Text("Like"),
],
),
),
],
),
SizedBox(height: 8.0,),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
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"] ?? '')
:
Container(width: 0.0, height: 0,),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
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"] ?? '')
:
Container(width: 0.0, height: 0,),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
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"] ?? '')
:
Container(width: 0.0, height: 0,),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
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)
:
Container(width: 0.0, height: 0,),
],
),
2022-09-01 19:14:18 +05:30
),
Text(indexController.currentFeature[0].properties!["cp"].toString()),
2022-07-22 10:27:11 +05:30
],
),
)
2022-07-14 23:10:24 +05:30
),
SizedBox(height: 60.0,)
2022-06-27 12:15:54 +05:30
],
2022-07-14 23:10:24 +05:30
),
);
2022-06-27 12:15:54 +05:30
}
2022-07-09 22:51:34 +05:30
2022-07-10 23:50:43 +05:30
Future<Widget> wantToGo(BuildContext context)async {
2022-07-14 23:10:24 +05:30
2022-07-10 23:50:43 +05:30
DatabaseHelper db = DatabaseHelper.instance;
return
Row(
2022-07-09 22:51:34 +05:30
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
2022-07-22 19:36:04 +05:30
indexController.rog_mode == 0 ?
IconButton(
icon: Icon(Icons.pin_drop_sharp, size: 32,),
onPressed: (){
GeoJsonMultiPoint mp = indexController.currentFeature[0].geometry as GeoJsonMultiPoint;
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude, mp.geoSerie!.geoPoints[0].longitude);
2022-07-09 22:51:34 +05:30
2022-07-22 19:36:04 +05:30
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,
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"],
auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0,
2022-09-01 19:14:18 +05:30
cp: indexController.currentFeature[0].properties!["cp"],
checkin_point: indexController.currentFeature[0].properties!["checkin_point"],
buy_point: indexController.currentFeature[0].properties!["buy_point"],
2022-07-22 19:36:04 +05:30
selected: false,
checkedin: false
);
destinationController.addDestinations(dest);
},
):
Container(),
2022-07-22 10:27:11 +05:30
SizedBox(width: 8.0,) ,
2022-07-14 23:10:24 +05:30
Obx((() =>
indexController.rog_mode == 1 ?
ElevatedButton(
onPressed: () async {
Destination dest = indexController.currentDestinationFeature[0]!;
//print("------ curent destination is ${dest!.checkedIn}-------");
if(dest != null){
2022-07-25 19:56:32 +05:30
//print("------ curent destination is ${dest!.checkedin}-------::::::::::");
2022-07-14 23:10:24 +05:30
destinationController.makeCheckin(dest, !dest.checkedin!);
}
},
child: indexController.currentDestinationFeature[0].checkedin == false ?
Text("Check in")
:
Text("Check out")
):
Container()
)
)
2022-07-09 22:51:34 +05:30
],
)
],
);
}
2022-06-27 12:15:54 +05:30
Widget getCheckin(BuildContext context){
2022-07-09 22:51:34 +05:30
2022-07-25 19:56:32 +05:30
//print("------ currentAction ----- ${indexController.currentAction}-----");
2022-07-09 22:51:34 +05:30
2022-06-27 12:15:54 +05:30
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
2022-07-14 23:10:24 +05:30
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
indexController.currentAction[0][0]["checkin"] == false ?
Column(
children: [
Row(
mainAxisSize: MainAxisSize.max,
2022-06-27 12:15:54 +05:30
children: [
ElevatedButton(
2022-07-14 23:10:24 +05:30
child: Text("Image"), onPressed: (){
final ImagePicker _picker = ImagePicker();
_picker.pickImage(source: ImageSource.camera).then((value){
2022-07-25 19:56:32 +05:30
//print("----- image---- ${value!.path}");
2022-07-14 23:10:24 +05:30
});
2022-06-27 12:15:54 +05:30
},
2022-07-14 23:10:24 +05:30
)
2022-06-27 12:15:54 +05:30
],
2022-07-14 23:10:24 +05:30
),
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
2022-07-25 19:56:32 +05:30
//print(indexController.currentAction[0]);
2022-07-14 23:10:24 +05:30
indexController.currentAction[0][0]["checkin"] = true;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
2022-07-25 19:56:32 +05:30
//print("---temp---${temp}");
2022-07-14 23:10:24 +05:30
indexController.currentAction.add([temp]);
}
indexController.makeAction(context);
},
child: Text("checkin".tr)
)
],
)
:
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
2022-07-25 19:56:32 +05:30
//print(indexController.currentAction[0]);
2022-07-14 23:10:24 +05:30
indexController.currentAction[0][0]["checkin"] = false;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
2022-07-25 19:56:32 +05:30
//print("---temp---${temp}");
2022-07-14 23:10:24 +05:30
indexController.currentAction.add([temp]);
}
indexController.makeAction(context);
},
child: Icon(
Icons.favorite, color: Colors.red)
2022-06-27 12:15:54 +05:30
2022-07-14 23:10:24 +05:30
,
)
],
2022-06-27 12:15:54 +05:30
)
],
);
}
2022-07-14 23:10:24 +05:30
2022-06-27 12:15:54 +05:30
2022-07-14 23:10:24 +05:30
Widget getDetails(BuildContext context, String label, String text, {bool isurl=false}){
2022-06-27 12:15:54 +05:30
return Row(
2022-07-14 23:10:24 +05:30
mainAxisAlignment: MainAxisAlignment.center,
2022-06-27 12:15:54 +05:30
children: [
2022-07-14 23:10:24 +05:30
Text(label),
2022-06-27 12:15:54 +05:30
SizedBox(width: 10.0,),
2022-07-15 21:50:14 +05:30
InkWell(
onTap: (){
if(isurl){
if(indexController.rog_mode == 0){
_launchURL(indexController.currentFeature[0].properties!["webcontents"]);
2022-07-14 23:10:24 +05:30
}
2022-07-15 21:50:14 +05:30
else {
indexController.currentDestinationFeature[0].webcontents;
}
}
},
child: Text(text,
style: TextStyle(
color: Colors.blue,
2022-07-14 23:10:24 +05:30
),
2022-07-15 21:50:14 +05:30
overflow: TextOverflow.ellipsis,
maxLines: 5,
),
),
2022-06-27 12:15:54 +05:30
],
);
}
}