|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
|
|
|
import 'package:project_telephony/base/base_style.dart';
|
|
|
|
|
|
|
|
import 'package:project_telephony/ui/widget/plone_back_button.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
|
|
|
class PrivacyRightsPage extends StatefulWidget {
|
|
|
|
final String name;
|
|
|
|
|
|
|
|
const PrivacyRightsPage({Key? key, required this.name}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_PrivacyRightsPageState createState() => _PrivacyRightsPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
final Uri _url = Uri.parse('https://www.dxbs.vip//explain.html');
|
|
|
|
// final Telephony telephony = Telephony.instance;
|
|
|
|
// late final bool permissionsGranted;
|
|
|
|
// String body = "";
|
|
|
|
// @override
|
|
|
|
// void initState() async {
|
|
|
|
// initPlatformState();
|
|
|
|
// }
|
|
|
|
bool sms = false;
|
|
|
|
bool plone = false;
|
|
|
|
bool callLog = false;
|
|
|
|
bool contacts = false;
|
|
|
|
|
|
|
|
@override
|
|
|
|
class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
Future.delayed(const Duration(seconds: 0), () async {
|
|
|
|
await _listenForPermissionStatus();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _listenForPermissionStatus() async {
|
|
|
|
sms = await Permission.sms.request().isGranted;
|
|
|
|
plone = await Permission.phone.request().isGranted;
|
|
|
|
callLog = await Permission.callLog.request().isGranted;
|
|
|
|
contacts = await Permission.contacts.request().isGranted;
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
elevation: 0,
|
|
|
|
title: Text(
|
|
|
|
widget.name,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: BaseStyle.fontSize34,
|
|
|
|
color: BaseStyle.color333333,
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
titleSpacing: 162.w,
|
|
|
|
leading: const CloudBackButton(isSpecial: true),
|
|
|
|
backgroundColor: kForeGroundColor),
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
_getRights("获取设备来电状态", "用于获取来电状态", plone),
|
|
|
|
_getRights("获取设备短信权限", "用于发送短信", sms),
|
|
|
|
_getRights("获取设备通话记录", "用于获取来电", callLog),
|
|
|
|
_getRights("获取设备通讯录", "用于插入排除手机号", contacts),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
bottomNavigationBar: GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
await _launchUrl();
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 64.w, vertical: 24.w),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 214.w, vertical: 26.w),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: const Color(0xFFF9F9F9),
|
|
|
|
borderRadius: BorderRadius.circular(8.w)),
|
|
|
|
child: Text(
|
|
|
|
"查看使用说明",
|
|
|
|
style: TextStyle(color: const Color(0xFF1890FF), fontSize: 28.sp),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _launchUrl() async {
|
|
|
|
if (!await launchUrl(_url)) {
|
|
|
|
throw 'Could not launch $_url';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_getRights(String name, String text, bool state) {
|
|
|
|
return ListTile(
|
|
|
|
onTap: () async {
|
|
|
|
if (!state) {
|
|
|
|
openAppSettings();
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
title: Text(
|
|
|
|
name,
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
text,
|
|
|
|
),
|
|
|
|
trailing: Wrap(
|
|
|
|
children: [
|
|
|
|
Text(state ? "已允许" : "未允许",
|
|
|
|
style: TextStyle(color: state ? Colors.green : Colors.red)),
|
|
|
|
const Icon(Icons.arrow_forward_ios),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|