master
王亚玲 3 years ago
commit d64edc3fa7

@ -1,5 +1,3 @@
import 'dart:async'; import 'dart:async';
@ -7,9 +5,9 @@ import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/ui/home/content_connect_page.dart'; import 'package:project_telephony/ui/home/content_connect_page.dart';
import 'package:project_telephony/ui/home/content_refuse_page.dart'; import 'package:project_telephony/ui/home/content_refuse_page.dart';
import 'package:project_telephony/ui/user/privacy_rights_page.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key); const HomePage({Key? key}) : super(key: key);
@ -21,7 +19,6 @@ bool sms=false;
bool plone = false; bool plone = false;
@override @override
class _HomePageState extends State<HomePage> with WidgetsBindingObserver { class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
@override @override
void initState() { void initState() {
@ -31,17 +28,21 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver{
_listenForPermissionStatus(); _listenForPermissionStatus();
setState(() {}); setState(() {});
} }
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
// //
WidgetsBinding.instance.removeObserver(this); WidgetsBinding.instance.removeObserver(this);
} }
Future<void> _listenForPermissionStatus() async { Future<void> _listenForPermissionStatus() async {
sms = await Permission.sms.request().isGranted; sms = await Permission.sms.request().isGranted;
plone = await Permission.phone.request().isGranted; plone = await Permission.phone.request().isGranted;
callLog = await Permission.callLog.request().isGranted;
setState(() {}); setState(() {});
} }
@override @override
void didChangeAppLifecycleState(AppLifecycleState state) { void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state); super.didChangeAppLifecycleState(state);
@ -63,6 +64,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver{
break; break;
} }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -89,7 +91,12 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver{
), ),
Positioned(top: 48.w, child: _warning()), Positioned(top: 48.w, child: _warning()),
Positioned(bottom: 64.w, child: _getBody()), Positioned(bottom: 64.w, child: _getBody()),
Align(child: SizedBox(width: double.infinity,height: 1600.w,),) Align(
child: SizedBox(
width: double.infinity,
height: 1600.w,
),
)
], ],
), ),
)); ));
@ -103,8 +110,9 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver{
// } // }
// } // }
_warning() { _warning() {
return Offstage(offstage: (sms && plone) ,child: return Offstage(
GestureDetector( offstage: (sms && plone && callLog),
child: GestureDetector(
onTap: () { onTap: () {
// print(); // print();
openAppSettings(); openAppSettings();
@ -116,18 +124,34 @@ _warning() {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w), borderRadius: BorderRadius.circular(8.w),
color: const Color(0xFFFFF2F2), color: const Color(0xFFFFF2F2),
border: Border.all(width: 1.w,color: const Color(0xFFFFC8C8)) border: Border.all(width: 1.w, color: const Color(0xFFFFC8C8))),
child: Row(
children: [
Image(
image: AssetImage(Assets.icons.horn.path),
width: 48.w,
height: 48.w,
), ),
child: Row(children: [
Image(image: AssetImage(Assets.icons.horn.path),width: 48.w,height: 48.w
,),
16.wb, 16.wb,
Text("必须权限没有授予本APP无法正常使用",style: TextStyle(color: const Color(0xFFFF3F3F),fontSize:24.sp ),) Text(
,32.wb, "必须权限没有授予本APP无法正常使用",
Image(image: AssetImage(Assets.icons.right.path),width:28.w ,height: 28.w,fit:BoxFit.fill,) style:
],), TextStyle(color: const Color(0xFFFF3F3F), fontSize: 24.sp),
),),); ),
32.wb,
Image(
image: AssetImage(Assets.icons.right.path),
width: 28.w,
height: 28.w,
fit: BoxFit.fill,
)
],
),
),
),
);
} }
_getBody() { _getBody() {
return Container( return Container(
padding: EdgeInsets.symmetric(horizontal: 64.w), padding: EdgeInsets.symmetric(horizontal: 64.w),
@ -162,7 +186,6 @@ _getBody() {
onTap: () { onTap: () {
print(title); print(title);
if (title == "接听后") { if (title == "接听后") {
Get.to(() => const ContentConnectPage()); Get.to(() => const ContentConnectPage());
} else { } else {
Get.to(() => const ContentRefusePage()); Get.to(() => const ContentRefusePage());
@ -178,15 +201,13 @@ _getBody() {
colors: [cl1, cl2])), colors: [cl1, cl2])),
width: 622.w, width: 622.w,
height: 192.w, height: 192.w,
child: Row(children: [ child: Row(
children: [
Container( Container(
padding: EdgeInsets.only(top: 40.w,left: 50.w padding: EdgeInsets.only(top: 40.w, left: 50.w),
), child: Column(
child:
Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(title, Text(title,
style: TextStyle( style: TextStyle(
fontSize: 36.sp, fontSize: 36.sp,
@ -200,14 +221,19 @@ _getBody() {
color: const Color(0xFFFFFFFF).withOpacity(0.6)), color: const Color(0xFFFFFFFF).withOpacity(0.6)),
), ),
], ],
),), ),
),
const Spacer(), const Spacer(),
Padding(padding: EdgeInsets.only(top: 40.w),child: Image.asset( Padding(
padding: EdgeInsets.only(top: 40.w),
child: Image.asset(
image, image,
width: 166.w, width: 166.w,
height: 152.w, height: 152.w,
fit: BoxFit.fill, fit: BoxFit.fill,
),) ),
,],))); ),
],
)));
} }
} }

