|
|
|
@ -1,10 +1,14 @@
|
|
|
|
|
import 'package:call_log/call_log.dart';
|
|
|
|
|
import 'package:flustars/flustars.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:project_telephony/ui/widget/plone_bottom.dart';
|
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:project_telephony/base/base_style.dart';
|
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
import '../../../../model/phone_num_model.dart';
|
|
|
|
|
import '../../../widget/scaffold_theme_widget.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CallRecordsList extends StatefulWidget {
|
|
|
|
|
const CallRecordsList({Key? key}) : super(key: key);
|
|
|
|
@ -15,28 +19,69 @@ class CallRecordsList extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _CallRecordsListState extends State<CallRecordsList> {
|
|
|
|
|
List<PhoneNumModel> phoneNum = [];
|
|
|
|
|
List<PhoneNumModel> phoneNum2 = [];
|
|
|
|
|
final EasyRefreshController _easyRefreshController = EasyRefreshController();
|
|
|
|
|
List a = [];
|
|
|
|
|
int b = 0;
|
|
|
|
|
late bool notifications;
|
|
|
|
|
late bool trackHistory;
|
|
|
|
|
late bool instantOrders;
|
|
|
|
|
late SharedPreferences prefs;
|
|
|
|
|
List<String> numList=[];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
// getList();
|
|
|
|
|
getList();
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_easyRefreshController.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getList() async {
|
|
|
|
|
phoneNum.clear();
|
|
|
|
|
final Iterable<CallLogEntry> entries = await CallLog.query();
|
|
|
|
|
for (CallLogEntry entrie in entries) {
|
|
|
|
|
if(!numList.contains(entrie.number)){
|
|
|
|
|
numList.add(entrie.number!);
|
|
|
|
|
phoneNum.add(PhoneNumModel(
|
|
|
|
|
num: entrie.number,
|
|
|
|
|
time: entrie.timestamp,
|
|
|
|
|
name: entrie.name,
|
|
|
|
|
state: false,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return
|
|
|
|
|
Expanded(
|
|
|
|
|
child: EasyRefresh(
|
|
|
|
|
firstRefresh: true,
|
|
|
|
|
header: MaterialHeader(),
|
|
|
|
|
onRefresh: () async {},
|
|
|
|
|
child: ListView.builder(itemBuilder: (context, index) {
|
|
|
|
|
var profileBuilder = FutureBuilder(
|
|
|
|
|
future: getList() , // a Future<String> or null
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
|
|
|
|
|
if(snapshot.connectionState==ConnectionState.done){
|
|
|
|
|
return ListView.builder(
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return _getBox(phoneNum[index]);
|
|
|
|
|
}),
|
|
|
|
|
));
|
|
|
|
|
},
|
|
|
|
|
itemCount: phoneNum.length,
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return ScaffoldThemeWidget(
|
|
|
|
|
bottom: '添加',
|
|
|
|
|
title: '从通话记录添加',
|
|
|
|
|
isBorder: true,
|
|
|
|
|
isOpacity: false,
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
child: profileBuilder
|
|
|
|
|
);
|
|
|
|
|
// Column(
|
|
|
|
|
// children: [
|
|
|
|
|
// Container(width: 750.w, height: 1000.w, child: Text("")
|
|
|
|
@ -58,9 +103,32 @@ class _CallRecordsListState extends State<CallRecordsList> {
|
|
|
|
|
// );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getBox(PhoneNumModel item){
|
|
|
|
|
return ListTile(
|
|
|
|
|
title: Text(item.num),
|
|
|
|
|
_getBox(PhoneNumModel item) {
|
|
|
|
|
return CheckboxListTile(
|
|
|
|
|
onChanged: (bool? value) {
|
|
|
|
|
setState((){
|
|
|
|
|
item.state = value!;
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
value: item.state,
|
|
|
|
|
title: Text(
|
|
|
|
|
item.num!,
|
|
|
|
|
style: TextStyle(fontSize: 32.w, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
DateUtil.formatDateMs(item.time! * 1000, format: 'MM/dd HH:mm'),
|
|
|
|
|
style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
|
|
|
|
|
),
|
|
|
|
|
30.wb,
|
|
|
|
|
Text(
|
|
|
|
|
item.name == null ? "" : item.name!,
|
|
|
|
|
style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|