master
王亚玲 2 years ago
parent 88891266f6
commit adbf8fcdd7

@ -120,4 +120,7 @@ class _Exclude {
///
String get find => '/app/exclude/find';
///
String get findAll =>'/app/exclude/findAll';
}

@ -2,7 +2,6 @@
import 'dart:async';
import 'package:bot_toast/bot_toast.dart';
import 'package:call_log/call_log.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -11,10 +10,12 @@ import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/providers/phone_num_provider.dart';
import 'package:project_telephony/providers/user_provider.dart';
import 'package:project_telephony/ui/home/call.dart';
import 'package:project_telephony/ui/loading.dart';
import 'package:project_telephony/ui/tab_navigator.dart';
import 'package:project_telephony/utils/developer_util.dart';
import 'package:project_telephony/utils/hive_store.dart';
import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:telephony/telephony.dart';
@ -23,6 +24,8 @@ void main() async {
const buildType = String.fromEnvironment('BUILD_TYPE');
DeveloperUtil.setDev(!(buildType.contains('PRODUCT')));
WidgetsFlutterBinding.ensureInitialized();
initializeService();
// UserTool.userProvider.viewLoading();
await HiveStore.init();
// await initializeService();
// Workmanager().initialize(

@ -3,8 +3,8 @@ import 'package:flutter/foundation.dart';
import 'package:platform/platform.dart';
import '../../constants/api.dart';
import '../../utils/inner_model/base_list_model.dart';
import '../../utils/toast/cloud_toast.dart';
import '../../utils/inner_model/base_list_model.dart';
import 'base_model.dart';
import 'net_interceptor.dart';

@ -48,4 +48,5 @@ class ListInnerModel {
factory ListInnerModel.fromJson(Map<String, dynamic> json) =>
_$ListInnerModelFromJson(json);
Map<String, dynamic> toJson() => _$ListInnerModelToJson(this);
}

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

@ -1,15 +1,15 @@
// // GENERATED CODE - DO NOT MODIFY BY HAND
//
// part of 'phone_num_model.dart';
//
// // **************************************************************************
// // JsonSerializableGenerator
// // **************************************************************************
//
// PhoneNumModel _$PhoneNumModelFromJson(Map<String, dynamic> json) =>
// PhoneNumModel(
// num: json['num'] as String,
// time: json['time'] as int,
// name: json['name'] as String,
// state: json['state']as bool,
// );
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'phone_num_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
PhoneNumModel _$PhoneNumModelFromJson(Map<String, dynamic> json) =>
PhoneNumModel(
num: json['num'] as String,
time: json['time'] as int,
name: json['name'] as String,
state: json['state']as bool,
);

@ -6,7 +6,6 @@ import 'package:project_telephony/utils/user_tool.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../constants/api.dart';
import '../model/exclude_phone_model.dart';
import '../model/hive/phone_model.dart';
import '../model/login_info_model.dart';
import '../model/network/api_client.dart';
@ -61,8 +60,8 @@ class UserProvider extends ChangeNotifier {
_isLogin = true;
// app
updateUserInfo();
prefs.setInt("numIndex", 0);//
prefs.setInt("numIndex", 1);//
prefs.setString("refSms","现在有事,等会回电");
// _viewLoading();//
// UserTool.phoneNumProvider.init();
// prefs.setStringList("dxText", [
@ -247,7 +246,7 @@ class UserProvider extends ChangeNotifier {
prefs.setStringList("nameList",nameList );
prefs.setStringList("number", numbers);
service.invoke("stopService");
// print("指定不发送${prefs.getStringList("specified")}");
print("指定不发送${prefs.getStringList("specified")}");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async {
service.startService();

@ -1,243 +0,0 @@
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:project_telephony/model/hive/phone_model.dart';
// import 'package:project_telephony/utils/headers.dart';
// import 'package:project_telephony/utils/hive_store.dart';
//
// import '../../base/base_style.dart';
// import '../widget/plone_back_button.dart';
// import '../widget/plone_bottom.dart';
// import 'call_list_page.dart';
//
// typedef NumList = Function(List<String> content);
//
// class AddressBook extends StatefulWidget {
// final NumList number;
//
// const AddressBook({Key? key, required this.number}) : super(key: key);
//
// @override
// _AddressBookState createState() => _AddressBookState();
// }
//
// class _AddressBookState extends State<AddressBook> {
// final EasyRefreshController _easyRefreshController = EasyRefreshController();
// String phoneName = "";
// List<PhoneModel> massList = [];
// List<PhoneNum> phoneList = [];
// List<String> NumList = [];
// bool state=false;
//
// @override
// void initState() {
// // print("这是我的第二个类型${massList.runtimeType}");
// // print(HiveStore.dataBox?.get("ml"));
// massList = HiveStore.dataBox?.get("ml").cast<PhoneModel>();
// // UserTool.phoneNumProvider.init();
// // massList=HiveStore.dataBox?.get("ml").cast<PhoneModel>();
// // List<dynamic> list<PhoneModel>
// // massList= HiveStore.dataBox?.get("ml");
// super.initState();
// }
//
// @override
// void dispose() {
// _easyRefreshController.dispose();
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// resizeToAvoidBottomInset: false,
// appBar: AppBar(
// elevation: 0,
// centerTitle: true,
// title: Text(
// '通讯录',
// style: TextStyle(
// fontSize: BaseStyle.fontSize34,
// color: BaseStyle.color333333,
// fontWeight: FontWeight.bold),
// ),
// // titleSpacing: 185.w,
// actions: [
// GestureDetector(
// onTap: () {
// showDialog(
// context: context,
// builder: (context) {
// return CupertinoAlertDialog(
// title: Text(
// "添加分组",
// style: TextStyle(
// color: BaseStyle.color333333,
// fontSize: 34.sp),
// ),
// content: Column(
// children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// CupertinoTextField(
// padding: EdgeInsets.symmetric(
// horizontal: 24.w, vertical: 20.w),
// decoration: BoxDecoration(
// border:
// Border.all(color: Colors.white),
// // borderRadius: BorderRadius.all(
// // Radius.circular(4.w)
// // ),
// color: const Color(0xFFF9F9F9)),
// placeholderStyle: TextStyle(
// fontSize: 28.sp,
// color: BaseStyle.color999999),
// placeholder: "请输入分组名称10个字以内",
// onChanged: (value) {
// phoneName = value;
// setState(() {});
// },
// ),
//
// 82.hb,
// // _getUpdate("爸爸", "123123123"),
// PloneBottom(
// blM: false,
// border: true,
// color1: const Color(0xFF1890FF),
// color2: const Color(0xFF74BCFF),
// onTap: () async {
// DateTime now = DateTime.now();
// String nowTime =
// "${now.year}-${now.month}-${now
// .day} ${now.hour}:${now
// .minute}:${now.millisecond}";
// massList.add(PhoneModel(
// time: nowTime,
// phoneList: [],
// state: false,
// title: phoneName));
// await HiveStore.dataBox
// ?.put("ml", massList);
// // massList.add(MassListModel(
// // state: false,
// // list: [],
// // title: phoneName,
// // time: nowTime));
// // // await
// // Navigator.pop(context);
// Get.back();
// _easyRefreshController.callRefresh();
// },
// text: "保存",
// )
// ],
// ),
// ],
// ),
// );
// });
// },
// child: Padding(
// padding: EdgeInsets.only(top: 40.w, right: 32.w),
// child: SizedBox(
// height: 28.w,
// width: 120.w,
// child: Text(
// "添加分组",
// style: TextStyle(
// color: BaseStyle.color333333, fontSize: 28.sp),
// ),
// )))
// ],
// leading: const CloudBackButton(isSpecial: true),
// backgroundColor: kForeGroundColor),
// backgroundColor: Colors.white,
// body: EasyRefresh(
// firstRefresh: true,
// header: MaterialHeader(),
// controller: _easyRefreshController,
// onRefresh: () async {
// // UserTool.phoneNumProvider.init();
// // massList=HiveStore.dataBox?.get("ml");
// // massList=HiveStore.dataBox?.get("ml").cast<PhoneModel>();
// // massList=HiveStore.dataBox?.get("ml").cast<List<PhoneModel>>();
// setState(() {});
// },
// child: ListView.builder(
// itemBuilder: (context, index) {
// return _getBox(
// massList[index], index, massList[index].phoneList!.length);
// },
// itemCount: massList.length,
// ),
// ),
// bottomNavigationBar: Padding(
// padding: EdgeInsets.only(bottom: 24.w),
// child: PloneBottom(
// onTap: () {
// widget.number(NumList);
// Get.back();
// },
// // border: state,
// opacity: 1,
// text: "确定",
// ),
// ));
// }
//
// _getBox(PhoneModel item, int index, int num) {
// return CheckboxListTile(
// onChanged: (bool? value) {
// setState(() {
// item.state = value!;
// state=value;
// if (item.state!) {
// item.phoneList?.forEach((element) {
// NumList.add(element.phone ?? "");
// });
// // item.phoneList!.map((e) => NumList.add(e.phone ??""));
// } else {
// item.phoneList?.forEach((element) {
// NumList.remove(element.phone ?? "");
// });
// // item.phoneList!.map((e) => NumList.remove(e.phone ??""));
// // phoneNum3.remove({"phone":num,"remark":name});
// // phoneNum3.remove(ExcludePnModel(phone: num, remark: name)) ;
// }
// });
// },
// value: item.state,
// title: GestureDetector(
// onTap: () {
// Navigator.of(context)
// .push(MaterialPageRoute(builder: (_) =>
// CallListPage(
// phoneNum: item.phoneList ?? [],
// title: item.title ?? "",
// index: index,
// ))).then((value) => _easyRefreshController.callRefresh());
// print(index);
// },
// child: Text(
// "${item.title}($num)",
// style: TextStyle(fontSize: 32.w, fontWeight: FontWeight.bold),
// ),
// ),
// subtitle: Row(
// children: [
// Text(
// item.time ?? "",
// 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,234 +0,0 @@
// import 'package:flutter/material.dart';
// import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:project_telephony/utils/headers.dart';
// import 'package:project_telephony/utils/hive_store.dart';
//
// import '../../base/base_style.dart';
// import '../../model/hive/phone_model.dart';
// import '../exclude/exclude_contacts_page.dart';
// import '../exclude/exclude_single_page.dart';
// import '../widget/plone_back_button.dart';
//
// class CallListPage extends StatefulWidget {
// final String title;
// final List<PhoneNum> phoneNum;
// final int index;
// const CallListPage({Key? key, required this.title, required this.phoneNum,required this.index})
// : super(key: key);
//
// @override
// _CallListPageState createState() => _CallListPageState();
// }
//
// class _CallListPageState extends State<CallListPage> {
// final EasyRefreshController _refreshController = EasyRefreshController();
// List<PhoneModel> messList = [];
// List<PhoneNum> numList = [];
//
// @override
// void dispose() {
// _refreshController.dispose();
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// resizeToAvoidBottomInset: false,
// appBar: AppBar(
// centerTitle: true,
// elevation: 0,
// title: Text(
// widget.title,
// style: TextStyle(
// fontSize: BaseStyle.fontSize34,
// color: BaseStyle.color333333,
// fontWeight: FontWeight.bold),
// ),
// // titleSpacing: 150.w,
// leading: const CloudBackButton(
// isSpecial: true,
// isSpecials: false,
// ),
// backgroundColor: kForeGroundColor),
// backgroundColor: Colors.white,
// body: EasyRefresh(
// firstRefresh: true,
// controller: _refreshController,
// header: MaterialHeader(),
// // footer: MaterialFooter(),
// onRefresh: () async {
// // await userProvider.updateUserInfo();
//
// setState(() {});
// },
// child: widget.phoneNum.isEmpty
// ? _getNullList()
// : _getNum(widget.phoneNum)
//
// // ListView(
// // children: [findList.isEmpty ? _getNullList() : _getNum()],
// // )
//
// ),
// bottomNavigationBar: Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// 62.wb,
// _getBottom("号码添加", const Color(0xFF1890FF), () {
// Navigator.of(context)
// .push(
// MaterialPageRoute(builder: (_) => ExcludeSinglePage( qf: true,index: widget.index,)),
// )
// .then((value) => _refreshController.callRefresh());
// }, Colors.white, Colors.white, 2, const Color(0xFF1890FF), 58, 24),
// 32.wb,
// _getBottom("通讯录中添加", Colors.white, () {
// Navigator.of(context)
// .push(
// MaterialPageRoute(
// builder: (_) => ExcludeContactsPage(
// qf: true,
// index: widget.index,
// )),
// )
// .then((val) => _refreshController.callRefresh());
// }, const Color(0xFF74BCFF), const Color(0xFF1890FF), 0, Colors.white,
// 96, 24),
// 62.wb,
// ],
// ),
// );
// }
//
// _getBottom(String text, Color textColor, VoidCallback ontap, Color color1,
// Color color2, int border, Color borderColor, int h, int v) {
// return GestureDetector(
// onTap: ontap,
// child: Container(
// padding: EdgeInsets.symmetric(horizontal: h.w, vertical: v.w),
// margin: EdgeInsets.only(bottom: 32.w),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(8.w),
// gradient: LinearGradient(
// colors: [color1, color2],
// end: Alignment.centerRight,
// begin: Alignment.centerLeft),
// border: Border.all(width: border.w, color: borderColor)),
// child: Text(
// text,
// style: TextStyle(
// fontSize: 28.sp, color: textColor, fontWeight: FontWeight.w500),
// ),
// ),
// );
// }
//
// _getNullList() {
// return Column(
// mainAxisAlignment: MainAxisAlignment.center,
// // crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// 490.hb,
// Image.asset(
// Assets.icons.nullphonelist.path,
// width: 240.w,
// height: 212.w,
// fit: BoxFit.fill,
// ),
// 48.hb,
// Text(
// "这里是空的",
// style: TextStyle(
// color: const Color(0xFF999999),
// fontWeight: FontWeight.bold,
// fontSize: 36.sp),
// ),
// 16.hb,
// Text(
// "还没有添加指定号码",
// style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
// ),
// 490.hb,
// ],
// );
// }
//
// _getNum(List<PhoneNum> item) {
// return ListView.builder(
// itemBuilder: (context, index) {
// return Container(
// margin: EdgeInsets.symmetric(horizontal: 16.w),
// child: ListTile(
// onTap: () async {},
// title: Text(
// item[index].name ?? "",
// style: TextStyle(fontSize: 32.w, fontWeight: FontWeight.bold),
// ),
// subtitle: Text(
// item[index].phone ?? "",
// style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
// ),
// trailing: TextButton(
// style: ButtonStyle(
// side: MaterialStateProperty.all(
// BorderSide(width: 2.w, color: const Color(0xFFE8E8E8)))),
// onPressed: () async {
// // print("123");
// messList =
// await HiveStore.dataBox?.get("ml").cast<PhoneModel>();
// // numList = HiveStore.dataBox?.get("pl").cast<PhoneNum>();
// // print(item[index]);
// // messList.removeWhere((element) => (element.phoneList)!.contains(item[index]));
// // numList.remove(item[index]);
// messList[widget.index].phoneList!.remove(item[index]);
// HiveStore.dataBox?.put("ml", messList);
// print(HiveStore.dataBox?.get("ml"));
// _refreshController.callRefresh();
// // print(HiveStore.dataBox?.get("pl"));
// },
// child: Text(
// "删除",
// style: TextStyle(fontSize: 28.sp, color: BaseStyle.color333333),
// ),
// ),
// ),
// );
//
// // CheckboxListTile(
// // onChanged: (bool? value) {
// // setState(() {
// // item[index].state = value!;
// // if (item[index].state!) {
// // // phoneNum3.add({"phone":num,"remark":name});
// // // phoneNum3.add((phone: num, remark: name));
// // } else {
// // // phoneNum3.remove({"phone":num,"remark":name});
// // // phoneNum3.remove(ExcludePnModel(phone: num, remark: name)) ;
// // }
// // });
// // },
// // value: item[index].state,
// // title: Text(
// // item[index].name ?? "",
// // style: TextStyle(fontSize: 32.w, fontWeight: FontWeight.bold),
// // ),
// // subtitle: Row(
// // children: [
// // Text(
// // item[index].phone ?? "",
// // style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
// // ),
// // // 30.wb,
// // // Text(
// // // item.name == null ? "" : item.name!,
// // // style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
// // // )
// // ],
// // ),
// // );
// },
// itemCount: widget.phoneNum.length,
// );
// }
// }

@ -1,280 +0,0 @@
// import 'package:flutter/material.dart';
// import 'package:flutter_sms/flutter_sms.dart';
// import 'package:project_telephony/base/base_style.dart';
// import 'package:project_telephony/ui/TextMe/text_template.dart';
// import 'package:project_telephony/ui/widget/plone_bottom.dart';
// import 'package:project_telephony/utils/headers.dart';
// import 'package:project_telephony/utils/toast/cloud_toast.dart';
// import 'package:velocity_x/velocity_x.dart';
//
// import '../../utils/user_tool.dart';
// import '../widget/plone_back_button.dart';
// import 'address_book.dart';
//
// class TextMePage extends StatefulWidget {
// const TextMePage({Key? key}) : super(key: key);
//
// @override
// _TextMePageState createState() => _TextMePageState();
// }
//
// class _TextMePageState extends State<TextMePage> {
// // String contentText = "";
// // String phoneText = "";
// String signatureText = "";
// late TextEditingController _controller;
// late TextEditingController _phoneController;
// List<String> list = [];
//
// @override
// void initState() {
// _controller = TextEditingController();
// _phoneController = TextEditingController();
// _controller.text = "";
// _phoneController.text = "";
// /* Future.delayed(const Duration(seconds: 0),(){
// if (UserTool.userProvider.isLogin) {
// _controller = TextEditingController();
// _phoneController = TextEditingController();
// _controller.text = "";
// _phoneController.text = "";
// } else {
// Get.to(() => const LoginPage());
// }
// });*/
// super.initState();
// }
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// resizeToAvoidBottomInset: false,
// appBar: AppBar(
// elevation: 0,
// title: Text(
// "群发短信",
// style: TextStyle(
// fontSize: BaseStyle.fontSize34,
// color: BaseStyle.color333333,
// fontWeight: FontWeight.bold),
// ),
// titleSpacing: 200.w,
// leading: const CloudBackButton(
// isSpecial: true,
// isSpecials: false,
// ),
// backgroundColor: kForeGroundColor),
// backgroundColor: Colors.white,
// body: ListView(
// children: [
// _getBox('短信内容', "选择短信模版", () {
// Get.to(() => TextTemplate(
// callback: (String content) {
// _controller.text = content;
// },
// ));
// }, "请输入短信内容...", _controller),
// 32.hb,
// _getBox('收信号码', "通讯录中选择", () {
// _phoneController.text="";
// Get.to(() => AddressBook(
// number: (List<String> content) {
// for (int i = 0; i < content.length; i++) {
// _phoneController.text += "${content[i]},";
// }
// },
// ));
// }, "请输入收信号码多个号码请用逗号隔开例如136xxxx6666132xxxx8888", _phoneController),
// 32.hb,
// _getBox2(),
// 64.hb,
// PloneBottom(
// onTap: () async {
// // final Telephony telephony = Telephony.instance;
// if(UserTool.userProvider.userInfo.isVip ==1){
// if (_controller.text.isEmpty &&
// _phoneController.text.isEmpty &&
// signatureText.isEmpty) {
// CloudToast.show("内容不可为空");
// } else {
// print(_controller.text);
// print(_phoneController.text);
// print(signatureText);
// await sendSMS(
// message: "$signatureText${_controller.text}",
// recipients: _phoneController.text.split(","),
// sendDirect: true);
// // print("asd${_phoneController.text.split(",")}");
// // await telephony.sendSms(
// // to: "13486828191;13395740386;18815060992;18294841148",
// // message: "$signatureText${_controller.text}"
// // );
// CloudToast.show("发送成功");
// // Telephony.sendSms(to: phoneNum!, message: idle);
// }
// }else{
// CloudToast.show("您还未开通会员");
// }
// },
// border: _controller.text.isEmpty ||
// _phoneController.text.isEmpty ||
// signatureText.isEmpty,
// opacity: _controller.text.isEmpty ||
// _phoneController.text.isEmpty ||
// signatureText.isEmpty
// ? 0.4
// : 1,
// text: "发送",
// )
// ],
// ),
// );
// }
//
// _getBox(String title, String onTapText, VoidCallback onTap, String hitText,
// TextEditingController controller) {
// return Column(
// children: [
// GestureDetector(
// onTap: onTap,
// child: Container(
// height: 100.w,
// margin: EdgeInsets.symmetric(horizontal: 64.w),
// child: Row(
// children: [
// Text(
// title,
// style: TextStyle(
// fontSize: 28.sp,
// color: BaseStyle.color999999,
// fontWeight: FontWeight.bold),
// ),
// 290.wb,
// Text(
// onTapText,
// style: TextStyle(
// fontSize: 28.sp, color: const Color(0xFF1890FF)),
// ),
// const Icon(
// Icons.keyboard_arrow_right,
// color: Color(0xFF1890FF),
// ),
// ],
// ),
// ),
// ),
// 16.hb,
// Container(
// height: 240.w,
// decoration: BoxDecoration(
// color: const Color(0xFFF9F9F9),
// borderRadius: BorderRadius.circular(8.w),
// ),
// padding: EdgeInsets.all(30.w),
// margin: EdgeInsets.symmetric(
// horizontal: 64.w,
// ),
// child: TextField(
// // focusNode: verifyNode,
// maxLines: 100,
// keyboardType: TextInputType.text,
// // onChanged: (text) {
// // if (title == "短信内容") {
// // _controller.text = text;
// // } else {
// // _phoneController.text = text;
// // }
// // setState(() {});
// // },
// onSubmitted: (text) {
// if (title == "短信内容") {
// _controller.text = text;
// } else {
// _phoneController.text = text;
// }
// setState(() {});
// },
// onEditingComplete: () {
// setState(() {});
// // _refreshController.callRefresh();
// },
// style: TextStyle(
// color: BaseStyle.color333333,
// fontSize: BaseStyle.fontSize28,
// ),
// controller: controller,
// decoration: InputDecoration(
// contentPadding: EdgeInsets.zero,
// filled: true,
// isDense: true,
// fillColor: Colors.transparent,
// hintText: hitText,
// hintStyle: TextStyle(
// color: BaseStyle.color999999,
// fontSize: 28.sp,
// ),
// border: InputBorder.none,
// ),
// ),
// ),
// ],
// );
// }
//
// _getBox2() {
// return Container(
// margin: EdgeInsets.symmetric(horizontal: 64.w),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// "短信签名",
// style: TextStyle(
// fontSize: 28.sp,
// color: const Color(0xFF999999),
// fontWeight: FontWeight.w600,
// ),
// ),
// 15.heightBox,
// TextField(
// // controller: controller,
// onChanged: (value) {
// signatureText = value;
// setState(() {});
// },
// decoration: InputDecoration(
// contentPadding: EdgeInsets.all(30.w),
// hintText: "请输入短信签名",
// hintStyle: TextStyle(
// fontSize: 28.sp,
// // fontWeight: FontWeight.w600,
// color: const Color(0xFF999999),
// ),
// fillColor: const Color(0xFFF9F9F9),
// filled: true,
// enabledBorder: const OutlineInputBorder(
// /*边角*/
// borderRadius: BorderRadius.all(
// Radius.circular(5), //5
// ),
// borderSide: BorderSide(
// color: Colors.white, //线
// width: 1, //线2
// ),
// ),
// focusedBorder: const OutlineInputBorder(
// borderSide: BorderSide(
// color: Colors.white, //
// width: 1, //5
// ),
// borderRadius: BorderRadius.all(
// Radius.circular(5), //30
// ),
// ),
// ),
// ),
// ],
// ),
// );
// }
// }

@ -1,191 +0,0 @@
// import 'package:bot_toast/bot_toast.dart';
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:project_telephony/utils/headers.dart';
// import 'package:project_telephony/utils/user_tool.dart';
// import 'package:shared_preferences/shared_preferences.dart';
//
// import '../../base/base_style.dart';
// import '../home/add_sms_page.dart';
// import '../widget/plone_back_button.dart';
//
// typedef TextCallback = Function(String content);
// class TextTemplate extends StatefulWidget {
// final TextCallback callback;
// const TextTemplate({Key? key,required this.callback}) : super(key: key);
//
// @override
// _TextTemplateState createState() => _TextTemplateState();
// }
//
// class _TextTemplateState extends State<TextTemplate> {
// EasyRefreshController refreshController = EasyRefreshController();
//
// List<String> textList = [];
//
// @override
// void initState() {
// addText();
// super.initState();
// }
//
// addText() async {
// final prefs = await SharedPreferences.getInstance();
// if (textList.length == 1) {
// prefs.setStringList("dxText", [
// "祝你万事顺心",
// "欢迎你的来电,祝你生活愉快",
// "感谢您的来电,我们会尽快处理",
// ]);
// }
// }
//
// @override
// void dispose() {
// // TODO: implement dispose
// refreshController.dispose();
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// resizeToAvoidBottomInset: false,
// appBar: AppBar(
// elevation: 0,
// title: Text(
// '短信模版',
// style: TextStyle(
// fontSize: BaseStyle.fontSize34,
// color: BaseStyle.color333333,
// fontWeight: FontWeight.bold),
// ),
// titleSpacing: 162.w,
// leading: const CloudBackButton(isSpecial: true),
// backgroundColor: kForeGroundColor),
// backgroundColor: Colors.white,
// body: EasyRefresh(
// firstRefresh: true,
// controller: refreshController,
// header: MaterialHeader(),
// footer: MaterialFooter(),
// onRefresh: () async {
// final prefs = await SharedPreferences.getInstance();
// textList = prefs.getStringList("dxText") ?? [];
// textList.add("自定义短信模版");
// setState(() {});
// },
// child: ListView(
// children: [
// SizedBox(
// height: 1000.w,
// child: ListView.builder(
// itemBuilder: (context, index) {
// return _getListContent(textList[index], index);
// },
// itemCount: textList.length,
// ))
// ],
// ),
// ),
// );
// }
//
// _getListContent(String item, int index) {
// return GestureDetector(
// onTap: () async {
// if (item != "自定义短信模版") {
// // BotToast.showText(text: item);
// widget.callback(item);
// Get.back();
// } else {
// if (UserTool.userProvider.userInfo.isVip == 1) {
// if (textList.length > 5) {
// BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信');
// } else {
// Navigator.of(context)
// .push(
// MaterialPageRoute(
// builder: (_) => AddSmsPage(status: 0, ploneBack: (String textContent) { },qfBool: true,)),
// )
// .then((val) =>refreshController.callRefresh());
// // textList.add("value");
// // await prefs.setStringList("dxTExt", textList);
// }
// } else {
// BotToast.showText(text: '请先开通会员');
// }
// }
// setState(() {});
// },
// onLongPress: () {
// if (item != "自定义短信模版") {
// if (textList.length == 3) {
// BotToast.showText(text: '内容不可删除');
// } else {
// showDialog(
// context: context,
// builder: (context) {
// return CupertinoAlertDialog(
// title: const Text("删除短信模板"),
// content: Column(
// children: [
// SizedBox(
// height: 10.w,
// ),
// const Align(
// child: Text("你确定要删除这个短信模版吗,删除之后无法还原。"),
// )
// ],
// ),
// actions: [
// CupertinoDialogAction(
// textStyle: const TextStyle(color: Color(0xFF999999)),
// onPressed: () {
// Navigator.pop(context);
// },
// child: const Text("取消"),
// ),
// CupertinoDialogAction(
// child: const Text("确定"),
// onPressed: () async {
// final prefs = await SharedPreferences.getInstance();
// textList.remove(item[index]);
// await prefs.setStringList("dxIndex", textList);
// refreshController.callRefresh();
// },
// ),
// ],
// );
// });
// }
// }
// setState(() {});
// },
// child: Container(
// // width: 686.w,
// height: 128.w,
// margin: EdgeInsets.only(top: 32.w, left: 64.w, right: 64.w),
// padding: EdgeInsets.only(left: 40.w, top: 45.w),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(16.w),
// gradient: const LinearGradient(
// begin: Alignment.centerLeft,
// end: Alignment.centerRight,
// colors: [
// Color(0xFFF9F9F9),
// Color(0xFFF9F9F9),
// ]),
// ),
// child: Text(
// item,
// style: TextStyle(
// fontSize: BaseStyle.fontSize28,
// color: BaseStyle.color333333,
// fontWeight: FontWeight.bold),
// ),
// ),
// );
// }
// }

@ -128,10 +128,13 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
} else {
BaseModel res = await apiClient
.request(API.exclude.add, data: {'exclude': excludeList});
print(excludeList);
if (res.code == 0) {
BotToast.showText(text: res.msg);
Get.back();
Get.back();
}else{
BotToast.showText(text: res.msg);
}
}
} else {

@ -1,134 +0,0 @@
// import 'package:flutter/material.dart';
// import 'package:flutter_screenutil/flutter_screenutil.dart';
// import 'package:get/get.dart';
// import 'package:provider/provider.dart';
// import 'package:shared_preferences/shared_preferences.dart';
//
// import '../../base/base_style.dart';
// import '../../constants/api.dart';
// import '../../model/network/api_client.dart';
// import '../../model/network/base_model.dart';
// import '../../providers/user_provider.dart';
// import '../../utils/toast/cloud_toast.dart';
// import '../user/content_details_page.dart';
// import '../widget/plone_back_button.dart';
// import '../widget/plone_bottom.dart';
//
// class AddSmsPage extends StatefulWidget {
// final int status;
// final TextCallback ploneBack;
// final bool qfBool;
// const AddSmsPage({Key? key, required this.status, required this.ploneBack,this.qfBool=false}) : super(key: key);
//
// @override
// _AddSmsPageState createState() => _AddSmsPageState();
// }
//
// class _AddSmsPageState extends State<AddSmsPage> {
// late TextEditingController _controller;
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
// String contant="";
//
//
// @override
// void initState() {
// super.initState();
// _controller = TextEditingController();
// }
// // final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// resizeToAvoidBottomInset: false,
// appBar: AppBar(
// elevation: 0,
// title: Text(
// '编辑短信标签',
// style: TextStyle(
// fontSize: BaseStyle.fontSize34,
// color: BaseStyle.color333333,
// fontWeight: FontWeight.bold),
// ),
// titleSpacing: 162.w,
// leading: const CloudBackButton(isSpecial: true),
// backgroundColor: kForeGroundColor),
// backgroundColor: Colors.white,
// body: Align(
// alignment: Alignment.topCenter,
// child: Container(
// height: 800.w,
// decoration: BoxDecoration(
// color: const Color(0xFFF9F9F9),
// borderRadius: BorderRadius.circular(16.w),
// ),
// padding: EdgeInsets.all(30.w),
// margin: EdgeInsets.symmetric(horizontal: 40.w, vertical: 50.w),
// child: TextField(
// maxLines: 100,
// keyboardType: TextInputType.text,
// onEditingComplete: () {
// setState(() {});
// // _refreshController.callRefresh();
// },
// style: TextStyle(
// color: BaseStyle.color333333,
// fontSize: BaseStyle.fontSize28,
// ),
// onChanged: (text) async{
// contant=text;
// setState((){});
// },
// controller: _controller,
// decoration: const InputDecoration(
// fillColor: Colors.transparent,
// contentPadding: EdgeInsets.zero,
// filled: true,
// isDense: true,
// hintText: "请输入所需短信标签",
// border: InputBorder.none,
// ),
// ),
// ),
// ),
// bottomNavigationBar: PloneBottom(
// border: _controller.text.isEmpty,
// opacity: contant.isEmpty ? 0.4 : 1,
// onTap: () async {
// final prefs = await SharedPreferences.getInstance();
// List<String>? contentList=prefs.getStringList("dxText");
// if(widget.qfBool){
// contentList?.add(contant);
// await prefs.setStringList("dxText", contentList!);
// Get.back();
// }else{
// BaseModel res = await apiClient.request(API.content.content, data: {
// 'content': _controller.text,
// 'status': widget.status,
// });
// if (res.code == 0) {
// setState(() {});
// widget.ploneBack(_controller.text);
// switch (widget.status) {
// case 1:
// await userProvider.updateConSms();
// break;
// case 2:
// await userProvider.updateRefSms();
// break;
// case 3:
// await userProvider.updateCallSms();
// break;
// case 4:
// await userProvider.updateIdleSms();
// break;
// }
// } else {
// CloudToast.show(res.msg);
// }
// Get.back();}
// },
// text: "保存",
// ).paddingOnly(bottom: 30.w),
// );
// }
// }

@ -1,279 +0,0 @@
// import 'package:bot_toast/bot_toast.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:project_telephony/utils/headers.dart';
// import 'package:provider/provider.dart';
//
// import '../../base/base_style.dart';
// import '../../constants/api.dart';
// import '../../model/contant_list_model.dart';
// import '../../model/network/api_client.dart';
// import '../../model/network/base_model.dart';
// import '../../model/sms_content_model.dart';
// import '../../providers/user_provider.dart';
// import '../../utils/toast/cloud_toast.dart';
// import '../widget/centertipsalterwidget.dart';
// import 'add_sms_page.dart';
//
// class AnswerIdleList extends StatefulWidget {
// final EasyRefreshController refreshController;
// final bool isIdle;
// final int num;
//
// const AnswerIdleList(
// {Key? key, required this.refreshController, required this.isIdle,required this.num})
// : super(key: key);
//
// @override
// _AnswerIdleListState createState() => _AnswerIdleListState();
// }
//
// class _AnswerIdleListState extends State<AnswerIdleList>
// with AutomaticKeepAliveClientMixin {
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
// List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容'];
// List<SmsContentModel> _model = [];
// List<ContantListModel> answerList=[];
// List<String> textListSMS = [];
// List<int> smsIdList = [];
// int isCheck = 0;
// bool val = true;
//
// // final EasyRefreshController _easyRefreshController = EasyRefreshController();
// @override
// Widget build(BuildContext context) {
// return Column(
// children: [
// _getText(),
// 32.hb,
// widget.isIdle
// ? val
// ? Expanded(
// // width: 662.w,
// // height: 800.w,
// child: EasyRefresh.custom(
// firstRefresh: true,
// controller: widget.refreshController,
// header: MaterialHeader(),
// // footer: MaterialFooter(),
// onRefresh: () async {
// await userProvider.updateUserInfo();
// print("这是数据$answerList");
// // userProvider.updateRefSms();
// // updateList();
// setState(() {});
// },
// slivers: [
// SliverList(
// delegate:
// SliverChildBuilderDelegate((context, index) {
// return _getBox(answerList[index], index);
// }, childCount: answerList.length)),
// ]))
// : _getEmptyList()
// : Expanded(
// // width: 662.w,
// // height: 800.w,
// child: EasyRefresh.custom(
// firstRefresh: true,
// controller: widget.refreshController,
// header: MaterialHeader(),
// // footer: MaterialFooter(),
// onRefresh: () async {
// await userProvider.updateUserInfo();
// print("这是数据$answerList");
// // userProvider.updateRefSms();
// // updateList();
// setState(() {});
// },
// slivers: [
// SliverList(
// delegate:
// SliverChildBuilderDelegate((context, index) {
// return _getBox(answerList[index], index);
// }, childCount: answerList.length))
// ]))
// ],
// );
// }
//
// updateList() async {
// if (userProvider.isLogin) {
// // textListSMS.clear();
// // smsIdList.clear();
// int i = 0;
// // contentRef
// var base = await apiClient.request(API.content.findByStatus, data: {'status': 1});
// if (base.code == 0) {
// _model=(base.data as List)
// .map((e) => SmsContentModel.fromJson(e))
// .toList();
// } else {
// CloudToast.show(base.msg);
// }
// for (var model in _model) {
// textListSMS.add(model.content);
// smsIdList.add(model.id);
// if (model.isChecked == 1) {
// isCheck = i;
// }
// i++;
// }
// textListSMS.add("自定义短信内容");
// } else {
// textListSMS = textList;
// }
// }
//
// _getText() {
// return Container(
// height: 128.w,
// // margin: EdgeInsets.only(top: 32.w, left: 64.w, right: 64.w),
// padding: EdgeInsets.only(left: 40.w, top: 45.w),
// child: ListTile(
// title: Text(
// "功能讲解",
// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp),
// ),
// subtitle: Text(
// widget.isIdle
// ? "您给朋友去电接听后所发送的短信":"朋友给你来电接听后所发送的短信",
// style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
// ),
// trailing: widget.isIdle
// ? Switch(
// value: val,
// onChanged: (value) async {
// // if(!value){
// //
// // }
// // await prefs.setBool("kg", value);
// // print("这是数据${prefs.getBool("kg")}");
// setState(() {
// val = value;
// });
// })
// : const SizedBox()),
// );
// }
//
// _getBox(ContantListModel item,int index) {
// return GestureDetector(
// onTap: () async {
// if (item.content != "自定义短信内容") {
// BaseModel res = await apiClient.request(API.content.checked,
// data: {'id': item.id, 'status': 1});
// if (res.code == 0) {
// setState(() {});
// userProvider.updateUserInfo();
// userProvider.updateConSms();
// widget.refreshController.callRefresh();
// } else {
// CloudToast.show(res.msg);
// }
// } else {
// if (userProvider.userInfo.isVip == 1) {
// if (answerList.length > 5) {
// BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信');
// } else {
// Get.to(AddSmsPage(
// status: 1,
// ploneBack: (String textContent) {
// widget.refreshController.callRefresh();
// },
// ));
// }
// } else {
// BotToast.showText(text: '请先开通会员');
// }
// }
// setState(() {});
// },
// onLongPress: () {
// if (item.content != "自定义短信内容") {
// if (answerList.length == 2 || isCheck == index) {
// if (answerList.length == 2) {
// BotToast.showText(text: '最后一条内容不可删除');
// } else if (isCheck == index) {
// BotToast.showText(text: '当前为选中内容,不可删除');
// }
// } else {
// showDialog(
// context: context,
// builder: (context) {
// return Centertipsalterwidget(
// desText: '你确定要删除这个短信模版吗,删除之后无法还原。',
// title: '删除短信模板',
// id: item.id,
// callback: (bool status) {
// widget.refreshController.callRefresh();
// },
// );
// });
// }
// }
// setState(() {});
// },
// child: Container(
// // width: 686.w,
// height: 128.w,
// margin: EdgeInsets.only(top: 32.w, left: 64.w, right: 64.w),
// padding: EdgeInsets.only(left: 40.w, top: 45.w),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(16),
// gradient: LinearGradient(
// begin: Alignment.centerLeft,
// end: Alignment.centerRight,
// colors: [
// index == isCheck
// ? const Color(0xFF1890FF)
// : const Color(0xFFF9F9F9),
// index == isCheck
// ? const Color(0xFF74BCFF)
// : const Color(0xFFF9F9F9),
// ]),
// ),
// child: Text(
// item.content,
// style: TextStyle(
// fontSize: BaseStyle.fontSize28,
// color: index == isCheck
// ? const Color(0xFFF9F9F9)
// : BaseStyle.color333333,
// fontWeight: FontWeight.bold),
// ),
// ),
// );
// }
//
// _getEmptyList() {
// return Column(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// 234.hb,
// Image.asset(
// Assets.images.emptylist.path,
// width: 240.w,
// height: 212.w,
// fit: BoxFit.fill,
// ),
// 48.hb,
// Text(
// "功能已关闭",
// style: TextStyle(
// color: const Color(0xFF999999),
// fontWeight: FontWeight.bold,
// fontSize: 36.sp),
// ),
// 16.hb,
// Text(
// "去电接听后将不会发送短信",
// style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
// ),
// ],
// );
// }
//
// @override
// bool get wantKeepAlive => true;
// }

@ -5,12 +5,27 @@ import 'package:call_log/call_log.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:telephony/telephony.dart';
const nId = "my_foreground";
const notificationId = 888;
Future<void> initializeService() async {
SharedPreferences.getInstance();
final service = FlutterBackgroundService();
const AndroidNotificationChannel channel = AndroidNotificationChannel(
nId, // id
'我的前台服务', // title
description:
'此通道用于重要通知。', // description
importance: Importance.low, // importance must be at low or higher level
);
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(channel);
await service.configure(
iosConfiguration: IosConfiguration(
// auto start service
@ -23,12 +38,18 @@ Future<void> initializeService() async {
androidConfiguration: AndroidConfiguration(
// this will be executed when app is in foreground or background in separated isolate
onStart: onStart,
// auto start service
autoStart: true,
isForegroundMode: true,
notificationChannelId: nId, // this must match with notification channel you created above.
initialNotificationTitle: 'AWESOME SERVICE',
initialNotificationContent: 'Initializing',
foregroundServiceNotificationId: notificationId,
),
);
service.startService();
// service.startService();
}
bool onIosBackground(ServiceInstance service) {
@ -37,8 +58,11 @@ bool onIosBackground(ServiceInstance service) {
return true;
}
// @pragma('vm:entry-point')
void onStart(ServiceInstance service) async {
DartPluginRegistrant.ensureInitialized();
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
service.on("stopService").listen((event) {
service.stopSelf();
});
@ -46,17 +70,34 @@ void onStart(ServiceInstance service) async {
int flag = 0;
String? phoneNum = "";
String callState;
Timer.periodic(const Duration(seconds: 1), (timer) async {
//
final SharedPreferences prefs = await SharedPreferences.getInstance();
//
CallState state = await Telephony.instance.callState;
callState = state.name;
List<String> noNumberList = prefs.getStringList("specified") ??[];
flutterLocalNotificationsPlugin.show(
notificationId,
'短信帮手',
'$callState ${DateTime.now().second}',
const NotificationDetails(
android: AndroidNotificationDetails(
nId,
'我的前台服务',
icon: 'ic_bg_service_small',
ongoing: true,
),
),
);
//
String content = prefs.getString("refSms")!;
String content = prefs.getString("refSms") ?? "现在有事,等会回电";
//
int? numberSet = prefs.getInt("numIndex") ?? 0;
print("号码设置$numberSet 发送内容$content");
int? numberSet = prefs.getInt("numIndex") ?? 1;
print("号码设置$numberSet 发送内容$content 指定不发送$noNumberList");
// print(flag);
if (callState == "IDLE") {
if (flag != 0) {
final Iterable<CallLogEntry> entry = await CallLog.query();
@ -64,39 +105,66 @@ void onStart(ServiceInstance service) async {
// print(phoneNum);
switch (numberSet) {
case 0:
print("所有都发");
// Telephony.backgroundInstance
// .sendSms(to: phoneNum!, message: content);
flag = 0;
if(!noNumberList.contains(phoneNum)){
print("所有都发+号码设置$numberSet+发送内容$content");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: content);
flag = 0;
}else{
print("指定不发送");
flag = 0;
}
break;
case 1:
if (flag > 0) {
print("来电拒接");
// print("来电拒接/未接");
// print("${phoneNum!}:${ref!}");
// Telephony.backgroundInstance
// .sendSms(to: phoneNum!, message: content);
if(!noNumberList.contains(phoneNum)) {
print("来电拒接+号码设置$numberSet+发送内容$content");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: content);
flag = 0;
}else{
print("指定不发送");
flag = 0;
}
// print("发送成功");
} else if (flag == -1) {
print("来电接听");
// print("来电接听");
// print("${phoneNum!}:$content");
// Telephony.backgroundInstance
// .sendSms(to: phoneNum!, message: content);
if(!noNumberList.contains(phoneNum)) {
print("来电接听+号码设置$numberSet+发送内容$content");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: content);
flag = 0;
}else{
print("指定不发送");
flag = 0;
}
}
flag = 0;
break;
case 2:
if (entry.first.duration! > 0) {
print("去电接听");
// print("${phoneNum!}:$content");
// Telephony.backgroundInstance
// .sendSms(to: phoneNum!, message: content);
} else {
print("去电挂断");
// print("${phoneNum!}:$content");
// Telephony.backgroundInstance
// .sendSms(to: phoneNum!, message: content);
if(flag==-2){
if (entry.first.duration! > 0) {
// print("${phoneNum!}:$content");
if(!noNumberList.contains(phoneNum)) {
print("去电接听+号码设置$numberSet+发送内容$content");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: content);
}
} else {
// print("${phoneNum!}:$content");
if(!noNumberList.contains(phoneNum)) {
print("去电挂断+号码设置$numberSet+发送内容$content");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: content);
}else{
print("指定不发送");
flag = 0;
}
}
}
flag = 0;
break;

@ -1,63 +0,0 @@
//
//
// import 'dart:async';
//
// import 'package:call_log/call_log.dart';
// import 'package:flutter_sms/flutter_sms.dart';
// import 'package:get/get_utils/get_utils.dart';
// import 'package:telephony/telephony.dart';
// import 'package:workmanager/workmanager.dart';
//
// import '../user/user_page.dart';
// Future<void> _sendSMS(String message, List<String> recipients) async {
// // await sendSMS(message: message, recipients: recipients, sendDirect: true);
// try{
// String result =
// await sendSMS(message: message, recipients: recipients, sendDirect: true);
// print(result);
// } catch (error){
// print(error.toString());
// }
//
// }
// void callbackDispatcher() {
// Workmanager().executeTask((task, inputData) async{
// // _sendSMS("感谢来电", ["13486828191"]);
// // ${Telephony.backgroundInstance.sendSms(to: "13486828191", message: "message")}
// print("123412312412312312431231231231231231313123:${ _sendSMS("感谢来电", ["13486828191"])}");
// await sendSMS(message: "感谢来电", recipients: ["1348å6828191"], sendDirect: true);
// // sms();//simpleTask will be emitted here.
// return Future.value(true);
// });
// }
// void sms() async{
// int flag = 0;
// String phoneNum="";
// String callState;
// CallState state = await Telephony.instance.callState;
// callState = state.name;
// // print(callState!+" $flag");
// if (callState == "IDLE") {
// if (flag != 0) {
// flag = 0;
// // print("object");
// final Iterable<CallLogEntry> result = await CallLog.query();
// phoneNum = result.first.number!;
// if(phoneNum.isEmpty){
// print("At Least 1 Person or Message Required");
// }else{
// print("你好$phoneNum");
// // telephony.sendSms(to: phoneNum, message: "1234");
// _sendSMS('感谢来电',[phoneNum]);
// // print("你好123123$phoneNum");
// }
// }
// } else if (callState == "RINGING") {
// flag++;
// print('flag $flag');
// } else if (callState == "OFFHOOK") {
// flag++;
// print('flag $flag');
// }
//
// }

@ -1,326 +0,0 @@
// import 'package:bot_toast/bot_toast.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:project_telephony/utils/headers.dart';
// import 'package:provider/provider.dart';
// import 'package:shared_preferences/shared_preferences.dart';
//
// import '../../base/base_style.dart';
// import '../../constants/api.dart';
// import '../../model/network/api_client.dart';
// import '../../model/network/base_model.dart';
// import '../../model/sms_content_model.dart';
// import '../../providers/user_provider.dart';
// import '../../utils/toast/cloud_toast.dart';
// import '../widget/centertipsalterwidget.dart';
// import 'add_sms_page.dart';
// import 'home_page.dart';
//
// class CallingIdleList extends StatefulWidget {
// final EasyRefreshController refreshController;
// final String title;
// final int status;
// final String? name;
// final Color themeColor;
//
// const CallingIdleList({
// Key? key,
// required this.title,
// required this.status,
// this.name = '',
// required this.themeColor,
// required this.refreshController,
// }) : super(key: key);
//
// @override
// _CallingIdleListState createState() => _CallingIdleListState();
// }
//
// class _CallingIdleListState extends State<CallingIdleList>
// with AutomaticKeepAliveClientMixin {
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
// final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
// List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容'];
// List<SmsContentModel> _model = [];
// List<String> textListSMS = [];
// List<int> smsIdList = [];
// int isCheck = 0;
// late bool val = true;
//
// @override
// void initState() {
// super.initState();
// }
//
// Future<void> getSwitch() async {
// final SharedPreferences prefs = await _prefs;
// val = prefs.getBool(widget.name!) ?? false;
//
// print(val);
// }
//
// Future<void> updateList() async {
// if (userProvider.isLogin) {
// textListSMS.clear();
// smsIdList.clear();
// int i = 0;
// var base = await apiClient
// .request(API.content.findByStatus, data: {'status': widget.status});
// if (base.code == 0) {
// _model = (base.data as List)
// .map((e) => SmsContentModel.fromJson(e))
// .toList();
// } else {
// CloudToast.show(base.msg);
// }
// for (var model in _model) {
// textListSMS.add(model.content);
// smsIdList.add(model.id);
// if (model.isChecked == 1) {
// isCheck = i;
// }
// i++;
// }
// textListSMS.add("自定义短信内容");
// } else {
// textListSMS = textList;
// }
// }
//
// @override
// Widget build(BuildContext context) {
// return EasyRefresh(
// firstRefresh: true,
// controller: widget.refreshController,
// header: MaterialHeader(),
// // footer: MaterialFooter(),
// onRefresh: () async {
// // await userProvider.updateUserInfo();
// getSwitch();
// await updateList();
// setState(() {});
// },
// child: ListView(
// children: [
// _getText(),
// 32.hb,
// // _getEmptyList(),
// widget.name!.isEmpty || val
// ?
// SizedBox(
// height: 1000.w,
// child: ListView.builder(
// itemBuilder: (context, index) {
// return _getBox(textListSMS[index], index);
// },
// itemCount: textListSMS.length,
// ))
// : _getEmptyList(),
// // SliverList(
// // delegate: SliverChildBuilderDelegate((context, index) {
// // return _getBox(textListSMS[index], index);
// // }, childCount: textListSMS.length),
// // ),
// ],
// ),
// );
// // Column(
// // children: [
// // _getText(),
// // 32.hb,
// // widget.name!.isEmpty || val
// // ? Expanded(
// // child: EasyRefresh.custom(
// // firstRefresh: true,
// // controller: widget.refreshController,
// // header: MaterialHeader(),
// // // footer: MaterialFooter(),
// // onRefresh: () async {
// // // await userProvider.updateUserInfo();
// // await updateList();
// // setState(() {});
// // },
// // slivers: [
// // SliverList(
// // delegate: SliverChildBuilderDelegate((context, index) {
// // return _getBox(textListSMS[index], index);
// // }, childCount: textListSMS.length),
// // ),
// // ],
// // ),
// // )
// // : _getEmptyList(),
// // ],
// // );
// }
// _getText() {
// return Container(
// height: 128.w,
// // width: 622.w,
// padding: EdgeInsets.only(left: 40.w, top: 45.w),
// child: ListTile(
// title: Text(
// "功能讲解",
// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp),
// ),
// subtitle: Text(
// widget.title,
// style: TextStyle(color: const Color(0xFF999999), fontSize: 27.sp),
// ),
// trailing: Offstage(
// offstage: widget.name!.isEmpty,
// child: Switch(
// value: val,
// onChanged: (value) async {
// final SharedPreferences prefs = await _prefs;
// setState(() {
// val = value;
// prefs.remove(widget.name!);
// prefs.setBool(widget.name!, val );
// });
// service.invoke("stopService");
// if (prefs.getBool('kg')!) {
// Future.delayed(const Duration(seconds: 1), () async {
// service.startService();
// });
// }
// },
// ),
// ),
// ),
// );
// }
//
// _getBox(String content, int index) {
// return GestureDetector(
// onTap: () async {
// if (content != "自定义短信内容") {
// BaseModel res = await apiClient.request(API.content.checked,
// data: {'id': smsIdList[index], 'status': widget.status});
// if (res.code == 0) {
// setState(() {});
// // await userProvider.updateUserInfo();
// switch (widget.status) {
// case 1:
// await userProvider.updateConSms();
// break;
// case 2:
// await userProvider.updateRefSms();
// break;
// case 3:
// await userProvider.updateCallSms();
// break;
// case 4:
// await userProvider.updateIdleSms();
// break;
// }
// widget.refreshController.callRefresh();
// } else {
// CloudToast.show(res.msg);
// }
// } else {
// if (userProvider.userInfo.isVip == 1) {
// if (textListSMS.length > 5) {
// BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信');
// } else {
// Get.to(
// AddSmsPage(
// status: widget.status,
// ploneBack: (String textContent) {
// widget.refreshController.callRefresh();
// },
// ),
// );
// }
// } else {
// BotToast.showText(text: '请先开通会员');
// }
// }
// setState(() {});
// },
// onLongPress: () {
// if (content != "自定义短信内容") {
// if (textListSMS.length == 2 || isCheck == index) {
// if (textListSMS.length == 2) {
// BotToast.showText(text: '最后一条内容不可删除');
// } else if (isCheck == index) {
// BotToast.showText(text: '当前为选中内容,不可删除');
// }
// } else {
// showDialog(
// context: context,
// builder: (context) {
// return Centertipsalterwidget(
// desText: '你确定要删除这个短信模版吗,删除之后无法还原。',
// title: '删除短信模板',
// id: smsIdList[index],
// callback: (bool status) {
// widget.refreshController.callRefresh();
// },
// );
// });
// }
// }
// setState(() {});
// },
// child: Container(
// // width: 686.w,
// height: 128.w,
// margin: EdgeInsets.only(top: 32.w, left: 64.w, right: 64.w),
// padding: EdgeInsets.only(left: 40.w, top: 45.w),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(16),
// gradient: LinearGradient(
// begin: Alignment.centerLeft,
// end: Alignment.centerRight,
// colors: [
// index == isCheck ? widget.themeColor : const Color(0xFFF9F9F9),
// index == isCheck
// ? widget.themeColor.withOpacity(0.5)
// : const Color(0xFFF9F9F9),
// ]),
// ),
// child: Text(
// content,
// style: TextStyle(
// fontSize: BaseStyle.fontSize28,
// color: index == isCheck
// ? const Color(0xFFF9F9F9)
// : BaseStyle.color333333,
// fontWeight: FontWeight.bold),
// ),
// ),
// );
// }
//
// _getEmptyList() {
// return Column(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// 234.hb,
// Image.asset(
// Assets.images.emptylist.path,
// width: 240.w,
// height: 212.w,
// fit: BoxFit.fill,
// ),
// 48.hb,
// Text(
// "功能已关闭",
// style: TextStyle(
// color: const Color(0xFF999999),
// fontWeight: FontWeight.bold,
// fontSize: 36.sp),
// ),
// 16.hb,
// Text(
// "去电拒接/未接后将不会发送短信",
// style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
// ),
// ],
// );
// }
//
// @override
// bool get wantKeepAlive => true;
// }

@ -1,125 +0,0 @@
// import 'package:flutter/material.dart';
// import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:project_telephony/base/base_style.dart';
// import 'package:project_telephony/ui/home/calling_idle_list.dart';
// import 'package:project_telephony/ui/widget/plone_back_button.dart';
// import 'package:project_telephony/utils/headers.dart';
// import 'package:tab_indicator_styler/tab_indicator_styler.dart';
//
// class ContentConnectPage extends StatefulWidget {
// const ContentConnectPage({Key? key}) : super(key: key);
//
// @override
// _ContentConnectPageState createState() => _ContentConnectPageState();
// }
//
// class _ContentConnectPageState extends State<ContentConnectPage>
// with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
// late TabController _tabController;
// final EasyRefreshController _answerRefreshController =
// EasyRefreshController();
// final EasyRefreshController _wasAnswerRefreshController =
// EasyRefreshController();
//
// @override
// void initState() {
// super.initState();
// _tabController = TabController(
// length: 2,
// initialIndex: 0,
// vsync: this,
// );
// }
//
// @override
// void dispose() {
// _tabController.dispose();
// _answerRefreshController.dispose();
// _wasAnswerRefreshController.dispose();
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// super.build(context);
// return Scaffold(
// appBar: AppBar(
// elevation: 0,
// title: Text(
// '选择短信内容',
// style: Theme.of(context).textTheme.headline6,
// ),
// leading: const CloudBackButton(isSpecial: true),
// backgroundColor: kForeGroundColor,
// ),
// backgroundColor: Colors.white,
// body: Column(
// children: [
// Container(
// width: double.infinity,
// height: 88.w,
// margin: EdgeInsets.symmetric(horizontal: 66.w),
// padding: EdgeInsets.all(8.w),
// decoration: BoxDecoration(
// color: const Color(0xFFF9F9F9),
// borderRadius: BorderRadius.all(Radius.circular(44.w))),
// child: TabBar(
// controller: _tabController,
// labelColor: const Color(0xFF1890FF),
// unselectedLabelColor: const Color(0xFF999999),
// unselectedLabelStyle:
// const TextStyle(fontWeight: FontWeight.bold),
// labelStyle: const TextStyle(fontWeight: FontWeight.bold),
// onTap: (num) {
// if (num == 0) {
// _answerRefreshController.callRefresh();
// } else {
// _wasAnswerRefreshController.callRefresh();
// }
// },
// indicator: RectangularIndicator(
// color: Colors.white,
// bottomLeftRadius: 44.w,
// bottomRightRadius: 44.w,
// topLeftRadius: 44.w,
// topRightRadius: 44.w,
// // paintingStyle: PaintingStyle.fill,
// ),
// tabs: const [
// Tab(
// text: "被叫接听",
// ),
// Tab(
// text: "主叫接听",
// ),
// ],
// ),
// ),
// Expanded(
// child: TabBarView(
// controller: _tabController,
// children: [
// CallingIdleList(
// refreshController: _answerRefreshController,
// title: '朋友给你来电接听后所发送的短信',
// status: 1,
// themeColor: const Color(0xFF1890FF),
// ),
// CallingIdleList(
// refreshController: _answerRefreshController,
// name: "callSwitch",
// title: '您给朋友去电接听后所发送的短信',
// status: 3,
// themeColor: const Color(0xFF1890FF),
// ),
// ],
// ),
// ),
// ],
// ),
// );
// }
//
// @override
// bool get wantKeepAlive => true;
// }

@ -1,128 +0,0 @@
// import 'package:flutter/material.dart';
// import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:project_telephony/base/base_style.dart';
// import 'package:project_telephony/ui/widget/plone_back_button.dart';
// import 'package:project_telephony/utils/headers.dart';
// import 'package:shared_preferences/shared_preferences.dart';
// import 'package:tab_indicator_styler/tab_indicator_styler.dart';
//
// import 'calling_idle_list.dart';
//
// class ContentRefusePage extends StatefulWidget {
// const ContentRefusePage({Key? key}) : super(key: key);
//
// @override
// _ContentRefusePageState createState() => _ContentRefusePageState();
// }
//
// class _ContentRefusePageState extends State<ContentRefusePage>
// with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
// late TabController _tabController;
// final EasyRefreshController _callingRefreshController =
// EasyRefreshController();
// final EasyRefreshController _wasCalledRefreshController =
// EasyRefreshController();
// bool? idleSwitch=true;
//
// @override
// void initState() {
// _tabController = TabController(length: 2, initialIndex: 0, vsync: this);
// getSwitch();
// super.initState();
// }
//
// @override
// void dispose() {
// _tabController.dispose();
// _callingRefreshController.dispose();
// _wasCalledRefreshController.dispose();
// super.dispose();
// }
//
// Future<void> getSwitch()async{
// final SharedPreferences prefs = await SharedPreferences.getInstance();
// idleSwitch=prefs.getBool("idleSwitch");
// }
//
// @override
// Widget build(BuildContext context) {
// super.build(context);
// return Scaffold(
// appBar: AppBar(
// elevation: 0,
// title: Text(
// '选择短信内容',
// style: Theme.of(context).textTheme.headline6,
// ),
// leading: const CloudBackButton(isSpecial: true),
// backgroundColor: kForeGroundColor,
// ),
// backgroundColor: Colors.white,
// body: Column(
// children: [
// Container(
// width: double.infinity,
// height: 88.w,
// margin: EdgeInsets.symmetric(horizontal: 66.w),
// padding: EdgeInsets.all(8.w),
// decoration: BoxDecoration(
// color: const Color(0xFFF9F9F9),
// borderRadius: BorderRadius.all(Radius.circular(44.w))),
// child: TabBar(
// // indicator: Decoration(),
// controller: _tabController,
// labelColor: const Color(0xFF1890FF),
// unselectedLabelColor: const Color(0xFF999999),
// unselectedLabelStyle:
// const TextStyle(fontWeight: FontWeight.bold),
// labelStyle: const TextStyle(fontWeight: FontWeight.bold),
// onTap: (num) {
// if (num == 0) {
// _callingRefreshController.callRefresh();
// } else {
// _wasCalledRefreshController.callRefresh();
// }
// },
// indicator: RectangularIndicator(
// color: Colors.white,
// bottomLeftRadius: 44.w,
// bottomRightRadius: 44.w,
// topLeftRadius: 44.w,
// topRightRadius: 44.w,
// ),
// tabs: const [
// Tab(
// text: "被叫拒接/未接",
// ),
// Tab(
// text: "主叫拒接/未接",
// ),
// ],
// ),
// ),
// Expanded(
// child: TabBarView(
// controller: _tabController,
// children:[
// CallingIdleList(
// status: 2,
// themeColor: const Color(0xFF13CA9D),
// title: '朋友给你来电接听后所发送的短信', refreshController: _callingRefreshController,
// ),
// CallingIdleList(
// name: "idleSwitch",
// status: 4,
// title: '您给朋友去电拒接/未接后所发送的短信',
// themeColor: const Color(0xFF13CA9D), refreshController: _wasCalledRefreshController,
// ),
// ],
// ),
// ),
// ],
// ),
// );
// }
//
// @override
// bool get wantKeepAlive => true;
// }

@ -9,12 +9,13 @@ import 'package:project_telephony/ui/home/set/func/user_info_func.dart';
import 'package:project_telephony/ui/home/set/phone_set_page.dart';
import 'package:project_telephony/ui/user/privacy_rights_page.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../providers/user_provider.dart';
import '../user/content_details_page.dart';
import '../user/privacy_rights_page.dart';
import 'content_connect_page.dart';
import 'content_refuse_page.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@ -40,6 +41,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
WidgetsBinding.instance.addObserver(this);
Future.delayed(const Duration(milliseconds: 500),(){
_listenForPermissionStatus();
});
setState(() {});

@ -0,0 +1,202 @@
import 'package:call_log/call_log.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/home/set/func/exclude_contacts_func.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../../utils/toast/cloud_toast.dart';
import '../../../model/phone_num_model.dart';
import '../../widget/scaffold_theme_widget.dart';
class CallRecordsList extends StatefulWidget {
const CallRecordsList({Key? key}) : super(key: key);
@override
_CallRecordsListState createState() => _CallRecordsListState();
}
class _CallRecordsListState extends State<CallRecordsList> {
List<PhoneNumModel> phoneNum = [];
List<PhoneNumModel> phoneNum2 = [];
// List<ExcludePnModel> phoneNum3 = [];
List phoneNum3=[];
// Map<String, String> get phoneNum3 => {};
final EasyRefreshController _easyRefreshController = EasyRefreshController();
late bool notifications;
late bool trackHistory;
late bool instantOrders;
late SharedPreferences prefs;
List<String> numList = [];
// List<String> =[]
@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,
));
}
}
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,
));
}
// 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 ScaffoldThemeWidget(
bottom: '添加',
title: '从通话记录添加',
isBorder: true,
isOpacity: phoneNum3.isNotEmpty,
onTap: () async {
if (phoneNum3.isEmpty) {
CloudToast.show('请选择手机号');
} else {
// print(phoneNum3);
await ExcludeFunc.getContactsList(phoneNum3);
// Navigator.pop(context,true);
Get.back();
Get.back();
}
// _easyRefreshController.callRefresh();
// phoneNum3.clear();
},
child: EasyRefresh(
firstRefresh: true,
header: MaterialHeader(),
controller: _easyRefreshController,
onRefresh: () async {
getList();
setState(() {});
},
child: ListView.builder(
itemBuilder: (context, index) {
return _getBox(phoneNum2[index], phoneNum2[index].num!,phoneNum2[index].name?? "");
},
itemCount: phoneNum2.length,
),
));
// var profileBuilder = FutureBuilder(
// // future: _incrementCounter(),
// 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("")
//
// // ListView(
// // children: [],
// // ),
// ),
// PloneBottom(onTap: () async {
// // Iterable<CallLogEntry> entries = await CallLog.get();
// final Iterable<CallLogEntry> entries = await CallLog.query();
// for (CallLogEntry entrie in entries) {
// a.add(entrie.number);
// }
// // var b = entries.length;
// print("通话记录条数$a");
// })
// ],
// );
}
_getBox(PhoneNumModel item, String num,String name) {
return CheckboxListTile(
onChanged: (bool? value) {
setState(() {
item.state = value!;
if (item.state) {
phoneNum3.add({"phone":num,"remark":name});
// phoneNum3.add((phone: num, remark: name));
} else {
phoneNum3.remove({"phone":num,"remark":name});
// phoneNum3.remove(ExcludePnModel(phone: num, remark: name)) ;
}
});
},
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),
)
],
),
);
}
}

