Browse Source

Merge branches 'dev' and 'master' of https://git.lotus-wallet.com/fmk/huixiang_app

 Conflicts:
	lib/home/points_mall_page.dart
	lib/union/union_page.dart
null_safety
哈哈哈 3 years ago
parent
commit
8f4801c049
  1. BIN
      assets/image/2x/icon_mine_card.png
  2. BIN
      assets/image/2x/icon_mine_order.png
  3. BIN
      assets/image/3x/icon_mine_card.png
  4. BIN
      assets/image/3x/icon_mine_order.png
  5. BIN
      assets/image/icon_mine_card.png
  6. BIN
      assets/image/icon_mine_order.png
  7. 5
      lib/home/points_mall_page.dart
  8. 32
      lib/integral/integral_page.dart
  9. 21
      lib/integral_store/integral_store_details_page.dart
  10. 4
      lib/mine/mine_page.dart
  11. 5
      lib/mine/mine_vip_level_page.dart
  12. 97
      lib/mine/vip_detail_page.dart
  13. 6
      lib/union/union_details_page.dart
  14. 343
      lib/union/union_page.dart
  15. 8
      pubspec.lock

BIN
assets/image/2x/icon_mine_card.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/image/2x/icon_mine_order.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 966 B

BIN
assets/image/3x/icon_mine_card.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
assets/image/3x/icon_mine_order.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/image/icon_mine_card.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 866 B

After

Width:  |  Height:  |  Size: 875 B

BIN
assets/image/icon_mine_order.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 605 B

After

Width:  |  Height:  |  Size: 510 B

5
lib/home/points_mall_page.dart

@ -440,8 +440,9 @@ class _PointsMallPage extends State<PointsMallPage>
borderRadius: BorderRadius.only(topRight: Radius.circular(4)), borderRadius: BorderRadius.only(topRight: Radius.circular(4)),
child: Image.asset( child: Image.asset(
"assets/image/icon_hot_right_top.png", "assets/image/icon_hot_right_top.png",
width: 36, width: 36.w,
height: 36, height: 36.h,
fit: BoxFit.cover,
), ),
), ),
), ),

32
lib/integral/integral_page.dart

