群发功能增加

master
王亚玲 2 years ago
parent e8a6602425
commit 339034f3c8

@ -5,7 +5,6 @@ import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -13,11 +12,11 @@ import 'package:fluwx/fluwx.dart';
import 'package:get/get_navigation/src/root/get_material_app.dart'; import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:power_logger/power_logger.dart';
import 'package:project_telephony/providers/phone_num_provider.dart'; import 'package:project_telephony/providers/phone_num_provider.dart';
import 'package:project_telephony/providers/user_provider.dart'; import 'package:project_telephony/providers/user_provider.dart';
import 'package:project_telephony/ui/home/call.dart';
import 'package:project_telephony/ui/loading.dart'; import 'package:project_telephony/ui/loading.dart';
import 'package:project_telephony/ui/tab_navigator.dart'; import 'package:project_telephony/ui/tab_navigator.dart';
@ -31,6 +30,7 @@ void main() async {
const buildType = String.fromEnvironment('BUILD_TYPE'); const buildType = String.fromEnvironment('BUILD_TYPE');
DeveloperUtil.setDev(!(buildType.contains('PRODUCT'))); DeveloperUtil.setDev(!(buildType.contains('PRODUCT')));
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await HiveStore.init();
// await initializeService(); // await initializeService();
// Workmanager().initialize( // Workmanager().initialize(
// callbackDispatcher, // The top level function, aka callbackDispatcher // callbackDispatcher, // The top level function, aka callbackDispatcher

@ -8,7 +8,7 @@ part of 'ContentHive.dart';
class ContentHiveAdapter extends TypeAdapter<ContentHive> { class ContentHiveAdapter extends TypeAdapter<ContentHive> {
@override @override
final int typeId = 0; final int typeId = 2;
@override @override
ContentHive read(BinaryReader reader) { ContentHive read(BinaryReader reader) {

@ -0,0 +1,54 @@
import 'package:hive/hive.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'phone_model.g.dart';
@JsonSerializable()
@HiveType(typeId: 0)
class PhoneModel extends Equatable {
@HiveField(0)
String? title;
@HiveField(1)
String? time;
@HiveField(2)
bool? state;
@HiveField(3)
List<PhoneNum>? phoneList;
factory PhoneModel.fromJson(Map<String, dynamic> json) =>
_$PhoneModelFromJson(json);
PhoneModel({
this.title,
this.time,
this.state,
this.phoneList,
});
@override
List<Object?> get props => [title, time, state, phoneList];
}
@JsonSerializable()
@HiveType(typeId: 1)
class PhoneNum extends Equatable {
@HiveField(0)
String? name;
@HiveField(1)
String? phone;
@HiveField(2)
bool? state;
factory PhoneNum.fromJson(Map<String, dynamic> json) =>
_$PhoneNumFromJson(json);
PhoneNum({
this.name,
this.phone,
this.state,
});
@override
List<Object?> get props => [name, phone, state];
}

@ -0,0 +1,109 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'phone_model.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class PhoneModelAdapter extends TypeAdapter<PhoneModel> {
@override
final int typeId = 0;
@override
PhoneModel read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return PhoneModel(
title: fields[0] as String?,
time: fields[1] as String?,
state: fields[2] as bool?,
phoneList: (fields[3] as List?)?.cast<PhoneNum>(),
);
}
@override
void write(BinaryWriter writer, PhoneModel obj) {
writer
..writeByte(4)
..writeByte(0)
..write(obj.title)
..writeByte(1)
..write(obj.time)
..writeByte(2)
..write(obj.state)
..writeByte(3)
..write(obj.phoneList);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is PhoneModelAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class PhoneNumAdapter extends TypeAdapter<PhoneNum> {
@override
final int typeId = 1;
@override
PhoneNum read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return PhoneNum(
name: fields[0] as String?,
phone: fields[1] as String?,
state: fields[2] as bool?,
);
}
@override
void write(BinaryWriter writer, PhoneNum obj) {
writer
..writeByte(3)
..writeByte(0)
..write(obj.name)
..writeByte(1)
..write(obj.phone)
..writeByte(2)
..write(obj.state);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is PhoneNumAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
PhoneModel _$PhoneModelFromJson(Map<String, dynamic> json) => PhoneModel(
title: json['title'] as String?,
time: json['time'] as String?,
state: json['state'] as bool?,
phoneList: (json['phoneList'] as List<dynamic>?)
?.map((e) => PhoneNum.fromJson(e as Map<String, dynamic>))
.toList(),
);
PhoneNum _$PhoneNumFromJson(Map<String, dynamic> json) => PhoneNum(
name: json['name'] as String?,
phone: json['phone'] as String?,
state: json['state'] as bool?,
);

@ -1,81 +0,0 @@
import 'package:hive/hive.dart';
@HiveType(typeId: 0)
class PhoneNumberHive{
@HiveField(0)
int? id;
@HiveField(1)
String? title;
@HiveField(2)
String? time;
@HiveField(3)
bool? state;
@HiveField(4)
List<PhoneNumModel>? phoneList;
PhoneNumberHive({
this.id,
this.title,
this.time,
this.state,
this.phoneList,
});
PhoneNumberHive.fromJson(Map<String,dynamic> json){
id=json['id'];
title=json['title'];
time=json['time'];
state=json['state'];
if(json['phoneList'] !=null){
phoneList=json['phoneList'].map((e) => PhoneNumModel.from(e)).toList();
}else{
phoneList=[];
}
}
Map<String,dynamic> toJson(){
final Map<String,dynamic> data= <String,dynamic>{};
data['id'] =id;
data['title']=title;
data['time']=time;
data['state']=state;
if(phoneList!=null){
data['phoneList']=phoneList!.map((e) => e.toJson()).toList();
}
return data;
}
}
@HiveType(typeId: 1)
class PhoneNumModel{
@HiveField(0)
int? id;
@HiveField(1)
String? name;
@HiveField(2)
String? phone;
@HiveField(3)
bool? state;
PhoneNumModel({
this.id,
this.name,
this.phone,
this.state,
});
PhoneNumModel.from(Map<String,dynamic> json){
id=json['id'];
name=json['name'];
phone=json['phone'];
state=json['state'];
}
Map<String,dynamic> toJson(){
final Map<String,dynamic> data=<String,dynamic>{};
data["id"]=id;
data['name']=name;
data['phone']=phone;
data['state']=state;
return data;
}
}

@ -1,28 +1,44 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
import '../model/phone_num_model.dart';
import 'package:project_telephony/utils/hive_store.dart';
import '../model/hive/phone_model.dart';
//
// await HiveStore.dataBox?.add(PhoneModel(name: full.displayName,phone:full.phones.first.number, state: false));
// phoneList=HiveStore.dataBox?.get(PhoneModel());
// HiveStore.dataBox?.add(PhoneNumberHive(state: false,phoneList: phoneList,title:"未分组联系人",time: ''));
class PhoneNumProvider extends ChangeNotifier{ class PhoneNumProvider extends ChangeNotifier{
final List<PhoneNumModel> _phoneNum=[PhoneNumModel(num: "",time: 0,name: "", state:false)]; List<Contact>? contacts;
List<PhoneNumModel> get phoneNum=>_phoneNum; final List<PhoneModel> _massList = [];
Future list(List<PhoneNumModel> phoneList) async{ List<PhoneNum> _phoneList = [];
// await HiveStore.dataBox!.get(); List<PhoneModel> get massList=>_massList;
// final Iterable<CallLogEntry> entries = await CallLog.query(); List<PhoneNum> get phoneList=>_phoneList;
Future init() async{
// for (CallLogEntry entrie in entries) { contacts = await FlutterContacts.getContacts();
// _phoneNum.add(PhoneNumModel( for (var element in contacts!) {
// num: entrie.number, final full = await FlutterContacts.getContact(element.id);
// time: entrie.timestamp, _phoneList.add(PhoneNum(name: full?.displayName, phone: full?.phones.first.number,state: false));
// name: entrie.name, //
// state: false, // print(full?.displayName);
// )); // print(full?.phones.first.number);
// // a.add(entrie.number); }
// } await HiveStore.dataBox!.put("pl",_phoneList) ;
// final phoneList=_phoneNum.toSet(); _massList.add(PhoneModel(title:"未分组联系人",time: "本机通讯录",phoneList:HiveStore.dataBox!.get("pl"),state: false));
// final phoneList= HiveStore.dataBox?.get(phoneNum); HiveStore.dataBox?.put("ml",_massList) ;
return ; // print( "这是我的类型${HiveStore.dataBox?.get("ml").runtimeType}");
}
Future upDate() async{
_phoneList=await HiveStore.dataBox?.get("pl");
} }
// Future // Future
} }

@ -30,6 +30,8 @@ class UserProvider extends ChangeNotifier {
Future<bool> init() async { Future<bool> init() async {
if (HiveStore.appBox?.containsKey('token') ?? false) { if (HiveStore.appBox?.containsKey('token') ?? false) {
final token = HiveStore.appBox?.get('token') as String; final token = HiveStore.appBox?.get('token') as String;
// UserTool.phoneNumProvider.init();
// print("重置");
_isLogin = true; _isLogin = true;
apiClient.setToken(token); apiClient.setToken(token);
await updateUserInfo(); await updateUserInfo();
@ -55,6 +57,7 @@ class UserProvider extends ChangeNotifier {
await updateUserInfo(); await updateUserInfo();
prefs.setInt("numIndex", 0); prefs.setInt("numIndex", 0);
_viewLoading(); _viewLoading();
UserTool.phoneNumProvider.init();
// prefs.setStringList("dxText",["祝你万事顺心","欢迎你的来电,祝你生活愉快","感谢您的来电,我们会尽快处理",]); // prefs.setStringList("dxText",["祝你万事顺心","欢迎你的来电,祝你生活愉快","感谢您的来电,我们会尽快处理",]);
updateConSms(); updateConSms();
updateRefSms(); updateRefSms();
@ -70,6 +73,7 @@ class UserProvider extends ChangeNotifier {
apiClient.clearToken(); apiClient.clearToken();
_isLogin = false; _isLogin = false;
await HiveStore.appBox?.delete('token'); await HiveStore.appBox?.delete('token');
HiveStore.dataBox?.delete("ml");
service.invoke("stopService"); service.invoke("stopService");
} }
@ -97,7 +101,7 @@ class UserProvider extends ChangeNotifier {
? "${base.data['content']}" ? "${base.data['content']}"
: "${UserTool.userProvider.userInfo.tag}${base.data['content']}"); : "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
service.invoke("stopService"); service.invoke("stopService");
if (prefs.getBool('kg')!) { if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async { Future.delayed(const Duration(seconds: 1), () async {
service.startService(); service.startService();
}); });
@ -120,7 +124,7 @@ class UserProvider extends ChangeNotifier {
? "${base.data['content']}" ? "${base.data['content']}"
: "${UserTool.userProvider.userInfo.tag}${base.data['content']}"); : "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
service.invoke("stopService"); service.invoke("stopService");
if (prefs.getBool('kg')!) { if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async { Future.delayed(const Duration(seconds: 1), () async {
service.startService(); service.startService();
}); });
@ -143,7 +147,7 @@ class UserProvider extends ChangeNotifier {
? "${base.data['content']}" ? "${base.data['content']}"
: "${UserTool.userProvider.userInfo.tag}${base.data['content']}"); : "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
service.invoke("stopService"); service.invoke("stopService");
if (prefs.getBool('kg')!) { if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async { Future.delayed(const Duration(seconds: 1), () async {
service.startService(); service.startService();
}); });
@ -166,7 +170,7 @@ class UserProvider extends ChangeNotifier {
? "${base.data['content']}" ? "${base.data['content']}"
: "${UserTool.userProvider.userInfo.tag}${base.data['content']}"); : "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
service.invoke("stopService"); service.invoke("stopService");
if (prefs.getBool('kg')!) { if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async { Future.delayed(const Duration(seconds: 1), () async {
service.startService(); service.startService();
}); });
@ -183,9 +187,9 @@ class UserProvider extends ChangeNotifier {
var base = await apiClient.request(API.exclude.find); var base = await apiClient.request(API.exclude.find);
if (base.code == 0) { if (base.code == 0) {
await prefs.remove('exclude'); await prefs.remove('exclude');
await prefs.setStringList('exclude', base.data); await prefs.setStringList('exclude', base.data ?? []);
service.invoke("stopService"); service.invoke("stopService");
if (prefs.getBool('kg')!) { if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async { Future.delayed(const Duration(seconds: 1), () async {
service.startService(); service.startService();
}); });
@ -214,13 +218,11 @@ class UserProvider extends ChangeNotifier {
await prefs.setStringList("addressList", numbers); await prefs.setStringList("addressList", numbers);
service.invoke("stopService"); service.invoke("stopService");
if (prefs.getBool('kg')!) { if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(seconds: 1), () async { Future.delayed(const Duration(seconds: 1), () async {
service.startService(); service.startService();
}); });
} }
notifyListeners(); notifyListeners();
} }
@ -241,7 +243,6 @@ class UserProvider extends ChangeNotifier {
// numbers.add(full!.phones.first.number); // numbers.add(full!.phones.first.number);
} }
} }
await prefs.setStringList("nameList",nameList ); await prefs.setStringList("nameList",nameList );
prefs.setStringList("number", numbers); prefs.setStringList("number", numbers);
// print(contacts.length); // print(contacts.length);

@ -1,19 +1,24 @@
import 'package:flustars/flustars.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_contacts/contact.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:flutter_easyrefresh/easy_refresh.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/headers.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:project_telephony/utils/hive_store.dart';
import '../../base/base_style.dart'; import '../../base/base_style.dart';
import '../../model/mass_list_model.dart';
import '../../model/phone_num_model.dart';
import '../widget/plone_back_button.dart'; import '../widget/plone_back_button.dart';
import '../widget/plone_bottom.dart'; import '../widget/plone_bottom.dart';
import 'call_list_page.dart';
typedef NumList = Function(List<String> content);
class AddressBook extends StatefulWidget { class AddressBook extends StatefulWidget {
const AddressBook({Key? key}) : super(key: key); final NumList number;
const AddressBook({Key? key, required this.number}) : super(key: key);
@override @override
_AddressBookState createState() => _AddressBookState(); _AddressBookState createState() => _AddressBookState();
@ -22,12 +27,20 @@ class AddressBook extends StatefulWidget {
class _AddressBookState extends State<AddressBook> { class _AddressBookState extends State<AddressBook> {
final EasyRefreshController _easyRefreshController = EasyRefreshController(); final EasyRefreshController _easyRefreshController = EasyRefreshController();
String phoneName = ""; String phoneName = "";
List<MassListModel> massList = []; List<PhoneModel> massList = [];
List<PhoneNumModel> phoneList = []; List<PhoneNum> phoneList = [];
List<String> NumList = [];
bool state=false;
@override @override
void initState() { void initState() {
a(); // 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(); super.initState();
} }
@ -37,179 +50,195 @@ class _AddressBookState extends State<AddressBook> {
super.dispose(); super.dispose();
} }
a() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
List<String> numbers = [];
List<String>? nameList = [];
List<Contact>? contacts;
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(
num: full.phones.first.number,
state: false,
time: 0,
name: full.displayName));
}
}
await prefs.setStringList("nameList", nameList );
prefs.setStringList("number", numbers);
print(phoneList);
massList.add(MassListModel(
state: false, list: phoneList, title: '未分组联系人', time: ''));
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
title: Text( centerTitle: true,
'通讯录', title: Text(
style: TextStyle( '通讯录',
fontSize: BaseStyle.fontSize34, style: TextStyle(
color: BaseStyle.color333333, fontSize: BaseStyle.fontSize34,
fontWeight: FontWeight.bold), color: BaseStyle.color333333,
), fontWeight: FontWeight.bold),
titleSpacing: 185.w, ),
actions: [ // titleSpacing: 185.w,
GestureDetector( actions: [
onTap: () { GestureDetector(
showDialog( onTap: () {
context: context, showDialog(
builder: (context) { context: context,
return CupertinoAlertDialog( builder: (context) {
title: Text( return CupertinoAlertDialog(
"添加分组", title: Text(
style: TextStyle( "添加分组",
color: BaseStyle.color333333, fontSize: 34.sp), style: TextStyle(
), color: BaseStyle.color333333,
content: Column( fontSize: 34.sp),
children: [ ),
Column( content: Column(
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ Column(
CupertinoTextField( crossAxisAlignment: CrossAxisAlignment.start,
padding: EdgeInsets.symmetric( children: [
horizontal: 24.w, vertical: 20.w), CupertinoTextField(
decoration: BoxDecoration( padding: EdgeInsets.symmetric(
border: Border.all(color: Colors.white), horizontal: 24.w, vertical: 20.w),
// borderRadius: BorderRadius.all( decoration: BoxDecoration(
// Radius.circular(4.w) border:
// ), Border.all(color: Colors.white),
color: const Color(0xFFF9F9F9)), // borderRadius: BorderRadius.all(
placeholderStyle: TextStyle( // Radius.circular(4.w)
fontSize: 28.sp, // ),
color: BaseStyle.color999999), color: const Color(0xFFF9F9F9)),
placeholder: "请输入分组名称10个字以内", placeholderStyle: TextStyle(
onChanged: (value) { fontSize: 28.sp,
phoneName = value; color: BaseStyle.color999999),
setState(() {}); placeholder: "请输入分组名称10个字以内",
}, onChanged: (value) {
), phoneName = value;
setState(() {});
},
),
82.hb, 82.hb,
// _getUpdate("爸爸", "123123123"), // _getUpdate("爸爸", "123123123"),
PloneBottom( PloneBottom(
blM: false, blM: false,
border: true, border: true,
color1: const Color(0xFF1890FF), color1: const Color(0xFF1890FF),
color2: const Color(0xFF74BCFF), color2: const Color(0xFF74BCFF),
onTap: () async { onTap: () async {
DateTime now = DateTime.now(); DateTime now = DateTime.now();
String nowTime = String nowTime =
"${now.year}-${now.month}-${now.day} ${now.hour}:${now.minute}:${now.millisecond}"; "${now.year}-${now.month}-${now
massList.add(MassListModel( .day} ${now.hour}:${now
state: false, .minute}:${now.millisecond}";
list: [], massList.add(PhoneModel(
title: phoneName, time: nowTime,
time: nowTime)); phoneList: [],
// await state: false,
Navigator.pop(context); title: phoneName));
_easyRefreshController.callRefresh(); await HiveStore.dataBox
}, ?.put("ml", massList);
text: "保存", // massList.add(MassListModel(
) // state: false,
], // list: [],
), // title: phoneName,
], // time: nowTime));
), // // await
); // Navigator.pop(context);
}); Get.back();
}, _easyRefreshController.callRefresh();
child: Padding( },
padding: EdgeInsets.only(top: 40.w, right: 32.w), text: "保存",
child: SizedBox( )
height: 28.w, ],
width: 120.w, ),
child: Text( ],
"添加分组", ),
style: TextStyle( );
color: BaseStyle.color333333, fontSize: 28.sp), });
), },
))) child: Padding(
], padding: EdgeInsets.only(top: 40.w, right: 32.w),
leading: const CloudBackButton(isSpecial: true), child: SizedBox(
backgroundColor: kForeGroundColor), height: 28.w,
backgroundColor: Colors.white, width: 120.w,
body: EasyRefresh( child: Text(
firstRefresh: true, "添加分组",
header: MaterialHeader(), style: TextStyle(
controller: _easyRefreshController, color: BaseStyle.color333333, fontSize: 28.sp),
onRefresh: () async { ),
setState(() {}); )))
}, ],
child: ListView.builder( leading: const CloudBackButton(isSpecial: true),
itemBuilder: (context, index) { backgroundColor: kForeGroundColor),
return _getBox(massList[index], index, massList[index].list.length); 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(() {});
}, },
itemCount: massList.length, 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(MassListModel item, int index, int num) { _getBox(PhoneModel item, int index, int num) {
return GestureDetector( return CheckboxListTile(
child: CheckboxListTile( onChanged: (bool? value) {
onChanged: (bool? value) { setState(() {
setState(() { item.state = value!;
item.state = value!; state=value;
if (item.state) { if (item.state!) {
// phoneNum3.add({"phone":num,"remark":name}); item.phoneList?.forEach((element) {
// phoneNum3.add((phone: num, remark: name)); NumList.add(element.phone ?? "");
});
} else { // item.phoneList!.map((e) => NumList.add(e.phone ??""));
// phoneNum3.remove({"phone":num,"remark":name}); } else {
// phoneNum3.remove(ExcludePnModel(phone: num, remark: name)) ; 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());
}, },
value: item.state, child: Text(
title: Text(
"${item.title}($num)", "${item.title}($num)",
style: TextStyle(fontSize: 32.w, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 32.w, fontWeight: FontWeight.bold),
), ),
subtitle: Row( ),
children: [ subtitle: Row(
Text( children: [
index == 0 ? "本机通讯录" : item.time, Text(
style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999), item.time ?? "",
), style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
// 30.wb, ),
// Text( // 30.wb,
// item.name == null ? "" : item.name!, // Text(
// style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999), // item.name == null ? "" : item.name!,
// ) // style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999),
], // )
), ],
), ),
); );
} }

@ -0,0 +1,250 @@
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 '../../utils/user_tool.dart';
import '../exclude/exclude_contacts_page.dart';
import '../exclude/exclude_single_page.dart';
import '../login/login_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
void initState() {
if (UserTool.userProvider.isLogin) {
if (UserTool.userProvider.userInfo.isVip != 1) {
//service.isRunning() as bool;
// endDate = DateUtil.formatDateMs(
// UserTool.userProvider.userInfo.end * 1000,
// format: DateFormats.y_mo_d);
} else {
Get.to(() => const LoginPage());
}
super.initState();
}
}
@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: (_) => const ExcludeSinglePage( qf: true,)),
)
.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,
);
}
}

@ -6,7 +6,6 @@ import 'package:project_telephony/ui/TextMe/text_template.dart';
import 'package:project_telephony/ui/widget/plone_bottom.dart'; import 'package:project_telephony/ui/widget/plone_bottom.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/toast/cloud_toast.dart'; import 'package:project_telephony/utils/toast/cloud_toast.dart';
import 'package:telephony/telephony.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
import '../widget/plone_back_button.dart'; import '../widget/plone_back_button.dart';
@ -25,6 +24,7 @@ class _TextMePageState extends State<TextMePage> {
String signatureText = ""; String signatureText = "";
late TextEditingController _controller; late TextEditingController _controller;
late TextEditingController _phoneController; late TextEditingController _phoneController;
List<String> list = [];
@override @override
void initState() { void initState() {
@ -58,7 +58,8 @@ class _TextMePageState extends State<TextMePage> {
body: ListView( body: ListView(
children: [ children: [
_getBox('短信内容', "选择短信模版", () { _getBox('短信内容', "选择短信模版", () {
Get.to(() => TextTemplate( Get.to(() =>
TextTemplate(
callback: (String content) { callback: (String content) {
_controller.text = content; _controller.text = content;
}, },
@ -66,7 +67,12 @@ class _TextMePageState extends State<TextMePage> {
}, "请输入短信内容...", _controller), }, "请输入短信内容...", _controller),
32.hb, 32.hb,
_getBox('收信号码', "通讯录中选择", () { _getBox('收信号码', "通讯录中选择", () {
Get.to(() => const AddressBook()); Get.to(() =>
AddressBook(number: (List<String> content) {
for(int i=0;i<content.length;i++){
_phoneController.text +="${content[i]},";
}
},));
}, "请输入收信号码多个号码请用逗号隔开例如136xxxx6666132xxxx8888", _phoneController), }, "请输入收信号码多个号码请用逗号隔开例如136xxxx6666132xxxx8888", _phoneController),
32.hb, 32.hb,
_getBox2(), _getBox2(),
@ -83,15 +89,10 @@ class _TextMePageState extends State<TextMePage> {
print(_phoneController.text); print(_phoneController.text);
print(signatureText); print(signatureText);
await sendSMS( await sendSMS(
message:"$signatureText${_controller.text}", message: "$signatureText${_controller.text}",
recipients: [ recipients: _phoneController.text.split(","),
"13395740386",
"13486828191",
// "18815060992",
// "18294841148"
],
sendDirect: true); sendDirect: true);
// print("asd${_phoneController.text.split(",")}");
// await telephony.sendSms( // await telephony.sendSms(
// to: "13486828191;13395740386;18815060992;18294841148", // to: "13486828191;13395740386;18815060992;18294841148",
// message: "$signatureText${_controller.text}" // message: "$signatureText${_controller.text}"
@ -104,8 +105,8 @@ class _TextMePageState extends State<TextMePage> {
_phoneController.text.isEmpty || _phoneController.text.isEmpty ||
signatureText.isEmpty, signatureText.isEmpty,
opacity: _controller.text.isEmpty || opacity: _controller.text.isEmpty ||
_phoneController.text.isEmpty || _phoneController.text.isEmpty ||
signatureText.isEmpty signatureText.isEmpty
? 0.4 ? 0.4
: 1, : 1,
text: "发送", text: "发送",
@ -170,11 +171,12 @@ class _TextMePageState extends State<TextMePage> {
// } // }
// setState(() {}); // setState(() {});
// }, // },
onSubmitted: (text){ onSubmitted: (text) {
if (title == "短信内容") { if (title == "短信内容") {
_controller.text = text; _controller.text = text;
} else { } else {
_phoneController.text = text; _phoneController.text = text;
} }
setState(() {}); setState(() {});
}, },

@ -73,7 +73,7 @@ class _TextTemplateState extends State<TextTemplate> {
footer: MaterialFooter(), footer: MaterialFooter(),
onRefresh: () async { onRefresh: () async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
textList = prefs.getStringList("dxText")!; textList = prefs.getStringList("dxText") ?? [];
textList.add("自定义短信模版"); textList.add("自定义短信模版");
setState(() {}); setState(() {});
}, },

@ -4,16 +4,18 @@ import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:velocity_x/velocity_x.dart';
import '../../constants/api.dart'; import '../../constants/api.dart';
import '../../model/exclude_phone_model.dart'; import '../../model/exclude_phone_model.dart';
import '../../model/hive/phone_model.dart';
import '../../model/network/api_client.dart'; import '../../model/network/api_client.dart';
import '../../model/network/base_model.dart'; import '../../model/network/base_model.dart';
import '../../utils/hive_store.dart';
class ExcludeContactsPage extends StatefulWidget { class ExcludeContactsPage extends StatefulWidget {
const ExcludeContactsPage({Key? key}) : super(key: key); final bool qf;
final int index;
const ExcludeContactsPage({Key? key, this.qf = false,this.index=0}) : super(key: key);
@override @override
_ExcludeContactsPageState createState() => _ExcludeContactsPageState(); _ExcludeContactsPageState createState() => _ExcludeContactsPageState();
@ -25,6 +27,8 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
List<String> numbers1 = []; List<String> numbers1 = [];
List<bool> status = []; List<bool> status = [];
var flag = true; var flag = true;
List<PhoneModel> messList = [];
List<PhoneNum> numList = [];
@override @override
void initState() { void initState() {
@ -37,15 +41,15 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
contacts = await FlutterContacts.getContacts(); contacts = await FlutterContacts.getContacts();
for (var element in contacts!) { for (var element in contacts!) {
final full = await FlutterContacts.getContact(element.id); final full = await FlutterContacts.getContact(element.id);
if(full?.phones.length==0){ if (full?.phones.length == 0) {
numbers.add(''); numbers.add('');
}else{ } else {
numbers.add(full!.phones.first.number); numbers.add(full!.phones.first.number);
} }
status.add(false); status.add(false);
} }
// await prefs.setStringList("addressList", numbers); // await prefs.setStringList("addressList", numbers);
print(contacts?.length); // print(contacts?.length);
setState(() {}); setState(() {});
} }
@ -58,11 +62,9 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
flag = false; flag = false;
return Container(); return Container();
} else { } else {
return ListView.builder( return ListView.builder(
itemCount: contacts!.length, itemCount: contacts!.length,
itemBuilder: (context, i) { itemBuilder: (context, i) {
return ListTile( return ListTile(
title: Text( title: Text(
contacts![i].displayName, contacts![i].displayName,
@ -106,15 +108,31 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
if (status[i] == true) { if (status[i] == true) {
excludeList.add( excludeList.add(
Exclude(phone: numbers[i], remark: contacts![i].displayName)); Exclude(phone: numbers[i], remark: contacts![i].displayName));
// numList.add(PhoneNum(phone: numbers[i],name: contacts![i].displayName,state: false));
} }
} }
if (status.contains(true)) { if (status.contains(true)) {
BaseModel res = await apiClient if (widget.qf) {
.request(API.exclude.add, data: {'exclude': excludeList}); messList = await HiveStore.dataBox?.get("ml").cast<PhoneModel>();
if (res.code == 0) { // numList = HiveStore.dataBox?.get("pl").cast<PhoneNum>();
BotToast.showText(text: res.msg); for (int i = 0; i < status.length; i++) {
Get.back(); if (status[i] == true) {
messList[widget.index].phoneList!.add(PhoneNum(phone: numbers[i],name: contacts![i].displayName,state: false));
}
}
HiveStore.dataBox?.put("ml", messList);
print(HiveStore.dataBox?.get("ml"));
Get.back(); Get.back();
// Get.back();
// _refreshController.callRefresh();
} else {
BaseModel res = await apiClient
.request(API.exclude.add, data: {'exclude': excludeList});
if (res.code == 0) {
BotToast.showText(text: res.msg);
Get.back();
Get.back();
}
} }
} else { } else {
BotToast.showText(text: "还未选中手机号"); BotToast.showText(text: "还未选中手机号");

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart'; import 'package:get/get_core/src/get_main.dart';
import 'package:project_telephony/model/hive/phone_model.dart';
import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
@ -11,9 +12,12 @@ import '../../constants/api.dart';
import '../../model/exclude_phone_model.dart'; import '../../model/exclude_phone_model.dart';
import '../../model/network/api_client.dart'; import '../../model/network/api_client.dart';
import '../../model/network/base_model.dart'; import '../../model/network/base_model.dart';
import '../../utils/hive_store.dart';
class ExcludeSinglePage extends StatefulWidget { class ExcludeSinglePage extends StatefulWidget {
const ExcludeSinglePage({Key? key}) : super(key: key); final bool qf;
final int index;
const ExcludeSinglePage({Key? key,this.qf=false,this.index=0}) : super(key: key);
@override @override
_ExcludeSinglePageState createState() => _ExcludeSinglePageState(); _ExcludeSinglePageState createState() => _ExcludeSinglePageState();
@ -47,6 +51,30 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
if (_phoneController.text.isEmpty) { if (_phoneController.text.isEmpty) {
BotToast.showText(text: "未输入手机号"); BotToast.showText(text: "未输入手机号");
} else { } else {
if(widget.qf){
List<PhoneModel> messList=[];
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?.add(
PhoneNum(
name: _nameController.text,
phone: _phoneController.text,
state: false,
)
);
// print(messList);
// messList.map((e) => e.phoneList!.add(PhoneNum(
// name: _nameController.text,
// phone:_phoneController.text ,
// state: false)));
HiveStore.dataBox?.put("ml", messList);
print(HiveStore.dataBox?.get("ml"));
// Get.back();
Get.back();
}else{
BaseModel res = await apiClient.request( BaseModel res = await apiClient.request(
API.exclude.add, API.exclude.add,
data: { data: {
@ -58,10 +86,10 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
); );
BotToast.showText(text: res.msg); BotToast.showText(text: res.msg);
if (res.code == 0) { if (res.code == 0) {
Get.back(); // Get.back();
Get.back(); Get.back();
} }
} }}
}, },
isOpacity: isOpacity:
_phoneController.text.isNotEmpty || _nameController.text.isNotEmpty, _phoneController.text.isNotEmpty || _nameController.text.isNotEmpty,

@ -60,8 +60,8 @@ void onStart(ServiceInstance service) async {
bool? callSw = prefs.getBool('callSwitch'); bool? callSw = prefs.getBool('callSwitch');
bool? idleSw = prefs.getBool('idleSwitch'); bool? idleSw = prefs.getBool('idleSwitch');
int? numberSet = prefs.getInt("numIndex") ?? 0; int? numberSet = prefs.getInt("numIndex") ?? 0;
List<String>? numberList = prefs.getStringList("addressList") ; List<String>? numberList = prefs.getStringList("addressList") ??[] ;
List<String>? noNumberList = prefs.getStringList("specified"); List<String>? noNumberList = prefs.getStringList("specified") ??[];
print("号码设置$numberSet 通讯列表$numberList 指定不发送$noNumberList"); print("号码设置$numberSet 通讯列表$numberList 指定不发送$noNumberList");
if (callState == "IDLE") { if (callState == "IDLE") {
if (flag != 0) { if (flag != 0) {
@ -72,13 +72,13 @@ void onStart(ServiceInstance service) async {
// if() // if()
switch (numberSet) { switch (numberSet) {
case 0: case 0:
if (!(noNumberList!.contains(phoneNum))) { if (!(noNumberList.contains(phoneNum))) {
if (flag > 0) { if (flag > 0) {
print("来电拒接/未接"); // print("来电拒接/未接");
print("${phoneNum!}:${ref!}"); print("${phoneNum!}:${ref!}");
Telephony.backgroundInstance Telephony.backgroundInstance
.sendSms(to: phoneNum!, message: ref); .sendSms(to: phoneNum!, message: ref);
print("发送成功"); // print("发送成功");
} else if (flag == -1) { } else if (flag == -1) {
print("来电接听"); print("来电接听");
print("${phoneNum!}:${con!}"); print("${phoneNum!}:${con!}");
@ -110,8 +110,8 @@ void onStart(ServiceInstance service) async {
} }
break; break;
case 1: case 1:
if ((numberList!.contains(phoneNum)) && if ((numberList.contains(phoneNum)) &&
!(noNumberList!.contains(phoneNum))) { !(noNumberList.contains(phoneNum))) {
if (flag > 0) { if (flag > 0) {
print("来电拒接/未接"); print("来电拒接/未接");
print("${phoneNum!}:${ref!}"); print("${phoneNum!}:${ref!}");
@ -149,8 +149,8 @@ void onStart(ServiceInstance service) async {
} }
break; break;
case 2: case 2:
if (!(numberList!.contains(phoneNum)) && if (!(numberList.contains(phoneNum)) &&
!(noNumberList!.contains(phoneNum))) { !(noNumberList.contains(phoneNum))) {
if (flag > 0) { if (flag > 0) {
print("来电拒接/未接"); print("来电拒接/未接");
print("${phoneNum!}:${ref!}"); print("${phoneNum!}:${ref!}");

@ -6,7 +6,6 @@ import 'dart:async';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../constants/environment/environment.dart';
import '../providers/user_provider.dart'; import '../providers/user_provider.dart';
import '../utils/hive_store.dart'; import '../utils/hive_store.dart';
@ -19,10 +18,9 @@ class Loading extends StatefulWidget {
} }
class _LoadingState extends State<Loading> { class _LoadingState extends State<Loading> {
Future initialAll() async { // Future initialAll() async {
await HiveStore.init(); //
} // }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -36,7 +34,7 @@ class _LoadingState extends State<Loading> {
// environment: env == 'dev', // environment: env == 'dev',
// ); // );
Future.delayed(const Duration(milliseconds: 1000), () async { Future.delayed(const Duration(milliseconds: 1000), () async {
await initialAll(); // await initialAll();
if (!await userProvider.init()) { if (!await userProvider.init()) {
await Get.offAll(() => const TabNavigator()); await Get.offAll(() => const TabNavigator());
// await Get.offAll(() => const LoginPage()); // await Get.offAll(() => const LoginPage());

@ -54,7 +54,7 @@ class _LoginPageState extends State<LoginPage> {
_smsCodeFocusNode = FocusNode(); _smsCodeFocusNode = FocusNode();
_phoneController = TextEditingController(); _phoneController = TextEditingController();
_smsCodeController = TextEditingController(); _smsCodeController = TextEditingController();
final userProvider = Provider.of<UserProvider>(context, listen: false); // final userProvider = Provider.of<UserProvider>(context, listen: false);
var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); var env = const String.fromEnvironment('ENV', defaultValue: 'dev');
if (kDebugMode) { if (kDebugMode) {
print('env :$env'); print('env :$env');

@ -30,10 +30,10 @@ class _TabNavigatorState extends State<TabNavigator>
void initState() { void initState() {
super.initState(); super.initState();
// //
Future.delayed(const Duration(milliseconds: 0), () async { // Future.delayed(const Duration(milliseconds: 0), () async {
//Hive.initFlutter; // //Hive.initFlutter;
await HiveStore.init(); // await HiveStore.init();
}); // });
_pages = [const HomePage(), const TextMePage(),const UserPage()]; _pages = [const HomePage(), const TextMePage(),const UserPage()];
_tabController = TabController( _tabController = TabController(
length: _pages.length, vsync: this, initialIndex: widget.index ?? 0); length: _pages.length, vsync: this, initialIndex: widget.index ?? 0);

@ -28,8 +28,6 @@ import '../home/call.dart';
import '../widget/appdialog.dart'; import '../widget/appdialog.dart';
import 'content_details_page.dart'; import 'content_details_page.dart';
class UserPage extends StatefulWidget { class UserPage extends StatefulWidget {
const UserPage({Key? key}) : super(key: key); const UserPage({Key? key}) : super(key: key);
@ -65,6 +63,7 @@ class _UserPageState extends State<UserPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
// showDialog(context: context, builder: (context){ // showDialog(context: context, builder: (context){
// return const AppDialog(); // return const AppDialog();
// }); // });
@ -91,6 +90,25 @@ class _UserPageState extends State<UserPage> {
// } // }
} }
@override
void didChangeDependencies() {
super.didChangeDependencies();
Future.delayed(const Duration(seconds: 1)).then((value) {
if (UserTool.userProvider.userInfo.isTrial != 1) {
showDialog(
context: context,
builder: (context) {
return const AppDialog();
}).then((value) => getRe());
}
});
}
getRe() async {
UserTool.userProvider.updateUserInfo();
_easyRefreshController.callRefresh();
}
// getRes() async{ // getRes() async{
// var res=await apiClient.request(API.app.trialVip); // var res=await apiClient.request(API.app.trialVip);
// if(res.code==0){ // if(res.code==0){
@ -122,16 +140,8 @@ class _UserPageState extends State<UserPage> {
_getRequests(); _getRequests();
// await UserTool.userProvider.updateUserInfo(); // await UserTool.userProvider.updateUserInfo();
if (UserTool.userProvider.isLogin) { if (UserTool.userProvider.isLogin) {
// var res=await apiClient.request(API.app.trialVip); // var res=await apiClient.request(API.app.trialVip);
//01 //01
if (UserTool.userProvider.userInfo.isTrial != 1) {
showDialog(
context: context,
builder: (context) {
return const AppDialog();
}).then((value) => _easyRefreshController.callRefresh());
}
// print(UserTool.userProvider.userInfo.end * 1000); // print(UserTool.userProvider.userInfo.end * 1000);
// print(DateTime.now().millisecondsSinceEpoch); // print(DateTime.now().millisecondsSinceEpoch);
if (UserTool.userProvider.userInfo.isVip != 1) { if (UserTool.userProvider.userInfo.isVip != 1) {
@ -147,7 +157,7 @@ class _UserPageState extends State<UserPage> {
// format: DateFormats.y_mo_d); // format: DateFormats.y_mo_d);
} else { } else {
vle = false; vle = false;
Get.to(()=>const LoginPage()); Get.to(() => const LoginPage());
} }
setState(() {}); setState(() {});
}, },
@ -164,7 +174,7 @@ class _UserPageState extends State<UserPage> {
_getSwitch(Assets.icons.sms.path, "短信标签", false), _getSwitch(Assets.icons.sms.path, "短信标签", false),
_getSwitch(Assets.icons.card.path, "卡密兑换", false), _getSwitch(Assets.icons.card.path, "卡密兑换", false),
// const Spacer(), // const Spacer(),
100.hb, 100.hb,
UserTool.userProvider.isLogin UserTool.userProvider.isLogin
? PloneBottom( ? PloneBottom(
border: false, border: false,
@ -444,6 +454,7 @@ class _UserPageState extends State<UserPage> {
// service.invoke("stopService"); // service.invoke("stopService");
// }); // });
service.invoke("stopService"); service.invoke("stopService");
/// ///
// exit(0); // exit(0);
// UserTool.userProvider.setKg(vle); // UserTool.userProvider.setKg(vle);
@ -488,22 +499,19 @@ class _UserPageState extends State<UserPage> {
case "卡密兑换": case "卡密兑换":
Navigator.of(context) Navigator.of(context)
.push( .push(
MaterialPageRoute(builder: (_) => const UserCardPage()), MaterialPageRoute(builder: (_) => const UserCardPage()),
) )
.then((val) => _getRequests() .then((val) => _getRequests()
// _easyRefreshController.callRefresh()
// _easyRefreshController.callRefresh() );
);
break; break;
default: default:
break; break;
} }
} }
}, },
child: Container( child: Container(
padding: EdgeInsets.symmetric(horizontal: 32.w), padding: EdgeInsets.symmetric(horizontal: 32.w),
child: ListTile( child: ListTile(

@ -74,8 +74,8 @@ _getBotton(String bContent, context) {
var res = await apiClient.request(API.app.trialVip); var res = await apiClient.request(API.app.trialVip);
if (res.code == 0) { if (res.code == 0) {
CloudToast.show(res.msg); CloudToast.show(res.msg);
UserTool.userProvider.updateUserInfo(); Get.back();
Navigator.pop(context); // Navigator.pop(context);
} else { } else {
CloudToast.show(res.msg); CloudToast.show(res.msg);

@ -48,6 +48,7 @@ class _ScaffoldThemeWidgetState extends State<ScaffoldThemeWidget> {
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
centerTitle: true,
title: Text( title: Text(
widget.title, widget.title,
style: TextStyle( style: TextStyle(
@ -55,7 +56,7 @@ class _ScaffoldThemeWidgetState extends State<ScaffoldThemeWidget> {
color: BaseStyle.color333333, color: BaseStyle.color333333,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
titleSpacing: widget.wid.w, // titleSpacing: widget.wid.w,
leading: const CloudBackButton(isSpecial: true), leading: const CloudBackButton(isSpecial: true),
backgroundColor: kForeGroundColor), backgroundColor: kForeGroundColor),
backgroundColor: Colors.white, backgroundColor: Colors.white,

@ -2,7 +2,9 @@ import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import '../model/hive/phone_number_hive.dart'; import '../model/hive/ContentHive.dart';
import '../model/hive/phone_model.dart';
class HiveStore { class HiveStore {
static Box? _appBox; static Box? _appBox;
@ -20,7 +22,9 @@ class HiveStore {
var dir = await getApplicationDocumentsDirectory(); var dir = await getApplicationDocumentsDirectory();
Hive.init(dir.path); Hive.init(dir.path);
// Hive.registerAdapter(MyObjectAdapter()); // Hive.registerAdapter(MyObjectAdapter());
// Hive.registerAdapter(PhoneNumberHive()); //HiveTypeId:0 Hive.registerAdapter(PhoneModelAdapter()); //HiveTypeId:0
Hive.registerAdapter(PhoneNumAdapter()); //HiveTypeId:1
Hive.registerAdapter(ContentHiveAdapter());//HiveTypeId:2
_appBox = await Hive.openBox('app'); _appBox = await Hive.openBox('app');
_userBox = await Hive.openBox('userBox'); _userBox = await Hive.openBox('userBox');
_dataBox = await Hive.openBox('dataBox'); _dataBox = await Hive.openBox('dataBox');

@ -7,10 +7,12 @@ import 'headers.dart';
class UserTool { class UserTool {
static UserProvider userProvider = static UserProvider userProvider =
Provider.of<UserProvider>(Get.context!, listen: false); Provider.of<UserProvider>(Get.context!, listen: false);
// static PhoneProvider phoneProvider=Provider.of<PhoneProvider>(Get.context!, listen: false);
}
class PhoneTool {
static PhoneNumProvider phoneNumProvider = static PhoneNumProvider phoneNumProvider =
Provider.of<PhoneNumProvider>(Get.context!, listen: false); Provider.of<PhoneNumProvider>(Get.context!, listen: false);
// static PhoneProvider phoneProvider=Provider.of<PhoneProvider>(Get.context!, listen: false);
} }
//
// class PhoneTool {
// static PhoneNumProvider phoneNumProvider =
// Provider.of<PhoneNumProvider>(Get.context!, listen: false);
// }

Loading…
Cancel
Save