master
王亚玲 2 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);
@ -17,12 +15,11 @@ class HomePage extends StatefulWidget {
_HomePageState createState() => _HomePageState(); _HomePageState createState() => _HomePageState();
} }
bool sms=false; 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() {
super.initState(); super.initState();
@ -31,23 +28,27 @@ 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);
switch (state){ switch (state) {
// //
// UI // UI
case AppLifecycleState.inactive: case AppLifecycleState.inactive:
print("应用处于闲置状态,这种状态的应用应该假设他们可能在任何时候暂停 切换到后台会触发======"); print("应用处于闲置状态,这种状态的应用应该假设他们可能在任何时候暂停 切换到后台会触发======");
break; break;
@ -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(
@ -76,20 +78,25 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver{
Positioned( Positioned(
top: 10.w, top: 10.w,
child: child:
// Container( // Container(
// height: 722.w, // height: 722.w,
// width: 722.w, // width: 722.w,
// decoration: BoxDecoration(image: DecorationImage(image:AssetImage(Assets.images.homeBg.path),fit:BoxFit.fill)), // decoration: BoxDecoration(image: DecorationImage(image:AssetImage(Assets.images.homeBg.path),fit:BoxFit.fill)),
// child: _warning(),) // child: _warning(),)
Image.asset( Image.asset(
Assets.images.homeBg.path, Assets.images.homeBg.path,
height: 722.w, height: 722.w,
width: 722.w, width: 722.w,
), ),
), ),
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,
),
)
], ],
), ),
)); ));
@ -102,33 +109,50 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver{
// return false; // return false;
// } // }
// } // }
_warning() { _warning() {
return Offstage(offstage: (sms && plone) ,child: return Offstage(
GestureDetector( offstage: (sms && plone && callLog),
onTap: (){ child: GestureDetector(
// print(); onTap: () {
openAppSettings(); // print();
}, openAppSettings();
child: Container( },
margin: EdgeInsets.symmetric(horizontal: 64.w), child: Container(
padding: EdgeInsets.symmetric(horizontal: 32.w,vertical: 20.w), margin: EdgeInsets.symmetric(horizontal: 64.w),
height: 88.w, padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w),
decoration: BoxDecoration( height: 88.w,
borderRadius:BorderRadius.circular(8.w), decoration: BoxDecoration(
color: const Color(0xFFFFF2F2), borderRadius: BorderRadius.circular(8.w),
border: Border.all(width: 1.w,color: const Color(0xFFFFC8C8)) color: const Color(0xFFFFF2F2),
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,
),
16.wb,
Text(
"必须权限没有授予本APP无法正常使用",
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,
)
],
),
),
), ),
child: Row(children: [ );
Image(image: AssetImage(Assets.icons.horn.path),width: 48.w,height: 48.w }
,),
16.wb, _getBody() {
Text("必须权限没有授予本APP无法正常使用",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() {
return Container( return Container(
padding: EdgeInsets.symmetric(horizontal: 64.w), padding: EdgeInsets.symmetric(horizontal: 64.w),
child: Column( child: Column(
@ -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());
@ -170,44 +193,47 @@ _getBody() {
} }
}, },
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.w), borderRadius: BorderRadius.circular(16.w),
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.centerLeft, begin: Alignment.centerLeft,
end: Alignment.centerRight, end: Alignment.centerRight,
colors: [cl1, cl2])), colors: [cl1, cl2])),
width: 622.w, width: 622.w,
height: 192.w, height: 192.w,
child: Row(children: [ child: Row(
Container(
padding: EdgeInsets.only(top: 40.w,left: 50.w
),
child:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Container(
Text(title, padding: EdgeInsets.only(top: 40.w, left: 50.w),
style: TextStyle( child: Column(
fontSize: 36.sp, crossAxisAlignment: CrossAxisAlignment.start,
color: const Color(0xFFFFFFFF), children: [
fontWeight: FontWeight.bold)), Text(title,
16.hb, style: TextStyle(
Text( fontSize: 36.sp,
text, color: const Color(0xFFFFFFFF),
style: TextStyle( fontWeight: FontWeight.bold)),
fontSize: 27.sp, 16.hb,
color: const Color(0xFFFFFFFF).withOpacity(0.6)), Text(
text,
style: TextStyle(
fontSize: 27.sp,
color: const Color(0xFFFFFFFF).withOpacity(0.6)),
),
],
),
),
const Spacer(),
Padding(
padding: EdgeInsets.only(top: 40.w),
child: Image.asset(
image,
width: 166.w,
height: 152.w,
fit: BoxFit.fill,
),
), ),
], ],
),), )));
const Spacer(),
Padding(padding: EdgeInsets.only(top: 40.w),child: Image.asset(
image,
width: 166.w,
height: 152.w,
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;
@ -23,25 +23,27 @@ final Uri _url = Uri.parse('https://www.dxbs.vip//explain.html');
// void initState() async { // void initState() async {
// initPlatformState(); // initPlatformState();
// } // }
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() {
super.initState(); super.initState();
Future.delayed(const Duration(seconds: 0),() async{ Future.delayed(const Duration(seconds: 0), () async {
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,32 +60,37 @@ 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(
_getRights("获取设备来电状态","用于获取来电状态",plone), children: [
_getRights("获取设备短信权限","用于发送短信",sms), _getRights("获取设备来电状态", "用于获取来电状态", plone),
_getRights("获取设备短信权限","用于发送短信",sms), _getRights("获取设备短信权限", "用于发送短信", sms),
_getRights("获取设备通话记录", "用于获取来电", callLog),
],) ],
),
,
bottomNavigationBar: GestureDetector( bottomNavigationBar: GestureDetector(
onTap:()async{ onTap: () async {
await _launchUrl(); await _launchUrl();
// await launchUrlString("tel:13111111111"); // await launchUrlString("tel:13111111111");
} , },
// 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(
decoration: BoxDecoration(color:const Color(0xFFF9F9F9),borderRadius: BorderRadius.circular(8.w) ), color: const Color(0xFFF9F9F9),
child: Text("查看使用说明",style: TextStyle(color: const Color(0xFF1890FF),fontSize: 28.sp),),),), 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,10 +111,11 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
throw 'Could not launch $_url'; throw 'Could not launch $_url';
} }
} }
_getRights( String name,String text,bool state){
return ListTile( _getRights(String name, String text, bool state) {
onTap: ()async{ return ListTile(
if(!state){ onTap: () async {
if (!state) {
openAppSettings(); openAppSettings();
} }
// if(!(sms && plone)){ // if(!(sms && plone)){
@ -132,19 +140,16 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
name, name,
style: Theme.of(context).textTheme.titleMedium, style: Theme.of(context).textTheme.titleMedium,
), ),
subtitle: Text( subtitle: Text(
text, text,
), ),
trailing: Wrap( trailing: Wrap(
children: [ children: [
Text(state ?"已允许":"未允许", Text(state ? "已允许" : "未允许",
style: TextStyle(color: state ?Colors.green:Colors.red)), style: TextStyle(color: state ? Colors.green : Colors.red)),
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