|
|
@ -1,10 +1,14 @@
|
|
|
|
import 'package:call_log/call_log.dart';
|
|
|
|
import 'package:call_log/call_log.dart';
|
|
|
|
|
|
|
|
import 'package:flustars/flustars.dart';
|
|
|
|
import 'package:flutter/material.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: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 '../../../../model/phone_num_model.dart';
|
|
|
|
|
|
|
|
import '../../../widget/scaffold_theme_widget.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CallRecordsList extends StatefulWidget {
|
|
|
|
class CallRecordsList extends StatefulWidget {
|
|
|
|
const CallRecordsList({Key? key}) : super(key: key);
|
|
|
|
const CallRecordsList({Key? key}) : super(key: key);
|
|
|
@ -15,28 +19,69 @@ class CallRecordsList extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
|
|
class _CallRecordsListState extends State<CallRecordsList> {
|
|
|
|
class _CallRecordsListState extends State<CallRecordsList> {
|
|
|
|
List<PhoneNumModel> phoneNum = [];
|
|
|
|
List<PhoneNumModel> phoneNum = [];
|
|
|
|
|
|
|
|
List<PhoneNumModel> phoneNum2 = [];
|
|
|
|
final EasyRefreshController _easyRefreshController = EasyRefreshController();
|
|
|
|
final EasyRefreshController _easyRefreshController = EasyRefreshController();
|
|
|
|
List a = [];
|
|
|
|
late bool notifications;
|
|
|
|
int b = 0;
|
|
|
|
late bool trackHistory;
|
|
|
|
|
|
|
|
late bool instantOrders;
|
|
|
|
|
|
|
|
late SharedPreferences prefs;
|
|
|
|
|
|
|
|
List<String> numList=[];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
// getList();
|
|
|
|
|
|
|
|
getList();
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
void dispose() {
|
|
|
|
_easyRefreshController.dispose();
|
|
|
|
_easyRefreshController.dispose();
|
|
|
|
super.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
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return
|
|
|
|
var profileBuilder = FutureBuilder(
|
|
|
|
Expanded(
|
|
|
|
future: getList() , // a Future<String> or null
|
|
|
|
child: EasyRefresh(
|
|
|
|
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
|
|
|
|
firstRefresh: true,
|
|
|
|
if(snapshot.connectionState==ConnectionState.done){
|
|
|
|
header: MaterialHeader(),
|
|
|
|
return ListView.builder(
|
|
|
|
onRefresh: () async {},
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
child: ListView.builder(itemBuilder: (context, index) {
|
|
|
|
|
|
|
|
return _getBox(phoneNum[index]);
|
|
|
|
return _getBox(phoneNum[index]);
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
));
|
|
|
|
itemCount: phoneNum.length,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return ScaffoldThemeWidget(
|
|
|
|
|
|
|
|
bottom: '添加',
|
|
|
|
|
|
|
|
title: '从通话记录添加',
|
|
|
|
|
|
|
|
isBorder: true,
|
|
|
|
|
|
|
|
isOpacity: false,
|
|
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: profileBuilder
|
|
|
|
|
|
|
|
);
|
|
|
|
// Column(
|
|
|
|
// Column(
|
|
|
|
// children: [
|
|
|
|
// children: [
|
|
|
|
// Container(width: 750.w, height: 1000.w, child: Text("")
|
|
|
|
// Container(width: 750.w, height: 1000.w, child: Text("")
|
|
|
@ -59,8 +104,31 @@ class _CallRecordsListState extends State<CallRecordsList> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_getBox(PhoneNumModel item) {
|
|
|
|
_getBox(PhoneNumModel item) {
|
|
|
|
return ListTile(
|
|
|
|
return CheckboxListTile(
|
|
|
|
title: Text(item.num),
|
|
|
|
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),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|