列表提交

master
王亚玲 2 years ago
parent d05397492a
commit c84b3b1fd8

@ -14,6 +14,7 @@ import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:power_logger/power_logger.dart'; import 'package:power_logger/power_logger.dart';
import 'package:project_telephony/providers/phone_num_provider.dart';
import 'package:project_telephony/providers/user_provider.dart'; import 'package:project_telephony/providers/user_provider.dart';
import 'package:project_telephony/ui/home/call.dart'; import 'package:project_telephony/ui/home/call.dart';
@ -71,6 +72,7 @@ class _MyAppState extends State<MyApp> {
return MultiProvider( return MultiProvider(
providers: [ providers: [
ChangeNotifierProvider(create: (context) => UserProvider()), ChangeNotifierProvider(create: (context) => UserProvider()),
ChangeNotifierProvider(create: (context)=>PhoneNumProvider()),
], ],
child: MediaQuery( child: MediaQuery(
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window), data: MediaQueryData.fromWindow(WidgetsBinding.instance.window),

@ -2,20 +2,22 @@ import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
part 'phone_num_model.g.dart'; part 'phone_num_model.g.dart';
@JsonSerializable() @JsonSerializable()
class PhoneNumModel extends Equatable{ class PhoneNumModel extends Equatable{
final String num; final String? num;
final int time; final int? time;
final String name; final String? name;
bool state ;
factory PhoneNumModel.fromJson(Map<String, dynamic> json) =>_$PhoneNumModelFromJson(json); factory PhoneNumModel.fromJson(Map<String, dynamic> json) =>_$PhoneNumModelFromJson(json);
const PhoneNumModel({ PhoneNumModel({
required this.name, required this.name,
required this.num, required this.num,
required this.time, required this.time,
required this.state,
}); });
@override @override
List<Object?> get props => [num,time,name]; List<Object?> get props => [num,time,name,state];
} }

@ -11,4 +11,5 @@ PhoneNumModel _$PhoneNumModelFromJson(Map<String, dynamic> json) =>
num: json['num'] as String, num: json['num'] as String,
time: json['time'] as int, time: json['time'] as int,
name: json['name'] as String, name: json['name'] as String,
state: json['state']as bool,
); );

@ -0,0 +1,28 @@
import 'package:call_log/call_log.dart';
import 'package:flutter/material.dart';
import '../model/phone_num_model.dart';
import '../utils/hive_store.dart';
class PhoneNumProvider extends ChangeNotifier{
final List<PhoneNumModel> _phoneNum=[PhoneNumModel(num: "",time: 0,name: "", state:false)];
List<PhoneNumModel> get phoneNum=>_phoneNum;
Future list(List<PhoneNumModel> phoneList) async{
// await HiveStore.dataBox!.get();
// final Iterable<CallLogEntry> entries = await CallLog.query();
// for (CallLogEntry entrie in entries) {
// _phoneNum.add(PhoneNumModel(
// num: entrie.number,
// time: entrie.timestamp,
// name: entrie.name,
// state: false,
// ));
// // a.add(entrie.number);
// }
// final phoneList=_phoneNum.toSet();
// final phoneList= HiveStore.dataBox?.get(phoneNum);
return ;
}
// Future
}

@ -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("")
@ -58,9 +103,32 @@ 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),
)
],
),
); );
} }
} }

@ -1,14 +1,17 @@
import 'package:call_log/call_log.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.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_contacts_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/ui/home/set/phone_num_list/call_records_list.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/ui/widget/plone_bottom.dart'; import 'package:project_telephony/ui/widget/plone_bottom.dart';
import '../../../base/base_style.dart'; import '../../../base/base_style.dart';
import '../../widget/plone_back_button.dart'; import '../../../model/phone_num_model.dart';
import '../../widget/scaffold_theme_widget.dart'; import '../../widget/scaffold_theme_widget.dart';
class SpecifyPhonePage extends StatefulWidget { class SpecifyPhonePage extends StatefulWidget {
@ -27,6 +30,7 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ScaffoldThemeWidget(title: "发送号码设置", bottom: '添加', onTap: () { return ScaffoldThemeWidget(title: "发送号码设置", bottom: '添加', onTap: () {
@ -49,14 +53,7 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
child: ListView( child: ListView(
children: [ children: [
_getAddPhone("通话记录添加", "通过本机通话记录添加号码", () { _getAddPhone("通话记录添加", "通过本机通话记录添加号码", () {
Get.to(() => ScaffoldThemeWidget( Get.to(() => const CallRecordsList());
bottom: '添加',
title: '从通话记录添加',
isBorder: true,
isOpacity: false,
onTap: () { },
child: const CallRecordsList()
));
}), }),
_getAddPhone("通迅录添加", "通过本机通讯录添加号码", () { _getAddPhone("通迅录添加", "通过本机通讯录添加号码", () {
Get.to(() => (const ExcludeContactsPage())); Get.to(() => (const ExcludeContactsPage()));

@ -1,10 +1,16 @@
// import 'package:project_telephony/providers/phone_provider.dart'; // import 'package:project_telephony/providers/phone_provider.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../providers/phone_num_provider.dart';
import '../providers/user_provider.dart'; import '../providers/user_provider.dart';
import 'headers.dart'; import 'headers.dart';
class UserTool { class UserTool {
static UserProvider userProvider = static UserProvider userProvider =
Provider.of<UserProvider>(Get.context!, listen: false); Provider.of<UserProvider>(Get.context!, listen: false);
// static PhoneProvider phoneProvider=Provider.of<PhoneProvider>(Get.context!, listen: false); // static PhoneProvider phoneProvider=Provider.of<PhoneProvider>(Get.context!, listen: false);
}
class PhoneTool {
static PhoneNumProvider phoneNumProvider =
Provider.of<PhoneNumProvider>(Get.context!, listen: false);
} }

Loading…
Cancel
Save