@ -249,11 +249,12 @@ class _IntegralPage extends State<IntegralPage> {
task.name, task.name,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF353535), color: Color(0xFF353535),
), ),
), ),
SizedBox( SizedBox(
width: 7, height: 7.h,
), ),
Row( Row(
children: [ children: [
@ -272,6 +273,7 @@ class _IntegralPage extends State<IntegralPage> {
"${task.complateNum ?? task.conplateNum}/${task.limitDay}"), "${task.complateNum ?? task.conplateNum}/${task.limitDay}"),
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF727272), color: Color(0xFF727272),
), ),
), ),
@ -291,7 +293,7 @@ class _IntegralPage extends State<IntegralPage> {
radius: 12, radius: 12,
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
padding: EdgeInsets.fromLTRB(12.w, 2.h, 12.w, 2.h), padding: EdgeInsets.fromLTRB(12.w, 4.h, 12.w, 4.h),
) )
], ],
), ),
@ -320,7 +322,7 @@ class _IntegralPage extends State<IntegralPage> {
style: TextStyle( style: TextStyle(
color: Color(0xFF353535), color: Color(0xFF353535),
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.bold), fontWeight: FontWeight.w500),
), ),
SizedBox( SizedBox(
height: 10.h, height: 10.h,
@ -331,7 +333,8 @@ class _IntegralPage extends State<IntegralPage> {
S.of(context).shenmijifendali, S.of(context).shenmijifendali,
style: TextStyle( style: TextStyle(
color: Color(0xFF727272), color: Color(0xFF727272),
fontSize: 12.sp, fontWeight: FontWeight.bold,
fontSize: 10.sp,
), ),
), ),
), ),
@ -374,7 +377,7 @@ class _IntegralPage extends State<IntegralPage> {
? Colors.white ? Colors.white
: Color(0xFF353535), : Color(0xFF353535),
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.w500,
), ),
), ),
Container( Container(
@ -441,6 +444,9 @@ class _IntegralPage extends State<IntegralPage> {
fontSize: 16.sp, fontSize: 16.sp,
color: Color(0xFF353535)), color: Color(0xFF353535)),
), ),
SizedBox(
height: 10.h,
),
Text( Text(
S.of(context).lianxuqiandaolingqushuangbeijifen, S.of(context).lianxuqiandaolingqushuangbeijifen,
style: TextStyle( style: TextStyle(
@ -471,6 +477,8 @@ class _IntegralPage extends State<IntegralPage> {
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
child: RoundButton( child: RoundButton(
width: 106,
height: 34,
text: (signInfo != null && signInfo.todayHasSignin) text: (signInfo != null && signInfo.todayHasSignin)
? S.of(context).yiqiandao ? S.of(context).yiqiandao
: S.of(context).lijiqiandao, : S.of(context).lijiqiandao,
@ -479,6 +487,7 @@ class _IntegralPage extends State<IntegralPage> {
? Colors.grey ? Colors.grey
: Color(0xFF32A060), : Color(0xFF32A060),
fontSize: 16.sp, fontSize: 16.sp,
fontWeight: FontWeight.w400,
padding: EdgeInsets.fromLTRB(16.w, 6.h, 16.w, 6.h), padding: EdgeInsets.fromLTRB(16.w, 6.h, 16.w, 6.h),
radius: 4, radius: 4,
), ),
@ -499,7 +508,9 @@ class _IntegralPage extends State<IntegralPage> {
BaseData baseData = await apiService.signIn(); BaseData baseData = await apiService.signIn();
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
querySignInfo(); querySignInfo();
SmartDialog.show(widget: SignInWidget("${signInfo.signInList.length + 1}", "${signInfo.rewardList[signInfo.signInList.length]}")); SmartDialog.show(
widget: SignInWidget("${signInfo.signInList.length + 1}",
"${signInfo.rewardList[signInfo.signInList.length]}"));
} }
} }
@ -519,7 +530,7 @@ class _IntegralPage extends State<IntegralPage> {
Text( Text(
signInfo != null ? "${signInfo.point}" : "0", signInfo != null ? "${signInfo.point}" : "0",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.w500,
fontSize: 21.sp, fontSize: 21.sp,
color: Colors.white, color: Colors.white,
), ),
@ -531,6 +542,7 @@ class _IntegralPage extends State<IntegralPage> {
S.of(context).wodejifenzhi, S.of(context).wodejifenzhi,
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.w400,
color: Color(0xFFF2F2F2), color: Color(0xFFF2F2F2),
), ),
) )
@ -548,7 +560,8 @@ class _IntegralPage extends State<IntegralPage> {
Navigator.of(context) Navigator.of(context)
.pushNamed('/router/mine_vip_level_page', arguments: { .pushNamed('/router/mine_vip_level_page', arguments: {
"rankLevel": rankLevel, "rankLevel": rankLevel,
"createTime": (userinfo != null) ? "${userinfo.createTime}" : "", "createTime":
(userinfo != null) ? "${userinfo.createTime}" : "",
"points": "points":
(userinfo != null) ? int.tryParse(userinfo.points) : 0, (userinfo != null) ? int.tryParse(userinfo.points) : 0,
}); });
@ -562,7 +575,7 @@ class _IntegralPage extends State<IntegralPage> {
? "${signInfo.rank.rankName.replaceAll("会员", "")}" ? "${signInfo.rank.rankName.replaceAll("会员", "")}"
: "", : "",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.w500,
fontSize: 21.sp, fontSize: 21.sp,
color: Colors.white, color: Colors.white,
), ),
@ -578,6 +591,7 @@ class _IntegralPage extends State<IntegralPage> {
S.of(context).wodehuiyuandengji, S.of(context).wodehuiyuandengji,
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.w400,
color: Color(0xFFF2F2F2), color: Color(0xFFF2F2F2),
), ),
), ),

21
lib/integral_store/integral_store_details_page.dart

@ -102,16 +102,15 @@ class _IntegralStoreDetailsPage extends State {
assetUriMatcher(): assetImageRender(), assetUriMatcher(): assetImageRender(),
networkSourceMatcher(extension: "svg"): networkSourceMatcher(extension: "svg"):
svgNetworkImageRender(), svgNetworkImageRender(),
networkSourceMatcher(): networkSourceMatcher(): networkImageRender(
networkImageRender( loadingWidget: () {
loadingWidget: () { // return Image.asset("assets/image/default_1.png",);
// return Image.asset("assets/image/default_1.png",); return Container();
return Container(); },
}, // mapUrl: (url) {
// mapUrl: (url) { // print("objectUrl: $url");
// print("objectUrl: $url"); // return "$url?imageMogr2/format/webp/blur/1x0/quality/75";
// return "$url?imageMogr2/format/webp/blur/1x0/quality/75"; // }
// }
), ),
}, },
), ),
@ -225,6 +224,7 @@ class _IntegralStoreDetailsPage extends State {
: S.of(context).yiduihuanjian("${goods.sales}"), : S.of(context).yiduihuanjian("${goods.sales}"),
style: TextStyle( style: TextStyle(
fontSize: 10.sp, fontSize: 10.sp,
fontWeight: FontWeight.w400,
color: Color(0xFFA29E9E), color: Color(0xFFA29E9E),
), ),
), ),
@ -242,6 +242,7 @@ class _IntegralStoreDetailsPage extends State {
goods == null ? "" : goods.description, goods == null ? "" : goods.description,
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF727272), color: Color(0xFF727272),
), ),
), ),

