|
@@ -16,7 +16,7 @@ import '../../../data/bean/user_info.dart';
|
|
|
import '../../../dialog/common_confirm_dialog_impl.dart';
|
|
import '../../../dialog/common_confirm_dialog_impl.dart';
|
|
|
import '../../../dialog/location_permission_dialog.dart';
|
|
import '../../../dialog/location_permission_dialog.dart';
|
|
|
import '../../../resource/string.gen.dart';
|
|
import '../../../resource/string.gen.dart';
|
|
|
-import '../../../utils/de_bounce.dart';
|
|
|
|
|
|
|
+import '../../../utils/action_limiter.dart';
|
|
|
import '../../../utils/permission_util.dart';
|
|
import '../../../utils/permission_util.dart';
|
|
|
import '../../../utils/toast_util.dart';
|
|
import '../../../utils/toast_util.dart';
|
|
|
|
|
|
|
@@ -47,7 +47,14 @@ class CommonPointSelectAddressController extends BaseController {
|
|
|
|
|
|
|
|
final refreshController = RefreshController(initialRefresh: false);
|
|
final refreshController = RefreshController(initialRefresh: false);
|
|
|
|
|
|
|
|
- final Debounce _searchDebounce = Debounce(debounceTime: 500);
|
|
|
|
|
|
|
+ final Rxn<PoiItem> _currentRangeCenterLocation = Rxn<PoiItem>();
|
|
|
|
|
+
|
|
|
|
|
+ PoiItem? get currentRangeCenterLocation => _currentRangeCenterLocation.value;
|
|
|
|
|
+
|
|
|
|
|
+ bool _isUserSelectLocation = false;
|
|
|
|
|
+
|
|
|
|
|
+ final ActionLimiter _debounceLimiter =
|
|
|
|
|
+ ActionLimiter(milliseconds: 300, mode: LimitMode.debounce);
|
|
|
|
|
|
|
|
final AccountRepository accountRepository;
|
|
final AccountRepository accountRepository;
|
|
|
|
|
|
|
@@ -67,24 +74,26 @@ class CommonPointSelectAddressController extends BaseController {
|
|
|
@override
|
|
@override
|
|
|
void onReady() {
|
|
void onReady() {
|
|
|
super.onReady();
|
|
super.onReady();
|
|
|
|
|
+ circleOptions.radius = commonPointRange;
|
|
|
_updateCurrentLocation();
|
|
_updateCurrentLocation();
|
|
|
mapController.setOnCameraChangeListener(
|
|
mapController.setOnCameraChangeListener(
|
|
|
(camera) {
|
|
(camera) {
|
|
|
|
|
+ circleOptions
|
|
|
|
|
+ ..longitude = camera.position.longitude
|
|
|
|
|
+ ..latitude = camera.position.latitude;
|
|
|
|
|
+
|
|
|
if (_isRangeChanging) {
|
|
if (_isRangeChanging) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (camera.function == CameraChangeType.onCameraChange) {
|
|
|
|
|
- //暂时隐藏范围
|
|
|
|
|
- if (circleOptions.visible == true) {
|
|
|
|
|
- circleOptions.visible = false;
|
|
|
|
|
- _updateOrAddCircle();
|
|
|
|
|
|
|
+ if (camera.function == CameraChangeType.onCameraChangeFinish) {
|
|
|
|
|
+ AtmobLog.d('zk', 'onCameraChangeFinish ');
|
|
|
|
|
+ circleOptions.visible = true;
|
|
|
|
|
+ if (!_isUserSelectLocation) {
|
|
|
|
|
+ _currentRangeCenterLocation.value = null;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ _isUserSelectLocation = false;
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
- circleOptions
|
|
|
|
|
- ..radius = commonPointRange
|
|
|
|
|
- ..longitude = camera.position.longitude
|
|
|
|
|
- ..visible = true
|
|
|
|
|
- ..latitude = camera.position.latitude;
|
|
|
|
|
|
|
+
|
|
|
_updateOrAddCircle();
|
|
_updateOrAddCircle();
|
|
|
if (_isFirstMoveCamera) {
|
|
if (_isFirstMoveCamera) {
|
|
|
_isFirstMoveCamera = false;
|
|
_isFirstMoveCamera = false;
|
|
@@ -93,17 +102,32 @@ class CommonPointSelectAddressController extends BaseController {
|
|
|
//重新还原数据
|
|
//重新还原数据
|
|
|
_resetPoiQuery();
|
|
_resetPoiQuery();
|
|
|
_poiSearch();
|
|
_poiSearch();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //暂时隐藏范围
|
|
|
|
|
+ if (circleOptions.visible == true) {
|
|
|
|
|
+ circleOptions.visible = false;
|
|
|
|
|
+ _updateOrAddCircle();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ void onSearchTextChange(String txt) {
|
|
|
|
|
+ if (_poiQuery.keyWord == txt) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ _poiQuery.keyWord = txt;
|
|
|
|
|
+ _resetPoiQuery();
|
|
|
|
|
+ _poiSearch();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
void _resetPoiQuery() {
|
|
void _resetPoiQuery() {
|
|
|
_pageNum = 1;
|
|
_pageNum = 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void _poiSearch() async {
|
|
void _poiSearch() async {
|
|
|
- _searchDebounce.onClick(() {
|
|
|
|
|
|
|
+ _debounceLimiter.run(() {
|
|
|
AtmobLog.d('zk', '_poiSearch: $_poiQuery');
|
|
AtmobLog.d('zk', '_poiSearch: $_poiQuery');
|
|
|
FlutterMap.paginatePoiSearch(
|
|
FlutterMap.paginatePoiSearch(
|
|
|
pageNum: _pageNum,
|
|
pageNum: _pageNum,
|
|
@@ -145,15 +169,6 @@ class CommonPointSelectAddressController extends BaseController {
|
|
|
Get.back();
|
|
Get.back();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void setCommonPointRange(double value) {
|
|
|
|
|
- _commonPointRange.value = value;
|
|
|
|
|
- circleOptions.radius = value;
|
|
|
|
|
- if (circleOptions.visible == true) {
|
|
|
|
|
- _updateOrAddCircle();
|
|
|
|
|
- _moveCameraToBounds();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
_moveCameraToBounds() {
|
|
_moveCameraToBounds() {
|
|
|
final latLngBounds = CameraUpdateUtil.getBounds(circleOptions.latitude,
|
|
final latLngBounds = CameraUpdateUtil.getBounds(circleOptions.latitude,
|
|
|
circleOptions.longitude, circleOptions.radius ?? 0);
|
|
circleOptions.longitude, circleOptions.radius ?? 0);
|
|
@@ -190,12 +205,23 @@ class CommonPointSelectAddressController extends BaseController {
|
|
|
searchFocusNode.requestFocus();
|
|
searchFocusNode.requestFocus();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ void setCommonPointRange(double value) {
|
|
|
|
|
+ _commonPointRange.value = value;
|
|
|
|
|
+ circleOptions.radius = value;
|
|
|
|
|
+ if (circleOptions.visible == true) {
|
|
|
|
|
+ _updateOrAddCircle();
|
|
|
|
|
+ _moveCameraToBounds();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
void setCommonPointRangeStart() {
|
|
void setCommonPointRangeStart() {
|
|
|
_isRangeChanging = true;
|
|
_isRangeChanging = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void setCommonPointRangeEnd() {
|
|
void setCommonPointRangeEnd() {
|
|
|
_isRangeChanging = false;
|
|
_isRangeChanging = false;
|
|
|
|
|
+ _resetPoiQuery();
|
|
|
|
|
+ _poiSearch();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void moveToCurrentLocation() async {
|
|
void moveToCurrentLocation() async {
|
|
@@ -225,6 +251,11 @@ class CommonPointSelectAddressController extends BaseController {
|
|
|
void _showCurrentRange(MapLocation location) {
|
|
void _showCurrentRange(MapLocation location) {
|
|
|
circleOptions.latitude = location.latitude;
|
|
circleOptions.latitude = location.latitude;
|
|
|
circleOptions.longitude = location.longitude;
|
|
circleOptions.longitude = location.longitude;
|
|
|
|
|
+ _isUserSelectLocation = true;
|
|
|
|
|
+ _currentRangeCenterLocation.value = PoiItem(
|
|
|
|
|
+ latitude: location.latitude,
|
|
|
|
|
+ longitude: location.longitude,
|
|
|
|
|
+ address: location.address);
|
|
|
_moveCameraToBounds();
|
|
_moveCameraToBounds();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -253,10 +284,31 @@ class CommonPointSelectAddressController extends BaseController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- onPoiItemClick(PoiItem item) {}
|
|
|
|
|
|
|
+ onPoiItemClick(PoiItem item) async {
|
|
|
|
|
+ _resetPoiQuery();
|
|
|
|
|
+ circleOptions
|
|
|
|
|
+ ..longitude = item.longitude
|
|
|
|
|
+ ..latitude = item.latitude;
|
|
|
|
|
+ _currentRangeCenterLocation.value = item;
|
|
|
|
|
+ _isUserSelectLocation = true;
|
|
|
|
|
+ _moveCameraToBounds();
|
|
|
|
|
+ if (sheetController.state?.isExpanded == true) {
|
|
|
|
|
+ await sheetController.scrollTo(0, duration: Duration(milliseconds: 1));
|
|
|
|
|
+ sheetController.snapToExtent(0,
|
|
|
|
|
+ duration: const Duration(milliseconds: 250));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
void onLoadMorePoiData() {
|
|
void onLoadMorePoiData() {
|
|
|
_pageNum++;
|
|
_pageNum++;
|
|
|
_poiSearch();
|
|
_poiSearch();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ void onSelectAddressDone() {
|
|
|
|
|
+ if (currentRangeCenterLocation == null) {
|
|
|
|
|
+ ToastUtil.show(StringName.selectAddressPlease);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Get.back(result: currentRangeCenterLocation);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|