@ -25,7 +25,7 @@ class ExcludeFunc {
//
static Future<bool> getContactsList(List numList) async {
BaseModel res =
await apiClient.request(API.exclude.add, data: {"exclude": numList});
await apiClient.request(API.exclude.add, data: {"exclude": numList});
if (res.code == 0) {
return true;
} else {

@ -1,200 +0,0 @@
// import 'package:call_log/call_log.dart';
// import 'package:flustars/flustars.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:project_telephony/base/base_style.dart';
// import 'package:project_telephony/ui/home/set/func/exclude_contacts_func.dart';
// import 'package:project_telephony/utils/headers.dart';
// import 'package:shared_preferences/shared_preferences.dart';
//
// import '../../../../model/phone_num_model.dart';
// import '../../../../utils/toast/cloud_toast.dart';
// import '../../../widget/scaffold_theme_widget.dart';
//
// class CallRecordsList extends StatefulWidget {
// const CallRecordsList({Key? key}) : super(key: key);
//
// @override
// _CallRecordsListState createState() => _CallRecordsListState();
// }
//
// class _CallRecordsListState extends State<CallRecordsList> {
// List<PhoneNumModel> phoneNum = [];
// List<PhoneNumModel> phoneNum2 = [];
// // List<ExcludePnModel> phoneNum3 = [];
// List phoneNum3=[];
// // Map<String, String> get phoneNum3 => {};
//
// final EasyRefreshController _easyRefreshController = EasyRefreshController();
// late bool notifications;
// late bool trackHistory;
// late bool instantOrders;
// late SharedPreferences prefs;
// List<String> numList = [];
//
// // List<String> =[]
// @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,
// ));
// }
// }
// 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,
// ));
// }
// // 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 ScaffoldThemeWidget(
// bottom: '添加',
// title: '从通话记录添加',
// isBorder: true,
// isOpacity: phoneNum3.isNotEmpty,
// onTap: () async {
// if (phoneNum3.isEmpty) {
// CloudToast.show('请选择手机号');
// } else {
// // print(phoneNum3);
// await ExcludeFunc.getContactsList(phoneNum3);
// // Navigator.pop(context,true);
// Get.back();
// Get.back();
// }
// // _easyRefreshController.callRefresh();
// // phoneNum3.clear();
// },
// child: EasyRefresh(
// firstRefresh: true,
// header: MaterialHeader(),
// controller: _easyRefreshController,
// onRefresh: () async {
// getList();
// setState(() {});
// },
// child: ListView.builder(
// itemBuilder: (context, index) {
// return _getBox(phoneNum2[index], phoneNum2[index].num!,phoneNum2[index].name?? "");
// },
// itemCount: phoneNum2.length,
// ),
// ));
// // var profileBuilder = FutureBuilder(
// // // future: _incrementCounter(),
// // 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("")
// //
// // // ListView(
// // // children: [],
// // // ),
// // ),
// // PloneBottom(onTap: () async {
// // // Iterable<CallLogEntry> entries = await CallLog.get();
// // final Iterable<CallLogEntry> entries = await CallLog.query();
// // for (CallLogEntry entrie in entries) {
// // a.add(entrie.number);
// // }
// // // var b = entries.length;
// // print("通话记录条数$a");
// // })
// // ],
// // );
// }
//
// _getBox(PhoneNumModel item, String num,String name) {
// return CheckboxListTile(
// onChanged: (bool? value) {
// setState(() {
// item.state = value!;
// if (item.state) {
// phoneNum3.add({"phone":num,"remark":name});
// // phoneNum3.add((phone: num, remark: name));
//
// } else {
// phoneNum3.remove({"phone":num,"remark":name});
// // phoneNum3.remove(ExcludePnModel(phone: num, remark: name)) ;
// }
// });
// },
// 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,18 +1,19 @@
import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:project_telephony/ui/home/set/specify_phone_page.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../base/base_style.dart';
import '../../../providers/user_provider.dart';
import '../../widget/plone_back_button.dart';
import '../call.dart';
import '../home_page.dart';
import '../home_page.dart';
class PhoneSetPage extends StatefulWidget {
const PhoneSetPage({Key? key}) : super(key: key);
@ -26,68 +27,75 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
List<Contact>? contact;
List<String> numbers = [];
List<String>? numList = [];
bool vle=false;
bool isVip=false;
bool vle = false;
bool isVip = false;
String? endDate;
final EasyRefreshController _refreshController = EasyRefreshController();
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
final EasyRefreshController _easyRefreshController=EasyRefreshController();
final EasyRefreshController _easyRefreshController = EasyRefreshController();
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
List setList = [
// {
// "icon": Assets.icons.rylyphone.path,
// "title": "任意来源号码发送",
// "text": "所有的号码来电都会发送",
// // "select": true,
// },
// {
// "icon": Assets.icons.txlphone.path,
// "title": "在通讯录中的号码发送",
// "text": "只给在通讯录中的号码来电发送",
// // "select": false,
// },
// {
// "icon": Assets.icons.notxlphone.path,
// "title": "不在通讯录中的号码发送",
// "text": "只给不在通讯录中的号码来电发送",
// // "select": false,
// },
// {
{
"icon": Assets.icons.switch1.path,
"title": "功能开关",
"text": "功能开启所有号码都发送",
// "select": true,
},
// {
// "icon": Assets.icons.rylyphone.path,
// "title": "只发来电接听",
// "text": "",
// // "select": true,
// },
{
"icon": Assets.icons.rylyphone.path,
"title": "任意来源号码发送",
"text": "所有的号码来电都会发送",
// "select": true,
"icon": Assets.icons.txlphone.path,
"title": "只发来电接听/挂断",
"text": "",
// "select": false,
},
{
"icon": Assets.icons.txlphone.path,
"title": "电接听/挂断",
"text": "只发来电",
"icon": Assets.icons.notxlphone.path,
"title": "只发去电接听/挂断",
"text": "",
// "select": false,
},
// {
// "icon": Assets.icons.notxlphone.path,
// "title": "只发去电挂断",
// "text": "",
// // "select": false,
// },
{
"icon": Assets.icons.notxlphone.path,
"title": "去电接听/挂断",
"text": "只发去电",
"title": "发送周期",
"text": "",
// "select": false,
},
];
List cycleList = [
'每天发送',
"一天内发送一次",
"三天内发送一次",
"七天天内发送一次",
"十五天内发送一次",
"三十天内发送一次"
];
String cycleText = "";
@override
void initState() {
// UserTool.userProvider.viewLoading();
super.initState();
}
@override
void dispose() {
_easyRefreshController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -110,9 +118,11 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
header: MaterialHeader(),
// footer: MaterialFooter(),
onRefresh: () async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
final SharedPreferences prefs =
await SharedPreferences.getInstance();
print(prefs.getInt("numIndex"));
select = (prefs.getInt("numIndex")) ?? 0;
cycleText = prefs.getString("cycle") ?? "每天发送";
_getRequests();
// _viewLoading();
setState(() {});
@ -120,59 +130,282 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
child: ListView(
children: [
// _getSwitch(),
_getList(),
// GestureDetector(
// onTap: () {
// Get.to(() => const SpecifyPhonePage());
// },
// child: Container(
// padding:
// EdgeInsets.symmetric(horizontal: 32.w, vertical: 30.w),
// height: 144.w,
// child: ListTile(
// leading: SizedBox(
// width: 72.w,
// height: 72.w,
// child: Image.asset(
// Assets.icons.zdphone.path,
// fit: BoxFit.fill,
// ),
// ),
// title: Text(
// "指定号码不发送",
// style: TextStyle(
// fontSize: 32.sp, fontWeight: FontWeight.bold),
// ),
// subtitle: Text(
// "通过添加指定号码来设置不发送",
// style: TextStyle(
// fontSize: 28.sp, color: const Color(0xFF999999)),
// ),
// trailing: SizedBox(
// width: 48.w,
// height: 48.w,
// child: const Icon(Icons.arrow_forward_ios),
// )),
// ),
// )
_getListBox(
Assets.icons.switch1.path,
"功能开关",
"功能开启所有号码都发送",
() async {},
Checkbox(
value: vle,
//
onChanged: (value) async {
final SharedPreferences prefs = await _prefs;
// if(!value){
//
// }
// await prefs.setBool("kg", value);
// print("这是数据${prefs.getBool("kg")}");
setState(() {
if (isVip) {
vle = value!;
// prefs.setBool("kg", vle);
// initializeService();
// print(vle);
if (vle) {
// print("true");
// prefs.remove("kg");
prefs.setBool("kg", vle);
service.startService();
// initializeService();
BotToast.showText(text: " 你开启了该功能");
} else {
// print("false");
// prefs.remove("kg");
prefs.setBool("kg", vle);
service.invoke("stopService");
BotToast.showText(text: "你已经关闭该功能");
// print("这是数据${prefs.getBool("kg")}");
}
} else {
BotToast.showText(text: "还没有开通会员,不可使用该功能");
}
});
},
),
),
_getListBox(
Assets.icons.rylyphone.path,
"所有都发送",
"",
() async {},
Radio(
groupValue: select,
value: 0,
onChanged: (int? value) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
select = 0;
await prefs.setInt("numIndex", 0);
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(milliseconds: 500), () async {
vle = true;
service.startService();
});
}
UserTool.userProvider.viewLoading();
_refreshController.callRefresh();
// select = 0;
setState(() {});
},
)),
_getListBox(
Assets.icons.rylyphone.path,
"只发来电接听/挂断",
"",
() async {},
Radio(
groupValue: select,
value: 1,
onChanged: (int? value) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
select = 1;
await prefs.setInt("numIndex", 1);
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(milliseconds: 500), () async {
vle = true;
service.startService();
});
}
UserTool.userProvider.viewLoading();
_refreshController.callRefresh();
// select = 1;
setState(() {});
},
)),
_getListBox(
Assets.icons.rylyphone.path,
"只发去电接听/挂断",
"",
() async {},
Radio(
groupValue: select,
value:2,
onChanged: (int? value) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
select = 2;
await prefs.setInt("numIndex", 2);
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(milliseconds: 500), () async {
vle = true;
service.startService();
});
}
UserTool.userProvider.viewLoading();
_refreshController.callRefresh();
// select = 2;
setState(() {});
},
)),
ListTile(
leading: SizedBox(
width: 72.w,
height: 72.w,
child: Image.asset(
Assets.icons.notxlphone.path,
fit: BoxFit.fill,
),
),
title: SizedBox(
child: Row(
children: [
Text(
"发送周期",
style:
TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold),
),
const Spacer(),
SizedBox(
child: Text(
cycleText,
style: TextStyle(fontSize: 24.sp, color: Colors.grey),
),
)
],
),
),
trailing: SizedBox(
width: 40.w,
height: 40.h,
child: const Icon(
Icons.keyboard_arrow_right,
)),
onTap: () {
showModalBottomSheet(
context: context,
backgroundColor: const Color.fromRGBO(255, 255, 255, 0),
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, dialogSetState) {
return Container(
width: double.infinity,
height: 600.w,
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
BorderRadius.all(Radius.circular(16.w))),
child: Column(
children: [
32.hb,
Row(
children: [
32.wb,
_buildButton(
title: '取消',
onPressed: () => Navigator.pop(context),
color: Colors.black26,
),
210.wb,
Text(
'选择周期',
textAlign: TextAlign.center,
style: TextStyle(
color: const Color(0xFF111111),
fontWeight: FontWeight.bold,
fontSize: 32.sp,
),
),
// _buildButton(
// title: '确定',
// onPressed: () async {
// BotToast.showText(text: "成功");
// Navigator.pop(context);
// setState(() {});
// },
// color: Colors.blue,
// ),
// 32.wb,
],
),
40.hb,
Expanded(
child: ListView.builder(
itemBuilder: (context, index) {
return GestureDetector(
onTap: () async {
final SharedPreferences prefs =
await SharedPreferences.getInstance();
BotToast.showText(text: "成功");
prefs.setString("cycle", cycleList[index]);
BotToast.showText(text: cycleList[index]);
Navigator.pop(context);
_refreshController.callRefresh();
dialogSetState(() {});
},
child: Container(
alignment: Alignment.center,
height: 80.w,
width: double.infinity,
color: Colors.white,
child: Text(cycleList[index],
style: TextStyle(
color: const Color(0xFF330000),
fontSize: BaseStyle.fontSize28)),
),
);
},
itemCount: cycleList.length,
)),
40.hb,
],
),
);
});
});
},
),
GestureDetector(
onTap: () {
Get.to(() => const SpecifyPhonePage());
},
child: SizedBox(
height: 144.w,
child: ListTile(
leading: SizedBox(
width: 72.w,
height: 72.w,
child: Image.asset(
Assets.icons.zdphone.path,
fit: BoxFit.fill,
),
),
title: Text(
"指定号码不发送",
style: TextStyle(
fontSize: 32.sp, fontWeight: FontWeight.bold),
),
subtitle: Text(
"通过添加指定号码来设置不发送",
style: TextStyle(
fontSize: 28.sp, color: const Color(0xFF999999)),
),
trailing:SizedBox(
width: 40.w,
height: 40.h,
child: const Icon(
Icons.keyboard_arrow_right,
))),
),
)
],
),
)
);
));
}
_getList() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w),
height: 640.w,
child: ListView.builder(
itemBuilder: (context, index) {
return _getListBox(setList, index,index!=0);
},
itemCount: setList.length,
),
);
}
//
// _getSwitch() {
// return Container(
@ -298,111 +531,29 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
//
setState(() {});
}
_getListBox(List item, int index,bool kg) {
final service = FlutterBackgroundService();
return GestureDetector(
onTap: () async {
if(kg){
final SharedPreferences prefs = await SharedPreferences.getInstance();
select = index;
await prefs.setInt("numIndex", index);
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async {
vle=true;
service.startService();
});
}
UserTool.userProvider.viewLoading();
_refreshController.callRefresh();
// print(_selectIndex);
}
setState(() {});
},
_getListBox(
String url, String title, String text, VoidCallback ontap, Widget child) {
// final service = FlutterBackgroundService();
return GestureDetector(
onTap: ontap,
child: ListTile(
leading: SizedBox(
width: 72.w,
height: 72.w,
child: Image.asset(
item[index]["icon"],
url,
fit: BoxFit.fill,
)),
title: Text(
item[index]["title"],
title,
style: TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold),
),
subtitle: Text(
item[index]["text"],
text,
style: TextStyle(fontSize: 28.sp, color: const Color(0xFF999999)),
),
trailing: SizedBox(
width: 40.w,
height: 40.w,
child: kg?
Radio(
onChanged: (int? value) async{
// final SharedPreferences prefs = await SharedPreferences.getInstance();
// select = index;
// await prefs.setInt("numIndex", index);
// service.invoke("stopService");
// if (prefs.getBool('kg')!) {
// Future.delayed(const Duration(seconds: 1), () async {
// service.startService();
// });
// }
// UserTool.userProvider.viewLoading();
// _refreshController.callRefresh();
// select = index;
// print(_selectIndex);
setState(() {});
},
groupValue: select,
value: index,
):Checkbox(
value: vle,
//
onChanged: (value) async{
final SharedPreferences prefs = await _prefs;
// if(!value){
//
// }
// await prefs.setBool("kg", value);
// print("这是数据${prefs.getBool("kg")}");
setState(() {
if (isVip) {
vle = value!;
// prefs.setBool("kg", vle);
// initializeService();
// print(vle);
if (vle) {
// print("true");
// prefs.remove("kg");
prefs.setBool("kg", vle);
service.startService();
initializeService();
BotToast.showText(text: " 你开启了该功能");
} else {
// print("false");
// prefs.remove("kg");
prefs.setBool("kg", vle);
service.invoke("stopService");
BotToast.showText(text: "你已经关闭该功能");
// print("这是数据${prefs.getBool("kg")}");
}
} else {
BotToast.showText(text: "还没有开通会员,不可使用该功能");
}
});
},
//
activeColor: Colors.blue,
//
checkColor: Colors.white,
),
),
trailing: SizedBox(width: 40.w, height: 40.w, child: child),
// BeeCheckRadio(
// value: index,
@ -411,4 +562,20 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
),
);
}
_buildButton({
required String title,
required VoidCallback? onPressed,
required Color color,
}) {
return GestureDetector(
onTap: onPressed,
// height: 48.w,
child: Text(title,
style: TextStyle(
color: color,
fontSize: 28.sp,
fontWeight: FontWeight.bold,
)),
);
}
}

