|
|
@@ -12,8 +12,10 @@ import 'package:location/resource/assets.gen.dart';
|
|
|
import 'package:location/resource/colors.gen.dart';
|
|
|
import 'package:location/resource/string.gen.dart';
|
|
|
import 'package:location/utils/common_expand.dart';
|
|
|
+import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
import 'package:sliding_sheet2/sliding_sheet2.dart';
|
|
|
import '../../../router/app_pages.dart';
|
|
|
+import '../../../utils/common_util.dart';
|
|
|
import '../../../widget/common_view.dart';
|
|
|
import 'common_point_select_address_controller.dart';
|
|
|
|
|
|
@@ -111,27 +113,31 @@ class CommonPointSelectAddressPage
|
|
|
}
|
|
|
|
|
|
Widget buildSlidingSheetView() {
|
|
|
- return SlidingSheet(
|
|
|
- listener: (SheetState state) {
|
|
|
- controller.setSheetProgress(state.progress);
|
|
|
- },
|
|
|
- controller: controller.sheetController,
|
|
|
- color: ColorName.transparent,
|
|
|
- elevation: 0,
|
|
|
- shadowColor: ColorName.transparent,
|
|
|
- cornerRadius: 0,
|
|
|
- snapSpec: SnapSpec(
|
|
|
- initialSnap: 0.45,
|
|
|
- // Enable snapping. This is true by default.
|
|
|
- snap: true,
|
|
|
- // Set custom snapping points.
|
|
|
- snappings: [0.45, 0.94],
|
|
|
- // Define to what the snappings relate to. In this case,
|
|
|
- // the total available space that the sheet can expand to.
|
|
|
- positioning: SnapPositioning.relativeToAvailableSpace,
|
|
|
- ),
|
|
|
- headerBuilder: selectAddressHeaderBuilder,
|
|
|
- customBuilder: selectAddressCustomBuilder);
|
|
|
+ return SizedBox(
|
|
|
+ width: double.infinity,
|
|
|
+ height: 1.sh,
|
|
|
+ child: SlidingSheet(
|
|
|
+ listener: (SheetState state) {
|
|
|
+ controller.setSheetProgress(state.progress);
|
|
|
+ },
|
|
|
+ controller: controller.sheetController,
|
|
|
+ color: ColorName.transparent,
|
|
|
+ elevation: 0,
|
|
|
+ shadowColor: ColorName.transparent,
|
|
|
+ cornerRadius: 0,
|
|
|
+ snapSpec: SnapSpec(
|
|
|
+ initialSnap: 0.45,
|
|
|
+ // Enable snapping. This is true by default.
|
|
|
+ snap: true,
|
|
|
+ // Set custom snapping points.
|
|
|
+ snappings: [0.45, 0.94],
|
|
|
+ // Define to what the snappings relate to. In this case,
|
|
|
+ // the total available space that the sheet can expand to.
|
|
|
+ positioning: SnapPositioning.relativeToAvailableSpace,
|
|
|
+ ),
|
|
|
+ headerBuilder: selectAddressHeaderBuilder,
|
|
|
+ customBuilder: selectAddressCustomBuilder),
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
Widget buildToolbarView() {
|
|
|
@@ -177,11 +183,73 @@ class CommonPointSelectAddressPage
|
|
|
|
|
|
Widget selectAddressCustomBuilder(BuildContext context,
|
|
|
ScrollController scrollController, SheetState state) {
|
|
|
- return ListView.builder(
|
|
|
- padding: EdgeInsets.zero,
|
|
|
- controller: scrollController,
|
|
|
- itemBuilder: (ctx, index) => Text('selectAddressCustomBuilder--$index'),
|
|
|
- itemCount: 100,
|
|
|
+ return Container(
|
|
|
+ color: Colors.white,
|
|
|
+ height: double.infinity,
|
|
|
+ child: SmartRefresher(
|
|
|
+ enablePullUp: true,
|
|
|
+ enablePullDown: false,
|
|
|
+ controller: controller.refreshController,
|
|
|
+ onLoading: controller.onLoadMorePoiData,
|
|
|
+ child: CustomScrollView(
|
|
|
+ controller: scrollController,
|
|
|
+ slivers: [
|
|
|
+ SliverToBoxAdapter(child: buildCurrentLocationView()),
|
|
|
+ Obx(() {
|
|
|
+ return SliverList.builder(
|
|
|
+ itemBuilder: (ctx, index) =>
|
|
|
+ buildPoiSearchItem(controller.poiList[index]),
|
|
|
+ itemCount: controller.poiList.length);
|
|
|
+ })
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget buildCurrentLocationView() {
|
|
|
+ return GestureDetector(
|
|
|
+ onTap: controller.moveToCurrentLocation,
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: '#F2F5FE'.color,
|
|
|
+ borderRadius: BorderRadius.circular(8.r),
|
|
|
+ border: Border.all(
|
|
|
+ color: '#D0D9F4'.color,
|
|
|
+ width: 0.5.w,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ margin: EdgeInsets.only(left: 12.w, right: 12.w, bottom: 8.w, top: 4.w),
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 13.w, vertical: 8.w),
|
|
|
+ child: Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 3.w),
|
|
|
+ child:
|
|
|
+ Assets.images.iconSelectCurrentLocation.image(width: 10.w)),
|
|
|
+ SizedBox(width: 8.w),
|
|
|
+ Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Text(StringName.currentLocation,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 12.sp,
|
|
|
+ color: ColorName.black90,
|
|
|
+ fontWeight: FontWeight.bold)),
|
|
|
+ SizedBox(height: 4.w),
|
|
|
+ Obx(() {
|
|
|
+ return Text(
|
|
|
+ addressCheck(
|
|
|
+ controller.mineUserInfo.lastLocation.value?.address),
|
|
|
+ style:
|
|
|
+ TextStyle(fontSize: 10.sp, color: ColorName.black50));
|
|
|
+ })
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -350,6 +418,67 @@ class CommonPointSelectAddressPage
|
|
|
],
|
|
|
));
|
|
|
}
|
|
|
+
|
|
|
+ Widget buildPoiSearchItem(PoiItem item) {
|
|
|
+ return GestureDetector(
|
|
|
+ onTap: controller.onPoiItemClick(item),
|
|
|
+ child: Container(
|
|
|
+ margin: EdgeInsets.only(left: 12.w, right: 12.w, bottom: 8.w, top: 4.w),
|
|
|
+ padding: EdgeInsets.only(left: 13.w, top: 8.w, bottom: 8.w),
|
|
|
+ child: Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 3.w),
|
|
|
+ child: Assets.images.iconPoiLocation.image(width: 10.w)),
|
|
|
+ SizedBox(width: 8.w),
|
|
|
+ Expanded(
|
|
|
+ child: IntrinsicHeight(
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Expanded(
|
|
|
+ child: Text(item.title ?? '',
|
|
|
+ overflow: TextOverflow.ellipsis,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 12.sp,
|
|
|
+ color: ColorName.black90,
|
|
|
+ fontWeight: FontWeight.bold)),
|
|
|
+ ),
|
|
|
+ SizedBox(width: 16.w),
|
|
|
+ buildDistanceTextView(item)
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ SizedBox(height: 4.w),
|
|
|
+ Text(item.address ?? '',
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 10.sp, color: ColorName.black50))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget buildDistanceTextView(PoiItem item) {
|
|
|
+ final location = controller.mineUserInfo.lastLocation.value;
|
|
|
+ if (location == null ||
|
|
|
+ location.latitude == null ||
|
|
|
+ location.longitude == null ||
|
|
|
+ item.longitude == null ||
|
|
|
+ item.latitude == null) {
|
|
|
+ return SizedBox.shrink();
|
|
|
+ }
|
|
|
+ final distance = MapUtil.calculateLineDistance(location.longitude!,
|
|
|
+ location.latitude!, item.longitude!, item.latitude!);
|
|
|
+ return Text(MapUtil.format(distance),
|
|
|
+ style: TextStyle(fontSize: 10.sp, color: ColorName.black30));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class CustomTrackShape extends RoundedRectSliderTrackShape {
|