Merge branch 'develop' into build-addGateway-20240814
This commit is contained in:
commit
d1513c4e3a
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
@ -31,11 +30,13 @@ class LockAddressGaoDePage extends StatefulWidget {
|
|||||||
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
|
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
|
||||||
with RouteAware {
|
with RouteAware {
|
||||||
final LockAddressGaoDeLogic logic = Get.put(LockAddressGaoDeLogic());
|
final LockAddressGaoDeLogic logic = Get.put(LockAddressGaoDeLogic());
|
||||||
final LockAddressGaoDeState state = Get.find<LockAddressGaoDeLogic>().state;
|
final LockAddressGaoDeState state = Get
|
||||||
|
.find<LockAddressGaoDeLogic>()
|
||||||
|
.state;
|
||||||
|
|
||||||
// 高德地图
|
// 高德地图
|
||||||
static AMapApiKey amapApiKeys =
|
static AMapApiKey amapApiKeys =
|
||||||
AMapApiKey(iosKey: F.aMapKey.iosKey, androidKey: F.aMapKey.androidKey);
|
AMapApiKey(iosKey: F.aMapKey.iosKey, androidKey: F.aMapKey.androidKey);
|
||||||
|
|
||||||
AMapController? mapController;
|
AMapController? mapController;
|
||||||
AMapFlutterLocation location = AMapFlutterLocation();
|
AMapFlutterLocation location = AMapFlutterLocation();
|
||||||
@ -52,51 +53,16 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
|
|||||||
requestPermission();
|
requestPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future<void> requestPermission() async {
|
|
||||||
// final status = await Permission.location.request();
|
|
||||||
// AppLog.log("Permission.location.request()=status:$status");
|
|
||||||
// permissionStatus = status;
|
|
||||||
// if(Platform.isIOS){
|
|
||||||
// _setLocationOption();
|
|
||||||
// requestIOSLocation();
|
|
||||||
// }
|
|
||||||
// switch (status) {
|
|
||||||
// case PermissionStatus.denied:
|
|
||||||
// // AppLog.log("拒绝");
|
|
||||||
// break;
|
|
||||||
// case PermissionStatus.granted:
|
|
||||||
// if(Platform.isIOS){
|
|
||||||
// // _setLocationOption();
|
|
||||||
// // requestIOSLocation();
|
|
||||||
// }else{
|
|
||||||
// requestAndroidLocation();
|
|
||||||
// location.startLocation();
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case PermissionStatus.limited:
|
|
||||||
// // AppLog.log("限制");
|
|
||||||
// break;
|
|
||||||
// case PermissionStatus.permanentlyDenied:
|
|
||||||
// // AppLog.log("永久的否认");
|
|
||||||
// break;
|
|
||||||
// case PermissionStatus.provisional:
|
|
||||||
// // AppLog.log("临时");
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// // AppLog.log("其他状态");
|
|
||||||
// // requestLocation();
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
Future<void> requestPermission() async {
|
Future<void> requestPermission() async {
|
||||||
final bool status = await PermissionDialog.request(Permission.location);
|
final bool status = await PermissionDialog.request(Permission.location);
|
||||||
if(Platform.isIOS){
|
if (Platform.isIOS) {
|
||||||
_setLocationOption();
|
_setLocationOption();
|
||||||
requestIOSLocation();
|
requestIOSLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Platform.isIOS || status) {
|
if (!Platform.isIOS || status) {
|
||||||
|
_setLocationOption();
|
||||||
requestAndroidLocation();
|
requestAndroidLocation();
|
||||||
location.startLocation();
|
location.startLocation();
|
||||||
}
|
}
|
||||||
@ -114,19 +80,18 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> requestIOSLocation() async {
|
Future<void> requestIOSLocation() async {
|
||||||
location = AMapFlutterLocation()
|
location.setLocationOption(AMapLocationOption());
|
||||||
..setLocationOption(AMapLocationOption())
|
location.onLocationChanged().listen((Map<String, Object> event) {
|
||||||
..onLocationChanged().listen((Map<String, Object> event) {
|
// AppLog.log("listenLocationChanged$event");
|
||||||
// AppLog.log("listenLocationChanged$event");
|
// EasyLoading.dismiss();
|
||||||
// EasyLoading.dismiss();
|
if (event.isNotEmpty) {
|
||||||
if (event.isNotEmpty) {
|
setState(() {
|
||||||
setState(() {
|
addressInfo = event;
|
||||||
addressInfo = event;
|
});
|
||||||
});
|
// location.stopLocation();
|
||||||
// location.stopLocation();
|
}
|
||||||
}
|
});
|
||||||
})
|
location.startLocation();
|
||||||
..startLocation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -152,85 +117,88 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
child: (addressInfo != null && addressInfo!.containsKey('latitude'))
|
child: (addressInfo != null && addressInfo!.containsKey('latitude'))
|
||||||
? Column(
|
? Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
height: 1.sw / 5 * 4,
|
||||||
|
width: 1.sw,
|
||||||
|
child: AMapWidget(
|
||||||
|
apiKey: amapApiKeys,
|
||||||
|
// 初始化地图中心
|
||||||
|
initialCameraPosition: CameraPosition(
|
||||||
|
target: LatLng(
|
||||||
|
double.parse(
|
||||||
|
addressInfo!['latitude'].toString()),
|
||||||
|
double.parse(
|
||||||
|
addressInfo!['longitude'].toString())),
|
||||||
|
zoom: 10.0,
|
||||||
|
),
|
||||||
|
//定位小蓝点
|
||||||
|
myLocationStyleOptions: MyLocationStyleOptions(
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
// 普通地图normal,卫星地图satellite,夜间视图night,导航视图 navi,公交视图bus,
|
||||||
|
mapType: MapType.normal,
|
||||||
|
// 缩放级别范围
|
||||||
|
minMaxZoomPreference:
|
||||||
|
const MinMaxZoomPreference(3, 20),
|
||||||
|
// 隐私政策包含高德 必须填写
|
||||||
|
privacyStatement: const AMapPrivacyStatement(
|
||||||
|
hasAgree: true, hasContains: true, hasShow: true),
|
||||||
|
// 地图创建成功时返回AMapController
|
||||||
|
onMapCreated: (AMapController controller) {
|
||||||
|
mapController = controller;
|
||||||
|
},
|
||||||
|
onLocationChanged: (AMapLocation location) {
|
||||||
|
print("onLocationChanged ${location}");
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
// color: Colors.red,
|
||||||
|
margin:
|
||||||
|
EdgeInsets.only(left: 25.w, top: 20.h, right: 25.w),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SizedBox(
|
Flexible(
|
||||||
height: 1.sw / 5 * 4,
|
child: Text('检查以确保以下地址是正确的'.tr,
|
||||||
width: 1.sw,
|
style: TextStyle(fontSize: 24.sp))),
|
||||||
child: AMapWidget(
|
],
|
||||||
apiKey: amapApiKeys,
|
),
|
||||||
// 初始化地图中心
|
),
|
||||||
initialCameraPosition: CameraPosition(
|
// SizedBox(height: 20.h),
|
||||||
target: LatLng(
|
Container(
|
||||||
double.parse(
|
// color: Colors.red,
|
||||||
addressInfo!['latitude'].toString()),
|
// height: 45.h,
|
||||||
double.parse(
|
margin: EdgeInsets.only(
|
||||||
addressInfo!['longitude'].toString())),
|
left: 25.w, top: 20.h, right: 25.w),
|
||||||
zoom: 10.0,
|
child: Column(
|
||||||
),
|
children: <Widget>[
|
||||||
//定位小蓝点
|
Row(
|
||||||
myLocationStyleOptions: MyLocationStyleOptions(
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
// 普通地图normal,卫星地图satellite,夜间视图night,导航视图 navi,公交视图bus,
|
|
||||||
mapType: MapType.normal,
|
|
||||||
// 缩放级别范围
|
|
||||||
minMaxZoomPreference:
|
|
||||||
const MinMaxZoomPreference(3, 20),
|
|
||||||
// 隐私政策包含高德 必须填写
|
|
||||||
privacyStatement: const AMapPrivacyStatement(
|
|
||||||
hasAgree: true, hasContains: true, hasShow: true),
|
|
||||||
// 地图创建成功时返回AMapController
|
|
||||||
onMapCreated: (AMapController controller) {
|
|
||||||
mapController = controller;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
// color: Colors.red,
|
|
||||||
margin:
|
|
||||||
EdgeInsets.only(left: 25.w, top: 20.h, right: 25.w),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Flexible(
|
Expanded(
|
||||||
child: Text('检查以确保以下地址是正确的'.tr,
|
child: Text(
|
||||||
style: TextStyle(fontSize: 24.sp))),
|
addressInfo!['address'].toString() ??
|
||||||
|
'',
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.grey,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
overflow: TextOverflow.clip))),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
SizedBox(height: 5.h),
|
||||||
// SizedBox(height: 20.h),
|
Container(
|
||||||
Container(
|
height: 1.h,
|
||||||
// color: Colors.red,
|
color: AppColors.mainColor,
|
||||||
// height: 45.h,
|
),
|
||||||
margin: EdgeInsets.only(
|
],
|
||||||
left: 25.w, top: 20.h, right: 25.w),
|
)),
|
||||||
child: Column(
|
],
|
||||||
children: <Widget>[
|
)
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
addressInfo!['address'].toString() ??
|
|
||||||
'',
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.grey,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
overflow: TextOverflow.clip))),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(height: 5.h),
|
|
||||||
Container(
|
|
||||||
height: 1.h,
|
|
||||||
color: AppColors.mainColor,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: SizedBox(
|
: SizedBox(
|
||||||
height: 1.sw / 5 * 4 + 65.h * 2,
|
height: 1.sw / 5 * 4 + 65.h * 2,
|
||||||
child: Center(child: Text('地图加载中,请稍候。。。'.tr))),
|
child: Center(child: Text('地图加载中,请稍候。。。'.tr))),
|
||||||
),
|
),
|
||||||
SizedBox(height: 200.h),
|
SizedBox(height: 200.h),
|
||||||
Row(
|
Row(
|
||||||
@ -242,14 +210,15 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
|
|||||||
style: TextStyle(color: Colors.black, fontSize: 24.sp),
|
style: TextStyle(color: Colors.black, fontSize: 24.sp),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.toNamed(Routers.addLockSelectCountryPage, arguments: <String, Object>{
|
Get.toNamed(Routers.addLockSelectCountryPage,
|
||||||
'addressInfo': {},
|
arguments: <String, Object>{
|
||||||
'pwdTimestamp': state.pwdTimestamp.value,
|
'addressInfo': {},
|
||||||
'lockInfo': state.lockInfo,
|
'pwdTimestamp': state.pwdTimestamp.value,
|
||||||
'featureValue': state.featureValue,
|
'lockInfo': state.lockInfo,
|
||||||
'featureSettingValue': state.featureSettingValue,
|
'featureValue': state.featureValue,
|
||||||
'featureSettingParams': state.featureSettingParams,
|
'featureSettingValue': state.featureSettingValue,
|
||||||
});
|
'featureSettingParams': state.featureSettingParams,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
@ -262,15 +231,16 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
|
|||||||
logic.showToast('还未获取到位置信息哦,请耐心等待一下!'.tr);
|
logic.showToast('还未获取到位置信息哦,请耐心等待一下!'.tr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Get.toNamed(Routers.saveLockPage, arguments: <String, Object?>{
|
Get.toNamed(Routers.saveLockPage,
|
||||||
'addressInfo': addressInfo,
|
arguments: <String, Object?>{
|
||||||
'pwdTimestamp': state.pwdTimestamp.value,
|
'addressInfo': addressInfo,
|
||||||
'lockInfo': state.lockInfo,
|
'pwdTimestamp': state.pwdTimestamp.value,
|
||||||
'featureValue': state.featureValue,
|
'lockInfo': state.lockInfo,
|
||||||
'featureSettingValue': state.featureSettingValue,
|
'featureValue': state.featureValue,
|
||||||
'featureSettingParams': state.featureSettingParams,
|
'featureSettingValue': state.featureSettingValue,
|
||||||
'isFromMap': 1,
|
'featureSettingParams': state.featureSettingParams,
|
||||||
});
|
'isFromMap': 1,
|
||||||
|
});
|
||||||
// Navigator.pushNamed(context, Routers.saveLockPage);
|
// Navigator.pushNamed(context, Routers.saveLockPage);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -193,11 +193,11 @@ dependencies:
|
|||||||
easy_refresh: ^3.3.4
|
easy_refresh: ^3.3.4
|
||||||
|
|
||||||
#高德地图定位
|
#高德地图定位
|
||||||
amap_flutter_location: ^3.0.0
|
amap_flutter_location: 3.0.0
|
||||||
#权限使用
|
#权限使用
|
||||||
permission_handler: ^11.3.1
|
permission_handler: ^11.3.1
|
||||||
#高德地图地图
|
#高德地图地图
|
||||||
amap_flutter_map: ^3.0.0
|
amap_flutter_map: 3.0.0
|
||||||
|
|
||||||
# 谷歌地图
|
# 谷歌地图
|
||||||
google_maps_flutter: ^2.2.5
|
google_maps_flutter: ^2.2.5
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user