4
lib/mine/mine_page.dart

@ -499,7 +499,7 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
Text( Text(
S.of(context).kaquan, S.of(context).kaquan,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w600, fontWeight: FontWeight.bold,
fontSize: 16.sp, fontSize: 16.sp,
color: Color(0xFF353535), color: Color(0xFF353535),
), ),
@ -512,7 +512,7 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
width: 2.w, width: 2.w,
height: 32.h, height: 32.h,
margin: EdgeInsets.only(left: 20.w, right: 20.w), margin: EdgeInsets.only(left: 20.w, right: 20.w),
color: Color(0xFFABABAB), color: Color(0xFFF7F7F7),
), ),
Expanded( Expanded(
flex: 1, flex: 1,

5
lib/mine/mine_vip_level_page.dart

@ -135,6 +135,7 @@ class _MineVipLevelPage extends State<MineVipLevelPage> {
style: TextStyle( style: TextStyle(
textBaseline: TextBaseline.alphabetic, textBaseline: TextBaseline.alphabetic,
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF353535), color: Color(0xFF353535),
), ),
), ),
@ -222,6 +223,7 @@ class _MineVipLevelPage extends State<MineVipLevelPage> {
style: TextStyle( style: TextStyle(
textBaseline: TextBaseline.alphabetic, textBaseline: TextBaseline.alphabetic,
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF353535), color: Color(0xFF353535),
), ),
), ),
@ -249,6 +251,7 @@ class _MineVipLevelPage extends State<MineVipLevelPage> {
S.of(context).youhuiquanwufajileijifen, S.of(context).youhuiquanwufajileijifen,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF353535), color: Color(0xFF353535),
), ),
), ),
@ -278,6 +281,7 @@ class _MineVipLevelPage extends State<MineVipLevelPage> {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF353535), color: Color(0xFF353535),
), ),
), ),
@ -289,6 +293,7 @@ class _MineVipLevelPage extends State<MineVipLevelPage> {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF353535), color: Color(0xFF353535),
), ),
), ),

97
lib/mine/vip_detail_page.dart

