From 11172fd6a24fee7db0ad0413687cdffed2dff63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=90=8C?= <494089941@qq.com> Date: Wed, 20 Apr 2022 20:48:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E7=90=86=E4=BF=A1=E6=81=AF=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../geograhic_information.dart | 73 ------------ .../geographic_information_page.dart | 109 +++++++++--------- lib/utils/application_utils.dart | 4 +- 3 files changed, 54 insertions(+), 132 deletions(-) delete mode 100644 lib/pages/geographic_information/geograhic_information.dart diff --git a/lib/pages/geographic_information/geograhic_information.dart b/lib/pages/geographic_information/geograhic_information.dart deleted file mode 100644 index 6707b934..00000000 --- a/lib/pages/geographic_information/geograhic_information.dart +++ /dev/null @@ -1,73 +0,0 @@ -import 'package:aku_new_community/base/base_style.dart'; -import 'package:aku_new_community/const/resource.dart'; -import 'package:aku_new_community/constants/api.dart'; -import 'package:aku_new_community/constants/saas_api.dart'; -import 'package:aku_new_community/model/common/img_model.dart'; -import 'package:aku_new_community/models/geographic_information/geographic_information_model.dart'; -import 'package:aku_new_community/utils/network/base_model.dart'; -import 'package:aku_new_community/utils/network/net_util.dart'; -import 'package:aku_new_community/widget/bee_scaffold.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:velocity_x/velocity_x.dart'; - -class GeographicInformationPage extends StatefulWidget { - GeographicInformationPage({ - Key? key, - }) : super(key: key); - - @override - _GeographicInformationPageState createState() => - _GeographicInformationPageState(); -} - -class _GeographicInformationPageState extends State { - GeographicInformationModel _model = GeographicInformationModel.init(); - bool _onload = true; - - @override - Widget build(BuildContext context) { - return BeeScaffold( - bodyColor: Colors.white, - title: '地理信息', - body: EasyRefresh( - firstRefresh: true, - header: MaterialHeader(), - onRefresh: () async { - BaseModel baseModel = - await NetUtil().get(API.manager.geographyInformation); - if (baseModel.success && baseModel.data != null) { - _model = GeographicInformationModel.fromJson(baseModel.data); - } - _onload = false; - setState(() {}); - }, - child: _onload - ? Container() - : ListView( - children: [ - SizedBox( - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - fit: BoxFit.cover, - image: SAASAPI.image(ImgModel.first(_model.imgUrls))), - width: double.infinity, - height: 424.w, - ), - 24.w.heightBox, - Padding( - padding: - EdgeInsets.only(left: 32.w, right: 32.w, top: 40.w), - child: Text( - _model.content ?? '', - style: TextStyle( - fontSize: 26.sp, - color: (ktextSubColor), - fontWeight: FontWeight.bold), - )), - ], - ), - )); - } -} diff --git a/lib/pages/geographic_information/geographic_information_page.dart b/lib/pages/geographic_information/geographic_information_page.dart index 63196d11..1437da76 100644 --- a/lib/pages/geographic_information/geographic_information_page.dart +++ b/lib/pages/geographic_information/geographic_information_page.dart @@ -1,73 +1,70 @@ -import 'package:aku_new_community/base/base_style.dart'; -import 'package:aku_new_community/const/resource.dart'; import 'package:aku_new_community/constants/api.dart'; -import 'package:aku_new_community/constants/saas_api.dart'; -import 'package:aku_new_community/model/common/img_model.dart'; -import 'package:aku_new_community/models/geographic_information/geographic_information_model.dart'; -import 'package:aku_new_community/utils/network/base_model.dart'; +import 'package:aku_new_community/pages/one_alarm/alarm_detail_page.dart'; +import 'package:aku_new_community/pages/one_alarm/widget/alarm_page.dart'; +import 'package:aku_new_community/provider/app_provider.dart'; +import 'package:aku_new_community/utils/headers.dart'; import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; +import 'package:amap_flutter_base/amap_flutter_base.dart'; +import 'package:amap_flutter_map/amap_flutter_map.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:velocity_x/velocity_x.dart'; +import 'package:flutter_icons/flutter_icons.dart'; +import 'package:get/get.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + class GeographicInformationPage extends StatefulWidget { - GeographicInformationPage({ - Key? key, - }) : super(key: key); + GeographicInformationPage({Key? key}) : super(key: key); @override - _GeographicInformationPageState createState() => - _GeographicInformationPageState(); + _GeographicInformationPageState createState() => _GeographicInformationPageState(); } class _GeographicInformationPageState extends State { - GeographicInformationModel _model = GeographicInformationModel.init(); - bool _onload = false; + AMapController? _mapController; + + @override + void initState() { + super.initState(); + PermissionUtil.getLocationPermission(); + } + + @override + void dispose() { + super.dispose(); + _mapController?.disponse(); + } @override Widget build(BuildContext context) { + final appProvider = Provider.of(context); return BeeScaffold( - bodyColor: Colors.white, - title: '地理信息', - body: EasyRefresh( - firstRefresh: true, - header: MaterialHeader(), - onRefresh: () async { - BaseModel baseModel = - await NetUtil().get(API.manager.geographyInformation); - if (baseModel.success && baseModel.data != null) { - _model = GeographicInformationModel.fromJson(baseModel.data); - } - _onload = false; - setState(() {}); - }, - child: _onload - ? Container() - : ListView( - children: [ - SizedBox( - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - fit: BoxFit.cover, - image: SAASAPI.image(ImgModel.first(_model.imgUrls))), - width: double.infinity, - height: 424.w, - ), - 24.w.heightBox, - Padding( - padding: - EdgeInsets.only(left: 32.w, right: 32.w, top: 40.w), - child: Text( - _model.content ?? '', - style: TextStyle( - fontSize: 26.sp, - color: (ktextSubColor), - fontWeight: FontWeight.bold), - )), - ], - ), - )); + title: '地理信息', + body: AMapWidget( + privacyStatement: AMapPrivacyStatement( + hasContains: true, hasShow: true, hasAgree: true), + onMapCreated: (controller) { + final appProvider = + Provider.of(context, listen: false); + LatLng _target = LatLng( + (appProvider.location?['latitude'] ?? 0) as double, + (appProvider.location?['longitude'] ?? 0) as double, + ); + _mapController = controller; + _mapController!.moveCamera( + CameraUpdate.newCameraPosition( + CameraPosition(target: _target, zoom: 18), + ), + ); + }, + myLocationStyleOptions: MyLocationStyleOptions( + true, + circleFillColor: Theme.of(context).primaryColor.withOpacity(0.2), + circleStrokeColor: Theme.of(context).primaryColor, + ), + ), + ); } } diff --git a/lib/utils/application_utils.dart b/lib/utils/application_utils.dart index 1d61f98a..83c5c1d1 100644 --- a/lib/utils/application_utils.dart +++ b/lib/utils/application_utils.dart @@ -6,7 +6,7 @@ import 'package:aku_new_community/pages/convenient_phone/convenient_phone_page.d import 'package:aku_new_community/pages/electronic_commerc/electronic_commerc_page.dart'; import 'package:aku_new_community/pages/event_activity/event_voting_page.dart'; import 'package:aku_new_community/pages/express_packages/express_package_page.dart'; -import 'package:aku_new_community/pages/geographic_information/geograhic_information.dart'; +import 'package:aku_new_community/pages/geographic_information/geographic_information_page.dart'; import 'package:aku_new_community/pages/goods_deto_page/goods_deto_page.dart'; import 'package:aku_new_community/pages/goods_manage_page/select_borrow_return_page.dart'; import 'package:aku_new_community/pages/house_introduce/house_introduce.dart'; @@ -176,8 +176,6 @@ class ApplicationUtil { title: '地理信息', imgPath: Assets.newIcon.icDlxx.path, onTap: () { - BotToast.showText(text: '此功能升级中,敬请期待'); - return; Get.to(() => GeographicInformationPage()); }), AppElement(