|
|
|
import 'dart:math';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:project_telephony/base/base_style.dart';
|
|
|
|
// import 'package:project_telephony/main.dart';
|
|
|
|
import 'package:project_telephony/ui/widget/plone_back_button.dart';
|
|
|
|
import 'package:project_telephony/ui/widget/plone_bottom.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
// import 'package:telephony/telephony.dart';
|
|
|
|
|
|
|
|
class PrivacyRightsPage extends StatefulWidget {
|
|
|
|
final String name;
|
|
|
|
const PrivacyRightsPage({Key? key, required this.name}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_PrivacyRightsPageState createState() => _PrivacyRightsPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
// final Telephony telephony = Telephony.instance;
|
|
|
|
// late final bool permissionsGranted;
|
|
|
|
// String body = "";
|
|
|
|
// @override
|
|
|
|
// initState() async {
|
|
|
|
|
|
|
|
// // initPlatformState();
|
|
|
|
// }
|
|
|
|
bool? pd;
|
|
|
|
|
|
|
|
class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
Future.delayed(const Duration(seconds: 2), () async {
|
|
|
|
await _refresh();
|
|
|
|
});
|
|
|
|
setState(() {});
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
_refresh() async {
|
|
|
|
var status = await Permission.camera.status;
|
|
|
|
pd = status.isDenied;
|
|
|
|
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: widget.name == "隐私政策"
|
|
|
|
? null
|
|
|
|
: Column(
|
|
|
|
children: [
|
|
|
|
_getRights(pd),
|
|
|
|
],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
// onMessage(SmsMessage message) async {
|
|
|
|
// setState(() {
|
|
|
|
// body = message.body ?? "error reading message body.";
|
|
|
|
// print(body);
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// onSendStatus(SendStatus status) {
|
|
|
|
// setState(() {
|
|
|
|
// body = status == SendStatus.SENT ? "sent" : "delivered";
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// Future<void> initPlatformState() async {
|
|
|
|
// final bool? result = await telephony.requestPhoneAndSmsPermissions;
|
|
|
|
// if (result != null && result) {
|
|
|
|
// telephony.listenIncomingSms(
|
|
|
|
// onNewMessage: onMessage,
|
|
|
|
// onBackgroundMessage: onBackgroundMessage,
|
|
|
|
// listenInBackground: true);
|
|
|
|
// }
|
|
|
|
// if (!mounted) return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
_getRights(bool pd) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {},
|
|
|
|
child: Container(
|
|
|
|
height: 144.w,
|
|
|
|
width: 750.w,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 64.w, vertical: 17.w),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'获取设备来电',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 32.sp,
|
|
|
|
color: BaseStyle.color333333,
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
16.hb,
|
|
|
|
Text('用于获取设备',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 28.sp, color: BaseStyle.color999999)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
269.wb,
|
|
|
|
Text(pd ? "未允许" : "已允许",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 24.sp,
|
|
|
|
color: pd
|
|
|
|
? const Color(0xFFFF4D4D)
|
|
|
|
: BaseStyle.color999999)),
|
|
|
|
SizedBox(
|
|
|
|
width: 48.w,
|
|
|
|
height: 48.w,
|
|
|
|
child: const Icon(
|
|
|
|
Icons.keyboard_arrow_right,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_getA() {
|
|
|
|
return PloneBottom(
|
|
|
|
onTap: () async {
|
|
|
|
var status = await Permission.camera.status;
|
|
|
|
if (status.isDenied) {
|
|
|
|
// openAppSettings();//返回后台
|
|
|
|
// print(status.isDenied);
|
|
|
|
// print("已允许");
|
|
|
|
} else {
|
|
|
|
print("未允许");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
// var status = await Permission.camera.status;
|
|
|
|
// if (status.isDenied) {
|
|
|
|
// return Text("已允许");
|
|
|
|
// } else {
|
|
|
|
// return Text("未允许");
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|