@ -194,7 +194,7 @@ class _VipDetailPage extends State<VipDetailPage> {
fadeSrc: "assets/image/default_1.png", fadeSrc: "assets/image/default_1.png",
), ),
SizedBox( SizedBox(
width: 12.w, width: 8.w,
), ),
Expanded( Expanded(
child: Container( child: Container(
@ -212,7 +212,7 @@ class _VipDetailPage extends State<VipDetailPage> {
vipCard != null ? vipCard.storeName : "", vipCard != null ? vipCard.storeName : "",
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 14.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.black, color: Colors.black,
), ),
@ -228,10 +228,10 @@ class _VipDetailPage extends State<VipDetailPage> {
TextSpan( TextSpan(
children: [ children: [
TextSpan( TextSpan(
text: "会员卡", text: S.of(context).huiyuanka,
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.w400,
color: Colors.black, color: Colors.black,
), ),
), ),
@ -263,7 +263,7 @@ class _VipDetailPage extends State<VipDetailPage> {
children: [ children: [
TextSpan( TextSpan(
text: text:
"¥${vipCard != null ? vipCard.balance : ""}", "¥ ${vipCard != null ? vipCard.balance : ""}",
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@ -348,10 +348,10 @@ class _VipDetailPage extends State<VipDetailPage> {
child: Text( child: Text(
vipCard != null vipCard != null
? "${vipCard.id.substring(0, 4)} " ? "${vipCard.id.substring(0, 4)} "
"${vipCard.id.substring(4, 8)} " "${vipCard.id.substring(4, 8)} "
"${vipCard.id.substring(8, 12)} " "${vipCard.id.substring(8, 12)} "
"${vipCard.id.substring(12, 16)} " "${vipCard.id.substring(12, 16)} "
"${vipCard.id.substring(16, vipCard.id.length)}" "${vipCard.id.substring(16, vipCard.id.length)}"
: "", : "",
maxLines: 1, maxLines: 1,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -361,11 +361,11 @@ class _VipDetailPage extends State<VipDetailPage> {
wordSpacing: vipCard == null wordSpacing: vipCard == null
? 10 ? 10
: (MediaQuery.of(context).size.width - 64.w) / : (MediaQuery.of(context).size.width - 64.w) /
(((vipCard.id.length) * 4)), (((vipCard.id.length) * 4)),
letterSpacing: vipCard == null letterSpacing: vipCard == null
? 8 ? 8
: (MediaQuery.of(context).size.width - 64.w) / : (MediaQuery.of(context).size.width - 64.w) /
(((vipCard.id.length) * 4)), (((vipCard.id.length) * 4)),
), ),
), ),
), ),
@ -407,10 +407,11 @@ class _VipDetailPage extends State<VipDetailPage> {
), ),
)), )),
GestureDetector( GestureDetector(
onTap: (){ onTap: () {
Navigator.of(context).pushNamed('/router/union_detail_page',arguments: {"id": orderInfo.storeId}); Navigator.of(context).pushNamed('/router/union_detail_page',
arguments: {"id": orderInfo.storeId});
}, },
child:Text( child: Text(
"查看", "查看",
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
@ -469,7 +470,7 @@ class _VipDetailPage extends State<VipDetailPage> {
flex: 1, flex: 1,
child: Text( child: Text(
(orderInfo.storeVO.openStartTime == null && (orderInfo.storeVO.openStartTime == null &&
orderInfo.storeVO.openEndTime == null) orderInfo.storeVO.openEndTime == null)
? S.of(context).quantian ? S.of(context).quantian
: "${orderInfo.storeVO.openStartTime.substring(0, orderInfo.storeVO.openStartTime.lastIndexOf(":"))}-${orderInfo.storeVO.openEndTime.substring(0, orderInfo.storeVO.openEndTime.lastIndexOf(":"))}", : "${orderInfo.storeVO.openStartTime.substring(0, orderInfo.storeVO.openStartTime.lastIndexOf(":"))}-${orderInfo.storeVO.openEndTime.substring(0, orderInfo.storeVO.openEndTime.lastIndexOf(":"))}",
style: TextStyle( style: TextStyle(
@ -514,40 +515,40 @@ class _VipDetailPage extends State<VipDetailPage> {
return products return products
.map( .map(
(e) => Container( (e) => Container(
margin: EdgeInsets.symmetric(horizontal: 2.w), margin: EdgeInsets.symmetric(horizontal: 2.w),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
MImage( MImage(
e.skuImg, e.skuImg,
width: 75.w, width: 75.w,
height: 75.h, height: 75.h,
fit: BoxFit.contain, fit: BoxFit.contain,
errorSrc: "assets/image/default_1.png", errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png", fadeSrc: "assets/image/default_1.png",
),
SizedBox(
height: 4.h,
),
if (isRemake)
Container(
width: 75.w,
child: Text(
e.productName,
maxLines: 1,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 10.sp,
color: Color(0xFF353535),
),
), ),
), SizedBox(
], height: 4.h,
), ),
), if (isRemake)
) Container(
width: 75.w,
child: Text(
e.productName,
maxLines: 1,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 10.sp,
color: Color(0xFF353535),
),
),
),
],
),
),
)
.toList(); .toList();
} }
} }

6
lib/union/union_details_page.dart

@ -721,7 +721,8 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
receiveVip() async { receiveVip() async {
BaseData baseData = await apiService.minLogin(storeInfo.id); BaseData baseData = await apiService.minLogin(storeInfo.id);
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
SmartDialog.showToast(S.of(context).lingquchenggong, alignment: Alignment.center); SmartDialog.showToast(S.of(context).lingquchenggong,
alignment: Alignment.center);
setState(() { setState(() {
isReceive = false; isReceive = false;
}); });
@ -909,7 +910,8 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
_loginMin() async { _loginMin() async {
if (storeInfo == null) return; if (storeInfo == null) return;
if (!isEnable()) { if (!isEnable()) {
SmartDialog.showToast(S.of(context).zanbuzhichixianshangdiancan, alignment: Alignment.center); SmartDialog.showToast(S.of(context).zanbuzhichixianshangdiancan,
alignment: Alignment.center);
return; return;
} }
BaseData baseData = await apiService.minLogin(storeInfo.id); BaseData baseData = await apiService.minLogin(storeInfo.id);

343
lib/union/union_page.dart

@ -1,14 +1,15 @@
import 'dart:io'; import 'dart:io';
import 'dart:ui'; import 'dart:ui';
import 'package:amap_flutter_location/amap_flutter_location.dart';
import 'package:amap_flutter_location/amap_location_option.dart';
import 'package:android_intent_plus/android_intent.dart'; import 'package:android_intent_plus/android_intent.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart';
import 'package:flutter_bmflocation/bdmap_location_flutter_plugin.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/main.dart'; import 'package:huixiang/main.dart';
@ -20,13 +21,15 @@ import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/icon_text.dart';
import 'package:huixiang/view_widget/item_title.dart'; import 'package:huixiang/view_widget/item_title.dart';
import 'package:amap_flutter_base/amap_flutter_base.dart';
import 'package:amap_flutter_map/amap_flutter_map.dart';
import 'package:huixiang/view_widget/request_permission.dart'; import 'package:huixiang/view_widget/request_permission.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'dart:typed_data';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
class UnionPage extends StatefulWidget { class UnionPage extends StatefulWidget {
@override @override
@ -38,15 +41,27 @@ class UnionPage extends StatefulWidget {
class _UnionPage extends State<UnionPage> class _UnionPage extends State<UnionPage>
with AutomaticKeepAliveClientMixin, WidgetsBindingObserver { with AutomaticKeepAliveClientMixin, WidgetsBindingObserver {
//使true //使true
CustomStyleOptions _customStyleOptions = CustomStyleOptions(false);
// //
void _loadCustomData() async { void _loadCustomData() async {
if (null == _customStyleOptions) {
_customStyleOptions = CustomStyleOptions(false);
}
ByteData styleByteData =
await rootBundle.load('assets/map_style/style.data');
_customStyleOptions.styleData = styleByteData.buffer.asUint8List();
ByteData styleExtraByteData =
await rootBundle.load('assets/map_style/style_extra.data');
_customStyleOptions.styleExtraData =
styleExtraByteData.buffer.asUint8List();
//setState修改CustomStyleOptions的enable为true
setState(() { setState(() {
_mapController.setCustomMapStyle('assets/map_style/chatian.sty', 0); _customStyleOptions.enabled = true;
}); });
} }
LocationFlutterPlugin aMapFlutterLocation; AMapFlutterLocation aMapFlutterLocation;
RefreshController refreshController = RefreshController refreshController =
RefreshController(initialRefresh: false); RefreshController(initialRefresh: false);
@ -55,6 +70,7 @@ class _UnionPage extends State<UnionPage>
super.dispose(); super.dispose();
WidgetsBinding.instance.removeObserver(this); WidgetsBinding.instance.removeObserver(this);
aMapFlutterLocation.stopLocation(); aMapFlutterLocation.stopLocation();
aMapFlutterLocation.destroy();
refreshController.dispose(); refreshController.dispose();
} }
@ -89,17 +105,19 @@ class _UnionPage extends State<UnionPage>
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
if (aMapFlutterLocation == null) { if (aMapFlutterLocation == null) {
aMapFlutterLocation = LocationFlutterPlugin(); AMapFlutterLocation.setApiKey("f39d1daa020a56f208eb2519f63e9534",
aMapFlutterLocation.onResultCallback().listen((event) { "feaae7986201b571cace1b83728be5bb");
aMapFlutterLocation = AMapFlutterLocation();
aMapFlutterLocation.onLocationChanged().listen((event) {
if (event != null && if (event != null &&
event["latitude"] != null && event["latitude"] != null &&
event["longitude"] != null) { event["longitude"] != null) {
print("location: $event"); print("location: $event");
if (event["latitude"] is String && event["longitude"] is String) { if (event["latitude"] is String && event["longitude"] is String) {
latLng = BMFCoordinate(double.tryParse(event["latitude"]), latLng = LatLng(double.tryParse(event["latitude"]),
double.tryParse(event["longitude"])); double.tryParse(event["longitude"]));
} else { } else {
latLng = BMFCoordinate(event["latitude"], event["longitude"]); latLng = LatLng(event["latitude"], event["longitude"]);
} }
saveLatLng( saveLatLng(
latLng, event["province"], event["city"], event["district"]); latLng, event["province"], event["city"], event["district"]);
@ -111,10 +129,12 @@ class _UnionPage extends State<UnionPage>
event["district"], event["district"],
editingController.text); editingController.text);
if (_mapController != null) if (_mapController != null)
_mapController.updateMapOptions(BMFMapOptions( _mapController.moveCamera(
center: latLng, CameraUpdate.newCameraPosition(CameraPosition(
zoomLevel: 15, target: latLng,
)); zoom: 15.0,
)),
);
} }
}); });
@ -126,25 +146,15 @@ class _UnionPage extends State<UnionPage>
}); });
} }
aMapFlutterLocation.prepareLoc({ aMapFlutterLocation.setLocationOption(AMapLocationOption(
"coorType": "bd09ll", needAddress: true,
"isNeedAddres": false, onceLocation: true,
"isNeedAltitude": false, locationMode: AMapLocationMode.Hight_Accuracy,
"isNeedLocationPoiList": false, desiredAccuracy: DesiredAccuracy.HundredMeters,
"isNeedLocationDescribe": false, desiredLocationAccuracyAuthorizationMode:
"isNeedNewVersionRgc": false, AMapLocationAccuracyAuthorizationMode.FullAndReduceAccuracy,
"scanspan": 0, pausesLocationUpdatesAutomatically: true,
"openGps": true, ));
"locationMode": 2,
}, {
"locationMode": "kCLLocationAccuracyBest",
"locationTimeout": 10,
"reGeocodeTimeout": 10,
"activityType": "CLActivityTypeAutomotiveNavigation",
"BMKLocationCoordinateType": "BMKLocationCoordinateTypeBMK09LL",
"BMKLocationCoordinateType": "BMKLocationCoordinateTypeBMK09LL",
"isNeedNewVersionRgc": false,
});
_loadCustomData(); _loadCustomData();
@ -152,9 +162,9 @@ class _UnionPage extends State<UnionPage>
startLocation(); startLocation();
} }
BMFCoordinate latLng; LatLng latLng;
saveLatLng(BMFCoordinate latLng, province, city, district) async { saveLatLng(LatLng latLng, province, city, district) async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString("latitude", "${latLng.latitude}"); await prefs.setString("latitude", "${latLng.latitude}");
await prefs.setString("longitude", "${latLng.longitude}"); await prefs.setString("longitude", "${latLng.longitude}");
@ -176,7 +186,7 @@ class _UnionPage extends State<UnionPage>
value.containsKey("city") && value.containsKey("city") &&
value.containsKey("district")) value.containsKey("district"))
{ {
latLng = BMFCoordinate(double.tryParse(value.getString("latitude")), latLng = LatLng(double.tryParse(value.getString("latitude")),
double.tryParse(value.getString("longitude"))), double.tryParse(value.getString("longitude"))),
queryStore( queryStore(
value.getString("latitude"), value.getString("latitude"),
@ -188,10 +198,14 @@ class _UnionPage extends State<UnionPage>
), ),
setState(() { setState(() {
if (_mapController != null) { if (_mapController != null) {
_mapController.updateMapOptions(BMFMapOptions( _mapController.moveCamera(
center: latLng, CameraUpdate.newCameraPosition(
zoomLevel: 15, CameraPosition(
)); target: latLng,
zoom: 15.0,
),
),
);
} }
}) })
} }
@ -221,7 +235,7 @@ class _UnionPage extends State<UnionPage>
storeList = (baseData.data as List<dynamic>) storeList = (baseData.data as List<dynamic>)
.map((e) => Store.fromJson(e)) .map((e) => Store.fromJson(e))
.toList(); .toList();
// buildMarker(); buildMarker();
refreshController.refreshCompleted(); refreshController.refreshCompleted();
if (mounted) setState(() {}); if (mounted) setState(() {});
} else { } else {
@ -229,20 +243,34 @@ class _UnionPage extends State<UnionPage>
} }
} }
// buildMarker() async { RepaintBoundary repaintBoundary;
// markers.clear();
// markers.addAll(storeList.map((element) => BMFMarker( buildMarker() async {
// position: BMFCoordinate(double.tryParse(element.latitude), markers.clear();
// double.tryParse(element.longitude)),
// centerOffset: BMFPoint(0.5, 0.9), BitmapDescriptor bitmapDescriptor = await BitmapDescriptor.fromAssetImage(
// enabled: false, ImageConfiguration(
// icon: "assets/image/icon_map_marker.png", bundle: DefaultAssetBundle.of(context),
// draggable: false, devicePixelRatio: MediaQuery.of(context)?.devicePixelRatio ?? 1.0,
// ))); locale: Localizations.localeOf(context),
// if (mounted) setState(() {}); textDirection: Directionality.of(context),
// } size: Size(35.w, 35.h),
// platform: defaultTargetPlatform,
// List<BMFMarker> markers = []; ),
"assets/image/icon_map_marker.png");
markers.addAll(storeList.map((element) => Marker(
position: LatLng(double.tryParse(element.latitude),
double.tryParse(element.longitude)),
anchor: Offset(0.5, 0.9),
clickable: false,
icon: bitmapDescriptor,
infoWindowEnable: true,
)));
if (mounted) setState(() {});
}
List<Marker> markers = [];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -262,7 +290,7 @@ class _UnionPage extends State<UnionPage>
PreferredSize( PreferredSize(
preferredSize: Size(double.infinity, 52.h), preferredSize: Size(double.infinity, 52.h),
child: Container( child: Container(
padding: EdgeInsets.only(top: 6.h), padding: EdgeInsets.only(top: 26.5.h),
color: Color(0xFFFAFAFA), color: Color(0xFFFAFAFA),
child: ItemTitle( child: ItemTitle(
text: S.of(context).jingbilianmenghuiyuandian, text: S.of(context).jingbilianmenghuiyuandian,
@ -278,17 +306,24 @@ class _UnionPage extends State<UnionPage>
// headerSliverBuilder: (context, inner) { // headerSliverBuilder: (context, inner) {
// return [ // return [
// SliverOverlapAbsorber( // SliverOverlapAbsorber(
// sliver: buildSliverAppBar(BMFMapWidget( // sliver: buildSliverAppBar(AMapWidget(
// mapOptions: BMFMapOptions( // initialCameraPosition: CameraPosition(
// center: BMFCoordinate(30.553111, 114.342366), // target: LatLng(30.553111, 114.342366),
// zoomLevel: 12, // zoom: 12.0,
// ), // ),
// onBMFMapCreated: onMapCreated, // onMapCreated: onMapCreated,
// // customStyleOptions: _customStyleOptions, // apiKey: aMapApiKeys,
// // gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[ // touchPoiEnabled: true,
// // Factory<OneSequenceGestureRecognizer>( // markers: markers.toSet(),
// // () => EagerGestureRecognizer()), // scrollGesturesEnabled: true,
// // ].toSet(), // customStyleOptions: _customStyleOptions,
// onPoiTouched: (poiTouch) {
// FocusScope.of(context).requestFocus(FocusNode());
// },
// gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
// Factory<OneSequenceGestureRecognizer>(
// () => EagerGestureRecognizer()),
// ].toSet(),
// )), // )),
// handle: // handle:
// NestedScrollView.sliverOverlapAbsorberHandleFor(context), // NestedScrollView.sliverOverlapAbsorberHandleFor(context),
@ -333,7 +368,7 @@ class _UnionPage extends State<UnionPage>
itemCount: storeList == null ? 0 : storeList.length, 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),
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 8.h, bottom: 84.h /* + (375.h - 88.h) + 4.h*/), top: 17.h, bottom: 84.h /* + (375.h - 88.h) + 4.h*/),
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return GestureDetector( return GestureDetector(
@ -425,10 +460,10 @@ class _UnionPage extends State<UnionPage>
}); });
} }
BMFMapController _mapController; AMapController _mapController;
TextEditingController editingController = TextEditingController(); TextEditingController editingController = TextEditingController();
void onMapCreated(BMFMapController controller) { void onMapCreated(AMapController controller) {
_mapController = controller; _mapController = controller;
} }
@ -438,17 +473,16 @@ class _UnionPage extends State<UnionPage>
margin: EdgeInsets.fromLTRB(16.w, 40, 16.w, 0), margin: EdgeInsets.fromLTRB(16.w, 40, 16.w, 0),
padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h), padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(4)), borderRadius: BorderRadius.all(Radius.circular(4)),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.black.withAlpha(12), color: Colors.black.withAlpha(12),
offset: Offset(0, 3), offset: Offset(0, 3),
blurRadius: 14, blurRadius: 14,
spreadRadius: 0, spreadRadius: 0,
) )
], ]),
),
child: TextField( child: TextField(
textInputAction: TextInputAction.search, textInputAction: TextInputAction.search,
onEditingComplete: () { onEditingComplete: () {
@ -479,81 +513,81 @@ class _UnionPage extends State<UnionPage>
); );
} }
// Widget buildSliverAppBar(BMFMapWidget map) { Widget buildSliverAppBar(AMapWidget map) {
// return SliverAppBar( return SliverAppBar(
// // //
// // floating: true, // floating: true,
// // snap: true, // snap: true,
// pinned: true, pinned: true,
// backgroundColor: Color(0xFFFAFAFA), backgroundColor: Color(0xFFFAFAFA),
// elevation: 0, elevation: 0,
// automaticallyImplyLeading: false, automaticallyImplyLeading: false,
// title: Container( title: Container(
// height: 36.h, height: 36.h,
// margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0), margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0),
// padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h), padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h),
// decoration: BoxDecoration( decoration: BoxDecoration(
// color: Colors.white, color: Colors.white,
// borderRadius: BorderRadius.all(Radius.circular(4)), borderRadius: BorderRadius.all(Radius.circular(4)),
// boxShadow: [ boxShadow: [
// BoxShadow( BoxShadow(
// color: Colors.black.withAlpha(12), color: Colors.black.withAlpha(12),
// offset: Offset(0, 3), offset: Offset(0, 3),
// blurRadius: 14, blurRadius: 14,
// spreadRadius: 0, spreadRadius: 0,
// ) )
// ]), ]),
// child: TextField( child: TextField(
// textInputAction: TextInputAction.search, textInputAction: TextInputAction.search,
// onEditingComplete: () { onEditingComplete: () {
// startLocation(); startLocation();
// }, },
// controller: editingController, controller: editingController,
// cursorHeight: 30.h, cursorHeight: 30.h,
// decoration: InputDecoration( decoration: InputDecoration(
// contentPadding: EdgeInsets.symmetric(vertical: 12.h), contentPadding: EdgeInsets.symmetric(vertical: 12.h),
// prefixIcon: Icon( prefixIcon: Icon(
// Icons.search, Icons.search,
// size: 24, size: 24,
// color: Colors.black, color: Colors.black,
// ), ),
// suffixIcon: InkWell( suffixIcon: InkWell(
// onTap: () { onTap: () {
// editingController.clear(); editingController.clear();
// }, },
// child: Icon( child: Icon(
// Icons.close, Icons.close,
// size: 19, size: 19,
// color: Colors.grey, color: Colors.grey,
// ), ),
// ), ),
// border: InputBorder.none, border: InputBorder.none,
// ), ),
// ), ),
// ), ),
// flexibleSpace: FlexibleSpaceBar( flexibleSpace: FlexibleSpaceBar(
// background: Container( background: Container(
// child: map, child: map,
// ), ),
// ), ),
// expandedHeight: 375.h, expandedHeight: 375.h,
// bottom: PreferredSize( bottom: PreferredSize(
// preferredSize: Size(double.infinity, 52.h), preferredSize: Size(double.infinity, 52.h),
// child: Container( child: Container(
// padding: EdgeInsets.only(top: 6.h), padding: EdgeInsets.only(top: 6.h),
// color: Color(0xFFFAFAFA), color: Color(0xFFFAFAFA),
// child: ItemTitle( child: ItemTitle(
// text: S.of(context).jingbilianmenghuiyuandian, text: S.of(context).jingbilianmenghuiyuandian,
// imgPath: "assets/image/icon_union_store.png", imgPath: "assets/image/icon_union_store.png",
// ), ),
// ), ),
// ), ),
// ); );
// } }
Widget buildStoreItem(Store store, position) { Widget buildStoreItem(Store store, position) {
return Container( return Container(
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 8.h), margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 16.h),
padding: EdgeInsets.fromLTRB(20.w, 20.h, 20.w, 20.h), padding: EdgeInsets.fromLTRB(20.w, 20.h, 20.w, 20.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
@ -617,9 +651,6 @@ class _UnionPage extends State<UnionPage>
), ),
], ],
), ),
SizedBox(
height: 4.h,
),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@ -658,10 +689,6 @@ class _UnionPage extends State<UnionPage>
), ),
], ],
), ),
// Expanded(
// child: Container(),
// flex: 1,
// ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,

8
pubspec.lock

@ -35,7 +35,7 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.5.0" version: "2.6.1"
barcode: barcode:
dependency: transitive dependency: transitive
description: description:
@ -886,7 +886,7 @@ packages:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.19" version: "0.3.0"
timing: timing:
dependency: transitive dependency: transitive
description: description:
@ -1049,7 +1049,7 @@ packages:
name: win32 name: win32
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.5" version: "2.2.5"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
@ -1072,5 +1072,5 @@ packages:
source: hosted source: hosted
version: "3.1.0" version: "3.1.0"
sdks: sdks:
dart: ">=2.12.0 <3.0.0" dart: ">=2.13.0 <3.0.0"
flutter: ">=2.0.0" flutter: ">=2.0.0"

Loading…
Cancel
Save