@ -1,310 +1,314 @@
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:project_telephony/constants/api.dart';
// import 'package:project_telephony/model/network/api_client.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/set/phone_num_list/call_records_list.dart';
// import 'package:project_telephony/ui/widget/plone_bottom.dart';
// import 'package:project_telephony/utils/headers.dart';
// import 'package:project_telephony/utils/toast/cloud_toast.dart';
// import 'package:project_telephony/utils/user_tool.dart';
//
// import '../../../base/base_style.dart';
// import '../../../model/exclude_phone_model.dart';
// import '../../widget/scaffold_theme_widget.dart';
// import 'func/exclude_contacts_func.dart';
//
// class SpecifyPhonePage extends StatefulWidget {
// const SpecifyPhonePage({Key? key}) : super(key: key);
//
// @override
// _SpecifyPhonePageState createState() => _SpecifyPhonePageState();
// }
//
// class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
// final EasyRefreshController _refreshController = EasyRefreshController();
// List<ExcludePhoneModel> findList = [];
// String name="";
// String phone="";
// @override
// void dispose() {
// _refreshController.dispose();
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// return ScaffoldThemeWidget(
// wid: 196,
// title: "指定号码",
// bottom: '添加',
// onTap: () {
// showModalBottomSheet(
// builder: (BuildContext context) {
// return Container(
// width: double.infinity,
// height: 750.w,
// padding: EdgeInsets.symmetric(horizontal: 32.w),
// child: Column(
// children: [
// 48.hb,
// Text(
// "添加号码",
// style: TextStyle(
// fontSize: 34.w, fontWeight: FontWeight.bold),
// ),
// Expanded(
// child: ListView(
// children: [
// _getAddPhone("通话记录添加", "通过本机通话记录添加号码", () {
// Navigator.of(context)
// .push(
// MaterialPageRoute(
// builder: (_) => const CallRecordsList()),
// )
// .then((val) =>_refreshController.callRefresh());
//
// // Get.to(() => const CallRecordsList());
// }),
// _getAddPhone("通迅录添加", "通过本机通讯录添加号码", () {
// Navigator.of(context)
// .push(
// MaterialPageRoute(
// builder: (_) => const ExcludeContactsPage()),
// )
// .then((val) =>_refreshController.callRefresh());
//
// }),
// _getAddPhone("添加单个或批量号码", "通过输入号码段添加批量号码", () {
// Navigator.of(context)
// .push(
// MaterialPageRoute(
// builder: (_) => const ExcludeSinglePage()),
// )
// .then((val) =>_refreshController.callRefresh());
// }),
// ],
// )),
// PloneBottom(
// onTap: () {
// Navigator.pop(context);
// },
// hPadding: 32,
// border: true,
// textColor: const Color(0xFF1890FF),
// color2: const Color(0xFFF9F9F9),
// color1: const Color(0xFFF9F9F9),
// text: "取消",
// ),
// 32.hb
// ],
// ),
// );
// },
// context: context);
//
// },
// child: EasyRefresh(
// firstRefresh: true,
// controller: _refreshController,
// header: MaterialHeader(),
// // footer: MaterialFooter(),
// onRefresh: () async {
// findList = await ExcludeFunc.getContacts();
// UserTool.userProvider.viewLoading();
// // await userProvider.updateUserInfo();
//
// setState(() {});
// },
// child: findList.isEmpty ? _getNullList() : _getNum()
//
// // ListView(
// // children: [findList.isEmpty ? _getNullList() : _getNum()],
// // )
//
// ),
// );
// }
//
// _getNum() {
// return ListView.builder(
// itemBuilder: (context, index) {
// return _getNumContant(findList[index],findList[index].id);
// },
// itemCount: findList.length,
// );
// }
//
// _getNumContant(ExcludePhoneModel item,int id) {
// return Container(
// margin: EdgeInsets.symmetric(horizontal: 16.w),
// child: ListTile(
// onTap: () {
// showDialog(
// context: context,
// builder: (context) {
// return CupertinoAlertDialog(
// title: Text(
// "修改名称",
// style: TextStyle(
// color: BaseStyle.color333333, fontSize: 34.sp),
// ),
// content: Column(
// children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// "名称",
// style: TextStyle(
// fontSize: 28.sp,
// color: BaseStyle.color999999,
// ),
// ),
// 24.hb,
// CupertinoTextField(
// padding: EdgeInsets.symmetric(
// horizontal: 24.w, vertical: 20.w),
// decoration: BoxDecoration(
// border: Border.all(color: Colors.white),
// // borderRadius: BorderRadius.all(
// // Radius.circular(4.w)
// // ),
// color: const Color(0xFFF9F9F9)),
// placeholderStyle:
// const TextStyle(color: BaseStyle.color333333),
// placeholder: item.remark,
// onChanged: (value) {
// name=value;
// setState(() {});
// },
// ),
// 20.hb,
// Text(
// "号码",
// style: TextStyle(
// fontSize: 28.sp,
// color: BaseStyle.color999999,
// ),
// ),
// 24.hb,
// CupertinoTextField(
// padding: EdgeInsets.symmetric(
// horizontal: 24.w, vertical: 20.w),
// decoration: BoxDecoration(
// border: Border.all(color: Colors.white),
// // borderRadius: BorderRadius.all(
// // Radius.circular(4.w)
// // ),
// color: const Color(0xFFF9F9F9)),
// placeholder: item.phone,
// onChanged: (value) {
// phone=value;
// setState(() {});
// },
// ),
// 82.hb,
// // _getUpdate("爸爸", "123123123"),
// PloneBottom(
// blM: false,
// border: true,
// color1: const Color(0xFF1890FF),
// color2: const Color(0xFF74BCFF),
// onTap: () async{
// Navigator.pop(context);
// var res=await ExcludeFunc.getUpdate(id, phone, item.remark.isEmpty?name:item.remark);
// _refreshController.callRefresh();
// print(res);
// },
// text: "保存",
// )
// ],
// ),
// ],
// ),
// );
// });
// },
// title: Text(
// item.remark.isEmpty? item.phone:item.remark,
// style: TextStyle(
// fontSize: 32.sp,
// color: BaseStyle.color333333,
// fontWeight: FontWeight.bold)),
// subtitle: Text(
// item.address,
// style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
// ),
// trailing: TextButton(
// style: ButtonStyle(
// side: MaterialStateProperty.all(
// BorderSide(width: 2.w, color: const Color(0xFFE8E8E8)))),
// onPressed: () async {
// print(id);
// var res =
// await apiClient.request(API.exclude.delete, data: {"id":id});
// if (res.code == 0) {
// _refreshController.callRefresh();
// CloudToast.show(res.msg);
// } else {
// CloudToast.show(res.msg);
// }
// },
// child: Text(
// "删除",
// style: TextStyle(fontSize: 28.sp, color: BaseStyle.color333333),
// ),
// ),
// ),
// );
// }
//
// _getAddPhone(String title, String text, VoidCallback widget) {
// return GestureDetector(
// onTap: widget,
// child: ListTile(
// title: Text(
// title,
// style: TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold),
// ),
// subtitle: Text(
// text,
// style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
// ),
// trailing: const Icon(Icons.chevron_right),
// ),
// );
// }
//
// _getNullList() {
// return Column(
// mainAxisAlignment: MainAxisAlignment.center,
// // crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// 490.hb,
// Image.asset(
// Assets.icons.nullphonelist.path,
// width: 240.w,
// height: 212.w,
// fit: BoxFit.fill,
// ),
// 48.hb,
// Text(
// "这里是空的",
// style: TextStyle(
// color: const Color(0xFF999999),
// fontWeight: FontWeight.bold,
// fontSize: 36.sp),
// ),
// 16.hb,
// Text(
// "还没有添加指定号码",
// style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
// ),
// 490.hb,
// ],
// );
// }
// }
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:project_telephony/constants/api.dart';
import 'package:project_telephony/model/network/api_client.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/widget/plone_bottom.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/toast/cloud_toast.dart';
import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart';
import '../../../base/base_style.dart';
import '../../../model/exclude_phone_model.dart';
import '../../../providers/user_provider.dart';
import '../../widget/scaffold_theme_widget.dart';
import 'call_records_list.dart';
import 'func/exclude_contacts_func.dart';
class SpecifyPhonePage extends StatefulWidget {
const SpecifyPhonePage({Key? key}) : super(key: key);
@override
_SpecifyPhonePageState createState() => _SpecifyPhonePageState();
}
class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
final EasyRefreshController _refreshController = EasyRefreshController();
List<ExcludePhoneModel> findList = [];
String name="";
String phone="";
@override
void dispose() {
_refreshController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ScaffoldThemeWidget(
wid: 196,
title: "指定号码",
bottom: '添加',
onTap: () {
showModalBottomSheet(
builder: (BuildContext context) {
return Container(
width: double.infinity,
height: 750.w,
padding: EdgeInsets.symmetric(horizontal: 32.w),
child: Column(
children: [
48.hb,
Text(
"添加号码",
style: TextStyle(
fontSize: 34.w, fontWeight: FontWeight.bold),
),
Expanded(
child: ListView(
children: [
// _getAddPhone("通话记录添加", "通过本机通话记录添加号码", () {
// Navigator.of(context)
// .push(
// MaterialPageRoute(
// builder: (_) => const CallRecordsList()),
// )
// .then((val) =>_refreshController.callRefresh());
//
// // Get.to(() => const CallRecordsList());
// }),
_getAddPhone("通迅录添加", "通过本机通讯录添加号码", () {
Navigator.of(context)
.push(
MaterialPageRoute(
builder: (_) => const ExcludeContactsPage()),
)
.then((val) =>_refreshController.callRefresh());
}),
// _getAddPhone("添加单个或批量号码", "通过输入号码段添加批量号码", () {
// Navigator.of(context)
// .push(
// MaterialPageRoute(
// builder: (_) => const ExcludeSinglePage()),
// )
// .then((val) =>_refreshController.callRefresh());
// }),
],
)),
PloneBottom(
onTap: () {
Navigator.pop(context);
},
hPadding: 32,
border: true,
textColor: const Color(0xFF1890FF),
color2: const Color(0xFFF9F9F9),
color1: const Color(0xFFF9F9F9),
text: "取消",
),
32.hb
],
),
);
},
context: context);
},
child: EasyRefresh(
firstRefresh: true,
controller: _refreshController,
header: MaterialHeader(),
// footer: MaterialFooter(),
onRefresh: () async {
findList = await ExcludeFunc.getContacts();
UserTool.userProvider.viewLoading();
// await userProvider.updateUserInfo();
setState(() {});
},
child: findList.isEmpty ? _getNullList() : _getNum()
// ListView(
// children: [findList.isEmpty ? _getNullList() : _getNum()],
// )
),
);
}
_getNum() {
return ListView.builder(
itemBuilder: (context, index) {
return _getNumContant(findList[index],findList[index].id);
},
itemCount: findList.length,
);
}
_getNumContant(ExcludePhoneModel item,int id) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 16.w),
child: ListTile(
onTap: () {
showDialog(
context: context,
builder: (context) {
return CupertinoAlertDialog(
title: Text(
"修改名称",
style: TextStyle(
color: BaseStyle.color333333, fontSize: 34.sp),
),
content: Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"名称",
style: TextStyle(
fontSize: 28.sp,
color: BaseStyle.color999999,
),
),
24.hb,
CupertinoTextField(
padding: EdgeInsets.symmetric(
horizontal: 24.w, vertical: 20.w),
decoration: BoxDecoration(
border: Border.all(color: Colors.white),
// borderRadius: BorderRadius.all(
// Radius.circular(4.w)
// ),
color: const Color(0xFFF9F9F9)),
placeholderStyle:
const TextStyle(color: BaseStyle.color333333),
placeholder: item.remark,
onChanged: (value) {
name=value;
setState(() {});
},
),
20.hb,
Text(
"号码",
style: TextStyle(
fontSize: 28.sp,
color: BaseStyle.color999999,
),
),
24.hb,
CupertinoTextField(
padding: EdgeInsets.symmetric(
horizontal: 24.w, vertical: 20.w),
decoration: BoxDecoration(
border: Border.all(color: Colors.white),
// borderRadius: BorderRadius.all(
// Radius.circular(4.w)
// ),
color: const Color(0xFFF9F9F9)),
placeholder: item.phone,
onChanged: (value) {
phone=value;
setState(() {});
},
),
82.hb,
// _getUpdate("爸爸", "123123123"),
PloneBottom(
blM: false,
border: true,
color1: const Color(0xFF1890FF),
color2: const Color(0xFF74BCFF),
onTap: () async{
Navigator.pop(context);
var res=await ExcludeFunc.getUpdate(id, phone, item.remark.isEmpty?name:item.remark);
_refreshController.callRefresh();
print(res);
},
text: "保存",
)
],
),
],
),
);
});
},
title: Text(
item.remark.isEmpty? item.phone:item.remark,
style: TextStyle(
fontSize: 32.sp,
color: BaseStyle.color333333,
fontWeight: FontWeight.bold)),
subtitle: Text(
item.address,
style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
),
trailing: TextButton(
style: ButtonStyle(
side: MaterialStateProperty.all(
BorderSide(width: 2.w, color: const Color(0xFFE8E8E8)))),
onPressed: () async {
print(id);
var res =
await apiClient.request(API.exclude.delete, data: {"id":id});
if (res.code == 0) {
_refreshController.callRefresh();
CloudToast.show(res.msg);
} else {
CloudToast.show(res.msg);
}
},
child: Text(
"删除",
style: TextStyle(fontSize: 28.sp, color: BaseStyle.color333333),
),
),
),
);
}
_getAddPhone(String title, String text, VoidCallback widget) {
return GestureDetector(
onTap: widget,
child: ListTile(
title: Text(
title,
style: TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold),
),
subtitle: Text(
text,
style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
),
trailing: const Icon(Icons.chevron_right),
),
);
}
_getNullList() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
490.hb,
Image.asset(
Assets.icons.nullphonelist.path,
width: 240.w,
height: 212.w,
fit: BoxFit.fill,
),
48.hb,
Text(
"这里是空的",
style: TextStyle(
color: const Color(0xFF999999),
fontWeight: FontWeight.bold,
fontSize: 36.sp),
),
16.hb,
Text(
"还没有添加指定号码",
style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
),
490.hb,
],
);
}
}

