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

@ -2,6 +2,7 @@
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';
@ -42,7 +43,7 @@ class MyApp extends StatefulWidget {
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
class _MyAppState extends State<MyApp> {
final telephony = Telephony.instance;
final prefs = SharedPreferences.getInstance();
Future<void> _Getpermission() async{
@ -58,9 +59,6 @@ class _MyAppState extends State<MyApp> {
// universalLink:"http://api.dxbs.vip/ "
);
}
@override
Widget build(BuildContext context) {
return MultiProvider(

@ -1,22 +1,22 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
part 'contant_list_model.g.dart';
@JsonSerializable()
class ContantListModel extends Equatable{
final int id;
final String content;
final int isChecked;
factory ContantListModel.fromJson(Map<String, dynamic> json) =>_$ContantListModelFromJson(json);
const ContantListModel({
required this.id,
required this.content,
required this.isChecked,
});
@override
List<Object?> get props => [id,content,isChecked];
}
// import 'package:equatable/equatable.dart';
// import 'package:json_annotation/json_annotation.dart';
//
// part 'contant_list_model.g.dart';
//
//
// @JsonSerializable()
// class ContantListModel extends Equatable{
// final int id;
// final String content;
// final int isChecked;
// factory ContantListModel.fromJson(Map<String, dynamic> json) =>_$ContantListModelFromJson(json);
//
//
// const ContantListModel({
// required this.id,
// required this.content,
// required this.isChecked,
// });
// @override
// List<Object?> get props => [id,content,isChecked];
// }

@ -1,14 +1,14 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'contant_list_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ContantListModel _$ContantListModelFromJson(Map<String, dynamic> json) =>
ContantListModel(
id: json['id'] as int,
content: json['content'] as String,
isChecked: json['is_checked'] as int,
);
// // GENERATED CODE - DO NOT MODIFY BY HAND
//
// part of 'contant_list_model.dart';
//
// // **************************************************************************
// // JsonSerializableGenerator
// // **************************************************************************
//
// ContantListModel _$ContantListModelFromJson(Map<String, dynamic> json) =>
// ContantListModel(
// id: json['id'] as int,
// content: json['content'] as String,
// isChecked: json['is_checked'] as int,
// );

@ -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,
// );

@ -5,36 +5,24 @@ part 'update_model.g.dart';
@JsonSerializable()
class UpdateModel extends Equatable {
final int updateStatus;
final int versionCode;
final String versionCode;
final String versionName;
final String modifyContent;
final String downloadUrl;
final String apkSize;
final String apkMd5;
factory UpdateModel.fromJson(Map<String, dynamic> json) =>
_$UpdateModelFromJson(json);
const UpdateModel({
required this.updateStatus,
required this.versionCode,
required this.versionName,
required this.modifyContent,
required this.downloadUrl,
required this.apkSize,
required this.apkMd5,
});
@override
List<Object?> get props => [
updateStatus,
versionCode,
versionName,
modifyContent,
downloadUrl,
apkSize,
apkMd5,
];
}

@ -7,11 +7,7 @@ part of 'update_model.dart';
// **************************************************************************
UpdateModel _$UpdateModelFromJson(Map<String, dynamic> json) => UpdateModel(
updateStatus: json['updateStatus'] as int,
versionCode: json['versionCode'] as int,
versionCode: json['versionCode'] as String,
versionName: json['versionName'] as String,
modifyContent: json['modifyContent'] as String,
downloadUrl: json['downloadUrl'] as String,
apkSize: json['apkSize'] as String,
apkMd5: json['apkMd5'] as String,
);

@ -6,6 +6,8 @@ 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';
import '../model/user_info_model.dart';
@ -35,10 +37,10 @@ class UserProvider extends ChangeNotifier {
_isLogin = true;
apiClient.setToken(token);
await updateUserInfo();
updateConSms();
updateRefSms();
updateCallSms();
updateIdleSms();
// updateConSms();
// updateRefSms();
// updateCallSms();
// updateIdleSms();
return true;
} else {
_isLogin = false;
@ -57,23 +59,24 @@ class UserProvider extends ChangeNotifier {
apiClient.setToken(token);
await HiveStore.appBox!.put('token', token);
_isLogin = true;
//app
await updateUserInfo();
prefs.setInt("numIndex", 0);
_viewLoading();
UserTool.phoneNumProvider.init();
prefs.setStringList("dxText", [
"祝你万事顺心",
"欢迎你的来电,祝你生活愉快",
"感谢您的来电,我们会尽快处理",
]);
// app
updateUserInfo();
prefs.setInt("numIndex", 0);//
// _viewLoading();//
// UserTool.phoneNumProvider.init();
// prefs.setStringList("dxText", [
// "祝你万事顺心",
// "欢迎你的来电,祝你生活愉快",
// "感谢您的来电,我们会尽快处理",
// ]);
// prefs.setStringList("dxText",["祝你万事顺心","欢迎你的来电,祝你生活愉快","感谢您的来电,我们会尽快处理",]);
updateConSms();
updateRefSms();
updateCallSms();
updateIdleSms();
viewLoading();
getExclude();
// updateConSms();
// updateRefSms();
// updateCallSms();
// updateIdleSms();
// viewLoading();
// getExclude();
}
Future logout() async {
@ -120,112 +123,131 @@ class UserProvider extends ChangeNotifier {
notifyListeners();
}
Future updateRefSms() async {
final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService();
var base = await apiClient.request(API.content.find, data: {'status': 2});
if (base.code == 0) {
await prefs.remove('refSms');
await prefs.setString(
'refSms',
(UserTool.userProvider.userInfo.tag) == ""
? "${base.data['content']}"
: "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async {
service.startService();
});
}
} else {
CloudToast.show(base.msg);
}
notifyListeners();
}
// Future updateRefSms() async {
// final prefs = await SharedPreferences.getInstance();
// final service = FlutterBackgroundService();
// var base = await apiClient.request(API.content.find, data: {'status': 2});
// if (base.code == 0) {
// await prefs.remove('refSms');
// await prefs.setString(
// 'refSms',
// (UserTool.userProvider.userInfo.tag) == ""
// ? "${base.data['content']}"
// : "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
// service.invoke("stopService");
// if (prefs.getBool('kg') ?? false) {
// Future.delayed(const Duration(seconds: 1), () async {
// service.startService();
// });
// }
// } else {
// CloudToast.show(base.msg);
// }
// notifyListeners();
// }
//
// Future updateCallSms() async {
// final prefs = await SharedPreferences.getInstance();
// final service = FlutterBackgroundService();//
// var base = await apiClient.request(API.content.find, data: {'status': 3});
// if (base.code == 0) {
// await prefs.remove('callSms');
// await prefs.setString(
// 'callSms',
// (UserTool.userProvider.userInfo.tag) == ""
// ? "${base.data['content']}"
// : "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
// service.invoke("stopService");
// if (prefs.getBool('kg') ?? false) {
// Future.delayed(const Duration(seconds: 1), () async {
// service.startService();
// });
// }
// } else {
// CloudToast.show(base.msg);
// }
// notifyListeners();
// }
//
// Future updateIdleSms() async {
// final prefs = await SharedPreferences.getInstance();
// final service = FlutterBackgroundService();
// var base = await apiClient.request(API.content.find, data: {'status': 4});
// if (base.code == 0) {
// await prefs.remove('idleSms');
// await prefs.setString(
// 'idleSms',
// (UserTool.userProvider.userInfo.tag) == ""
// ? "${base.data['content']}"
// : "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
// service.invoke("stopService");
// if (prefs.getBool('kg') ?? false) {
// Future.delayed(const Duration(seconds: 1), () async {
// service.startService();
// });
// }
// } else {
// CloudToast.show(base.msg);
// }
// notifyListeners();
// }
//
// Future getExclude() async {
// final prefs = await SharedPreferences.getInstance();
// final service = FlutterBackgroundService();
// var base = await apiClient.request(API.exclude.find);
// if (base.code == 0) {
// await prefs.remove('exclude');
// prefs.setStringList('exclude', base.data);
// service.invoke("stopService");
// if (prefs.getBool('kg') ?? false) {
// Future.delayed(const Duration(seconds: 1), () async {
// service.startService();
// });
// }
// } else {
// CloudToast.show(base.msg);
// }
// notifyListeners();
// }
Future updateCallSms() async {
final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService();
var base = await apiClient.request(API.content.find, data: {'status': 3});
if (base.code == 0) {
await prefs.remove('callSms');
await prefs.setString(
'callSms',
(UserTool.userProvider.userInfo.tag) == ""
? "${base.data['content']}"
: "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async {
service.startService();
});
}
} else {
CloudToast.show(base.msg);
}
notifyListeners();
}
Future updateIdleSms() async {
final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService();
var base = await apiClient.request(API.content.find, data: {'status': 4});
if (base.code == 0) {
await prefs.remove('idleSms');
await prefs.setString(
'idleSms',
(UserTool.userProvider.userInfo.tag) == ""
? "${base.data['content']}"
: "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async {
service.startService();
});
}
} else {
CloudToast.show(base.msg);
}
notifyListeners();
}
Future getExclude() async {
final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService();
var base = await apiClient.request(API.exclude.find);
if (base.code == 0) {
await prefs.remove('exclude');
await prefs.setStringList('exclude', base.data ?? []);
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async {
service.startService();
});
}
} else {
CloudToast.show(base.msg);
}
notifyListeners();
}
Future viewLoading( ) async {
List<String>? numList=[];
List<String>? numbers=[];
List<String> numList=[];
List<String> numbers=[];
List<String> nameList=[];
List<PhoneModel> massList = [];
List<PhoneNum> phoneList = [];
final service = FlutterBackgroundService();
final SharedPreferences prefs = await SharedPreferences.getInstance();
var contact = await FlutterContacts.getContacts();
for (var element in contact) {
var numberList = await ExcludeFunc.getContacts() ;
List<Contact> contact = await FlutterContacts.getContacts();//
for (var element in contact ) {
final full = await FlutterContacts.getContact(element.id);
numbers.add(full!.phones.first.number.replaceAll(" ", ""));
if(full?.phones.length==0){
numbers.add('');
}else{
numbers.add(full!.phones.first.number.replaceAll(" ", ""));
nameList.add(full.displayName);
numbers.add(full.phones.first.number);
phoneList.add(PhoneNum(name: full.displayName, phone: full.phones.first.number,state: false));
// phoneList.add(PhoneNumModel(time: 0, name: full!.displayName, state: false, num: full.phones.first.number));
// numbers.add(full!.phones.first.number);
}
// status.add(false);
}
var numberList = await ExcludeFunc.getContacts();
// print("numbersList$numberList");
for (int i = 0; i < numberList.length; i++) {
numList.add(numberList[i].phone);
}
await prefs.setStringList("specified", numList);
await prefs.setStringList("addressList", numbers);
await HiveStore.dataBox!.put("pl",phoneList) ;
massList.add(PhoneModel(title:"未分组联系人",time: "本机通讯录",phoneList:HiveStore.dataBox!.get("pl"),state: false));
HiveStore.dataBox?.put("ml",massList) ;
prefs.setStringList("specified", numList);
prefs.setStringList("addressList", numbers);
prefs.setStringList("nameList",nameList );
prefs.setStringList("number", numbers);
service.invoke("stopService");
// print("指定不发送${prefs.getStringList("specified")}");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async {
service.startService();
@ -234,27 +256,27 @@ class UserProvider extends ChangeNotifier {
notifyListeners();
}
Future _viewLoading() async {
List<Contact>? contacts;
List<String> numbers=[];
List<String> nameList=[];
final SharedPreferences prefs = await SharedPreferences.getInstance();
contacts = await FlutterContacts.getContacts();
for (var element in contacts) {
final full = await FlutterContacts.getContact(element.id);
if(full?.phones.length==0){
numbers.add('');
}else{
nameList.add(full!.displayName);
numbers.add(full.phones.first.number);
// phoneList.add(PhoneNumModel(time: 0, name: full!.displayName, state: false, num: full.phones.first.number));
// numbers.add(full!.phones.first.number);
}
}
await prefs.setStringList("nameList",nameList );
prefs.setStringList("number", numbers);
// print(contacts.length);
notifyListeners();
}
// Future _viewLoading() async {
// List<Contact>? contacts;
// List<String> numbers=[];
// List<String> nameList=[];
// final SharedPreferences prefs = await SharedPreferences.getInstance();
// contacts = await FlutterContacts.getContacts();
// for (var element in contacts) {
// final full = await FlutterContacts.getContact(element.id);
// if(full?.phones.length==0){
// numbers.add('');
// }else{
// nameList.add(full!.displayName);
// numbers.add(full.phones.first.number);
// // phoneList.add(PhoneNumModel(time: 0, name: full!.displayName, state: false, num: full.phones.first.number));
// // numbers.add(full!.phones.first.number);
// }
// }
// prefs.setStringList("nameList",nameList );
// prefs.setStringList("number", numbers);
// // print(contacts.length);
// notifyListeners();
// }
}

@ -1,243 +1,243 @@
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),
// )
],
),
);
}
}
// 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 +1,234 @@
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,
);
}
}
// 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 +1,280 @@
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
),
),
),
),
],
),
);
}
}
// 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 +1,191 @@
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),
),
),
);
}
}
// 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),
// ),
// ),
// );
// }
// }

