|
|
@ -1,9 +1,13 @@
|
|
|
|
|
|
|
|
import 'package:call_log/call_log.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_background_service/flutter_background_service.dart';
|
|
|
|
import 'package:project_telephony/ui/home/set/specify_phone_page.dart';
|
|
|
|
import 'package:project_telephony/ui/home/set/specify_phone_page.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
|
|
|
import '../../../base/base_style.dart';
|
|
|
|
import '../../../base/base_style.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../model/phone_num_model.dart';
|
|
|
|
import '../../widget/plone_back_button.dart';
|
|
|
|
import '../../widget/plone_back_button.dart';
|
|
|
|
|
|
|
|
|
|
|
|
// class setItem{
|
|
|
|
// class setItem{
|
|
|
@ -20,6 +24,12 @@ class PhoneSetPage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
|
|
class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
int select = 0;
|
|
|
|
int select = 0;
|
|
|
|
|
|
|
|
List<Contact>? contact;
|
|
|
|
|
|
|
|
List<String> numbers = [];
|
|
|
|
|
|
|
|
List<String>? numList=[];
|
|
|
|
|
|
|
|
List<String> numList2=[];
|
|
|
|
|
|
|
|
List<String>? numList3=[];
|
|
|
|
|
|
|
|
|
|
|
|
List setList = [
|
|
|
|
List setList = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"icon": Assets.icons.rylyphone.path,
|
|
|
|
"icon": Assets.icons.rylyphone.path,
|
|
|
@ -40,7 +50,11 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
// "select": false,
|
|
|
|
// "select": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
_viewLoading();
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
}
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
@ -111,11 +125,58 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future _viewLoading() async {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
|
|
|
|
contact = await FlutterContacts.getContacts();
|
|
|
|
|
|
|
|
for (var element in contact!) {
|
|
|
|
|
|
|
|
final full = await FlutterContacts.getContact(element.id);
|
|
|
|
|
|
|
|
numbers.add(full!.phones.first.number.replaceAll(" ",""));
|
|
|
|
|
|
|
|
// status.add(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
await prefs.setStringList("addressList", numbers);
|
|
|
|
|
|
|
|
// phoneNum.clear();
|
|
|
|
|
|
|
|
// final Iterable<CallLogEntry> entries = await CallLog.query();
|
|
|
|
|
|
|
|
// numList= prefs.getStringList('addressList');
|
|
|
|
|
|
|
|
// count=numList?.length;
|
|
|
|
|
|
|
|
// for (CallLogEntry entrie in entries) {
|
|
|
|
|
|
|
|
// if (!numList2.contains(numList)) {
|
|
|
|
|
|
|
|
// numList2.add(entrie.number!);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// for(int i=0;i<count!;i++){
|
|
|
|
|
|
|
|
// numList2.remove(numList![i]);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// print(numList2);
|
|
|
|
|
|
|
|
// await prefs.setStringList("noAddressList", numList2);
|
|
|
|
|
|
|
|
// for (int i = 0; i < phoneNum.length; i++) {
|
|
|
|
|
|
|
|
// phoneNum2.add(PhoneNumModel(
|
|
|
|
|
|
|
|
// num: phoneNum[i].num,
|
|
|
|
|
|
|
|
// time: phoneNum[i].time,
|
|
|
|
|
|
|
|
// name: phoneNum[i].name,
|
|
|
|
|
|
|
|
// state: phoneNum[i].state,
|
|
|
|
|
|
|
|
// ));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
}
|
|
|
|
_getListBox(List item, int index) {
|
|
|
|
_getListBox(List item, int index) {
|
|
|
|
|
|
|
|
final service = FlutterBackgroundService();
|
|
|
|
return GestureDetector(
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
onTap: () async{
|
|
|
|
|
|
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
select = index;
|
|
|
|
select = index;
|
|
|
|
|
|
|
|
await prefs.setInt("numIndex", index);
|
|
|
|
|
|
|
|
if(await service.isRunning()){
|
|
|
|
|
|
|
|
service.invoke("stopService");
|
|
|
|
|
|
|
|
Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
|
|
|
|
service.startService();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
service.startService();
|
|
|
|
|
|
|
|
Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
|
|
|
|
service.invoke("stopService");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
// print(_selectIndex);
|
|
|
|
// print(_selectIndex);
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|