diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index 5bb3dee..21b2ab9 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -152,6 +152,9 @@ class DestinationController extends GetxController { if (is_photo_shoot.value == true) { photos.clear(); showModalBottomSheet( + constraints: BoxConstraints.loose(Size( + Get.width, + Get.height * 0.75)), context: Get.context!, isScrollControlled: true, builder: ((context) => CameraPage())).whenComplete(() { @@ -174,6 +177,9 @@ class DestinationController extends GetxController { is_in_checkin.value = true; is_at_start.value = true; showModalBottomSheet( + constraints: BoxConstraints.loose(Size( + Get.width, + Get.height * 0.75)), context: Get.context!, isScrollControlled: true, builder: ((context) => BottomSheetNew())).whenComplete(() { @@ -187,6 +193,9 @@ class DestinationController extends GetxController { chekcs = 2; is_in_checkin.value = true; showModalBottomSheet( + constraints: BoxConstraints.loose(Size( + Get.width, + Get.height * 0.75)), context: Get.context!, isScrollControlled: true, builder: ((context) => BottomSheetNew())).whenComplete(() { @@ -223,6 +232,9 @@ class DestinationController extends GetxController { is_in_checkin.value = true; photos.clear(); showModalBottomSheet( + constraints: BoxConstraints.loose(Size( + Get.width, + Get.height * 0.75)), context: Get.context!, isScrollControlled: true, builder: ((context) => CameraPage( @@ -273,6 +285,9 @@ class DestinationController extends GetxController { is_at_goal.value = true; photos.clear(); showModalBottomSheet( + constraints: BoxConstraints.loose(Size( + Get.width, + Get.height * 0.75)), context: Get.context!, isScrollControlled: true, builder: ((context) => CameraPage( @@ -290,6 +305,9 @@ class DestinationController extends GetxController { chekcs = 6; is_at_start.value = true; showModalBottomSheet( + constraints: BoxConstraints.loose(Size( + Get.width, + Get.height * 0.75)), context: Get.context!, isScrollControlled: true, builder: ((context) => BottomSheetNew())).whenComplete(() { @@ -395,6 +413,9 @@ class DestinationController extends GetxController { is_in_checkin.value = true; photos.clear(); showModalBottomSheet( + constraints: BoxConstraints.loose(Size( + Get.width, + Get.height * 0.75)), context: Get.context!, isScrollControlled: true, builder: ((context) => CameraPage( diff --git a/lib/pages/destination_map/destination_map_page.dart b/lib/pages/destination_map/destination_map_page.dart index c164f3e..17ad8b9 100644 --- a/lib/pages/destination_map/destination_map_page.dart +++ b/lib/pages/destination_map/destination_map_page.dart @@ -1,4 +1,3 @@ - import 'dart:async'; 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/bottom_sheet_new.dart'; - class DestinationMapPage extends StatelessWidget { DestinationMapPage({Key? key}) : super(key: key); final IndexController indexController = Get.find(); - final DestinationController destinationController = Get.find(); + final DestinationController destinationController = + Get.find(); StreamSubscription? subscription; final PopupController _popupLayerController = PopupController(); - List? getPoints(){ - print("##### --- route point ${indexController.routePoints.length}"); - List pts = []; - for(PointLatLng p in indexController.routePoints){ - LatLng l = LatLng(p.latitude, p.longitude); - pts.add(l); - } - return pts; + List? getPoints() { + print("##### --- route point ${indexController.routePoints.length}"); + List pts = []; + for (PointLatLng p in indexController.routePoints) { + LatLng l = LatLng(p.latitude, p.longitude); + pts.add(l); } + return pts; + } - List? getMarkers() { - List pts = []; - int index = -1; - for (int i = 0; i < destinationController.destinations.length; i++) { - Destination d = destinationController.destinations[i]; - print("^^^^ $d ^^^^"); - Marker m = Marker( + List? getMarkers() { + List pts = []; + int index = -1; + for (int i = 0; i < destinationController.destinations.length; i++) { + Destination d = destinationController.destinations[i]; + print("^^^^ $d ^^^^"); + Marker m = Marker( point: LatLng(d.lat!, d.lon!), anchorPos: AnchorPos.align(AnchorAlign.center), - builder:(cts){ - + builder: (cts) { return InkWell( - onTap: (){ - print("-- Destination is --- ${d.name} ------"); - if(indexController.currentDestinationFeature.isNotEmpty) { - indexController.currentDestinationFeature.clear(); - } - indexController.currentDestinationFeature.add(d); - //indexController.getAction(); - - showModalBottomSheet(context: Get.context!, isScrollControlled: true, - builder:((context) => BottomSheetNew()) - ).whenComplete((){ - print("---- set skip gps to false -----"); - destinationController.skip_gps = false; - }); + onTap: () { + print("-- Destination is --- ${d.name} ------"); + if (indexController.currentDestinationFeature.isNotEmpty) { + indexController.currentDestinationFeature.clear(); + } + indexController.currentDestinationFeature.add(d); + //indexController.getAction(); + + showModalBottomSheet( + context: Get.context!, + isScrollControlled: true, + constraints: BoxConstraints.loose( + Size(Get.width, Get.height * 0.75)), + builder: ((context) => BottomSheetNew())).whenComplete(() { + print("---- set skip gps to false -----"); + destinationController.skip_gps = false; + }); }, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - width:20, - height:20, - decoration: BoxDecoration( + width: 20, + height: 20, + decoration: BoxDecoration( color: Colors.red, shape: BoxShape.circle, border: Border.all( color: Colors.white, - width: d.checkin_radious != null ? d.checkin_radious! : 1, + width: + d.checkin_radious != null ? d.checkin_radious! : 1, ), ), 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); - } - return pts; + }); + + pts.add(m); } + return pts; + } @override Widget build(BuildContext context) { - return Obx((() => - Stack( - children: [ - // indexController.is_rog_mapcontroller_loaded.value == false ? - // Center(child: CircularProgressIndicator()) - // : - // Padding( - // padding: const EdgeInsets.only(left:8.0), - // child: BreadCrumbWidget(mapController:indexController.rogMapController), - // ), - Padding( - padding: const EdgeInsets.only(top:0.0), - //child: TravelMap(), - child: - TravelMap(), - ), - ], - ) - )); + return Obx((() => Stack( + children: [ + // indexController.is_rog_mapcontroller_loaded.value == false ? + // Center(child: CircularProgressIndicator()) + // : + // Padding( + // padding: const EdgeInsets.only(left:8.0), + // child: BreadCrumbWidget(mapController:indexController.rogMapController), + // ), + Padding( + padding: const EdgeInsets.only(top: 0.0), + //child: TravelMap(), + child: TravelMap(), + ), + ], + ))); } FlutterMap TravelMap() { return FlutterMap( mapController: indexController.rogMapController, - options: MapOptions( - onMapReady: (){ - indexController.is_rog_mapcontroller_loaded.value = true; - subscription = indexController.rogMapController.mapEventStream.listen((MapEvent mapEvent) { - if (mapEvent is MapEventMoveStart) { - } + options: MapOptions( + onMapReady: () { + indexController.is_rog_mapcontroller_loaded.value = true; + subscription = indexController.rogMapController.mapEventStream + .listen((MapEvent mapEvent) { + if (mapEvent is MapEventMoveStart) {} if (mapEvent is MapEventMoveEnd) { //destinationController.is_gps_selected.value = true; //indexController.mapController!.move(c.center, c.zoom); LatLngBounds bounds = indexController.rogMapController.bounds!; indexController.currentBound.clear(); indexController.currentBound.add(bounds); - if(indexController.currentUser.isEmpty){ + if (indexController.currentUser.isEmpty) { indexController.loadLocationsBound(); } } }); - } , - bounds: indexController.currentBound.isNotEmpty ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]), - zoom: 1, - maxZoom: 42, - interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag, - ), - children: [ - const BaseLayer(), - Obx(() => - indexController.routePointLenght > 0 ? - PolylineLayer( - polylines: [ - Polyline( - points: getPoints()!, - strokeWidth: 6.0, - color: Colors.indigo - ), - ], - ) - - : - Container(), + }, + bounds: indexController.currentBound.isNotEmpty + ? indexController.currentBound[0] + : LatLngBounds.fromPoints([ + LatLng(35.03999881162295, 136.40587119778962), + LatLng(36.642756778706904, 137.95226720406063) + ]), + zoom: 1, + maxZoom: 42, + interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag, ), - CurrentLocationLayer(), - MarkerLayer( - markers: getMarkers()! - ), - ], - - ); + children: [ + const BaseLayer(), + Obx( + () => indexController.routePointLenght > 0 + ? PolylineLayer( + polylines: [ + Polyline( + points: getPoints()!, + strokeWidth: 6.0, + color: Colors.indigo), + ], + ) + : Container(), + ), + CurrentLocationLayer(), + MarkerLayer(markers: getMarkers()!), + ], + ); } } diff --git a/lib/pages/search/search_page.dart b/lib/pages/search/search_page.dart index 7188379..b6cd85a 100644 --- a/lib/pages/search/search_page.dart +++ b/lib/pages/search/search_page.dart @@ -7,22 +7,24 @@ import 'package:rogapp/pages/search/search_controller.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart'; class SearchPage extends StatelessWidget { - SearchPage({Key? key}) : super(key: key); + SearchPage({Key? key}) : super(key: key); SearchBarController searchController = Get.find(); IndexController indexController = Get.find(); - Image getImage(int index){ - if(searchController.searchResults[index].properties!["photos"] == null || searchController.searchResults[index].properties!["photos"] == ""){ + Image getImage(int index) { + if (searchController.searchResults[index].properties!["photos"] == null || + searchController.searchResults[index].properties!["photos"] == "") { return const Image(image: AssetImage('assets/images/empty_image.png')); - } - else{ + } else { return Image( - image: NetworkImage(searchController.searchResults[index].properties!["photos"]), - errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { + image: NetworkImage( + searchController.searchResults[index].properties!["photos"]), + errorBuilder: + (BuildContext context, Object exception, StackTrace? stackTrace) { return Image.asset("assets/images/empty_image.png"); }, - ); + ); } } @@ -33,60 +35,67 @@ class SearchPage extends StatelessWidget { elevation: 0, backgroundColor: Colors.white, leading: IconButton( - onPressed:(){ - Get.back(); - }, - icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black,) - ), + onPressed: () { + Get.back(); + }, + icon: const Icon( + Icons.arrow_back_ios_new, + color: Colors.black, + )), centerTitle: true, //title: const CupertinoSearchTextField(), - ), body: SingleChildScrollView( child: TypeAheadField( - textFieldConfiguration: TextFieldConfiguration( - autofocus: true, - style: DefaultTextStyle.of(context).style.copyWith( - fontStyle: FontStyle.normal, - 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 - }, + textFieldConfiguration: TextFieldConfiguration( + autofocus: true, + style: DefaultTextStyle.of(context).style.copyWith( + fontStyle: FontStyle.normal, + 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 + }, ), ), - 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( // itemCount: searchController.searchResults.length, // itemBuilder: (context, index){ @@ -111,4 +120,4 @@ class SearchPage extends StatelessWidget { // ) ); } -} \ No newline at end of file +} diff --git a/lib/widgets/bottom_sheet_new.dart b/lib/widgets/bottom_sheet_new.dart index 4404bc5..b323cc8 100644 --- a/lib/widgets/bottom_sheet_new.dart +++ b/lib/widgets/bottom_sheet_new.dart @@ -991,11 +991,15 @@ class BottomSheetNew extends GetView { } }, child: SizedBox( - width: MediaQuery.of(context).size.width - 160, - child: Text( - text, - style: TextStyle( - color: isurl ? Colors.blue : Colors.black, + width: MediaQuery.of(context).size.width - (MediaQuery.of(context).size.width * 0.28), + child: Expanded( + child: Text( + text, + textDirection: TextDirection.ltr, + textAlign: TextAlign.justify, + style: TextStyle( + color: isurl ? Colors.blue : Colors.black, + ), ), ), ), diff --git a/lib/widgets/destination_widget.dart b/lib/widgets/destination_widget.dart index 4d2d34e..e45f1b5 100644 --- a/lib/widgets/destination_widget.dart +++ b/lib/widgets/destination_widget.dart @@ -9,40 +9,44 @@ import 'package:rogapp/widgets/bottom_sheet_new.dart'; import 'package:timeline_tile/timeline_tile.dart'; class DestinationWidget extends StatelessWidget { - DestinationWidget({ Key? key }) : super(key: key); + DestinationWidget({Key? key}) : super(key: key); - final DestinationController destinationController = Get.find(); + final DestinationController destinationController = + Get.find(); final IndexController indexController = Get.find(); final List _items = List.generate(50, (int index) => index); - Image getImage(int index){ - if(destinationController.destinations[index].photos== null || destinationController.destinations[index].photos == ""){ + Image getImage(int index) { + if (destinationController.destinations[index].photos == null || + destinationController.destinations[index].photos == "") { return const Image(image: AssetImage('assets/images/empty_image.png')); - } - else{ - print("------- image is ${destinationController.destinations[index].photos!}------"); + } else { + print( + "------- image is ${destinationController.destinations[index].photos!}------"); String _photo = destinationController.destinations[index].photos!; - if(_photo.contains('http')){ - return Image(image: NetworkImage( - destinationController.destinations[index].photos!), - errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { - return Image.asset("assets/images/empty_image.png"); - }, - ); - } - else { - String serverUrl = ConstValues.currentServer(); - //print("==== photo is ${server_url + '/media/compressed/' + destinationController.destinations[index].photos!} ==="); - return Image(image: NetworkImage( - '$serverUrl/media/compressed/' + destinationController.destinations[index].photos!), - errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { - return Image.asset("assets/images/empty_image.png"); - }, - ); - } - + if (_photo.contains('http')) { + return Image( + image: + NetworkImage(destinationController.destinations[index].photos!), + errorBuilder: + (BuildContext context, Object exception, StackTrace? stackTrace) { + return Image.asset("assets/images/empty_image.png"); + }, + ); + } else { + String serverUrl = ConstValues.currentServer(); + //print("==== photo is ${server_url + '/media/compressed/' + destinationController.destinations[index].photos!} ==="); + return Image( + image: NetworkImage('$serverUrl/media/compressed/' + + 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() { Destination? d; - for(Destination ad in destinationController.destinations){ - if(ad.selected == true){ + for (Destination ad in destinationController.destinations) { + if (ad.selected == true) { d = ad; break; } } - if(d != null){ + if (d != null) { print("--- selected destination is ${d.list_order}"); destinationController.makeOrder(d, -1); } @@ -87,42 +91,41 @@ class DestinationWidget extends StatelessWidget { void moveDown() { Destination? d; - for(Destination ad in destinationController.destinations){ - if(ad.selected == true){ + for (Destination ad in destinationController.destinations) { + if (ad.selected == true) { d = ad; break; } } - if(d != null){ + if (d != null) { print("--- selected destination is ${d.list_order}"); destinationController.makeOrder(d, 1); } } - void clearall(){ + void clearall() { Get.defaultDialog( - title: "are_you_sure_want_to_delete_all".tr, - middleText: "all_added_destination_will_be_deleted".tr, - backgroundColor: Colors.blue.shade300, - titleStyle: const TextStyle(color: Colors.white), - middleTextStyle: const TextStyle(color: Colors.white), - textConfirm: "confirm".tr, - textCancel: "cancel".tr, - cancelTextColor: Colors.white, - confirmTextColor: Colors.blue, - buttonColor: Colors.white, - barrierDismissible: false, - radius: 10, - content: const Column( - children: [ - ], - ), - onConfirm: (){ - destinationController.deleteAllDestinations(); - Get.back(); - Get.snackbar("deleted".tr, "all_destinations_are_deleted_successfully".tr); - } - ); + title: "are_you_sure_want_to_delete_all".tr, + middleText: "all_added_destination_will_be_deleted".tr, + backgroundColor: Colors.blue.shade300, + titleStyle: const TextStyle(color: Colors.white), + middleTextStyle: const TextStyle(color: Colors.white), + textConfirm: "confirm".tr, + textCancel: "cancel".tr, + cancelTextColor: Colors.white, + confirmTextColor: Colors.blue, + buttonColor: Colors.white, + barrierDismissible: false, + radius: 10, + content: const Column( + children: [], + ), + onConfirm: () { + destinationController.deleteAllDestinations(); + Get.back(); + Get.snackbar( + "deleted".tr, "all_destinations_are_deleted_successfully".tr); + }); } void interChange() { @@ -142,123 +145,157 @@ class DestinationWidget extends StatelessWidget { @override Widget build(BuildContext context) { + print( + "------ destination widget------ ${destinationController.destinationCount.value} ----------"); - print("------ destination widget------ ${destinationController.destinationCount.value} ----------"); - - return - Obx(() => - Stack( + return Obx(() => Stack( children: [ - Padding( - padding: const EdgeInsets.only(top:45.0), - child: ListView.builder( + Padding( + padding: const EdgeInsets.only(top: 45.0), + child: ListView.builder( itemCount: destinationController.destinationCount.value, itemBuilder: (BuildContext context, int index) { - return - TimelineTile( - alignment: TimelineAlign.manual, - lineXY: 0.2, - isFirst: index == 0 ? true : false, - indicatorStyle: IndicatorStyle( - indicator: CircleAvatar( - child: Text(destinationController.destinations[index].list_order.toString(), style: const TextStyle(color: Colors.white),), - backgroundColor: Colors.red, - ), - ), - key: Key(index.toString()), - 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!), + return TimelineTile( + alignment: TimelineAlign.manual, + lineXY: 0.2, + isFirst: index == 0 ? true : false, + indicatorStyle: IndicatorStyle( + indicator: CircleAvatar( + child: Text( + destinationController.destinations[index].list_order + .toString(), + style: const TextStyle(color: Colors.white), + ), + backgroundColor: Colors.red, ), ), - ), - 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() - , - ); - - } - ), + key: Key(index.toString()), + 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( + 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( - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.3), - spreadRadius: 5, - blurRadius: 3, - offset: const Offset(0, 7), // changes position of shadow - ), - ], - ), - height: 44.0, - width: MediaQuery.of(context).size.width, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - IconButton( - icon:const Icon(Icons.delete_forever), - //onPressed: (){doDelete();}, - onPressed: clearall, - ), - IconButton( - icon:const Icon(Icons.cancel), - //onPressed: (){doDelete();}, - onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? doDelete : null, - ), - IconButton( - icon:const Icon(Icons.move_up), - onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? moveUp : 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, - // ), - ], - ), - ) + Container( + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.3), + spreadRadius: 5, + blurRadius: 3, + offset: const Offset(0, 7), // changes position of shadow + ), + ], + ), + height: 44.0, + width: MediaQuery.of(context).size.width, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + icon: const Icon(Icons.delete_forever), + //onPressed: (){doDelete();}, + onPressed: clearall, + ), + IconButton( + icon: const Icon(Icons.cancel), + //onPressed: (){doDelete();}, + onPressed: destinationController + .currentSelectedDestinations.isNotEmpty + ? doDelete + : null, + ), + IconButton( + icon: const Icon(Icons.move_up), + onPressed: destinationController + .currentSelectedDestinations.isNotEmpty + ? moveUp + : 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, + // ), + ], + ), + ) ], - ) - ); + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/list_widget.dart b/lib/widgets/list_widget.dart index a8f9958..12a6f0b 100644 --- a/lib/widgets/list_widget.dart +++ b/lib/widgets/list_widget.dart @@ -9,7 +9,7 @@ import 'package:rogapp/utils/const.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart'; class ListWidget extends StatefulWidget { - const ListWidget({ Key? key }) : super(key: key); + const ListWidget({Key? key}) : super(key: key); @override State createState() => _ListWidgetState(); @@ -18,30 +18,33 @@ class ListWidget extends StatefulWidget { class _ListWidgetState extends State { final IndexController indexController = Get.find(); - final DestinationController destinationController = Get.find(); + final DestinationController destinationController = + Get.find(); - Image getImage(int index){ - if(indexController.locations[0].collection[index].properties!["photos"] == null || indexController.locations[0].collection[index].properties!["photos"] == ""){ + Image getImage(int index) { + 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')); - } - else{ + } else { print("==== photo index is $index ==="); String serverUrl = ConstValues.currentServer(); - GeoJsonFeature gf = indexController.locations[0].collection[index]; + GeoJsonFeature gf = + indexController.locations[0].collection[index]; String _photo = gf.properties!["photos"]; return Image( - image: NetworkImage( - '$serverUrl/media/compressed/' + _photo - ), - errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { + image: NetworkImage('$serverUrl/media/compressed/' + _photo), + errorBuilder: + (BuildContext context, Object exception, StackTrace? stackTrace) { return Image.asset("assets/images/empty_image.png"); }, - ); + ); } } - void changeCurrentFeature(GeoJsonFeature fs){ - if(indexController.currentFeature.isNotEmpty){ + void changeCurrentFeature(GeoJsonFeature fs) { + if (indexController.currentFeature.isNotEmpty) { indexController.currentFeature.clear(); } indexController.currentFeature.add(fs); @@ -65,9 +68,11 @@ class _ListWidgetState extends State { Future matrixDistance(int i) async { // 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 dest2 = createDestination(indexController.locations[0].collection[i]); + Destination dest2 = + createDestination(indexController.locations[0].collection[i]); // Get the distance between these two destinations final res = await MatrixService.getDestinations([desCurr, dest2]); @@ -78,76 +83,106 @@ class _ListWidgetState extends State { Future _pullRefresh() async { print("pull to refesh"); - indexController.locations[0].collection.sort((a, b) => + indexController.locations[0].collection.sort((a, b) => (a.properties!['cp'] as Comparable) - .compareTo(b.properties!['cp'] as Comparable)); - setState(() { - }); + .compareTo(b.properties!['cp'] as Comparable)); + setState(() {}); } @override Widget build(BuildContext context) { - return Obx(() => - indexController.locations.isNotEmpty ? - RefreshIndicator( - onRefresh: _pullRefresh, - child: ListView.builder( + return Obx( + () => indexController.locations.isNotEmpty + ? RefreshIndicator( + onRefresh: _pullRefresh, + child: ListView.builder( itemCount: indexController.locations[0].collection.length, shrinkWrap: true, - itemBuilder: (_, index){ + itemBuilder: (_, index) { bool _is_found = false; - for(Destination d in destinationController.destinations){ - if(indexController.locations[0].collection[index].properties!['location_id'] == d.location_id){ + for (Destination d in destinationController.destinations) { + if (indexController.locations[0].collection[index] + .properties!['location_id'] == + d.location_id) { _is_found = true; break; } } return Card( child: ListTile( - selected: _is_found, - - selectedTileColor: Colors.yellow.shade200, - onTap: (){ - GeoJsonFeature gf = indexController.locations[0].collection[index]; - changeCurrentFeature(gf); - showModalBottomSheet( - isScrollControlled: true, - 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(""), - subtitle: indexController.locations[0].collection[index].properties!['category'] != null ? Text(indexController.locations[0].collection[index].properties!['category']) : const Text(""), - trailing: Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - indexController.locations[0].collection[index].properties!['sub_loc_id'] != null ? Text(indexController.locations[0].collection[index].properties!['sub_loc_id']) : const Text(""), - SizedBox( - width: 100, - child: FutureBuilder( - 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),); - } - }, - ), - ) - ], - ) - ), + selected: _is_found, + selectedTileColor: Colors.yellow.shade200, + onTap: () { + GeoJsonFeature gf = + indexController.locations[0].collection[index]; + changeCurrentFeature(gf); + showModalBottomSheet( + constraints: BoxConstraints.loose( + Size(Get.width, Get.height * 0.75)), + isScrollControlled: true, + 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(""), + subtitle: indexController.locations[0].collection[index] + .properties!['category'] != + null + ? Text(indexController.locations[0] + .collection[index].properties!['category']) + : const Text(""), + trailing: Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + indexController.locations[0].collection[index] + .properties!['sub_loc_id'] != + null + ? Text(indexController + .locations[0] + .collection[index] + .properties!['sub_loc_id']) + : const Text(""), + SizedBox( + width: 100, + child: FutureBuilder( + 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, + ), + ); } -} \ No newline at end of file +} diff --git a/lib/widgets/map_widget.dart b/lib/widgets/map_widget.dart index 61af01c..603de1a 100644 --- a/lib/widgets/map_widget.dart +++ b/lib/widgets/map_widget.dart @@ -14,176 +14,194 @@ import 'package:rogapp/widgets/base_layer_widget.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart'; class MapWidget extends StatelessWidget { - final IndexController indexController = Get.find(); - final DestinationController destinationController = Get.find(); + final DestinationController destinationController = + Get.find(); - MapWidget({ Key? key}) : super(key: key); + MapWidget({Key? key}) : super(key: key); StreamSubscription? subscription; - Widget getMarkerShape(GeoJsonFeature i, BuildContext context){ + Widget getMarkerShape(GeoJsonFeature i, BuildContext context) { GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint; //print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}"); RegExp regex = RegExp(r'([.]*0)(?!.*\d)'); return Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - InkWell( - onTap: () { - GeoJsonFeature? fs = indexController.getFeatureForLatLong(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude); - print("------- fs $fs------"); - if(fs != null){ - indexController.currentFeature.clear(); - indexController.currentFeature.add(fs); - //print("----- fs is ${fs.properties!['photos']}"); - indexController.getAction(); - - showModalBottomSheet( - context: context, - isScrollControlled: true, - isDismissible: true, - builder:((context) => BottomSheetNew()) - //builder:((context) => BottomSheetWidget()) - ).whenComplete((){ - destinationController.skip_gps = false; - }); - } + mainAxisAlignment: MainAxisAlignment.start, + children: [ + InkWell( + onTap: () { + GeoJsonFeature? fs = indexController.getFeatureForLatLong( + p.geoSerie!.geoPoints[0].latitude, + p.geoSerie!.geoPoints[0].longitude); + print("------- fs $fs------"); + if (fs != null) { + indexController.currentFeature.clear(); + indexController.currentFeature.add(fs); + //print("----- fs is ${fs.properties!['photos']}"); + indexController.getAction(); - - - - }, - child: Container( - height: 32, - width: 32, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.transparent, - border: Border.all( - color: i.properties!['buy_point'] > 0 ? Colors.blue : Colors.red, - width: 3, - style: BorderStyle.solid - ) - ), - child: Stack( - alignment: Alignment.center, - children: [ - const Icon(Icons.circle,size: 6.0,), - i.properties!['cp'] == -1 ? - Transform.rotate( - alignment: Alignment.centerLeft, - origin: Offset.fromDirection(1, 26), - angle: 270 * pi / 180, - child: const Icon(Icons.play_arrow_outlined, color: Colors.red, size: 70,)): - Container(color: Colors.transparent,), - ], - ) - ), - ), - Container(color: Colors.white, child: Text(TextUtils.getDisplayTextFeture(i), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color:Colors.red,))), - ], - ); + showModalBottomSheet( + constraints: + BoxConstraints.loose(Size(Get.width, Get.height * 0.75)), + context: context, + isScrollControlled: true, + isDismissible: true, + builder: ((context) => BottomSheetNew()) + //builder:((context) => BottomSheetWidget()) + ).whenComplete(() { + destinationController.skip_gps = false; + }); + } + }, + child: Container( + height: 32, + width: 32, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.transparent, + border: Border.all( + color: i.properties!['buy_point'] > 0 + ? Colors.blue + : Colors.red, + width: 3, + style: BorderStyle.solid)), + child: Stack( + alignment: Alignment.center, + children: [ + const Icon( + Icons.circle, + size: 6.0, + ), + i.properties!['cp'] == -1 + ? Transform.rotate( + alignment: Alignment.centerLeft, + origin: Offset.fromDirection(1, 26), + angle: 270 * pi / 180, + child: const Icon( + Icons.play_arrow_outlined, + color: Colors.red, + size: 70, + )) + : 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? getPoints(){ - print("##### --- route point ${indexController.routePoints.length}"); - List pts = []; - for(PointLatLng p in indexController.routePoints){ - LatLng l = LatLng(p.latitude, p.longitude); - pts.add(l); - } - return pts; + List? getPoints() { + print("##### --- route point ${indexController.routePoints.length}"); + List pts = []; + for (PointLatLng p in indexController.routePoints) { + LatLng l = LatLng(p.latitude, p.longitude); + pts.add(l); } + return pts; + } @override Widget build(BuildContext context) { - - print("---------- rog mode is ${indexController.rog_mode.value.toString()}----------"); + print( + "---------- rog mode is ${indexController.rog_mode.value.toString()}----------"); final PopupController _popupController = PopupController(); return Stack( - children: [ - Obx(() => - indexController.is_loading == true ? const Padding( - padding: EdgeInsets.only(top: 60.0), - child: CircularProgressIndicator(), - ): - FlutterMap( - mapController: indexController.mapController, - options: MapOptions( - maxZoom:18.4, - onMapReady: (){ - indexController.is_mapController_loaded.value = true; - subscription = indexController.mapController.mapEventStream.listen((MapEvent mapEvent) { - if (mapEvent is MapEventMoveStart) { - //print(DateTime.now().toString() + ' [MapEventMoveStart] START'); - // do something - } - if (mapEvent is MapEventMoveEnd && indexController.currentUser.isEmpty) { - //print(DateTime.now().toString() + ' [MapEventMoveStart] END'); - indexController.loadLocationsBound(); - //indexController.rogMapController!.move(c.center, c.zoom); - } - }); + children: [ + Obx(() => indexController.is_loading == true + ? const Padding( + padding: EdgeInsets.only(top: 60.0), + child: CircularProgressIndicator(), + ) + : FlutterMap( + mapController: indexController.mapController, + options: MapOptions( + maxZoom: 18.4, + onMapReady: () { + indexController.is_mapController_loaded.value = true; + subscription = indexController.mapController.mapEventStream + .listen((MapEvent mapEvent) { + if (mapEvent is MapEventMoveStart) { + //print(DateTime.now().toString() + ' [MapEventMoveStart] START'); + // do something + } + if (mapEvent is MapEventMoveEnd && + indexController.currentUser.isEmpty) { + //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, - }, - //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){ - - }, - onTap: (_, __) => - _popupController - .hideAllPopups(), // Hide popup when the map is tapped. - ), - children: [ - 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(), + onPositionChanged: (MapPosition pos, isvalue) {}, + onTap: (_, __) => _popupController + .hideAllPopups(), // Hide popup when the map is tapped. + ), + children: [ + const BaseLayer(), + Obx( + () => indexController.routePointLenght > 0 + ? PolylineLayer( + polylines: [ + Polyline( + points: getPoints()!, + strokeWidth: 6.0, + color: Colors.indigo), + ], ) - : - const Center(child: CircularProgressIndicator()) - , - ], - ) - ) - ], - ); + : 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(), + ) + : const Center(child: CircularProgressIndicator()), + ], + )) + ], + ); } -} \ No newline at end of file +}