@ -1,134 +1,134 @@
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),
);
}
}
// 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 +1,279 @@
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;
}
// 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;
// }

@ -3,23 +3,15 @@ import 'dart:ui';
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:shared_preferences/shared_preferences.dart';
import 'package:telephony/telephony.dart';
Future<void> initializeService() async {
// SharedPreferences preferences = await SharedPreferences.getInstance();
SharedPreferences.getInstance();
final service = FlutterBackgroundService();
await service.configure(
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,
),
iosConfiguration: IosConfiguration(
// auto start service
autoStart: true,
@ -28,10 +20,16 @@ Future<void> initializeService() async {
// you have to enable background fetch capability on xcode project
onBackground: onIosBackground,
),
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,
),
);
service.startService();
}
// }
bool onIosBackground(ServiceInstance service) {
WidgetsFlutterBinding.ensureInitialized();
@ -41,162 +39,76 @@ bool onIosBackground(ServiceInstance service) {
void onStart(ServiceInstance service) async {
DartPluginRegistrant.ensureInitialized();
service.on("stopService").listen((event) {
service.stopSelf();
});
//
int flag = 0;
String? phoneNum = "";
String callState;
service.on('stopService').listen((event) {
service.stopSelf();
});
Timer.periodic(const Duration(seconds: 1), (timer) async {
//
final SharedPreferences prefs = await SharedPreferences.getInstance();
//
CallState state = await Telephony.instance.callState;
callState = state.name;
// print("$callState$flag");
// print(entry.first.duration);
String? ref = prefs.getString('refSms');
String? con = prefs.getString('conSms');
String? call = prefs.getString('callSms');
String? idle = prefs.getString('idleSms');
bool? callSw = prefs.getBool('callSwitch') ?? true;
bool? idleSw = prefs.getBool('idleSwitch') ?? true;
//
String content = prefs.getString("refSms")!;
//
int? numberSet = prefs.getInt("numIndex") ?? 0;
List<String>? numberList = prefs.getStringList("addressList") ??[] ;
List<String>? noNumberList = prefs.getStringList("specified") ??[];
print("号码设置$numberSet 通讯列表$numberList 指定不发送$noNumberList");
print("号码设置$numberSet 发送内容$content");
if (callState == "IDLE") {
if (flag != 0) {
final Iterable<CallLogEntry> entry = await CallLog.query();
phoneNum = entry.first.number;
print(phoneNum);
// if()
// print(phoneNum);
switch (numberSet) {
case 0:
if (!(noNumberList.contains(phoneNum))) {
if (flag > 0) {
// print("来电拒接/未接");
// print("${phoneNum!}:${ref!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: ref!);
// print("发送成功");
} else if (flag == -1) {
print("来电接听");
print("${phoneNum!}:${con!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: con);
} else {
if (entry.first.duration! > 0) {
if (callSw) {
print(callSw);
print("${phoneNum!}:${call!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: call);
}
print("去电接听");
} else {
if (idleSw) {
print(idleSw);
print("${phoneNum!}:${idle!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: idle);
}
print("去电未接");
}
print("发送成功");
}
flag = 0;
}else{
print("123412434124132312232341241242321312312323123323");
}
print("所有都发");
// Telephony.backgroundInstance
// .sendSms(to: phoneNum!, message: content);
flag = 0;
break;
case 1:
if ((numberList.contains(phoneNum)) &&
!(noNumberList.contains(phoneNum))) {
if (flag > 0) {
print("来电拒接/未接");
print("${phoneNum!}:${ref!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: ref);
print("发送成功");
} else if (flag == -1) {
print("来电接听");
print("${phoneNum!}:${con!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: con);
} else {
if (entry.first.duration! > 0) {
if (callSw) {
print(callSw);
print("${phoneNum!}:${call!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: call);
}
print("去电接听");
} else {
if (idleSw) {
print(idleSw);
print("${phoneNum!}:${idle!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: idle);
}
print("去电未接");
}
print("发送成功");
}
flag = 0;
}else{
print("123412434124132312232341241242321312312323123323");
if (flag > 0) {
print("来电拒接");
// print("来电拒接/未接");
// print("${phoneNum!}:${ref!}");
// Telephony.backgroundInstance
// .sendSms(to: phoneNum!, message: content);
// print("发送成功");
} else if (flag == -1) {
print("来电接听");
// print("来电接听");
// print("${phoneNum!}:$content");
// Telephony.backgroundInstance
// .sendSms(to: phoneNum!, message: content);
}
flag = 0;
break;
case 2:
if (!(numberList.contains(phoneNum)) &&
!(noNumberList.contains(phoneNum))) {
if (flag > 0) {
print("来电拒接/未接");
print("${phoneNum!}:${ref!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: ref);
print("发送成功");
} else if (flag == -1) {
print("来电接听");
print("${phoneNum!}:${con!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: con);
} else {
if (entry.first.duration! > 0) {
if (callSw) {
print(callSw);
print("${phoneNum!}:${call!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: call);
}
print("去电接听");
} else {
if (idleSw) {
print(idleSw);
print("${phoneNum!}:${idle!}");
Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: idle);
}
print("去电未接");
}
print("发送成功");
}
flag = 0;
}else{
print("123412434124132312232341241242321312312323123323");
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);
}
flag = 0;
break;
}
}
} else if (callState == "RINGING") {
//
flag = 1;
print('通话');
print("打印");
} else if (callState == "OFFHOOK") {
//
if (flag > 0) flag *= -1;
if (flag == 0) flag = -2;
print('不通话');
print("打印");
}
});
}

@ -1,326 +1,326 @@
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;
}
// 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 +1,125 @@
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;
}
// 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 +1,128 @@
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;
}
// 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;
// }

@ -11,6 +11,7 @@ import 'package:project_telephony/ui/user/privacy_rights_page.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:url_launcher/url_launcher.dart';
import '../user/content_details_page.dart';
import '../user/privacy_rights_page.dart';
import 'content_connect_page.dart';
import 'content_refuse_page.dart';
@ -69,7 +70,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
// print('版本构建号$buildNumber');
// print("服务器上的${res.versionCode}");
// print("服务器上的${res.versionName}");
if (res.versionCode > int.parse(buildNumber)) {
if (int.parse(res.versionCode )> int.parse(buildNumber)) {
// CloudToast.show("是否进行版本更新");
showDialog(
context: context,
@ -258,11 +259,12 @@ alignment: Alignment.center,
48.hb,
_getSet(),
32.hb,
_getContainer("接听后", "编辑接听后发送的短信内容", Assets.images.answer.path,
const Color(0xFF74BCFF), const Color(0xFF1890FF)),
30.hb,
_getContainer("拒接/未接后", "编辑拒接/未接后发送的短信内容", Assets.images.refused.path,
// _getContainer("接听后", "编辑接听后发送的短信内容", Assets.images.answer.path,
// const Color(0xFF74BCFF), const Color(0xFF1890FF)),
// 30.hb,
_getContainer("编辑短信", "编辑拒接/未接后发送的短信内容", Assets.images.refused.path,
const Color(0xFF72E4C8), const Color(0xFF13CA9D))
,50.hb
],
),
);
@ -317,6 +319,7 @@ alignment: Alignment.center,
_getContainer(String title, String text, String image, Color cl1, Color cl2) {
return GestureDetector(
onTap: () async {
Get.to(() => ContentDetailsPage(ploneBack: (String textContent) { }, content: '',));
// Get.to(()=>UpdatePage());
// FlutterXUpdate.checkUpdate(
// // topImageRes:'vipbanner',
@ -333,12 +336,12 @@ alignment: Alignment.center,
// print(version);
// print(buildNumber); supportSilentInstall:
// print(title);
if (title == "接听后") {
Get.to(() => const ContentConnectPage());
} else {
Get.to(() => const ContentRefusePage());
// print("未接听");
}
// if (title == "接听后") {
// Get.to(() => const ContentConnectPage());
// } else {
// Get.to(() => const ContentRefusePage());
// // print("未接听");
// }
},
child: Container(
decoration: BoxDecoration(
@ -348,24 +351,24 @@ alignment: Alignment.center,
end: Alignment.centerRight,
colors: [cl1, cl2])),
width: 622.w,
height: 192.w,
height: 300.w,
child: Row(
children: [
Container(
padding: EdgeInsets.only(top: 40.w, left: 50.w),
padding: EdgeInsets.only(top: 100.w, left: 50.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title,
style: TextStyle(
fontSize: 36.sp,
fontSize: 60.sp,
color: const Color(0xFFFFFFFF),
fontWeight: FontWeight.bold)),
16.hb,
Text(
text,
style: TextStyle(
fontSize: 27.sp,
fontSize: 28.sp,
color: const Color(0xFFFFFFFF).withOpacity(0.6)),
),
],
@ -373,7 +376,7 @@ alignment: Alignment.center,
),
const Spacer(),
Padding(
padding: EdgeInsets.only(top: 40.w),
padding: EdgeInsets.only(top: 148.w),
child: Image.asset(
image,
width: 166.w,

@ -25,13 +25,10 @@ class UserInfoFunc {
return UpdateModel.fromJson(res.data);
} else {
return const UpdateModel(
versionCode: 0,
updateStatus: 0,
versionCode: "",
versionName: '',
modifyContent: '',
apkSize: '',
apkMd5: '',
downloadUrl: '');
);
}
}
}

@ -1,202 +1,200 @@
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();
// 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();
// }
// });
// return ScaffoldThemeWidget(
// bottom: '添加',
// title: '从通话记录添加',
// isBorder: true,
// isOpacity: false,
// onTap: () {
// // _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");
// // })
// // ],
// // );
// }
//
// },
// 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),
)
],
),
);
}
}
// _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,18 @@
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:shared_preferences/shared_preferences.dart';
import '../../../base/base_style.dart';
import '../../widget/plone_back_button.dart';
import '../call.dart';
import '../home_page.dart';
// class setItem{
//
// }
class PhoneSetPage extends StatefulWidget {
const PhoneSetPage({Key? key}) : super(key: key);
@ -26,8 +26,39 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
List<Contact>? contact;
List<String> numbers = [];
List<String>? numList = [];
bool vle=false;
bool isVip=false;
String? endDate;
final EasyRefreshController _refreshController = EasyRefreshController();
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
final EasyRefreshController _easyRefreshController=EasyRefreshController();
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": "任意来源号码发送",
@ -36,14 +67,14 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
},
{
"icon": Assets.icons.txlphone.path,
"title": "在通讯录中的号码发送",
"text": "给在通讯录中的号码来电发送",
"title": "来电接听/挂断",
"text": "发来电",
// "select": false,
},
{
"icon": Assets.icons.notxlphone.path,
"title": "不在通讯录中的号码发送",
"text": "给不在通讯录中的号码来电发送",
"title": "去电接听/挂断",
"text": "发去电",
// "select": false,
},
];
@ -52,7 +83,11 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
void initState() {
super.initState();
}
@override
void dispose() {
_easyRefreshController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -78,74 +113,127 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
final SharedPreferences prefs = await SharedPreferences.getInstance();
print(prefs.getInt("numIndex"));
select = (prefs.getInt("numIndex")) ?? 0;
_getRequests();
// _viewLoading();
setState(() {});
},
child: ListView(
children: [
// _getSwitch(),
_getList(),
24.hb,
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),
)),
),
)
// 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),
// )),
// ),
// )
],
),
)
// Column(
// children: [
//
//
//
// ],
// ),
);
}
_getList() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 30.w),
height: 500.w,
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w),
height: 640.w,
child: ListView.builder(
itemBuilder: (context, index) {
return _getListBox(setList, index);
return _getListBox(setList, index,index!=0);
},
itemCount: setList.length,
),
);
}
//
// _getSwitch() {
// return Container(
// padding: EdgeInsets.symmetric(horizontal: 32.w),
// child: ListTile(
// // onTap: (() {}),
// leading: Image.asset(
// Assets.icons.switch1.path,
// height: 54.w,
// width: 56.w,
// fit: BoxFit.fill,
// ),
// title: Text(
// "功能开关",
// style: TextStyle(
// color: BaseStyle.color333333,
// fontSize: BaseStyle.fontSize34,
// fontWeight: FontWeight.bold),
// ),
// trailing: Checkbox(
// value: vle,
// //
// onChanged: (value) {
// setState(() {
// vle=value!;
// });
// },
// //
// activeColor: Colors.blue,
// //
// checkColor: Colors.white,
// ),
//
//
// // Switch(
// // value: vle,
// // onChanged: (value) async {
// // final SharedPreferences prefs = await _prefs;
// // setState(() {
// // if (isVip) {
// // vle = value;
// // if (vle) {
// // print("true");
// // prefs.remove("kg");
// // prefs.setBool("kg", vle);
// // service.startService();
// // initializeService();
// // BotToast.showText(text: " 你开启了该功能");
// // } else {
// // prefs.remove("kg");
// // prefs.setBool("kg", vle);
// // service.invoke("stopService");
// // BotToast.showText(text: "你已经关闭该功能");
// // }
// // } else {
// // BotToast.showText(text: "还没有开通会员,不可使用该功能");
// // }
// // });
// // }),
// ));
// }
// Future _viewLoading() async {
// final SharedPreferences prefs = await SharedPreferences.getInstance();
// contact = await FlutterContacts.getContacts();
@ -184,24 +272,54 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
// // }
// setState(() {});
// }
_getListBox(List item, int index) {
_getRequests() async {
UserTool.userProvider.updateUserInfo();
if (UserTool.userProvider.isLogin) {
// print(UserTool.userProvider.userInfo.end * 1000);
// print(DateTime.now().millisecondsSinceEpoch);
if (UserTool.userProvider.userInfo.isVip != 1) {
isVip = false;
vle = false;
// UserTool.userProvider.updateUserInfo();
_easyRefreshController.callRefresh();
} else {
isVip = true;
vle = await service.isRunning();
// print(vle);
// _easyRefreshController.callRefresh();
}
//service.isRunning() as bool;
// endDate = DateUtil.formatDateMs(
// UserTool.userProvider.userInfo.end * 1000,
// format: DateFormats.y_mo_d);
} else {
vle = false;
}
//
setState(() {});
}
_getListBox(List item, int index,bool kg) {
final service = FlutterBackgroundService();
return GestureDetector(
onTap: () async {
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 {
service.startService();
});
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);
}
UserTool.userProvider.viewLoading();
_refreshController.callRefresh();
// print(_selectIndex);
setState(() {});
},
child: ListTile(
@ -223,7 +341,8 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
trailing: SizedBox(
width: 40.w,
height: 40.w,
child: Radio(
child: kg?
Radio(
onChanged: (int? value) async{
// final SharedPreferences prefs = await SharedPreferences.getInstance();
// select = index;
@ -242,6 +361,46 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
},
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,
),
),

@ -1,310 +1,310 @@
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/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,
// ],
// );
// }
// }

@ -10,11 +10,13 @@ import 'package:project_telephony/ui/login/login_psd_page.dart';
import 'package:project_telephony/ui/user/set_password_page.dart';
import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:provider/provider.dart';
import '../../base/base_style.dart';
import '../../constants/api.dart';
import '../../constants/environment/environment.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';
@ -46,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);
@override
void initState() {
super.initState();
@ -165,11 +167,11 @@ class _LoginPageState extends State<LoginPage> {
});
if (base.code == 0) {
print("1");
await UserTool.userProvider.setToken(base.data['token']);
print("2");
await userProvider.setToken(base.data['token']);
userProvider.viewLoading();
Get.offAll(const TabNavigator());
print("3");
if (UserTool.userProvider.userInfo.havePwd == 0) {
Get.to(() => const SetPasswordPage());
}

@ -6,14 +6,14 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:project_telephony/extensions/num_ext.dart';
import 'package:project_telephony/ui/login/login_page.dart';
import 'package:provider/provider.dart';
import '../../base/base_style.dart';
import '../../constants/api.dart';
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';
@ -35,7 +35,7 @@ class _LoginPsdPageState extends State<LoginPsdPage> {
late TextEditingController _pwdController;
DateTime? _lastTap;
late bool _showPwd = true;
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
@override
void initState() {
super.initState();
@ -136,14 +136,11 @@ class _LoginPsdPageState extends State<LoginPsdPage> {
'password': _pwdController.text
});
if (base.code == 0) {
print("1");
await UserTool.userProvider.setToken(base.data['token']);
print("2");
Get.offAll(const TabNavigator());
print("3");
await userProvider.setToken(base.data['token']);
userProvider.viewLoading();
Get.offAll(const TabNavigator());
} else {
CloudToast.show(base.msg);
}
}
},

@ -2,8 +2,6 @@ import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:project_telephony/ui/user/user_page.dart';
import 'package:project_telephony/utils/headers.dart';
import 'TextMe/text_me_page.dart';
import 'home/home_page.dart';
class TabNavigator extends StatefulWidget {

@ -1,12 +1,14 @@
import 'package:flutter/material.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 '../../constants/api.dart';
import '../../model/network/api_client.dart';
import '../../model/network/base_model.dart';
import '../../utils/toast/cloud_toast.dart';
import '../home/home_page.dart';
import '../widget/plone_back_button.dart';
import '../widget/plone_bottom.dart';
@ -28,6 +30,7 @@ class _ContentDetailsPageState extends State<ContentDetailsPage> {
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
String cText="";
final FocusNode verifyNode=FocusNode();
@override
void initState() {
super.initState();
@ -46,7 +49,7 @@ final FocusNode verifyNode=FocusNode();
appBar: AppBar(
elevation: 0,
title: Text(
'编辑短信标签',
'编辑短信',
style: TextStyle(
fontSize: BaseStyle.fontSize34,
color: BaseStyle.color333333,
@ -90,7 +93,7 @@ final FocusNode verifyNode=FocusNode();
filled: true,
isDense: true,
fillColor: Colors.transparent ,
hintText: widget.content.isNotEmpty ? "" : "请输入所需短信标签",
hintText: widget.content.isNotEmpty ? "" : "请输入所需短信",
hintStyle: TextStyle(
color: widget.content != ""
? const Color(0xFF333333)
@ -106,13 +109,21 @@ final FocusNode verifyNode=FocusNode();
opacity: cText.isNotEmpty ? 1 : 0.4,
onTap: () async {
// print(_controller.text);
final prefs = await SharedPreferences.getInstance();
BaseModel res =
await apiClient.request(API.app.addTag, data: {'tag': _controller.text});
if (res.code == 0) {
setState(() {});
widget.ploneBack(_controller.text);
UserTool.userProvider.updateUserInfo();
UserTool.userProvider.updateConSms();
prefs.setString("refSms", _controller.text);
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async {
service.startService();
});
}
// UserTool.userProvider.updateUserInfo();
// UserTool.userProvider.updateConSms();
Get.back();
} else {
CloudToast.show(res.msg);

@ -169,14 +169,14 @@ class _UserPageState extends State<UserPage> {
72.hb,
_getBanner(),
64.hb,
_getSwitch2(),
// _getSwitch2(),
_getSwitch(Assets.icons.privacy.path, "隐私政策", false),
_getSwitch(
Assets.icons.permissions.path, "权限说明", false),
_getSwitch(Assets.icons.sms.path, "短信标签", false),
// _getSwitch(Assets.icons.sms.path, "短信标签", false),
_getSwitch(Assets.icons.card.path, "卡密兑换", false),
// const Spacer(),
100.hb,
200.hb,
UserTool.userProvider.isLogin
? PloneBottom(
border: false,
@ -406,78 +406,76 @@ class _UserPageState extends State<UserPage> {
}
//
_getSwitch2() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 32.w),
child: ListTile(
// onTap: (() {}),
leading: Image.asset(
Assets.icons.switch1.path,
height: 54.w,
width: 56.w,
fit: BoxFit.fill,
),
title: Text(
"功能开关",
style: TextStyle(
color: BaseStyle.color333333,
fontSize: BaseStyle.fontSize34,
fontWeight: FontWeight.bold),
),
trailing: Switch(
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();
if (vle) {
print("true");
prefs.remove("kg");
prefs.setBool("kg", vle);
// Future.delayed(const Duration(seconds: 1), () async {
// service.startService();
// });
service.startService();
// WidgetsFlutterBinding.ensureInitialized();
initializeService();
// UserTool.userProvider.setKg(vle)
// initializeService();
// initializeService();
BotToast.showText(text: " 你开启了该功能");
// initializeService();
// print("这是数据${prefs.getBool("kg")}");
} else {
prefs.remove("kg");
prefs.setBool("kg", vle);
// Future.delayed(const Duration(seconds: 1), () async {
// service.invoke("stopService");
// });
service.invoke("stopService");
///
// exit(0);
// UserTool.userProvider.setKg(vle);
// prefs.setBool("kg", false);
// initializeService();
BotToast.showText(text: "你已经关闭该功能");
// print("这是数据${prefs.getBool("kg")}");
}
} else {
BotToast.showText(text: "还没有开通会员,不可使用该功能");
}
});
}),
));
}
// _getSwitch2() {
// return Container(
// padding: EdgeInsets.symmetric(horizontal: 32.w),
// child: ListTile(
// // onTap: (() {}),
// leading: Image.asset(
// Assets.icons.switch1.path,
// height: 54.w,
// width: 56.w,
// fit: BoxFit.fill,
// ),
// title: Text(
// "功能开关",
// style: TextStyle(
// color: BaseStyle.color333333,
// fontSize: BaseStyle.fontSize34,
// fontWeight: FontWeight.bold),
// ),
// trailing: Switch(
// 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();
// if (vle) {
// print("true");
// prefs.remove("kg");
// prefs.setBool("kg", vle);
// // Future.delayed(const Duration(seconds: 1), () async {
// // service.startService();
// // });
// service.startService();
// // WidgetsFlutterBinding.ensureInitialized();
// initializeService();
// // UserTool.userProvider.setKg(vle)
// // initializeService();
// // initializeService();
// BotToast.showText(text: " 你开启了该功能");
// // initializeService();
// // print("这是数据${prefs.getBool("kg")}");
// } else {
// prefs.remove("kg");
// prefs.setBool("kg", vle);
// // Future.delayed(const Duration(seconds: 1), () async {
// // service.invoke("stopService");
// // });
// service.invoke("stopService");
// // exit(0);
// // UserTool.userProvider.setKg(vle);
// // prefs.setBool("kg", false);
// // initializeService();
//
// BotToast.showText(text: "你已经关闭该功能");
// // print("这是数据${prefs.getBool("kg")}");
// }
// } else {
// BotToast.showText(text: "还没有开通会员,不可使用该功能");
// }
// });
// }),
// ));
// }
_getSwitch(String url, String name, bool pd) {
return GestureDetector(

@ -352,14 +352,14 @@ packages:
name: flutter_background_service_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.4.0"
flutter_background_service_platform_interface:
dependency: transitive
description:
name: flutter_background_service_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.2.0"
flutter_contacts:
dependency: "direct main"
description:

@ -1,38 +1,18 @@
name: project_telephony
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.16.0 <3.0.0"
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.5
telephony:
git:
@ -44,6 +24,7 @@ dependencies:
git:
url: https://git.oa00.com/austin_dai/permission_handler.git
# 后台设置
# flutter_background_service: ^2.4.3
flutter_background_service:
git:
url: https://git.oa00.com/austin_dai/flutter_background_service.git

@ -1,7 +1,6 @@
import 'dart:io';
import 'package:common_utils/common_utils.dart';
import 'package:flustars/flustars.dart';
import 'package:grinder/grinder.dart';
import 'package:path/path.dart';
import 'package:pub_semver/pub_semver.dart';

Loading…
Cancel
Save