diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 0ad2aa32..b40cf1fc 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -5,6 +5,8 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> + + @@ -26,6 +29,18 @@ This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> + + + + + + + + + + + + diff --git a/lib/main.dart b/lib/main.dart index 39f32681..a1e57fee 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:akuCommunity/pages/sign/sign_in_page.dart'; +import 'package:amap_map_fluttify/amap_map_fluttify.dart'; import 'package:ani_route/ani_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; @@ -14,7 +15,9 @@ import 'package:oktoast/oktoast.dart'; import 'package:akuCommunity/routers/router_init.dart'; void main() { + WidgetsFlutterBinding.ensureInitialized(); ARoute.init(true); + AmapLocation.instance.init(iosKey: 'ios key'); runApp(MyApp()); } diff --git a/lib/pages/one_alarm/one_alarm_page.dart b/lib/pages/one_alarm/one_alarm_page.dart deleted file mode 100644 index f1b9855a..00000000 --- a/lib/pages/one_alarm/one_alarm_page.dart +++ /dev/null @@ -1,263 +0,0 @@ -import 'dart:ui'; -import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter_icons/flutter_icons.dart'; -import 'package:sliding_up_panel/sliding_up_panel.dart'; -import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; -import 'package:akuCommunity/utils/screenutil.dart'; -import 'package:akuCommunity/widget/common_app_bar.dart'; - -class OneAlarmPage extends StatefulWidget { - OneAlarmPage({Key key}) : super(key: key); - - @override - _OneAlarmPageState createState() => _OneAlarmPageState(); -} - -class _OneAlarmPageState extends State { - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: PreferredSize( - child: CommonAppBar( - title: '一键报警', - subtitle: '功能说明', - ), - preferredSize: Size.fromHeight(kToolbarHeight), - ), - body: Stack( - alignment: Alignment.topCenter, - children: [ - SlidingUpPanel( - maxHeight: Screenutil.length(271), - minHeight: Screenutil.length(271), - parallaxOffset: .5, - panelSnapping: false, - body: _body(), - panelBuilder: (sc) => _panel(sc), - ), - Positioned( - right: Screenutil.length(34), - bottom: Screenutil.length(304), - child: InkWell( - child: Container( - height: Screenutil.length(66), - width: Screenutil.length(66), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(Screenutil.length(66)), - boxShadow: [ - BoxShadow( - color: Color(0xff000000).withOpacity(0.12), - offset: Offset(1, 1)) - ], - ), - child: Icon( - Icons.gps_fixed, - size: Screenutil.length(44), - color: Color(0xff666666), - ), - ), - ), - ), - Positioned( - top: Screenutil.length(32), - child: Container( - width: Screenutil.length(686), - padding: EdgeInsets.only( - top: Screenutil.length(24), - bottom: Screenutil.length(24), - left: Screenutil.length(32), - ), - decoration: BoxDecoration( - color: Colors.white.withOpacity(0.9), - borderRadius: BorderRadius.circular(12), - boxShadow: [ - BoxShadow( - color: Color(0xff5C5959).withOpacity(0.2), - offset: Offset(1, 1)) - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "当前位置(仅供参考)", - style: TextStyle( - fontWeight: FontWeight.w600, - color: Color(0xff333333), - fontSize: Screenutil.size(28), - ), - ), - Container( - margin: EdgeInsets.only(top: Screenutil.length(20)), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Icon( - Entypo.location_pin, - color: Color(0xff666666), - size: Screenutil.size(28), - ), - Container( - margin: EdgeInsets.only(left: Screenutil.length(10)), - child: Text( - "广东省深圳市龙岗区吉信街22-1附近", - style: TextStyle( - color: Color(0xff666666), - fontSize: Screenutil.size(28), - ), - ), - ), - ], - ), - ), - ], - ), - ), - ), - ], - ), - ); - } - - Widget _panel(ScrollController sc) { - return MediaQuery.removePadding( - context: context, - removeTop: true, - child: Stack( - overflow: Overflow.visible, - children: [ - ListView( - controller: sc, - children: [ - Container( - margin: EdgeInsets.only(top: Screenutil.length(146)), - width: MediaQuery.of(context).size.width, - alignment: Alignment.center, - child: Text( - '谎报警情,依法追责', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: Screenutil.size(32), - color: Color(0xffe02020), - ), - ), - ), - Container( - margin: EdgeInsets.only(top: Screenutil.length(8)), - width: MediaQuery.of(context).size.width, - alignment: Alignment.center, - child: Text( - '谎报警情将可能被处以五日以上十日以下拘留', - style: TextStyle( - fontSize: Screenutil.size(24), - color: Color(0xff999999), - ), - ), - ), - ], - ), - Positioned( - top: -Screenutil.length(98), - width: MediaQuery.of(context).size.width, - child: Center( - child: Container( - padding: EdgeInsets.all(Screenutil.length(12)), - height: Screenutil.length(196), - width: Screenutil.length(196), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(Screenutil.length(196))), - ), - child: Container( - height: Screenutil.length(172), - width: Screenutil.length(172), - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.bottomLeft, - end: Alignment.topLeft, - colors: [Color(0xffef0909), Color(0xffff8880)], - ), - borderRadius: BorderRadius.all( - Radius.circular(Screenutil.length(172))), - boxShadow: [ - BoxShadow( - color: Color(0xfffd7770).withOpacity(0.33), - offset: Offset(0, Screenutil.length(10)), - blurRadius: Screenutil.length(20), - spreadRadius: Screenutil.length(4), - ) - ], - ), - child: Icon( - Feather.phone_call, - color: Colors.white, - size: Screenutil.size(87), - ), - ), - ), - ), - ), - ], - ), - ); - } - - Widget _button(String label, IconData icon, Color color) { - return Column( - children: [ - Container( - padding: const EdgeInsets.all(16.0), - child: Icon( - icon, - color: Colors.white, - ), - decoration: - BoxDecoration(color: color, shape: BoxShape.circle, boxShadow: [ - BoxShadow( - color: Color.fromRGBO(0, 0, 0, 0.15), - blurRadius: 8.0, - ) - ]), - ), - SizedBox( - height: 12.0, - ), - Text(label), - ], - ); - } - - Widget _body() { - return FlutterMap( - options: MapOptions( - center: LatLng(22.3817, 114.05), - zoom: 13, - maxZoom: 15, - ), - layers: [ - TileLayerOptions( - urlTemplate: "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}", - ), - MarkerLayerOptions(markers: [ - Marker( - point: LatLng(22.3817, 114.05), - builder: (ctx) => Icon( - Icons.location_on, - color: Colors.blue, - size: 48.0, - ), - height: 60), - ]), - ], - ); - } -} diff --git a/lib/pages/one_alarm/widget/alarm_page.dart b/lib/pages/one_alarm/widget/alarm_page.dart new file mode 100644 index 00000000..5e952913 --- /dev/null +++ b/lib/pages/one_alarm/widget/alarm_page.dart @@ -0,0 +1,268 @@ +import 'package:akuCommunity/utils/screenutil.dart'; +import 'package:akuCommunity/widget/common_app_bar.dart'; +import 'package:flutter/material.dart'; +import 'package:amap_map_fluttify/amap_map_fluttify.dart'; +import 'package:amap_location_fluttify/amap_location_fluttify.dart'; +import 'package:flutter_icons/flutter_icons.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class PermissionUtil { + static Future getLocationPermission() async { + return await Permission.locationWhenInUse.request().isGranted; + } +} + +class AlarmPage extends StatefulWidget { + AlarmPage({Key key, bundle}) : super(key: key); + + @override + _AlarmPageState createState() => _AlarmPageState(); +} + +class _AlarmPageState extends State { + final _option = MyLocationOption( + show: true, + myLocationType: MyLocationType.Locate, + ); + Future _makephonenum(String url)async{ + (await canLaunch(url))?await launch(url):throw 'Could not launch $url'; + } + + AmapController _amapController; + Location _location; + @override + void initState() { + super.initState(); + AmapLocation.instance.fetchLocation().then((location) { + _location = location; + setState(() {}); + }); + PermissionUtil.getLocationPermission(); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: PreferredSize( + child: CommonAppBar( + title: '一键报警', + subtitle: '功能说明', + ), + preferredSize: Size.fromHeight(kToolbarHeight), + ), + body: Stack( + alignment: Alignment.topCenter, + children: [ + AmapView( + onMapCreated: (controller) async { + _amapController = controller; + await _amapController.showMyLocation(_option); + }, + mapType: MapType.Standard, + showZoomControl: false, + zoomLevel: 16, + ), + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.only(top: Screenutil.length(32)), + width: 686.w, + height: Screenutil.length(148), + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.9), + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Color(0xE8FFFFFF).withOpacity(0.10), + offset: Offset(0, 2)), + ]), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: Screenutil.length(24)), + Container( + margin: EdgeInsets.only( + top: Screenutil.length(24), + left: Screenutil.length(32)), + child: Text( + '当前位置(仅供参考)', + style: TextStyle( + fontWeight: FontWeight.w600, + color: Color(0xff333333), + fontSize: Screenutil.size(28)), + ), + ), + Container( + margin: EdgeInsets.only( + top: Screenutil.length(20), + left: Screenutil.length(32)), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon( + Entypo.location_pin, + color: Color(0xff666666), + size: Screenutil.size(29), + ), + Container( + margin: + EdgeInsets.only(left: Screenutil.length(5)), + child: Text( + (_location == null) + ? '加载中……' + : _location.aoiName, + style: TextStyle( + color: Color(0xff666666), + fontSize: Screenutil.size(28), + ), + ), + ), + ], + ), + ), + ], + )), + Spacer(), + Row( + children: [ + Spacer(), + Container( + alignment: Alignment.center, + width: Screenutil.length(66), + height: Screenutil.length(66), + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(Screenutil.length(66)), + boxShadow: [ + BoxShadow( + color: Color(0x1F000000), + offset: Offset(3, 4), + blurRadius: 6, + spreadRadius: 1, + ) + ]), + child: FlatButton( + padding: EdgeInsets.zero, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(Screenutil.length(66))), + color: Color(0xFFFFFFFF), + onPressed: () { + _amapController?.setCenterCoordinate( + _location.latLng); + Future.delayed(Duration(milliseconds: 500), () { + if (mounted) _amapController.setZoomLevel(16); + }); + }, + child: Icon( + Icons.location_searching, + size: Screenutil.length(44), + ), + ), + ), + SizedBox(width: Screenutil.length(34)), + ], + ), + SizedBox( + height: Screenutil.length(29), + ), + Container( + width: double.infinity, + height: Screenutil.length(271), + alignment: Alignment.center, + decoration: + BoxDecoration(color: Color(0xFFFFFFFF).withOpacity(0.9)), + child: Stack( + overflow: Overflow.visible, + alignment: Alignment.topCenter, + children: [ + Positioned( + bottom: Screenutil.length(173), + child: Container( + padding: EdgeInsets.all(Screenutil.length(12)), + height: Screenutil.length(196), + width: Screenutil.length(196), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(Screenutil.length(196))), + ), + child: Container( + height: Screenutil.length(172), + width: Screenutil.length(172), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.bottomLeft, + end: Alignment.topLeft, + colors: [Color(0xffef0909), Color(0xffff8880)], + ), + borderRadius: BorderRadius.all( + Radius.circular(Screenutil.length(172))), + boxShadow: [ + BoxShadow( + color: Color(0xfffd7770).withOpacity(0.33), + offset: Offset(0, Screenutil.length(10)), + blurRadius: Screenutil.length(20), + spreadRadius: Screenutil.length(4), + ) + ], + ), + child: FlatButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Screenutil.length(172))), + onPressed: () { + setState(() { + _makephonenum('tel:110'); + }); + }, + child: Icon( + Feather.phone_call, + color: Colors.white, + size: Screenutil.size(87), + ), + ), + ), + ), + ), + Column( + children: [ + SizedBox(height: Screenutil.length(146)), + Text( + '谎报警情,依法追责', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: Screenutil.size(32), + color: Color(0xffe02020), + ), + ), + Spacer(), + Text( + '谎报警情将可能被处以五日以上十日以下拘留', + style: TextStyle( + fontSize: Screenutil.size(24), + color: Color(0xff999999), + ), + ), + SizedBox(height: 19.5), + ], + ), + ], + ), + ), + ], + ) + ], + ), + ); + } +} diff --git a/lib/pages/one_alarm/widget/explain_template.dart b/lib/pages/one_alarm/widget/explain_template.dart index 9a23e2de..5857023f 100644 --- a/lib/pages/one_alarm/widget/explain_template.dart +++ b/lib/pages/one_alarm/widget/explain_template.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_beautiful_popup/main.dart'; import 'package:akuCommunity/utils/screenutil.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; class ExplainTemplate extends BeautifulPopupTemplate { @@ -14,7 +15,7 @@ class ExplainTemplate extends BeautifulPopupTemplate { @override Color get primaryColor => options.primaryColor ?? Color(0xff15c0ec); @override - final maxWidth = Screenutil.length(400); + final maxWidth = 400.w; @override final maxHeight = Screenutil.length(617); @override diff --git a/lib/pages/sign/sign_in_page.dart b/lib/pages/sign/sign_in_page.dart index 87db652d..8bf1b139 100644 --- a/lib/pages/sign/sign_in_page.dart +++ b/lib/pages/sign/sign_in_page.dart @@ -176,7 +176,7 @@ class _SignInPageState extends State { @override Widget build(BuildContext context) { double _statusHeight = MediaQuery.of(context).padding.top; - ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true); + ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); return Scaffold( backgroundColor: Colors.white, appBar: _appBar(), diff --git a/lib/pages/tab_navigator.dart b/lib/pages/tab_navigator.dart index 6129dc95..51d1fc97 100644 --- a/lib/pages/tab_navigator.dart +++ b/lib/pages/tab_navigator.dart @@ -35,7 +35,7 @@ class _TabNavigatorState extends State { @override Widget build(BuildContext context) { - ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true); + ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); double iconSize = ScreenUtil().setWidth(44); //底部导航来 List _bottomNav = [ diff --git a/lib/pages/total_application_page/total_applications_page.dart b/lib/pages/total_application_page/total_applications_page.dart index 8a992f5a..b912210b 100644 --- a/lib/pages/total_application_page/total_applications_page.dart +++ b/lib/pages/total_application_page/total_applications_page.dart @@ -1,3 +1,5 @@ +import 'package:akuCommunity/pages/one_alarm/widget/alarm_page.dart'; +import 'package:ani_route/ani_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:akuCommunity/utils/screenutil.dart'; @@ -195,8 +197,7 @@ class _TotalApplicationsPageState extends State { context, PageName.goods_manage_page.toString()); break; case '一键报警': - Navigator.pushNamed( - context, PageName.one_alarm_page.toString()); + ARoute.push(context, AlarmPage()); break; default: break; diff --git a/lib/routers/page_routers.dart b/lib/routers/page_routers.dart index 345dcdfd..b36df771 100644 --- a/lib/routers/page_routers.dart +++ b/lib/routers/page_routers.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/pages/one_alarm/widget/alarm_page.dart'; import 'package:akuCommunity/pages/setting_page/agreement_page/privacy_page.dart'; import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; @@ -168,6 +169,7 @@ enum PageName { things_evaluate_page, agreement_page, privacy_page, + alarm_page, } class Bundle { @@ -368,4 +370,6 @@ final Map pageRoutes = { PageBuilder(builder: (bundle) => ThingsCreatePage(bundle: bundle)), PageName.things_evaluate_page: PageBuilder(builder: (bundle) => ThingsEvaluatePage(bundle: bundle)), + PageName.alarm_page: + PageBuilder(builder: (bundle)=>AlarmPage(bundle:bundle),) }; diff --git a/pubspec.lock b/pubspec.lock index 7ee23107..c9d7f0d9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -8,6 +8,34 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "7.0.0" + amap_core_fluttify: + dependency: transitive + description: + name: amap_core_fluttify + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.12.0" + amap_location_fluttify: + dependency: "direct main" + description: + name: amap_location_fluttify + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.18.0" + amap_map_fluttify: + dependency: "direct main" + description: + name: amap_map_fluttify + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.29.0" + amap_search_fluttify: + dependency: transitive + description: + name: amap_search_fluttify + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.14.0" analyzer: dependency: transitive description: @@ -162,6 +190,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.1" + core_location_fluttify: + dependency: transitive + description: + name: core_location_fluttify + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.4.1" crypto: dependency: transitive description: @@ -432,7 +467,7 @@ packages: name: flutter_screenutil url: "https://pub.flutter-io.cn" source: hosted - version: "2.3.1" + version: "3.2.0" flutter_slidable: dependency: "direct main" description: @@ -485,6 +520,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "8.8.1" + foundation_fluttify: + dependency: transitive + description: + name: foundation_fluttify + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.9.10+1" glob: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0583f4f5..80a1423f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,7 +47,7 @@ dependencies: flutter_redux: ^0.5.3 provider: ^4.1.3 # 屏幕适配 - flutter_screenutil: ^2.3.1 + flutter_screenutil: ^3.2.0 cupertino_icons: ^0.1.3 # 打电话等各种功能 url_launcher: 5.5.2 @@ -112,6 +112,9 @@ dependencies: flutter_picker: ^1.1.5 #加载动画 loading_animations: ^2.1.0 + #高德地图 + amap_map_fluttify: + amap_location_fluttify: #用户存储路径 path_provider: ^1.6.18