master
戴余标 2 years ago
parent 221820c0d8
commit f5d14e1060

@ -42,6 +42,8 @@
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<!-- Provide required visibility configuration for API level 30 and above -->
<queries>
<!-- If your app checks for SMS support -->

@ -1,4 +1,11 @@
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_utils/get_utils.dart';
import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart';
class ExcludeContactsPage extends StatefulWidget {
@ -9,13 +16,87 @@ class ExcludeContactsPage extends StatefulWidget {
}
class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
late List<Contact> contacts;
List<String> numbers = [];
List<bool> status = [];
var flag = true;
@override
void initState() {
super.initState();
_incrementCounter();
}
Future _incrementCounter() async {
contacts = await FlutterContacts.getContacts();
for (var element in contacts) {
final full = await FlutterContacts.getContact(element.id);
numbers.add(full!.phones.first.number);
status.add(false);
}
setState(() {});
}
@override
Widget build(BuildContext context) {
var profileBuilder = FutureBuilder(
future: _incrementCounter(),
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting && flag) {
flag = false;
return Container();
} else {
return ListView.builder(
itemCount: contacts.length,
itemBuilder: (context, i) => ListTile(
title: Text(
contacts[i].displayName,
style: TextStyle(
fontSize: 32.sp,
fontWeight: FontWeight.w600,
),
),
subtitle: Text(
numbers[i],
style: TextStyle(
fontSize: 28.sp,
fontWeight: FontWeight.w300,
),
),
trailing: Checkbox(
value: status[i],
//
onChanged: (value) {
setState(() {
status[i] = !status[i];
});
},
//
activeColor: Colors.blue,
//
checkColor: Colors.white,
),
).paddingOnly(left: 20.w),
);
}
},
);
return ScaffoldThemeWidget(
title: "从通讯录添加",
bottom: "添加",
onTap: () { },
child: Container(),
onTap: () {
if(status.contains(true)){
// BotToast.showText(text: "");
Get.back();
}else{
BotToast.showText(text: "还未选中手机号");
}
},
isOpacity: status.contains(true),
isBorder: true,
child: profileBuilder,
);
}
}

@ -0,0 +1,68 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart';
import 'package:velocity_x/velocity_x.dart';
class ExcludeSinglePage extends StatefulWidget {
const ExcludeSinglePage({Key? key}) : super(key: key);
@override
_ExcludeSinglePageState createState() => _ExcludeSinglePageState();
}
class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
@override
Widget build(BuildContext context) {
return ScaffoldThemeWidget(
title: '添加单个或批量号码',
bottom: "添加",
onTap: () {},
child: Container(
padding: EdgeInsets.only(top: 25.h, left: 50.w, right: 50.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
addNumber("号码", "请输入号码"),
15.heightBox,
addNumber("名称", "请输入名称"),
15.heightBox,
RichText(
text: const TextSpan(
children: [
TextSpan(text: "使用说明:"),
TextSpan(text: "如输入000*可屏蔽所有000开头的号码")
],
),
),
],
),
),
);
}
addNumber(String title, content) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 18,
color: Colors.black38,
fontWeight: FontWeight.w600,
),
),
15.heightBox,
TextField(
decoration: InputDecoration(
hintText: content,
border: const OutlineInputBorder(
),
),
),
],
);
}
}

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:project_telephony/ui/exclude/exclude_contacts_page.dart';
import 'package:project_telephony/ui/exclude/exclude_single_page.dart';
import 'package:project_telephony/ui/home/home_page.dart';
import 'package:project_telephony/ui/home/set/phone_num_list/call_records_list.dart';
import 'package:project_telephony/utils/headers.dart';
@ -29,7 +30,10 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
@override
Widget build(BuildContext context) {
return ScaffoldThemeWidget(title: "发送号码设置", bottom: '添加', onTap: () {
return ScaffoldThemeWidget(
title: "发送号码设置",
bottom: '添加',
onTap: () {
showModalBottomSheet(
builder: (BuildContext context) {
return Container(
@ -42,8 +46,7 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
Text(
"添加号码",
style: TextStyle(
fontSize: 34.w,
fontWeight: FontWeight.bold),
fontSize: 34.w, fontWeight: FontWeight.bold),
),
Expanded(
child: ListView(
@ -54,15 +57,15 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
title: '从通话记录添加',
isBorder: true,
isOpacity: false,
onTap: () { },
child: const CallRecordsList()
));
onTap: () {},
child: const CallRecordsList()));
}),
_getAddPhone("通迅录添加", "通过本机通讯录添加号码", () {
Get.to(() => (const ExcludeContactsPage()));
}),
_getAddPhone(
"添加单个或批量号码", "通过输入号码段添加批量号码", () {}),
_getAddPhone("添加单个或批量号码", "通过输入号码段添加批量号码", () {
Get.to(() => (const ExcludeSinglePage()));
}),
],
)),
PloneBottom(
@ -96,9 +99,9 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
child: ListView(
children: [
_getNullList(),
],
)),);
)),
);
// PloneBottom(
// onTap: () {
// showModalBottomSheet(

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
@ -8,8 +7,6 @@ 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;
@ -30,6 +27,7 @@ final Uri _url = Uri.parse('https://www.dxbs.vip//explain.html');
bool sms = false;
bool plone = false;
bool callLog = false;
bool contacts = false;
@override
class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
@ -45,6 +43,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
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(() {});
}
@ -69,6 +68,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
_getRights("获取设备来电状态", "用于获取来电状态", plone),
_getRights("获取设备短信权限", "用于发送短信", sms),
_getRights("获取设备通话记录", "用于获取来电", callLog),
_getRights("获取设备通讯录", "用于插入排除手机号", contacts),
],
),
bottomNavigationBar: GestureDetector(
@ -121,6 +121,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
onTap: () async {
if (!state) {
openAppSettings();
setState(() {});
}
// if(!(sms && plone)){
// // print(sms);

@ -23,20 +23,22 @@ class ScaffoldThemeWidget extends StatefulWidget {
final bool isBorder;
final bool isOpacity;
final VoidCallback onTap;
const ScaffoldThemeWidget(
{Key? key, required this.title, required this.child, required this.bottom, this.isBorder = false, this.isOpacity = true,required this.onTap
})
: super(key: key);
const ScaffoldThemeWidget({
Key? key,
required this.title,
required this.child,
required this.bottom,
this.isBorder = false,
this.isOpacity = true,
required this.onTap,
}) : super(key: key);
@override
_ScaffoldThemeWidgetState createState() => _ScaffoldThemeWidgetState();
}
class _ScaffoldThemeWidgetState extends State<ScaffoldThemeWidget> {
@override
void initState() {
super.initState();
}
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
@override
@ -59,7 +61,7 @@ class _ScaffoldThemeWidgetState extends State<ScaffoldThemeWidget> {
body: widget.child,
bottomNavigationBar: PloneBottom(
onTap: widget.onTap,
border:widget.isBorder,
border: widget.isBorder,
opacity: widget.isOpacity ? 1 : 0.4,
text: widget.bottom,
).paddingOnly(bottom: 30.w),

@ -360,6 +360,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
flutter_contacts:
dependency: "direct main"
description:
name: flutter_contacts
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.5"
flutter_easyrefresh:
dependency: "direct main"
description:

@ -93,6 +93,8 @@ dependencies:
url_launcher: ^6.1.5
#tabBar样式切换
tab_indicator_styler: ^2.0.0
#手机通讯录
flutter_contacts: ^1.1.5
# # jdk
# jverify: ^2.2.5

Loading…
Cancel
Save