|
|
|
@ -38,7 +38,8 @@ class UnionPage extends StatefulWidget {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin, WidgetsBindingObserver { |
|
|
|
|
class _UnionPage extends State<UnionPage> |
|
|
|
|
with AutomaticKeepAliveClientMixin, WidgetsBindingObserver { |
|
|
|
|
//默认设置为不使用自定义地图,如果需要直接显示,在初始化是设置为true |
|
|
|
|
CustomStyleOptions _customStyleOptions = CustomStyleOptions(false); |
|
|
|
|
|
|
|
|
@ -80,7 +81,7 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin, Wi
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) { |
|
|
|
|
setState(() { |
|
|
|
|
print("object: ${MediaQuery.of(context).viewInsets.bottom}"); |
|
|
|
|
if(MediaQuery.of(context).viewInsets.bottom == 0){ |
|
|
|
|
if (MediaQuery.of(context).viewInsets.bottom == 0) { |
|
|
|
|
if (iskeyboardShow) { |
|
|
|
|
iskeyboardShow = false; |
|
|
|
|
//关闭键盘 软键盘关闭了, 清除输入控件的焦点, 否则重新进入页面会导致软键盘再弹出问题 |
|
|
|
@ -290,191 +291,179 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin, Wi
|
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
|
}, |
|
|
|
|
child: Scaffold( |
|
|
|
|
resizeToAvoidBottomInset: true, |
|
|
|
|
body: NestedScrollView( |
|
|
|
|
physics: PageScrollPhysics(), |
|
|
|
|
headerSliverBuilder: (context, inner) { |
|
|
|
|
return [ |
|
|
|
|
SliverOverlapAbsorber( |
|
|
|
|
sliver: buildSliverAppBar(AMapWidget( |
|
|
|
|
initialCameraPosition: CameraPosition( |
|
|
|
|
target: LatLng(30.553111, 114.342366), |
|
|
|
|
zoom: 12.0, |
|
|
|
|
), |
|
|
|
|
onMapCreated: onMapCreated, |
|
|
|
|
apiKey: aMapApiKeys, |
|
|
|
|
touchPoiEnabled: true, |
|
|
|
|
markers: markers.toSet(), |
|
|
|
|
scrollGesturesEnabled: true, |
|
|
|
|
customStyleOptions: _customStyleOptions, |
|
|
|
|
onPoiTouched: (poiTouch) { |
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
|
}, |
|
|
|
|
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[ |
|
|
|
|
Factory<OneSequenceGestureRecognizer>( |
|
|
|
|
() => EagerGestureRecognizer()), |
|
|
|
|
].toSet(), |
|
|
|
|
)), |
|
|
|
|
handle: |
|
|
|
|
NestedScrollView.sliverOverlapAbsorberHandleFor(context), |
|
|
|
|
) |
|
|
|
|
]; |
|
|
|
|
}, |
|
|
|
|
body: Builder( |
|
|
|
|
builder: (context) { |
|
|
|
|
return CustomScrollView( |
|
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
|
slivers: [ |
|
|
|
|
SliverOverlapInjector( |
|
|
|
|
handle: NestedScrollView.sliverOverlapAbsorberHandleFor( |
|
|
|
|
context), |
|
|
|
|
), |
|
|
|
|
SliverToBoxAdapter( |
|
|
|
|
child: Container( |
|
|
|
|
height: MediaQuery.of(context).size.height - |
|
|
|
|
102.h - |
|
|
|
|
MediaQuery.of(context).padding.top, |
|
|
|
|
child: SmartRefresher( |
|
|
|
|
controller: refreshController, |
|
|
|
|
enablePullUp: false, |
|
|
|
|
enablePullDown: true, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
header: MyHeader(), |
|
|
|
|
onRefresh: () { |
|
|
|
|
startLocation(); |
|
|
|
|
}, |
|
|
|
|
child: ListView.builder( |
|
|
|
|
itemCount: |
|
|
|
|
storeList == null ? 0 : storeList.length, |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
top: 8.h, |
|
|
|
|
bottom: 84.h + (375.h - 88.h) + 4.h), |
|
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pushNamed( |
|
|
|
|
'/router/union_detail_page', |
|
|
|
|
arguments: { |
|
|
|
|
"id": storeList[position].id |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: buildStoreItem( |
|
|
|
|
storeList[position], position), |
|
|
|
|
); |
|
|
|
|
}), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
)), |
|
|
|
|
resizeToAvoidBottomInset: false, |
|
|
|
|
appBar: PreferredSize( |
|
|
|
|
preferredSize: Size(double.infinity, 75.h), |
|
|
|
|
child: buildSearchItem(), |
|
|
|
|
), |
|
|
|
|
body: Column( |
|
|
|
|
children: [ |
|
|
|
|
PreferredSize( |
|
|
|
|
preferredSize: Size(double.infinity, 52.h), |
|
|
|
|
child: Container( |
|
|
|
|
padding: EdgeInsets.only(top: 6.h), |
|
|
|
|
color: Color(0xFFFAFAFA), |
|
|
|
|
child: ItemTitle( |
|
|
|
|
text: S.of(context).jingbilianmenghuiyuandian, |
|
|
|
|
imgPath: "assets/image/icon_union_store.png", |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
buildItem(), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
// body: NestedScrollView( |
|
|
|
|
// physics: PageScrollPhysics(), |
|
|
|
|
// headerSliverBuilder: (context, inner) { |
|
|
|
|
// return [ |
|
|
|
|
// SliverOverlapAbsorber( |
|
|
|
|
// sliver: buildSliverAppBar(AMapWidget( |
|
|
|
|
// initialCameraPosition: CameraPosition( |
|
|
|
|
// target: LatLng(30.553111, 114.342366), |
|
|
|
|
// zoom: 12.0, |
|
|
|
|
// ), |
|
|
|
|
// onMapCreated: onMapCreated, |
|
|
|
|
// apiKey: aMapApiKeys, |
|
|
|
|
// touchPoiEnabled: true, |
|
|
|
|
// markers: markers.toSet(), |
|
|
|
|
// scrollGesturesEnabled: true, |
|
|
|
|
// customStyleOptions: _customStyleOptions, |
|
|
|
|
// onPoiTouched: (poiTouch) { |
|
|
|
|
// FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
|
// }, |
|
|
|
|
// gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[ |
|
|
|
|
// Factory<OneSequenceGestureRecognizer>( |
|
|
|
|
// () => EagerGestureRecognizer()), |
|
|
|
|
// ].toSet(), |
|
|
|
|
// )), |
|
|
|
|
// handle: |
|
|
|
|
// NestedScrollView.sliverOverlapAbsorberHandleFor(context), |
|
|
|
|
// ) |
|
|
|
|
// ]; |
|
|
|
|
// }, |
|
|
|
|
// body: Builder( |
|
|
|
|
// builder: (context) { |
|
|
|
|
// return CustomScrollView( |
|
|
|
|
// physics: NeverScrollableScrollPhysics(), |
|
|
|
|
// slivers: [ |
|
|
|
|
// SliverOverlapInjector( |
|
|
|
|
// handle: NestedScrollView.sliverOverlapAbsorberHandleFor( |
|
|
|
|
// context), |
|
|
|
|
// ), |
|
|
|
|
// SliverToBoxAdapter( |
|
|
|
|
// child: |
|
|
|
|
// ), |
|
|
|
|
// ], |
|
|
|
|
// ); |
|
|
|
|
// }, |
|
|
|
|
// ),), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget buildItem() { |
|
|
|
|
return Container( |
|
|
|
|
height: MediaQuery.of(context).size.height - |
|
|
|
|
102.h - |
|
|
|
|
MediaQuery.of(context).padding.top, |
|
|
|
|
child: SmartRefresher( |
|
|
|
|
controller: refreshController, |
|
|
|
|
enablePullUp: false, |
|
|
|
|
enablePullDown: true, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
header: MyHeader(), |
|
|
|
|
onRefresh: () { |
|
|
|
|
startLocation(); |
|
|
|
|
}, |
|
|
|
|
child: ListView.builder( |
|
|
|
|
itemCount: storeList == null ? 0 : storeList.length, |
|
|
|
|
// padding: EdgeInsets.only(top: 8.h, bottom: 84.h + (375.h - 88.h) + 4.h), |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
top: 8.h, bottom: 84.h /* + (375.h - 88.h) + 4.h*/), |
|
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pushNamed('/router/union_detail_page', |
|
|
|
|
arguments: {"id": storeList[position].id}); |
|
|
|
|
}, |
|
|
|
|
child: buildStoreItem(storeList[position], position), |
|
|
|
|
); |
|
|
|
|
}), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
startLocation() async { |
|
|
|
|
if (Platform.isAndroid) { |
|
|
|
|
if (!(await Permission.locationWhenInUse.serviceStatus.isEnabled)) { |
|
|
|
|
enableLocation(); |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!(await Permission.locationWhenInUse.serviceStatus.isEnabled)) { |
|
|
|
|
enableLocation(); |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
print("object: isGranted: ${await Permission.location.isGranted}"); |
|
|
|
|
print("object: isDenied: ${await Permission.location.isDenied}"); |
|
|
|
|
print("object: isLimited: ${await Permission.location.isLimited}"); |
|
|
|
|
print("object: isPermanentlyDenied: ${await Permission.location.isPermanentlyDenied}"); |
|
|
|
|
print("object: isRestricted: ${await Permission.location.isRestricted}"); |
|
|
|
|
print("object: isUndetermined: ${await Permission.location.isUndetermined}"); |
|
|
|
|
print("object: shouldShowRequestRationale: ${await Permission.location.shouldShowRequestRationale}"); |
|
|
|
|
print("object: status: ${await Permission.location.status}"); |
|
|
|
|
print("object: value: -------------------------"); |
|
|
|
|
|
|
|
|
|
if (await Permission.location.isPermanentlyDenied) { |
|
|
|
|
print("object: requestDialog"); |
|
|
|
|
requestDialog(); |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
} else if (await Permission.location.isGranted) { |
|
|
|
|
print("object: showLoadingDialog"); |
|
|
|
|
showLoadingDialog(); |
|
|
|
|
aMapFlutterLocation.startLocation(); |
|
|
|
|
} else if (await Permission.location.isUndetermined) { |
|
|
|
|
await Permission.location.request(); |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
} else { |
|
|
|
|
if (Platform.isAndroid) { |
|
|
|
|
await Permission.location.request(); |
|
|
|
|
} else if (Platform.isIOS) { |
|
|
|
|
if (Platform.isIOS) { |
|
|
|
|
//去设置中心 |
|
|
|
|
iosLocationSetting(); |
|
|
|
|
requestDialog(); |
|
|
|
|
} else { |
|
|
|
|
await Permission.location.request(); |
|
|
|
|
} |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
iosLocationSetting() async { |
|
|
|
|
enableLocation() { |
|
|
|
|
showCupertinoDialog( |
|
|
|
|
context: context, |
|
|
|
|
builder: (context) { |
|
|
|
|
return RequestPermission( |
|
|
|
|
"assets/image/icon_permission_location_bg.png", |
|
|
|
|
S.of(context).nindingweigongnengweikaiqi, |
|
|
|
|
S.of(context).weilexiangnintuijianfujindemendianxinxi, |
|
|
|
|
S.of(context).queding, |
|
|
|
|
(result) async { |
|
|
|
|
if (result) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
heightRatioWithWidth: 0.84, |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
context: context, |
|
|
|
|
builder: (context) { |
|
|
|
|
return RequestPermission( |
|
|
|
|
"assets/image/icon_permission_location_bg.png", |
|
|
|
|
S.of(context).nindingweigongnengweikaiqi, |
|
|
|
|
S.of(context).weilexiangnintuijianfujindemendianxinxi, |
|
|
|
|
S.of(context).dakaidingwei, |
|
|
|
|
(result) async { |
|
|
|
|
if (result) { |
|
|
|
|
final AndroidIntent intent = AndroidIntent( |
|
|
|
|
action: 'action_location_source_settings', |
|
|
|
|
package: "com.zsw.huixiang"); |
|
|
|
|
await intent.launch(); |
|
|
|
|
// startLocation(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
heightRatioWithWidth: 0.84, |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
enableLocation() { |
|
|
|
|
requestDialog() { |
|
|
|
|
showCupertinoDialog( |
|
|
|
|
context: context, |
|
|
|
|
builder: (context) { |
|
|
|
|
return RequestPermission( |
|
|
|
|
"assets/image/icon_permission_location_bg.png", |
|
|
|
|
"您定位功能开关未开启,请点击去打開定位", |
|
|
|
|
"为了向您推荐附近的门店信息,推荐您在使用期间让我们使用位置信息", |
|
|
|
|
S.of(context).dakaidingwei, |
|
|
|
|
S.of(context).nindingweiquanxianweiyunxu, |
|
|
|
|
S.of(context).weilexiangnintuijianfujindemendianxinxi, |
|
|
|
|
S.of(context).kaiqiquanxian, |
|
|
|
|
(result) async { |
|
|
|
|
if (result) { |
|
|
|
|
final AndroidIntent intent = AndroidIntent( |
|
|
|
|
action: 'action_location_source_settings', |
|
|
|
|
package: "com.zsw.huixiang"); |
|
|
|
|
await intent.launch(); |
|
|
|
|
// startLocation(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
heightRatioWithWidth: 0.84, |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
requestDialog() { |
|
|
|
|
showCupertinoDialog( |
|
|
|
|
context: context, |
|
|
|
|
builder: (context) { |
|
|
|
|
return RequestPermission( |
|
|
|
|
"assets/image/icon_permission_location_bg.png", |
|
|
|
|
"您未开启位置权限,请点击开启", |
|
|
|
|
"为了向您推荐附近的门店信息,推荐您在使用期间让我们使用位置信息", |
|
|
|
|
S.of(context).kaiqiquanxian, (result) async { |
|
|
|
|
if (result) { |
|
|
|
|
if (Platform.isAndroid) { |
|
|
|
|
final AndroidIntent intent = AndroidIntent( |
|
|
|
|
action: 'action_application_details_settings', |
|
|
|
|
data: 'package:com.zsw.huixiang'); |
|
|
|
|
await intent.launch(); |
|
|
|
|
await openAppSettings(); |
|
|
|
|
if (await Permission.location.isGranted) { |
|
|
|
|
startLocation(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
heightRatioWithWidth: 0.84, |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -485,6 +474,52 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin, Wi
|
|
|
|
|
_mapController = controller; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget buildSearchItem() { |
|
|
|
|
return Container( |
|
|
|
|
height: 36.h, |
|
|
|
|
margin: EdgeInsets.fromLTRB(16.w, 40, 16.w, 0), |
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Colors.white, |
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(4)), |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 3), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0, |
|
|
|
|
) |
|
|
|
|
]), |
|
|
|
|
child: TextField( |
|
|
|
|
textInputAction: TextInputAction.search, |
|
|
|
|
onEditingComplete: () { |
|
|
|
|
startLocation(); |
|
|
|
|
}, |
|
|
|
|
controller: editingController, |
|
|
|
|
cursorHeight: 30.h, |
|
|
|
|
decoration: InputDecoration( |
|
|
|
|
contentPadding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
|
prefixIcon: Icon( |
|
|
|
|
Icons.search, |
|
|
|
|
size: 24, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
|
suffixIcon: InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
editingController.clear(); |
|
|
|
|
}, |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.close, |
|
|
|
|
size: 19, |
|
|
|
|
color: Colors.grey, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
border: InputBorder.none, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget buildSliverAppBar(AMapWidget map) { |
|
|
|
|
return SliverAppBar( |
|
|
|
|
// 滑上去时搜索隐藏 |
|
|
|
@ -626,17 +661,21 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin, Wi
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
(store.distance ?? 0) > 1000 |
|
|
|
|
? S.of(context).gongli( |
|
|
|
|
((store.distance ?? 0) / 1000 * 100).toInt() / |
|
|
|
|
100.0) |
|
|
|
|
: S.of(context).mi( |
|
|
|
|
((store.distance ?? 0) * 100).toInt() / 100.0), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF4C4C4C), |
|
|
|
|
fontSize: 12, |
|
|
|
|
Visibility( |
|
|
|
|
child: Text( |
|
|
|
|
(store.distance ?? 0) > 1000 |
|
|
|
|
? S.of(context).gongli( |
|
|
|
|
((store.distance ?? 0) / 1000 * 100).toInt() / |
|
|
|
|
100.0) |
|
|
|
|
: S.of(context).mi( |
|
|
|
|
((store.distance ?? 0) * 100).toInt() / |
|
|
|
|
100.0), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF4C4C4C), |
|
|
|
|
fontSize: 12, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
visible: store.distance != null, |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 16.w, |
|
|
|
@ -656,7 +695,10 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin, Wi
|
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Expanded(child: Container(), flex: 1,), |
|
|
|
|
Expanded( |
|
|
|
|
child: Container(), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
child: Text( |
|
|
|
|
S.of(context).manlijiandaijinquan(50, 25), |
|
|
|
@ -673,8 +715,8 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin, Wi
|
|
|
|
|
Text( |
|
|
|
|
(store.openStartTime == null && |
|
|
|
|
store.openEndTime == null) |
|
|
|
|
? "全天" |
|
|
|
|
: "${store.openStartTime}-${store.openEndTime}", |
|
|
|
|
? S.of(context).quantian |
|
|
|
|
: "${store.openStartTime.substring(0, store.openStartTime.lastIndexOf(":"))}-${store.openEndTime.substring(0, store.openEndTime.lastIndexOf(":"))}", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFA29E9E), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
@ -687,7 +729,7 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin, Wi
|
|
|
|
|
color: Color(0xFF353535), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|