@ -7,6 +7,7 @@ import 'package:project_telephony/utils/headers.dart';
import 'package:provider/provider.dart';
import '../providers/user_provider.dart';
import 'login/login_page.dart';

@ -48,7 +48,7 @@ class _LoginPageState extends State<LoginPage> {
late FocusNode _smsCodeFocusNode;
bool _cantSelected = false;
DateTime? _lastTap;
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
@override
void initState() {
super.initState();
@ -167,11 +167,8 @@ class _LoginPageState extends State<LoginPage> {
});
if (base.code == 0) {
await userProvider.setToken(base.data['token']);
userProvider.viewLoading();
await UserTool.userProvider.setToken(base.data['token']);
Get.offAll(const TabNavigator());
if (UserTool.userProvider.userInfo.havePwd == 0) {
Get.to(() => const SetPasswordPage());
}

@ -15,7 +15,6 @@ import '../../gen/assets.gen.dart';
import '../../model/network/api_client.dart';
import '../../providers/user_provider.dart';
import '../../utils/toast/cloud_toast.dart';
import '../../utils/user_tool.dart';
import '../tab_navigator.dart';
import '../user/content_authority_page.dart';
import '../widget/image_scaffold.dart';
@ -137,7 +136,8 @@ class _LoginPsdPageState extends State<LoginPsdPage> {
});
if (base.code == 0) {
await userProvider.setToken(base.data['token']);
userProvider.viewLoading();
// userProvider.viewLoading();
// UserTool.userProvider.viewLoading();
Get.offAll(const TabNavigator());
} else {
CloudToast.show(base.msg);

@ -8,29 +8,30 @@ class BaseModel<T> {
int code;
String msg;
dynamic data;
BaseModel({
required this.code,
required this.msg,
this.data,
});
List<T> map(T Function(dynamic json) f) {
if (data == null) return [];
return (data! as List<T>).map(f).toList();
}
factory BaseModel.unknown() => BaseModel(
code: -1,
msg: 'UNKNOW FAIL',
);
code: -1,
msg: 'UNKNOW FAIL',
);
factory BaseModel.dioErr(DioError err) => BaseModel(
code: err.response?.statusCode ?? -1,
msg: err.message,
);
code: err.response?.statusCode ?? -1,
msg: err.message,
);
factory BaseModel.fromJson(Map<String, dynamic> json) =>
_$BaseModelFromJson(json) as BaseModel<T>;
Map<String, dynamic> toJson() => _$BaseModelToJson(this);
}

