diff --git a/android/app/build.gradle b/android/app/build.gradle index 9bf4780..f273b4d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -62,6 +62,12 @@ android { release { signingConfig signingConfigs.release } + debug { + signingConfig signingConfigs.release + } + profile{ + signingConfig signingConfigs.release + } } } diff --git a/assets/manage/dingwei.png b/assets/manage/dingwei.png new file mode 100644 index 0000000..06c84b8 Binary files /dev/null and b/assets/manage/dingwei.png differ diff --git a/assets/manage/location.png b/assets/manage/location.png new file mode 100644 index 0000000..e4750b7 Binary files /dev/null and b/assets/manage/location.png differ diff --git a/assets/manage/police.png b/assets/manage/police.png new file mode 100644 index 0000000..4db0991 Binary files /dev/null and b/assets/manage/police.png differ diff --git a/assets/manage/warning.png b/assets/manage/warning.png new file mode 100644 index 0000000..cd14f83 Binary files /dev/null and b/assets/manage/warning.png differ diff --git a/lib/main.dart b/lib/main.dart index ac472cf..a1bf4a7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,7 +13,9 @@ import 'package:get/get.dart'; import 'package:provider/provider.dart'; void main() async { + WidgetsFlutterBinding.ensureInitialized(); await AmapCore.init(''); + await AmapLocation.instance.init(iosKey: ''); runApp(MyApp()); } diff --git a/lib/tools/permission_tool.dart b/lib/tools/permission_tool.dart new file mode 100644 index 0000000..4657981 --- /dev/null +++ b/lib/tools/permission_tool.dart @@ -0,0 +1,7 @@ +import 'package:permission_handler/permission_handler.dart'; + +class PermissionTool { + static Future getLocationPermission() async { + return await Permission.locationWhenInUse.request().isGranted; + } +} diff --git a/lib/ui/home/application/applications_page.dart b/lib/ui/home/application/applications_page.dart index 1fc94c8..fa693ea 100644 --- a/lib/ui/home/application/applications_page.dart +++ b/lib/ui/home/application/applications_page.dart @@ -6,6 +6,7 @@ import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_and import 'package:aku_community_manager/ui/sub_pages/decoration_manager/decoration_manager_page.dart'; import 'package:aku_community_manager/ui/sub_pages/items_outdoor/items_outdoor_page.dart'; import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_page.dart'; +import 'package:aku_community_manager/ui/tool_pages/warning/warning_page.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -48,10 +49,10 @@ class _ApplicationPageState extends State '活动管理', R.ASSETS_HOME_IC_ACTIVITY_PNG, ActivityManagerPage()), AppApplication('访客管理', R.ASSETS_HOME_IC_VISITORS_PNG, VisitorManagerPage()), AppApplication('借还管理', R.ASSETS_HOME_IC_BORROW_PNG, BorrowManagerPage()), - AppApplication('一键报警', R.ASSETS_HOME_IC_POLICE_PNG, Scaffold()), + AppApplication('一键报警', R.ASSETS_HOME_IC_POLICE_PNG, WarningPage()), ]; List _wisdomApplications = [ - AppApplication('一键报警', R.ASSETS_HOME_IC_POLICE_PNG, Scaffold()), + AppApplication('一键报警', R.ASSETS_HOME_IC_POLICE_PNG, WarningPage()), AppApplication('访客管理', R.ASSETS_HOME_IC_VISITORS_PNG, VisitorManagerPage()), AppApplication('报事报修', R.ASSETS_HOME_IC_SERVICE_PNG, BusinessAndFixPage()), AppApplication('物品出户', R.ASSETS_HOME_IC_ARTICLE_PNG, ItemsOutdoorPage()), diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index a900a26..916c6c2 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -13,6 +13,7 @@ import 'package:aku_community_manager/ui/login/login_page.dart'; import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_page.dart'; import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_and_fix_page.dart'; import 'package:aku_community_manager/ui/tool_pages/scan_page.dart'; +import 'package:aku_community_manager/ui/tool_pages/warning/warning_page.dart'; import 'package:aku_ui/aku_ui.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:flutter/material.dart'; @@ -312,9 +313,12 @@ class _HomePageState extends State { mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ _menuButton( - R.ASSETS_HOME_IC_POLICE_PNG, '一键报警', HomePage()), - _menuButton(R.ASSETS_HOME_IC_VISITORS_PNG, '访客管理', - VisitorManagerPage()), + R.ASSETS_HOME_IC_POLICE_PNG, '一键报警', WarningPage()), + _menuButton( + R.ASSETS_HOME_IC_VISITORS_PNG, + '访客管理', + VisitorManagerPage(), + ), _menuButton( R.ASSETS_HOME_IC_SERVICE_PNG, '报事报修', diff --git a/lib/ui/tool_pages/warning/warning_detail_page.dart b/lib/ui/tool_pages/warning/warning_detail_page.dart new file mode 100644 index 0000000..1c48928 --- /dev/null +++ b/lib/ui/tool_pages/warning/warning_detail_page.dart @@ -0,0 +1,43 @@ +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:flutter/material.dart'; + +class WarningDetailPage extends StatefulWidget { + WarningDetailPage({Key key}) : super(key: key); + + @override + _WarningDetailPageState createState() => _WarningDetailPageState(); +} + +class _WarningDetailPageState extends State { + @override + Widget build(BuildContext context) { + return AkuScaffold( + appBarColor: Color(0xFFF9F9F9), + title: '功能说明', + body: ListView( + padding: EdgeInsets.all(32.w), + children: [ + Text( + '一键报警', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 32.w, + fontWeight: FontWeight.bold, + ), + ), + AkuBox.h(20), + Text( + '点击“呼叫110”后,您可以直接拨打本地110。页面中提供了您当前所在位置,以便您与警方沟通。(GPS信号弱时,位置可能存在偏移)', + style: TextStyle( + color: Color(0xFF666666), + fontSize: 28.w, + ), + ), + ], + ), + // body: , + ); + } +} diff --git a/lib/ui/tool_pages/warning/warning_page.dart b/lib/ui/tool_pages/warning/warning_page.dart new file mode 100644 index 0000000..ddc2158 --- /dev/null +++ b/lib/ui/tool_pages/warning/warning_page.dart @@ -0,0 +1,252 @@ +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/permission_tool.dart'; +import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/tool_pages/warning/warning_detail_page.dart'; +import 'package:aku_community_manager/ui/tool_pages/warning/warning_sub_page.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_ui/common_widgets/aku_cupertino_button.dart'; +import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:amap_map_fluttify/amap_map_fluttify.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class WarningPage extends StatefulWidget { + WarningPage({Key key}) : super(key: key); + + @override + _WarningPageState createState() => _WarningPageState(); +} + +class _WarningPageState extends State { + AmapController _amapController; + Location _location; + + @override + Widget build(BuildContext context) { + return AkuScaffold( + title: '一键报警', + actions: [ + AkuMaterialButton( + padding: EdgeInsets.symmetric(horizontal: 32.w), + onPressed: () { + Get.to(WarningDetailPage()); + }, + child: Text( + '功能说明', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + ), + ), + ), + ], + body: Stack( + children: [ + AmapView( + zoomLevel: 15, + showZoomControl: false, + showCompass: false, + showScaleControl: false, + onMapCreated: (controller) async { + _amapController = controller; + _getLocation(); + }, + ), + + ///首部地址栏 + Positioned( + top: 0, + left: 0, + right: 0, + child: Container( + margin: EdgeInsets.all(32.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16.w), + color: Color(0xE8FFFFFF), + boxShadow: [ + BoxShadow( + offset: Offset(0, 4.w), + blurRadius: 6.w, + spreadRadius: 4.w, + color: Color(0x1A5C5959), + ), + ], + ), + padding: EdgeInsets.symmetric( + horizontal: 32.w, + vertical: 24.w, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '当前位置(仅供参考)', + style: TextStyle( + fontWeight: FontWeight.bold, + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + ), + ), + AkuBox.h(20), + Row( + children: [ + Image.asset( + R.ASSETS_MANAGE_LOCATION_PNG, + height: 29.w, + width: 21.w, + ), + AkuBox.w(10), + Expanded( + child: Text( + _location?.address ?? '加载中', + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: AppStyle.minorTextColor, + fontSize: 28.sp, + ), + ), + ), + ], + ), + ], + ), + ), + ), + + ///底部 + Positioned( + bottom: 0, + left: 0, + right: 0, + height: 271.w, + child: Container( + color: Colors.white.withOpacity(0.9), + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + '谎报警情,依法追责', + style: TextStyle( + color: Color(0xFFE02020), + fontSize: 32.sp, + fontWeight: FontWeight.w900, + ), + ), + AkuBox.h(8), + Text( + '谎报警情将可能被处以五日以上十日以下拘留', + style: TextStyle( + color: AppStyle.minorTextColor, + fontSize: 24.sp, + ), + ), + AkuBox.h(40), + ], + ), + ), + ), + + ///底部按钮 + Positioned( + bottom: 173.w, + left: 0, + right: 0, + child: Center( + child: Container( + height: 196.w, + width: 196.w, + alignment: Alignment.center, + child: AkuCupertinoButton( + minWidth: 0, + onPressed: () { + Get.to(WarningSubPage()); + }, + child: Container( + height: 172.w, + width: 172.w, + alignment: Alignment.center, + child: Image.asset( + R.ASSETS_MANAGE_POLICE_PNG, + height: 86.w, + width: 86.w, + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular((172 / 2).w), + gradient: LinearGradient( + colors: [ + Color(0xFFFF8880), + Color(0xFFEF0909), + ], + begin: Alignment.topRight, + end: Alignment.bottomLeft, + ), + boxShadow: [ + BoxShadow( + color: Color(0x54FD7770), + offset: Offset(0, 10.w), + blurRadius: 20.w, + spreadRadius: 4.w, + ), + ], + ), + ), + ), + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.9), + borderRadius: BorderRadius.circular((196 / 2).w), + ), + ), + ), + ), + + ///定位按钮 + Positioned( + bottom: 300.w, + right: 34.w, + child: AkuCupertinoButton( + minWidth: 0, + onPressed: () { + _getLocation(); + }, + child: Container( + alignment: Alignment.center, + child: Image.asset( + R.ASSETS_MANAGE_DINGWEI_PNG, + height: 40.w, + width: 40.w, + ), + height: 66.w, + width: 66.w, + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + offset: Offset(3.w, 4.w), + blurRadius: 6.w, + spreadRadius: 1.w, + color: Color(0x1F000000), + ) + ], + borderRadius: BorderRadius.circular(33.w), + ), + ), + ), + ), + ], + ), + ); + } + + _getLocation() { + PermissionTool.getLocationPermission().then((state) { + if (state) { + AmapLocation.instance.fetchLocation().then((location) { + _amapController.setCenterCoordinate(location.latLng); + _location = location; + setState(() {}); + }); + } + }); + } +} diff --git a/lib/ui/tool_pages/warning/warning_sub_page.dart b/lib/ui/tool_pages/warning/warning_sub_page.dart new file mode 100644 index 0000000..b709885 --- /dev/null +++ b/lib/ui/tool_pages/warning/warning_sub_page.dart @@ -0,0 +1,99 @@ +import 'dart:async'; + +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/tool_pages/warning/warning_detail_page.dart'; +import 'package:aku_community_manager/ui/tool_pages/warning/warning_success.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_ui/common_widgets/aku_cupertino_button.dart'; +import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class WarningSubPage extends StatefulWidget { + WarningSubPage({Key key}) : super(key: key); + + @override + _WarningSubPageState createState() => _WarningSubPageState(); +} + +class _WarningSubPageState extends State { + Timer _timer; + Timer _countTimer; + int _count = 3; + @override + void dispose() { + _timer?.cancel(); + _countTimer?.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AkuScaffold( + title: '一键报警', + actions: [ + AkuMaterialButton( + onPressed: () { + Get.to(WarningDetailPage()); + }, + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: Text('功能说明'), + ) + ], + body: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Stack( + children: [ + GestureDetector( + onTapDown: (detail) { + BotToast.showText(text: _count.toString()); + _countTimer = Timer.periodic(Duration(seconds: 1), (timer) { + _count--; + BotToast.showText(text: _count.toString()); + }); + _timer = Timer(Duration(seconds: 3), () { + Get.off(WarningSuccess()); + }); + }, + onTapCancel: () { + _count = 3; + _timer?.cancel(); + }, + onTapUp: (detail) { + _count = 3; + _timer?.cancel(); + }, + child: Image.asset( + R.ASSETS_MANAGE_WARNING_PNG, + height: 420.w, + width: 420.w, + ), + ), + ], + ), + Text( + '深圳华悦茂峰', + style: TextStyle( + fontSize: 44.w, + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + ), + ), + AkuBox.h(8), + Text( + '请长按上方进行报警', + style: TextStyle( + fontSize: 30.w, + color: AppStyle.minorTextColor, + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/ui/tool_pages/warning/warning_success.dart b/lib/ui/tool_pages/warning/warning_success.dart new file mode 100644 index 0000000..8201563 --- /dev/null +++ b/lib/ui/tool_pages/warning/warning_success.dart @@ -0,0 +1,70 @@ +import 'dart:async'; + +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/tool_pages/warning/warning_detail_page.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class WarningSuccess extends StatefulWidget { + WarningSuccess({Key key}) : super(key: key); + + @override + _WarningSuccessState createState() => _WarningSuccessState(); +} + +class _WarningSuccessState extends State { + Timer _timer; + @override + void dispose() { + _timer?.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AkuScaffold( + title: '一键报警', + actions: [ + AkuMaterialButton( + onPressed: () { + Get.to(WarningDetailPage()); + }, + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: Text('功能说明'), + ) + ], + body: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Image.asset( + R.ASSETS_MANAGE_WARNING_PNG, + height: 420.w, + width: 420.w, + ), + Text( + '深圳华悦茂峰', + style: TextStyle( + fontSize: 44.w, + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + ), + ), + AkuBox.h(8), + Text( + '报警成功', + style: TextStyle( + fontSize: 30.w, + color: AppStyle.minorTextColor, + ), + ), + ], + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 43a5358..b68d509 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -296,6 +296,20 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.9.2" + permission_handler: + dependency: "direct main" + description: + name: permission_handler + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.0.1+1" + permission_handler_platform_interface: + dependency: transitive + description: + name: permission_handler_platform_interface + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.1" pin_input_text_field: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index d9fef7d..4065cfe 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -60,6 +60,8 @@ dependencies: amap_map_fluttify: ^0.29.0 + permission_handler: ^5.0.1+1 + aku_ui: git: url: http://test.akuhotel.com:8099/aku_fe/aku_ui.git