You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
project_telephony/lib/ui/user/privacy_rights_page.dart

119 lines
3.0 KiB

2 years ago
import 'package:flutter/material.dart';
2 years ago
import 'package:permission_handler/permission_handler.dart';
2 years ago
2 years ago
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';
2 years ago
2 years ago
class PrivacyRightsPage extends StatefulWidget {
final String name;
2 years ago
2 years ago
const PrivacyRightsPage({Key? key, required this.name}) : super(key: key);
@override
_PrivacyRightsPageState createState() => _PrivacyRightsPageState();
}
2 years ago
// final Telephony telephony = Telephony.instance;
2 years ago
// late final bool permissionsGranted;
// String body = "";
// @override
2 years ago
// void initState() async {
// initPlatformState();
2 years ago
// }
2 years ago
bool sms=false;
bool plone=false;
2 years ago
2 years ago
@override
class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
2 years ago
@override
void initState() {
super.initState();
2 years ago
Future.delayed(const Duration(seconds: 0),() async{
await _listenForPermissionStatus();
});
2 years ago
}
2 years ago
Future<void> _listenForPermissionStatus() async {
sms=await Permission.sms.request().isGranted;
plone =await Permission.phone.request().isGranted;
2 years ago
setState(() {});
2 years ago
}
2 years ago
@override
Widget build(BuildContext context) {
return Scaffold(
2 years ago
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: _getRights(),
2 years ago
);
2 years ago
}
2 years ago
// Color getPermissionColor() {
// if(true){
// return Colors.red;
// }else{
// return Colors.green;
2 years ago
// }
// }
2 years ago
2 years ago
// String getPermissionStu() {
// if (false) {
// return "未允许";
// } else {
// return "已允许";
// }
// }
_getRights(){
return ListTile(
onTap: ()async{
2 years ago
if(!(sms && plone)){
2 years ago
// print(sms);
// print(plone);
2 years ago
openAppSettings();
}else{
2 years ago
// print("123123123123");
2 years ago
}
2 years ago
// await Permission.phone.request();
// await Permission.sms.request();
// Map<Permission, PermissionStatus> statuses = await [
// Permission.sms,
// Permission.phone,
// ].request();
//
// openAppSettings();
2 years ago
// print(await Permission.phone.request().isGranted);
// print(await Permission.sms.request().isGranted);
2 years ago
},
2 years ago
title: Text(
2 years ago
'获取设备来电',
2 years ago
style: Theme.of(context).textTheme.titleMedium,
2 years ago
),
2 years ago
subtitle: const Text(
"获取设备",
2 years ago
),
trailing: Wrap(
children: [
2 years ago
Text(sms & plone ?"已允许":"未允许",
style: TextStyle(color: sms & plone ?Colors.green:Colors.red)),
2 years ago
const Icon(Icons.arrow_forward_ios),
],
),
2 years ago
);
}
2 years ago
2 years ago
}