@ -6,7 +6,6 @@ import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class PrivacyRightsPage extends StatefulWidget { class PrivacyRightsPage extends StatefulWidget {
final String name; final String name;
@ -15,6 +14,7 @@ class PrivacyRightsPage extends StatefulWidget {
@override @override
_PrivacyRightsPageState createState() => _PrivacyRightsPageState(); _PrivacyRightsPageState createState() => _PrivacyRightsPageState();
} }
final Uri _url = Uri.parse('https://www.dxbs.vip//explain.html'); final Uri _url = Uri.parse('https://www.dxbs.vip//explain.html');
// final Telephony telephony = Telephony.instance; // final Telephony telephony = Telephony.instance;
// late final bool permissionsGranted; // late final bool permissionsGranted;
@ -25,10 +25,9 @@ final Uri _url = Uri.parse('https://www.dxbs.vip//explain.html');
// } // }
bool sms = false; bool sms = false;
bool plone = false; bool plone = false;
bool callLog = false;
@override @override
class _PrivacyRightsPageState extends State<PrivacyRightsPage> { class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
@override @override
void initState() { void initState() {
@ -37,11 +36,14 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
await _listenForPermissionStatus(); await _listenForPermissionStatus();
}); });
} }
Future<void> _listenForPermissionStatus() async { Future<void> _listenForPermissionStatus() async {
sms = await Permission.sms.request().isGranted; sms = await Permission.sms.request().isGranted;
plone = await Permission.phone.request().isGranted; plone = await Permission.phone.request().isGranted;
callLog = await Permission.callLog.request().isGranted;
setState(() {}); setState(() {});
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -58,15 +60,13 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
leading: const CloudBackButton(isSpecial: true), leading: const CloudBackButton(isSpecial: true),
backgroundColor: kForeGroundColor), backgroundColor: kForeGroundColor),
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: Column(children: [ body: Column(
children: [
_getRights("获取设备来电状态", "用于获取来电状态", plone), _getRights("获取设备来电状态", "用于获取来电状态", plone),
_getRights("获取设备短信权限", "用于发送短信", sms), _getRights("获取设备短信权限", "用于发送短信", sms),
_getRights("获取设备短信权限","用于发送短信",sms), _getRights("获取设备通话记录", "用于获取来电", callLog),
],
],) ),
,
bottomNavigationBar: GestureDetector( bottomNavigationBar: GestureDetector(
onTap: () async { onTap: () async {
await _launchUrl(); await _launchUrl();
@ -76,14 +76,21 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
// onTap: () async{ // onTap: () async{
// //
// }, // },
child: child: Container(
Container(margin: margin: EdgeInsets.symmetric(horizontal: 64.w, vertical: 24.w),
EdgeInsets.symmetric(horizontal: 64.w,vertical: 24.w),
padding: EdgeInsets.symmetric(horizontal: 214.w, vertical: 26.w), padding: EdgeInsets.symmetric(horizontal: 214.w, vertical: 26.w),
decoration: BoxDecoration(color:const Color(0xFFF9F9F9),borderRadius: BorderRadius.circular(8.w) ), decoration: BoxDecoration(
child: Text("查看使用说明",style: TextStyle(color: const Color(0xFF1890FF),fontSize: 28.sp),),),), color: const Color(0xFFF9F9F9),
borderRadius: BorderRadius.circular(8.w)),
child: Text(
"查看使用说明",
style: TextStyle(color: const Color(0xFF1890FF), fontSize: 28.sp),
),
),
),
); );
} }
// Color getPermissionColor() { // Color getPermissionColor() {
// if(true){ // if(true){
// return Colors.red; // return Colors.red;
@ -104,6 +111,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
throw 'Could not launch $_url'; throw 'Could not launch $_url';
} }
} }
_getRights(String name, String text, bool state) { _getRights(String name, String text, bool state) {
return ListTile( return ListTile(
onTap: () async { onTap: () async {
@ -142,9 +150,6 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
const Icon(Icons.arrow_forward_ios), const Icon(Icons.arrow_forward_ios),
], ],
), ),
); );
} }
} }

@ -782,16 +782,20 @@ packages:
permission_handler: permission_handler:
dependency: "direct main" dependency: "direct main"
description: description:
name: permission_handler path: "."
url: "https://pub.dartlang.org" ref: HEAD
source: hosted resolved-ref: bd29aebfbeba4072d78468d3f623017459cc9566
url: "https://git.oa00.com/austin_dai/permission_handler.git"
source: git
version: "10.0.0" version: "10.0.0"
permission_handler_android: permission_handler_android:
dependency: transitive dependency: transitive
description: description:
name: permission_handler_android path: "."
url: "https://pub.dartlang.org" ref: HEAD
source: hosted resolved-ref: b9cfe590e6f2ca13990c696802e285d747ac7067
url: "https://git.oa00.com/austin_dai/permission_handler_android.git"
source: git
version: "10.0.0" version: "10.0.0"
permission_handler_apple: permission_handler_apple:
dependency: transitive dependency: transitive

@ -40,7 +40,9 @@ dependencies:
# 获取通话记录 # 获取通话记录
call_log: ^4.0.0 call_log: ^4.0.0
permission_handler: ^10.0.0 permission_handler:
git:
url: https://git.oa00.com/austin_dai/permission_handler.git
# 后台设置 # 后台设置
flutter_background_service: ^2.1.3 flutter_background_service: ^2.1.3
flutter_background_service_android: ^2.0.3 flutter_background_service_android: ^2.0.3

Loading…
Cancel
Save