@ -11,3 +11,10 @@ BaseModel<T> _$BaseModelFromJson<T>(Map<String, dynamic> json) => BaseModel<T>(
msg: json['msg'] as String,
data: json['data'],
);
Map<String, dynamic> _$BaseModelToJson<T>(BaseModel<T> instance) =>
<String, dynamic>{
'code': instance.code,
'msg': instance.msg,
'data': instance.data,
};

@ -225,6 +225,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
dbus:
dependency: transitive
description:
name: dbus
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.3"
decimal:
dependency: transitive
description:
@ -331,21 +338,17 @@ packages:
flutter_background_service:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: ee40fe3df73119bc7064e34d36fc7d8a0194e651
url: "https://git.oa00.com/austin_dai/flutter_background_service.git"
source: git
version: "2.1.3"
name: flutter_background_service
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.5"
flutter_background_service_android:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: "63a2277119558ed55de1098b5c05040ef9ff845d"
url: "https://git.oa00.com/austin_dai/flutter_background_service_android.git"
source: git
version: "2.0.3"
name: flutter_background_service_android
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
flutter_background_service_ios:
dependency: transitive
description:
@ -402,6 +405,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
url: "https://pub.dartlang.org"
source: hosted
version: "12.0.2"
flutter_local_notifications_linux:
dependency: transitive
description:
name: flutter_local_notifications_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.0"
flutter_native_splash:
dependency: "direct dev"
description:
@ -1083,6 +1107,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
timezone:
dependency: transitive
description:
name: timezone
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.0"
timing:
dependency: transitive
description:

@ -24,13 +24,19 @@ dependencies:
git:
url: https://git.oa00.com/austin_dai/permission_handler.git
# 后台设置
flutter_background_service: ^2.4.5
flutter_background_service_android: ^3.0.2
flutter_local_notifications: ^12.0.2
# flutter_background_service: ^2.4.3
flutter_background_service:
git:
url: https://git.oa00.com/austin_dai/flutter_background_service.git
flutter_background_service_android:
git:
url: https://git.oa00.com/austin_dai/flutter_background_service_android.git
# flutter_background_service:
# git:
# url: https://git.oa00.com/austin_dai/flutter_background_service.git
# flutter_background_service_android:
# git:
# url: https://git.oa00.com/austin_dai/flutter_background_service_android.git
# flutter_local_notifications: ^12.0.2
device_info_plus: any
# 屏幕适配
flutter_screenutil: ^5.5.3+2

Loading…
Cancel
Save