fix bottomsheel

This commit is contained in:
Mohamed Nouffer
2023-09-06 21:36:11 +05:30
parent 36751f6ef7
commit 44a3fc21fb
7 changed files with 676 additions and 547 deletions

View File

@ -152,6 +152,9 @@ class DestinationController extends GetxController {
if (is_photo_shoot.value == true) { if (is_photo_shoot.value == true) {
photos.clear(); photos.clear();
showModalBottomSheet( showModalBottomSheet(
constraints: BoxConstraints.loose(Size(
Get.width,
Get.height * 0.75)),
context: Get.context!, context: Get.context!,
isScrollControlled: true, isScrollControlled: true,
builder: ((context) => CameraPage())).whenComplete(() { builder: ((context) => CameraPage())).whenComplete(() {
@ -174,6 +177,9 @@ class DestinationController extends GetxController {
is_in_checkin.value = true; is_in_checkin.value = true;
is_at_start.value = true; is_at_start.value = true;
showModalBottomSheet( showModalBottomSheet(
constraints: BoxConstraints.loose(Size(
Get.width,
Get.height * 0.75)),
context: Get.context!, context: Get.context!,
isScrollControlled: true, isScrollControlled: true,
builder: ((context) => BottomSheetNew())).whenComplete(() { builder: ((context) => BottomSheetNew())).whenComplete(() {
@ -187,6 +193,9 @@ class DestinationController extends GetxController {
chekcs = 2; chekcs = 2;
is_in_checkin.value = true; is_in_checkin.value = true;
showModalBottomSheet( showModalBottomSheet(
constraints: BoxConstraints.loose(Size(
Get.width,
Get.height * 0.75)),
context: Get.context!, context: Get.context!,
isScrollControlled: true, isScrollControlled: true,
builder: ((context) => BottomSheetNew())).whenComplete(() { builder: ((context) => BottomSheetNew())).whenComplete(() {
@ -223,6 +232,9 @@ class DestinationController extends GetxController {
is_in_checkin.value = true; is_in_checkin.value = true;
photos.clear(); photos.clear();
showModalBottomSheet( showModalBottomSheet(
constraints: BoxConstraints.loose(Size(
Get.width,
Get.height * 0.75)),
context: Get.context!, context: Get.context!,
isScrollControlled: true, isScrollControlled: true,
builder: ((context) => CameraPage( builder: ((context) => CameraPage(
@ -273,6 +285,9 @@ class DestinationController extends GetxController {
is_at_goal.value = true; is_at_goal.value = true;
photos.clear(); photos.clear();
showModalBottomSheet( showModalBottomSheet(
constraints: BoxConstraints.loose(Size(
Get.width,
Get.height * 0.75)),
context: Get.context!, context: Get.context!,
isScrollControlled: true, isScrollControlled: true,
builder: ((context) => CameraPage( builder: ((context) => CameraPage(
@ -290,6 +305,9 @@ class DestinationController extends GetxController {
chekcs = 6; chekcs = 6;
is_at_start.value = true; is_at_start.value = true;
showModalBottomSheet( showModalBottomSheet(
constraints: BoxConstraints.loose(Size(
Get.width,
Get.height * 0.75)),
context: Get.context!, context: Get.context!,
isScrollControlled: true, isScrollControlled: true,
builder: ((context) => BottomSheetNew())).whenComplete(() { builder: ((context) => BottomSheetNew())).whenComplete(() {
@ -395,6 +413,9 @@ class DestinationController extends GetxController {
is_in_checkin.value = true; is_in_checkin.value = true;
photos.clear(); photos.clear();
showModalBottomSheet( showModalBottomSheet(
constraints: BoxConstraints.loose(Size(
Get.width,
Get.height * 0.75)),
context: Get.context!, context: Get.context!,
isScrollControlled: true, isScrollControlled: true,
builder: ((context) => CameraPage( builder: ((context) => CameraPage(

View File

@ -1,4 +1,3 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -15,65 +14,68 @@ import 'package:rogapp/utils/text_util.dart';
import 'package:rogapp/widgets/base_layer_widget.dart'; import 'package:rogapp/widgets/base_layer_widget.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart';
class DestinationMapPage extends StatelessWidget { class DestinationMapPage extends StatelessWidget {
DestinationMapPage({Key? key}) : super(key: key); DestinationMapPage({Key? key}) : super(key: key);
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>(); final DestinationController destinationController =
Get.find<DestinationController>();
StreamSubscription? subscription; StreamSubscription? subscription;
final PopupController _popupLayerController = PopupController(); final PopupController _popupLayerController = PopupController();
List<LatLng>? getPoints(){ List<LatLng>? getPoints() {
print("##### --- route point ${indexController.routePoints.length}"); print("##### --- route point ${indexController.routePoints.length}");
List<LatLng> pts = []; List<LatLng> pts = [];
for(PointLatLng p in indexController.routePoints){ for (PointLatLng p in indexController.routePoints) {
LatLng l = LatLng(p.latitude, p.longitude); LatLng l = LatLng(p.latitude, p.longitude);
pts.add(l); pts.add(l);
}
return pts;
} }
return pts;
}
List<Marker>? getMarkers() { List<Marker>? getMarkers() {
List<Marker> pts = []; List<Marker> pts = [];
int index = -1; int index = -1;
for (int i = 0; i < destinationController.destinations.length; i++) { for (int i = 0; i < destinationController.destinations.length; i++) {
Destination d = destinationController.destinations[i]; Destination d = destinationController.destinations[i];
print("^^^^ $d ^^^^"); print("^^^^ $d ^^^^");
Marker m = Marker( Marker m = Marker(
point: LatLng(d.lat!, d.lon!), point: LatLng(d.lat!, d.lon!),
anchorPos: AnchorPos.align(AnchorAlign.center), anchorPos: AnchorPos.align(AnchorAlign.center),
builder:(cts){ builder: (cts) {
return InkWell( return InkWell(
onTap: (){ onTap: () {
print("-- Destination is --- ${d.name} ------"); print("-- Destination is --- ${d.name} ------");
if(indexController.currentDestinationFeature.isNotEmpty) { if (indexController.currentDestinationFeature.isNotEmpty) {
indexController.currentDestinationFeature.clear(); indexController.currentDestinationFeature.clear();
} }
indexController.currentDestinationFeature.add(d); indexController.currentDestinationFeature.add(d);
//indexController.getAction(); //indexController.getAction();
showModalBottomSheet(context: Get.context!, isScrollControlled: true, showModalBottomSheet(
builder:((context) => BottomSheetNew()) context: Get.context!,
).whenComplete((){ isScrollControlled: true,
print("---- set skip gps to false -----"); constraints: BoxConstraints.loose(
destinationController.skip_gps = false; Size(Get.width, Get.height * 0.75)),
}); builder: ((context) => BottomSheetNew())).whenComplete(() {
print("---- set skip gps to false -----");
destinationController.skip_gps = false;
});
}, },
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
width:20, width: 20,
height:20, height: 20,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.red, color: Colors.red,
shape: BoxShape.circle, shape: BoxShape.circle,
border: Border.all( border: Border.all(
color: Colors.white, color: Colors.white,
width: d.checkin_radious != null ? d.checkin_radious! : 1, width:
d.checkin_radious != null ? d.checkin_radious! : 1,
), ),
), ),
child: Center( child: Center(
@ -83,90 +85,93 @@ class DestinationMapPage extends StatelessWidget {
), ),
), ),
), ),
Container( color: Colors.yellow, child: Text(TextUtils.getDisplayText(d), style: const TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, overflow: TextOverflow.visible),)), Container(
color: Colors.yellow,
child: Text(
TextUtils.getDisplayText(d),
style: const TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
overflow: TextOverflow.visible),
)),
], ],
), ),
); );
});
}); pts.add(m);
pts.add(m);
}
return pts;
} }
return pts;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Obx((() => return Obx((() => Stack(
Stack( children: [
children: [ // indexController.is_rog_mapcontroller_loaded.value == false ?
// indexController.is_rog_mapcontroller_loaded.value == false ? // Center(child: CircularProgressIndicator())
// Center(child: CircularProgressIndicator()) // :
// : // Padding(
// Padding( // padding: const EdgeInsets.only(left:8.0),
// padding: const EdgeInsets.only(left:8.0), // child: BreadCrumbWidget(mapController:indexController.rogMapController),
// child: BreadCrumbWidget(mapController:indexController.rogMapController), // ),
// ), Padding(
Padding( padding: const EdgeInsets.only(top: 0.0),
padding: const EdgeInsets.only(top:0.0), //child: TravelMap(),
//child: TravelMap(), child: TravelMap(),
child: ),
TravelMap(), ],
), )));
],
)
));
} }
FlutterMap TravelMap() { FlutterMap TravelMap() {
return FlutterMap( return FlutterMap(
mapController: indexController.rogMapController, mapController: indexController.rogMapController,
options: MapOptions( options: MapOptions(
onMapReady: (){ onMapReady: () {
indexController.is_rog_mapcontroller_loaded.value = true; indexController.is_rog_mapcontroller_loaded.value = true;
subscription = indexController.rogMapController.mapEventStream.listen((MapEvent mapEvent) { subscription = indexController.rogMapController.mapEventStream
if (mapEvent is MapEventMoveStart) { .listen((MapEvent mapEvent) {
} if (mapEvent is MapEventMoveStart) {}
if (mapEvent is MapEventMoveEnd) { if (mapEvent is MapEventMoveEnd) {
//destinationController.is_gps_selected.value = true; //destinationController.is_gps_selected.value = true;
//indexController.mapController!.move(c.center, c.zoom); //indexController.mapController!.move(c.center, c.zoom);
LatLngBounds bounds = indexController.rogMapController.bounds!; LatLngBounds bounds = indexController.rogMapController.bounds!;
indexController.currentBound.clear(); indexController.currentBound.clear();
indexController.currentBound.add(bounds); indexController.currentBound.add(bounds);
if(indexController.currentUser.isEmpty){ if (indexController.currentUser.isEmpty) {
indexController.loadLocationsBound(); indexController.loadLocationsBound();
} }
} }
}); });
} , },
bounds: indexController.currentBound.isNotEmpty ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]), bounds: indexController.currentBound.isNotEmpty
zoom: 1, ? indexController.currentBound[0]
maxZoom: 42, : LatLngBounds.fromPoints([
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag, LatLng(35.03999881162295, 136.40587119778962),
), LatLng(36.642756778706904, 137.95226720406063)
children: [ ]),
const BaseLayer(), zoom: 1,
Obx(() => maxZoom: 42,
indexController.routePointLenght > 0 ? interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
PolylineLayer(
polylines: [
Polyline(
points: getPoints()!,
strokeWidth: 6.0,
color: Colors.indigo
),
],
)
:
Container(),
), ),
CurrentLocationLayer(), children: [
MarkerLayer( const BaseLayer(),
markers: getMarkers()! Obx(
), () => indexController.routePointLenght > 0
], ? PolylineLayer(
polylines: [
); Polyline(
points: getPoints()!,
strokeWidth: 6.0,
color: Colors.indigo),
],
)
: Container(),
),
CurrentLocationLayer(),
MarkerLayer(markers: getMarkers()!),
],
);
} }
} }

View File

@ -7,22 +7,24 @@ import 'package:rogapp/pages/search/search_controller.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart';
class SearchPage extends StatelessWidget { class SearchPage extends StatelessWidget {
SearchPage({Key? key}) : super(key: key); SearchPage({Key? key}) : super(key: key);
SearchBarController searchController = Get.find<SearchBarController>(); SearchBarController searchController = Get.find<SearchBarController>();
IndexController indexController = Get.find<IndexController>(); IndexController indexController = Get.find<IndexController>();
Image getImage(int index){ Image getImage(int index) {
if(searchController.searchResults[index].properties!["photos"] == null || searchController.searchResults[index].properties!["photos"] == ""){ if (searchController.searchResults[index].properties!["photos"] == null ||
searchController.searchResults[index].properties!["photos"] == "") {
return const Image(image: AssetImage('assets/images/empty_image.png')); return const Image(image: AssetImage('assets/images/empty_image.png'));
} } else {
else{
return Image( return Image(
image: NetworkImage(searchController.searchResults[index].properties!["photos"]), image: NetworkImage(
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { searchController.searchResults[index].properties!["photos"]),
errorBuilder:
(BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png"); return Image.asset("assets/images/empty_image.png");
}, },
); );
} }
} }
@ -33,58 +35,65 @@ class SearchPage extends StatelessWidget {
elevation: 0, elevation: 0,
backgroundColor: Colors.white, backgroundColor: Colors.white,
leading: IconButton( leading: IconButton(
onPressed:(){ onPressed: () {
Get.back(); Get.back();
}, },
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black,) icon: const Icon(
), Icons.arrow_back_ios_new,
color: Colors.black,
)),
centerTitle: true, centerTitle: true,
//title: const CupertinoSearchTextField(), //title: const CupertinoSearchTextField(),
), ),
body: SingleChildScrollView( body: SingleChildScrollView(
child: TypeAheadField( child: TypeAheadField(
textFieldConfiguration: TextFieldConfiguration( textFieldConfiguration: TextFieldConfiguration(
autofocus: true, autofocus: true,
style: DefaultTextStyle.of(context).style.copyWith( style: DefaultTextStyle.of(context).style.copyWith(
fontStyle: FontStyle.normal, fontStyle: FontStyle.normal,
fontSize: 15.0, fontSize: 15.0,
),
decoration: InputDecoration(
border: const OutlineInputBorder(),
hintText: "検索",
prefixIcon: const Icon(Icons.search),
suffixIcon: IconButton(
icon: const Icon(Icons.clear),
onPressed: () {
// clear the text field
},
), ),
decoration: InputDecoration(
border: const OutlineInputBorder(),
hintText: "検索",
prefixIcon: const Icon(Icons.search),
suffixIcon: IconButton(
icon: const Icon(Icons.clear),
onPressed: () {
// clear the text field
},
), ),
), ),
suggestionsCallback: (pattern) async{
return searchController.searchResults.where((GeoJsonFeature element) => element.properties!["location_name"].toString().contains(pattern));
//return await
},
itemBuilder: (context, GeoJsonFeature suggestion){
return ListTile(
title: Text(suggestion.properties!["location_name"]),
subtitle: suggestion.properties!["category"] != null ? Text(suggestion.properties!["category"]) : const Text(""),
//leading: getImage(index),
);
},
onSuggestionSelected: (GeoJsonFeature suggestion){
indexController.currentFeature.clear();
indexController.currentFeature.add(suggestion);
Get.back();
showModalBottomSheet(
isScrollControlled: true,
context: context,
//builder: (context) => BottomSheetWidget(),
builder:((context) => BottomSheetNew())
);
},
), ),
suggestionsCallback: (pattern) async {
return searchController.searchResults.where(
(GeoJsonFeature element) => element.properties!["location_name"]
.toString()
.contains(pattern));
//return await
},
itemBuilder: (context, GeoJsonFeature suggestion) {
return ListTile(
title: Text(suggestion.properties!["location_name"]),
subtitle: suggestion.properties!["category"] != null
? Text(suggestion.properties!["category"])
: const Text(""),
//leading: getImage(index),
);
},
onSuggestionSelected: (GeoJsonFeature suggestion) {
indexController.currentFeature.clear();
indexController.currentFeature.add(suggestion);
Get.back();
showModalBottomSheet(
constraints:
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
isScrollControlled: true,
context: context,
//builder: (context) => BottomSheetWidget(),
builder: ((context) => BottomSheetNew()));
},
),
), ),
// Obx(() => // Obx(() =>
// ListView.builder( // ListView.builder(

View File

@ -991,11 +991,15 @@ class BottomSheetNew extends GetView<BottomSheetController> {
} }
}, },
child: SizedBox( child: SizedBox(
width: MediaQuery.of(context).size.width - 160, width: MediaQuery.of(context).size.width - (MediaQuery.of(context).size.width * 0.28),
child: Text( child: Expanded(
text, child: Text(
style: TextStyle( text,
color: isurl ? Colors.blue : Colors.black, textDirection: TextDirection.ltr,
textAlign: TextAlign.justify,
style: TextStyle(
color: isurl ? Colors.blue : Colors.black,
),
), ),
), ),
), ),

View File

@ -9,40 +9,44 @@ import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:timeline_tile/timeline_tile.dart'; import 'package:timeline_tile/timeline_tile.dart';
class DestinationWidget extends StatelessWidget { class DestinationWidget extends StatelessWidget {
DestinationWidget({ Key? key }) : super(key: key); DestinationWidget({Key? key}) : super(key: key);
final DestinationController destinationController = Get.find<DestinationController>(); final DestinationController destinationController =
Get.find<DestinationController>();
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
final List<int> _items = List<int>.generate(50, (int index) => index); final List<int> _items = List<int>.generate(50, (int index) => index);
Image getImage(int index){ Image getImage(int index) {
if(destinationController.destinations[index].photos== null || destinationController.destinations[index].photos == ""){ if (destinationController.destinations[index].photos == null ||
destinationController.destinations[index].photos == "") {
return const Image(image: AssetImage('assets/images/empty_image.png')); return const Image(image: AssetImage('assets/images/empty_image.png'));
} } else {
else{ print(
print("------- image is ${destinationController.destinations[index].photos!}------"); "------- image is ${destinationController.destinations[index].photos!}------");
String _photo = destinationController.destinations[index].photos!; String _photo = destinationController.destinations[index].photos!;
if(_photo.contains('http')){ if (_photo.contains('http')) {
return Image(image: NetworkImage( return Image(
destinationController.destinations[index].photos!), image:
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { NetworkImage(destinationController.destinations[index].photos!),
return Image.asset("assets/images/empty_image.png"); errorBuilder:
}, (BuildContext context, Object exception, StackTrace? stackTrace) {
); return Image.asset("assets/images/empty_image.png");
} },
else { );
String serverUrl = ConstValues.currentServer(); } else {
//print("==== photo is ${server_url + '/media/compressed/' + destinationController.destinations[index].photos!} ==="); String serverUrl = ConstValues.currentServer();
return Image(image: NetworkImage( //print("==== photo is ${server_url + '/media/compressed/' + destinationController.destinations[index].photos!} ===");
'$serverUrl/media/compressed/' + destinationController.destinations[index].photos!), return Image(
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { image: NetworkImage('$serverUrl/media/compressed/' +
return Image.asset("assets/images/empty_image.png"); destinationController.destinations[index].photos!),
}, errorBuilder:
); (BuildContext context, Object exception, StackTrace? stackTrace) {
} return Image.asset("assets/images/empty_image.png");
},
);
}
} }
} }
@ -73,13 +77,13 @@ class DestinationWidget extends StatelessWidget {
void moveUp() { void moveUp() {
Destination? d; Destination? d;
for(Destination ad in destinationController.destinations){ for (Destination ad in destinationController.destinations) {
if(ad.selected == true){ if (ad.selected == true) {
d = ad; d = ad;
break; break;
} }
} }
if(d != null){ if (d != null) {
print("--- selected destination is ${d.list_order}"); print("--- selected destination is ${d.list_order}");
destinationController.makeOrder(d, -1); destinationController.makeOrder(d, -1);
} }
@ -87,42 +91,41 @@ class DestinationWidget extends StatelessWidget {
void moveDown() { void moveDown() {
Destination? d; Destination? d;
for(Destination ad in destinationController.destinations){ for (Destination ad in destinationController.destinations) {
if(ad.selected == true){ if (ad.selected == true) {
d = ad; d = ad;
break; break;
} }
} }
if(d != null){ if (d != null) {
print("--- selected destination is ${d.list_order}"); print("--- selected destination is ${d.list_order}");
destinationController.makeOrder(d, 1); destinationController.makeOrder(d, 1);
} }
} }
void clearall(){ void clearall() {
Get.defaultDialog( Get.defaultDialog(
title: "are_you_sure_want_to_delete_all".tr, title: "are_you_sure_want_to_delete_all".tr,
middleText: "all_added_destination_will_be_deleted".tr, middleText: "all_added_destination_will_be_deleted".tr,
backgroundColor: Colors.blue.shade300, backgroundColor: Colors.blue.shade300,
titleStyle: const TextStyle(color: Colors.white), titleStyle: const TextStyle(color: Colors.white),
middleTextStyle: const TextStyle(color: Colors.white), middleTextStyle: const TextStyle(color: Colors.white),
textConfirm: "confirm".tr, textConfirm: "confirm".tr,
textCancel: "cancel".tr, textCancel: "cancel".tr,
cancelTextColor: Colors.white, cancelTextColor: Colors.white,
confirmTextColor: Colors.blue, confirmTextColor: Colors.blue,
buttonColor: Colors.white, buttonColor: Colors.white,
barrierDismissible: false, barrierDismissible: false,
radius: 10, radius: 10,
content: const Column( content: const Column(
children: [ children: [],
], ),
), onConfirm: () {
onConfirm: (){ destinationController.deleteAllDestinations();
destinationController.deleteAllDestinations(); Get.back();
Get.back(); Get.snackbar(
Get.snackbar("deleted".tr, "all_destinations_are_deleted_successfully".tr); "deleted".tr, "all_destinations_are_deleted_successfully".tr);
} });
);
} }
void interChange() { void interChange() {
@ -142,123 +145,157 @@ class DestinationWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print(
"------ destination widget------ ${destinationController.destinationCount.value} ----------");
print("------ destination widget------ ${destinationController.destinationCount.value} ----------"); return Obx(() => Stack(
return
Obx(() =>
Stack(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(top:45.0), padding: const EdgeInsets.only(top: 45.0),
child: ListView.builder( child: ListView.builder(
itemCount: destinationController.destinationCount.value, itemCount: destinationController.destinationCount.value,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return return TimelineTile(
TimelineTile( alignment: TimelineAlign.manual,
alignment: TimelineAlign.manual, lineXY: 0.2,
lineXY: 0.2, isFirst: index == 0 ? true : false,
isFirst: index == 0 ? true : false, indicatorStyle: IndicatorStyle(
indicatorStyle: IndicatorStyle( indicator: CircleAvatar(
indicator: CircleAvatar( child: Text(
child: Text(destinationController.destinations[index].list_order.toString(), style: const TextStyle(color: Colors.white),), destinationController.destinations[index].list_order
backgroundColor: Colors.red, .toString(),
), style: const TextStyle(color: Colors.white),
), ),
key: Key(index.toString()), backgroundColor: Colors.red,
endChild: Card(
child: Container(
constraints: const BoxConstraints(
minHeight: 80,
),
child: ListTile(
onTap: () async {
{
Destination? fs = destinationController.destinations[index];
print("----fsf-----$index");
if(indexController.currentDestinationFeature.isNotEmpty) {
indexController.currentDestinationFeature.clear();
}
indexController.currentDestinationFeature.add(fs);
print("--- ndexController.currentDestinationFeature ----- ${ indexController.currentDestinationFeature[0].name} ----");
//indexController.getAction();
showModalBottomSheet(context: context, isScrollControlled: true,
//builder:((context) => BottomSheetWidget())
builder:((context) => BottomSheetNew())
);
}
},
onLongPress: (){
destinationController.toggleSelection(destinationController.destinations[index]);
},
selectedTileColor: Colors.amberAccent,
selected:destinationController.destinations[index].selected!,
leading: getImage(index),
title: Text(destinationController.destinations[index].name!),
subtitle: Text(destinationController.destinations[index].category!),
), ),
), ),
), key: Key(index.toString()),
startChild: endChild: Card(
index > 0 && destinationController.matrix["routes"][0]["legs"] != null ? child: Container(
Column( constraints: const BoxConstraints(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, minHeight: 80,
children: [ ),
Text(destinationController.matrix["routes"][0]["legs"][index -1]["distance"] != null ? destinationController.matrix["routes"][0]["legs"][index-1]["distance"]["text"].toString(): ''), child: ListTile(
Text(destinationController.matrix["routes"][0]["legs"][index -1]["duration"] != null ? destinationController.matrix["routes"][0]["legs"][index-1]["duration"]["text"].toString() : '') onTap: () async {
], {
): Destination? fs =
Container() destinationController.destinations[index];
, print("----fsf-----$index");
); if (indexController
.currentDestinationFeature.isNotEmpty) {
indexController.currentDestinationFeature
.clear();
}
indexController.currentDestinationFeature
.add(fs);
print(
"--- ndexController.currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} ----");
//indexController.getAction();
} showModalBottomSheet(
), constraints: BoxConstraints.loose(
Size(Get.width, Get.height * 0.75)),
context: context,
isScrollControlled: true,
//builder:((context) => BottomSheetWidget())
builder: ((context) => BottomSheetNew()));
}
},
onLongPress: () {
destinationController.toggleSelection(
destinationController.destinations[index]);
},
selectedTileColor: Colors.amberAccent,
selected: destinationController
.destinations[index].selected!,
leading: getImage(index),
title: Text(destinationController
.destinations[index].name!),
subtitle: Text(destinationController
.destinations[index].category!),
),
),
),
startChild: index > 0 &&
destinationController.matrix["routes"][0]
["legs"] !=
null
? Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(destinationController.matrix["routes"][0]
["legs"][index - 1]["distance"] !=
null
? destinationController.matrix["routes"][0]
["legs"][index - 1]["distance"]
["text"]
.toString()
: ''),
Text(destinationController.matrix["routes"][0]
["legs"][index - 1]["duration"] !=
null
? destinationController.matrix["routes"][0]
["legs"][index - 1]["duration"]
["text"]
.toString()
: '')
],
)
: Container(),
);
}),
), ),
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.grey.withOpacity(0.3), color: Colors.grey.withOpacity(0.3),
spreadRadius: 5, spreadRadius: 5,
blurRadius: 3, blurRadius: 3,
offset: const Offset(0, 7), // changes position of shadow offset: const Offset(0, 7), // changes position of shadow
), ),
], ],
), ),
height: 44.0, height: 44.0,
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
IconButton( IconButton(
icon:const Icon(Icons.delete_forever), icon: const Icon(Icons.delete_forever),
//onPressed: (){doDelete();}, //onPressed: (){doDelete();},
onPressed: clearall, onPressed: clearall,
), ),
IconButton( IconButton(
icon:const Icon(Icons.cancel), icon: const Icon(Icons.cancel),
//onPressed: (){doDelete();}, //onPressed: (){doDelete();},
onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? doDelete : null, onPressed: destinationController
), .currentSelectedDestinations.isNotEmpty
IconButton( ? doDelete
icon:const Icon(Icons.move_up), : null,
onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? moveUp : null, ),
), IconButton(
IconButton( icon: const Icon(Icons.move_up),
icon:const Icon(Icons.move_down), onPressed: destinationController
onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? moveDown : null, .currentSelectedDestinations.isNotEmpty
), ? moveUp
// IconButton( : null,
// icon:Icon(Icons.sync), ),
// onPressed: destinationController.destination_index_data.length == 2 ? interChange : null, IconButton(
// ), icon: const Icon(Icons.move_down),
], onPressed: destinationController
), .currentSelectedDestinations.isNotEmpty
) ? moveDown
: null,
),
// IconButton(
// icon:Icon(Icons.sync),
// onPressed: destinationController.destination_index_data.length == 2 ? interChange : null,
// ),
],
),
)
], ],
) ));
);
} }
} }

View File

@ -9,7 +9,7 @@ import 'package:rogapp/utils/const.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart';
class ListWidget extends StatefulWidget { class ListWidget extends StatefulWidget {
const ListWidget({ Key? key }) : super(key: key); const ListWidget({Key? key}) : super(key: key);
@override @override
State<ListWidget> createState() => _ListWidgetState(); State<ListWidget> createState() => _ListWidgetState();
@ -18,30 +18,33 @@ class ListWidget extends StatefulWidget {
class _ListWidgetState extends State<ListWidget> { class _ListWidgetState extends State<ListWidget> {
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>(); final DestinationController destinationController =
Get.find<DestinationController>();
Image getImage(int index){ Image getImage(int index) {
if(indexController.locations[0].collection[index].properties!["photos"] == null || indexController.locations[0].collection[index].properties!["photos"] == ""){ if (indexController.locations[0].collection[index].properties!["photos"] ==
null ||
indexController.locations[0].collection[index].properties!["photos"] ==
"") {
return const Image(image: AssetImage('assets/images/empty_image.png')); return const Image(image: AssetImage('assets/images/empty_image.png'));
} } else {
else{
print("==== photo index is $index ==="); print("==== photo index is $index ===");
String serverUrl = ConstValues.currentServer(); String serverUrl = ConstValues.currentServer();
GeoJsonFeature<dynamic> gf = indexController.locations[0].collection[index]; GeoJsonFeature<dynamic> gf =
indexController.locations[0].collection[index];
String _photo = gf.properties!["photos"]; String _photo = gf.properties!["photos"];
return Image( return Image(
image: NetworkImage( image: NetworkImage('$serverUrl/media/compressed/' + _photo),
'$serverUrl/media/compressed/' + _photo errorBuilder:
), (BuildContext context, Object exception, StackTrace? stackTrace) {
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png"); return Image.asset("assets/images/empty_image.png");
}, },
); );
} }
} }
void changeCurrentFeature(GeoJsonFeature fs){ void changeCurrentFeature(GeoJsonFeature fs) {
if(indexController.currentFeature.isNotEmpty){ if (indexController.currentFeature.isNotEmpty) {
indexController.currentFeature.clear(); indexController.currentFeature.clear();
} }
indexController.currentFeature.add(fs); indexController.currentFeature.add(fs);
@ -65,9 +68,11 @@ class _ListWidgetState extends State<ListWidget> {
Future<String> matrixDistance(int i) async { Future<String> matrixDistance(int i) async {
// Create two destinations directly from indexController.locations[0].collection // Create two destinations directly from indexController.locations[0].collection
Destination desCurr = Destination(lat: indexController.current_lat, lon: indexController.current_lon); Destination desCurr = Destination(
lat: indexController.current_lat, lon: indexController.current_lon);
//Destination dest1 = createDestination(indexController.locations[0].collection[0]); //Destination dest1 = createDestination(indexController.locations[0].collection[0]);
Destination dest2 = createDestination(indexController.locations[0].collection[i]); Destination dest2 =
createDestination(indexController.locations[0].collection[i]);
// Get the distance between these two destinations // Get the distance between these two destinations
final res = await MatrixService.getDestinations([desCurr, dest2]); final res = await MatrixService.getDestinations([desCurr, dest2]);
@ -80,74 +85,104 @@ class _ListWidgetState extends State<ListWidget> {
print("pull to refesh"); print("pull to refesh");
indexController.locations[0].collection.sort((a, b) => indexController.locations[0].collection.sort((a, b) =>
(a.properties!['cp'] as Comparable) (a.properties!['cp'] as Comparable)
.compareTo(b.properties!['cp'] as Comparable)); .compareTo(b.properties!['cp'] as Comparable));
setState(() { setState(() {});
});
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Obx(() => return Obx(
indexController.locations.isNotEmpty ? () => indexController.locations.isNotEmpty
RefreshIndicator( ? RefreshIndicator(
onRefresh: _pullRefresh, onRefresh: _pullRefresh,
child: ListView.builder( child: ListView.builder(
itemCount: indexController.locations[0].collection.length, itemCount: indexController.locations[0].collection.length,
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (_, index){ itemBuilder: (_, index) {
bool _is_found = false; bool _is_found = false;
for(Destination d in destinationController.destinations){ for (Destination d in destinationController.destinations) {
if(indexController.locations[0].collection[index].properties!['location_id'] == d.location_id){ if (indexController.locations[0].collection[index]
.properties!['location_id'] ==
d.location_id) {
_is_found = true; _is_found = true;
break; break;
} }
} }
return Card( return Card(
child: ListTile( child: ListTile(
selected: _is_found, selected: _is_found,
selectedTileColor: Colors.yellow.shade200,
selectedTileColor: Colors.yellow.shade200, onTap: () {
onTap: (){ GeoJsonFeature gf =
GeoJsonFeature gf = indexController.locations[0].collection[index]; indexController.locations[0].collection[index];
changeCurrentFeature(gf); changeCurrentFeature(gf);
showModalBottomSheet( showModalBottomSheet(
isScrollControlled: true, constraints: BoxConstraints.loose(
context: context, Size(Get.width, Get.height * 0.75)),
//builder: (context) => BottomSheetWidget(), isScrollControlled: true,
builder:((context) => BottomSheetNew()) context: context,
); //builder: (context) => BottomSheetWidget(),
}, builder: ((context) => BottomSheetNew()));
leading: getImage(index), },
title: indexController.locations[0].collection[index].properties!['location_name'] != null ? Text(indexController.locations[0].collection[index].properties!['location_name'].toString()) : const Text(""), leading: getImage(index),
subtitle: indexController.locations[0].collection[index].properties!['category'] != null ? Text(indexController.locations[0].collection[index].properties!['category']) : const Text(""), title: indexController.locations[0].collection[index]
trailing: Column( .properties!['location_name'] !=
crossAxisAlignment: CrossAxisAlignment.end, null
children: [ ? Text(indexController.locations[0]
indexController.locations[0].collection[index].properties!['sub_loc_id'] != null ? Text(indexController.locations[0].collection[index].properties!['sub_loc_id']) : const Text(""), .collection[index].properties!['location_name']
SizedBox( .toString())
width: 100, : const Text(""),
child: FutureBuilder<String>( subtitle: indexController.locations[0].collection[index]
future: matrixDistance(index), .properties!['category'] !=
builder: (context, snapshot){ null
if(snapshot.connectionState == ConnectionState.waiting){ ? Text(indexController.locations[0]
return const Center(child: CircularProgressIndicator(),); .collection[index].properties!['category'])
} : const Text(""),
if(snapshot.hasError){ trailing: Column(
return const Text("-"); crossAxisAlignment: CrossAxisAlignment.end,
} children: [
else{ indexController.locations[0].collection[index]
return Text(snapshot.data ?? '', style: const TextStyle(color: Colors.red, fontWeight: FontWeight.bold),); .properties!['sub_loc_id'] !=
} null
}, ? Text(indexController
), .locations[0]
) .collection[index]
], .properties!['sub_loc_id'])
) : const Text(""),
), SizedBox(
width: 100,
child: FutureBuilder<String>(
future: matrixDistance(index),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
if (snapshot.hasError) {
return const Text("-");
} else {
return Text(
snapshot.data ?? '',
style: const TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold),
);
}
},
),
)
],
)),
); );
}, },
), ),
) : const SizedBox(width: 0, height: 0,), )
); : const SizedBox(
width: 0,
height: 0,
),
);
} }
} }

View File

@ -14,176 +14,194 @@ import 'package:rogapp/widgets/base_layer_widget.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart';
class MapWidget extends StatelessWidget { class MapWidget extends StatelessWidget {
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>(); final DestinationController destinationController =
Get.find<DestinationController>();
MapWidget({ Key? key}) : super(key: key); MapWidget({Key? key}) : super(key: key);
StreamSubscription? subscription; StreamSubscription? subscription;
Widget getMarkerShape(GeoJsonFeature i, BuildContext context){ Widget getMarkerShape(GeoJsonFeature i, BuildContext context) {
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint; GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
//print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}"); //print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
RegExp regex = RegExp(r'([.]*0)(?!.*\d)'); RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
InkWell( InkWell(
onTap: () { onTap: () {
GeoJsonFeature? fs = indexController.getFeatureForLatLong(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude); GeoJsonFeature? fs = indexController.getFeatureForLatLong(
print("------- fs $fs------"); p.geoSerie!.geoPoints[0].latitude,
if(fs != null){ p.geoSerie!.geoPoints[0].longitude);
indexController.currentFeature.clear(); print("------- fs $fs------");
indexController.currentFeature.add(fs); if (fs != null) {
//print("----- fs is ${fs.properties!['photos']}"); indexController.currentFeature.clear();
indexController.getAction(); indexController.currentFeature.add(fs);
//print("----- fs is ${fs.properties!['photos']}");
indexController.getAction();
showModalBottomSheet( showModalBottomSheet(
context: context, constraints:
isScrollControlled: true, BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
isDismissible: true, context: context,
builder:((context) => BottomSheetNew()) isScrollControlled: true,
//builder:((context) => BottomSheetWidget()) isDismissible: true,
).whenComplete((){ builder: ((context) => BottomSheetNew())
destinationController.skip_gps = false; //builder:((context) => BottomSheetWidget())
}); ).whenComplete(() {
} destinationController.skip_gps = false;
});
}
},
child: Container(
}, height: 32,
child: Container( width: 32,
height: 32, decoration: BoxDecoration(
width: 32, shape: BoxShape.circle,
decoration: BoxDecoration( color: Colors.transparent,
shape: BoxShape.circle, border: Border.all(
color: Colors.transparent, color: i.properties!['buy_point'] > 0
border: Border.all( ? Colors.blue
color: i.properties!['buy_point'] > 0 ? Colors.blue : Colors.red, : Colors.red,
width: 3, width: 3,
style: BorderStyle.solid style: BorderStyle.solid)),
) child: Stack(
), alignment: Alignment.center,
child: Stack( children: [
alignment: Alignment.center, const Icon(
children: [ Icons.circle,
const Icon(Icons.circle,size: 6.0,), size: 6.0,
i.properties!['cp'] == -1 ? ),
Transform.rotate( i.properties!['cp'] == -1
alignment: Alignment.centerLeft, ? Transform.rotate(
origin: Offset.fromDirection(1, 26), alignment: Alignment.centerLeft,
angle: 270 * pi / 180, origin: Offset.fromDirection(1, 26),
child: const Icon(Icons.play_arrow_outlined, color: Colors.red, size: 70,)): angle: 270 * pi / 180,
Container(color: Colors.transparent,), child: const Icon(
], Icons.play_arrow_outlined,
) color: Colors.red,
), size: 70,
), ))
Container(color: Colors.white, child: Text(TextUtils.getDisplayTextFeture(i), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color:Colors.red,))), : Container(
], color: Colors.transparent,
); ),
],
)),
),
Container(
color: Colors.white,
child: Text(TextUtils.getDisplayTextFeture(i),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.red,
))),
],
);
} }
List<LatLng>? getPoints(){ List<LatLng>? getPoints() {
print("##### --- route point ${indexController.routePoints.length}"); print("##### --- route point ${indexController.routePoints.length}");
List<LatLng> pts = []; List<LatLng> pts = [];
for(PointLatLng p in indexController.routePoints){ for (PointLatLng p in indexController.routePoints) {
LatLng l = LatLng(p.latitude, p.longitude); LatLng l = LatLng(p.latitude, p.longitude);
pts.add(l); pts.add(l);
}
return pts;
} }
return pts;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print(
print("---------- rog mode is ${indexController.rog_mode.value.toString()}----------"); "---------- rog mode is ${indexController.rog_mode.value.toString()}----------");
final PopupController _popupController = PopupController(); final PopupController _popupController = PopupController();
return Stack( return Stack(
children: [ children: [
Obx(() => Obx(() => indexController.is_loading == true
indexController.is_loading == true ? const Padding( ? const Padding(
padding: EdgeInsets.only(top: 60.0), padding: EdgeInsets.only(top: 60.0),
child: CircularProgressIndicator(), child: CircularProgressIndicator(),
): )
FlutterMap( : FlutterMap(
mapController: indexController.mapController, mapController: indexController.mapController,
options: MapOptions( options: MapOptions(
maxZoom:18.4, maxZoom: 18.4,
onMapReady: (){ onMapReady: () {
indexController.is_mapController_loaded.value = true; indexController.is_mapController_loaded.value = true;
subscription = indexController.mapController.mapEventStream.listen((MapEvent mapEvent) { subscription = indexController.mapController.mapEventStream
if (mapEvent is MapEventMoveStart) { .listen((MapEvent mapEvent) {
//print(DateTime.now().toString() + ' [MapEventMoveStart] START'); if (mapEvent is MapEventMoveStart) {
// do something //print(DateTime.now().toString() + ' [MapEventMoveStart] START');
} // do something
if (mapEvent is MapEventMoveEnd && indexController.currentUser.isEmpty) { }
//print(DateTime.now().toString() + ' [MapEventMoveStart] END'); if (mapEvent is MapEventMoveEnd &&
indexController.loadLocationsBound(); indexController.currentUser.isEmpty) {
//indexController.rogMapController!.move(c.center, c.zoom); //print(DateTime.now().toString() + ' [MapEventMoveStart] END');
} indexController.loadLocationsBound();
}); //indexController.rogMapController!.move(c.center, c.zoom);
}
});
},
//center: LatLng(37.15319600454702, 139.58765950528198),
bounds: indexController.currentBound.isNotEmpty
? indexController.currentBound[0]
: LatLngBounds.fromPoints([
LatLng(35.03999881162295, 136.40587119778962),
LatLng(36.642756778706904, 137.95226720406063)
]),
zoom: 1,
interactiveFlags:
InteractiveFlag.pinchZoom | InteractiveFlag.drag,
}, onPositionChanged: (MapPosition pos, isvalue) {},
//center: LatLng(37.15319600454702, 139.58765950528198), onTap: (_, __) => _popupController
bounds: indexController.currentBound.isNotEmpty ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]), .hideAllPopups(), // Hide popup when the map is tapped.
zoom: 1, ),
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag, children: [
const BaseLayer(),
onPositionChanged: (MapPosition pos, isvalue){ Obx(
() => indexController.routePointLenght > 0
}, ? PolylineLayer(
onTap: (_, __) => polylines: [
_popupController Polyline(
.hideAllPopups(), // Hide popup when the map is tapped. points: getPoints()!,
), strokeWidth: 6.0,
children: [ color: Colors.indigo),
const BaseLayer(), ],
Obx(() =>
indexController.routePointLenght > 0 ?
PolylineLayer(
polylines: [
Polyline(
points: getPoints()!,
strokeWidth: 6.0,
color: Colors.indigo
),
],
)
:
Container(),
),
CurrentLocationLayer(),
indexController.locations.isNotEmpty && indexController.locations[0].collection.isNotEmpty ?
MarkerLayer(
markers:indexController.locations[0].collection.map((i) {
print("i si ${i.properties!['location_id']}");
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
return Marker(
anchorPos: AnchorPos.exactly(Anchor(108.0, 18.0)),
height: 32.0,
width: 120.0,
point: LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude),
builder: (ctx){
return getMarkerShape(i, context);
},
);
}).toList(),
) )
: : Container(),
const Center(child: CircularProgressIndicator()) ),
, CurrentLocationLayer(),
], indexController.locations.isNotEmpty &&
) indexController.locations[0].collection.isNotEmpty
) ? MarkerLayer(
], markers:
); indexController.locations[0].collection.map((i) {
print("i si ${i.properties!['location_id']}");
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
GeoJsonMultiPoint p =
i.geometry as GeoJsonMultiPoint;
print(
"lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
return Marker(
anchorPos: AnchorPos.exactly(Anchor(108.0, 18.0)),
height: 32.0,
width: 120.0,
point: LatLng(p.geoSerie!.geoPoints[0].latitude,
p.geoSerie!.geoPoints[0].longitude),
builder: (ctx) {
return getMarkerShape(i, context);
},
);
}).toList(),
)
: const Center(child: CircularProgressIndicator()),
],
))
],
);
} }
} }