From 339034f3c81626969d82136e4cf16d5b11031bb6 Mon Sep 17 00:00:00 2001 From: wylyl22 <2373073266@qq.com> Date: Wed, 21 Sep 2022 16:20:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=A4=E5=8F=91=E5=8A=9F=E8=83=BD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 6 +- lib/model/hive/ContentHive.g.dart | 2 +- lib/model/hive/phone_model.dart | 54 ++++ lib/model/hive/phone_model.g.dart | 109 +++++++ lib/model/hive/phone_number_hive.dart | 81 ----- lib/providers/phone_num_provider.dart | 54 ++-- lib/providers/user_provider.dart | 21 +- lib/ui/TextMe/address_book.dart | 369 ++++++++++++---------- lib/ui/TextMe/call_list_page.dart | 250 +++++++++++++++ lib/ui/TextMe/text_me_page.dart | 30 +- lib/ui/TextMe/text_template.dart | 2 +- lib/ui/exclude/exclude_contacts_page.dart | 44 ++- lib/ui/exclude/exclude_single_page.dart | 34 +- lib/ui/home/call.dart | 18 +- lib/ui/loading.dart | 10 +- lib/ui/login/login_page.dart | 2 +- lib/ui/tab_navigator.dart | 8 +- lib/ui/user/user_page.dart | 46 +-- lib/ui/widget/appdialog.dart | 4 +- lib/ui/widget/scaffold_theme_widget.dart | 3 +- lib/utils/hive_store.dart | 8 +- lib/utils/user_tool.dart | 12 +- 22 files changed, 803 insertions(+), 364 deletions(-) create mode 100644 lib/model/hive/phone_model.dart create mode 100644 lib/model/hive/phone_model.g.dart delete mode 100644 lib/model/hive/phone_number_hive.dart create mode 100644 lib/ui/TextMe/call_list_page.dart diff --git a/lib/main.dart b/lib/main.dart index ba3cf08..3be61bd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,7 +5,6 @@ import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_background_service/flutter_background_service.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: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/user_provider.dart'; -import 'package:project_telephony/ui/home/call.dart'; + import 'package:project_telephony/ui/loading.dart'; import 'package:project_telephony/ui/tab_navigator.dart'; @@ -31,6 +30,7 @@ void main() async { const buildType = String.fromEnvironment('BUILD_TYPE'); DeveloperUtil.setDev(!(buildType.contains('PRODUCT'))); WidgetsFlutterBinding.ensureInitialized(); + await HiveStore.init(); // await initializeService(); // Workmanager().initialize( // callbackDispatcher, // The top level function, aka callbackDispatcher diff --git a/lib/model/hive/ContentHive.g.dart b/lib/model/hive/ContentHive.g.dart index 6bca3b7..d0921b8 100644 --- a/lib/model/hive/ContentHive.g.dart +++ b/lib/model/hive/ContentHive.g.dart @@ -8,7 +8,7 @@ part of 'ContentHive.dart'; class ContentHiveAdapter extends TypeAdapter { @override - final int typeId = 0; + final int typeId = 2; @override ContentHive read(BinaryReader reader) { diff --git a/lib/model/hive/phone_model.dart b/lib/model/hive/phone_model.dart new file mode 100644 index 0000000..c5dbcff --- /dev/null +++ b/lib/model/hive/phone_model.dart @@ -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? phoneList; + + factory PhoneModel.fromJson(Map json) => + _$PhoneModelFromJson(json); + + PhoneModel({ + this.title, + this.time, + this.state, + this.phoneList, + }); + + @override + List 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 json) => + _$PhoneNumFromJson(json); + + PhoneNum({ + this.name, + this.phone, + this.state, + }); + + @override + List get props => [name, phone, state]; +} diff --git a/lib/model/hive/phone_model.g.dart b/lib/model/hive/phone_model.g.dart new file mode 100644 index 0000000..b7439e1 --- /dev/null +++ b/lib/model/hive/phone_model.g.dart @@ -0,0 +1,109 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'phone_model.dart'; + +// ************************************************************************** +// TypeAdapterGenerator +// ************************************************************************** + +class PhoneModelAdapter extends TypeAdapter { + @override + final int typeId = 0; + + @override + PhoneModel read(BinaryReader reader) { + final numOfFields = reader.readByte(); + final fields = { + 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(), + ); + } + + @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 { + @override + final int typeId = 1; + + @override + PhoneNum read(BinaryReader reader) { + final numOfFields = reader.readByte(); + final fields = { + 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 json) => PhoneModel( + title: json['title'] as String?, + time: json['time'] as String?, + state: json['state'] as bool?, + phoneList: (json['phoneList'] as List?) + ?.map((e) => PhoneNum.fromJson(e as Map)) + .toList(), + ); + +PhoneNum _$PhoneNumFromJson(Map json) => PhoneNum( + name: json['name'] as String?, + phone: json['phone'] as String?, + state: json['state'] as bool?, + ); diff --git a/lib/model/hive/phone_number_hive.dart b/lib/model/hive/phone_number_hive.dart deleted file mode 100644 index da42aed..0000000 --- a/lib/model/hive/phone_number_hive.dart +++ /dev/null @@ -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? phoneList; - - PhoneNumberHive({ - this.id, - this.title, - this.time, - this.state, - this.phoneList, - }); - PhoneNumberHive.fromJson(Map 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 toJson(){ - final Map data= {}; - 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 json){ - id=json['id']; - name=json['name']; - phone=json['phone']; - state=json['state']; - } - Map toJson(){ - final Map data={}; - data["id"]=id; - data['name']=name; - data['phone']=phone; - data['state']=state; - return data; - } -} \ No newline at end of file diff --git a/lib/providers/phone_num_provider.dart b/lib/providers/phone_num_provider.dart index 36032a3..e006ae0 100644 --- a/lib/providers/phone_num_provider.dart +++ b/lib/providers/phone_num_provider.dart @@ -1,28 +1,44 @@ 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{ - final List _phoneNum=[PhoneNumModel(num: "",time: 0,name: "", state:false)]; - List get phoneNum=>_phoneNum; - Future list(List phoneList) async{ - // await HiveStore.dataBox!.get(); - // final Iterable entries = await CallLog.query(); - - // for (CallLogEntry entrie in entries) { - // _phoneNum.add(PhoneNumModel( - // num: entrie.number, - // time: entrie.timestamp, - // name: entrie.name, - // state: false, - // )); - // // a.add(entrie.number); - // } - // final phoneList=_phoneNum.toSet(); - // final phoneList= HiveStore.dataBox?.get(phoneNum); - return ; + List? contacts; + final List _massList = []; + List _phoneList = []; + List get massList=>_massList; + List get phoneList=>_phoneList; + Future init() async{ + contacts = await FlutterContacts.getContacts(); + for (var element in contacts!) { + final full = await FlutterContacts.getContact(element.id); + _phoneList.add(PhoneNum(name: full?.displayName, phone: full?.phones.first.number,state: false)); + // + // print(full?.displayName); + // print(full?.phones.first.number); + } + await HiveStore.dataBox!.put("pl",_phoneList) ; + _massList.add(PhoneModel(title:"未分组联系人",time: "本机通讯录",phoneList:HiveStore.dataBox!.get("pl"),state: false)); + HiveStore.dataBox?.put("ml",_massList) ; + // print( "这是我的类型${HiveStore.dataBox?.get("ml").runtimeType}"); + + } + Future upDate() async{ + _phoneList=await HiveStore.dataBox?.get("pl"); + + } // Future } \ No newline at end of file diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index 47b41d3..a54992f 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -30,6 +30,8 @@ class UserProvider extends ChangeNotifier { Future init() async { if (HiveStore.appBox?.containsKey('token') ?? false) { final token = HiveStore.appBox?.get('token') as String; + // UserTool.phoneNumProvider.init(); + // print("重置"); _isLogin = true; apiClient.setToken(token); await updateUserInfo(); @@ -55,6 +57,7 @@ class UserProvider extends ChangeNotifier { await updateUserInfo(); prefs.setInt("numIndex", 0); _viewLoading(); + UserTool.phoneNumProvider.init(); // prefs.setStringList("dxText",["祝你万事顺心","欢迎你的来电,祝你生活愉快","感谢您的来电,我们会尽快处理",]); updateConSms(); updateRefSms(); @@ -70,6 +73,7 @@ class UserProvider extends ChangeNotifier { apiClient.clearToken(); _isLogin = false; await HiveStore.appBox?.delete('token'); + HiveStore.dataBox?.delete("ml"); service.invoke("stopService"); } @@ -97,7 +101,7 @@ class UserProvider extends ChangeNotifier { ? "${base.data['content']}" : "【${UserTool.userProvider.userInfo.tag}】${base.data['content']}"); service.invoke("stopService"); - if (prefs.getBool('kg')!) { + if (prefs.getBool('kg') ?? false) { Future.delayed(const Duration(seconds: 1), () async { service.startService(); }); @@ -120,7 +124,7 @@ class UserProvider extends ChangeNotifier { ? "${base.data['content']}" : "【${UserTool.userProvider.userInfo.tag}】${base.data['content']}"); service.invoke("stopService"); - if (prefs.getBool('kg')!) { + if (prefs.getBool('kg') ?? false) { Future.delayed(const Duration(seconds: 1), () async { service.startService(); }); @@ -143,7 +147,7 @@ class UserProvider extends ChangeNotifier { ? "${base.data['content']}" : "【${UserTool.userProvider.userInfo.tag}】${base.data['content']}"); service.invoke("stopService"); - if (prefs.getBool('kg')!) { + if (prefs.getBool('kg') ?? false) { Future.delayed(const Duration(seconds: 1), () async { service.startService(); }); @@ -166,7 +170,7 @@ class UserProvider extends ChangeNotifier { ? "${base.data['content']}" : "【${UserTool.userProvider.userInfo.tag}】${base.data['content']}"); service.invoke("stopService"); - if (prefs.getBool('kg')!) { + if (prefs.getBool('kg') ?? false) { Future.delayed(const Duration(seconds: 1), () async { service.startService(); }); @@ -183,9 +187,9 @@ class UserProvider extends ChangeNotifier { var base = await apiClient.request(API.exclude.find); if (base.code == 0) { await prefs.remove('exclude'); - await prefs.setStringList('exclude', base.data); + await prefs.setStringList('exclude', base.data ?? []); service.invoke("stopService"); - if (prefs.getBool('kg')!) { + if (prefs.getBool('kg') ?? false) { Future.delayed(const Duration(seconds: 1), () async { service.startService(); }); @@ -214,13 +218,11 @@ class UserProvider extends ChangeNotifier { await prefs.setStringList("addressList", numbers); service.invoke("stopService"); - if (prefs.getBool('kg')!) { + if (prefs.getBool('kg') ?? false) { Future.delayed(const Duration(seconds: 1), () async { service.startService(); }); } - - notifyListeners(); } @@ -241,7 +243,6 @@ class UserProvider extends ChangeNotifier { // numbers.add(full!.phones.first.number); } } - await prefs.setStringList("nameList",nameList ); prefs.setStringList("number", numbers); // print(contacts.length); diff --git a/lib/ui/TextMe/address_book.dart b/lib/ui/TextMe/address_book.dart index 839bfba..e5b46ba 100644 --- a/lib/ui/TextMe/address_book.dart +++ b/lib/ui/TextMe/address_book.dart @@ -1,19 +1,24 @@ +import 'package:flustars/flustars.dart'; import 'package:flutter/cupertino.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:project_telephony/model/hive/phone_model.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 '../../model/mass_list_model.dart'; -import '../../model/phone_num_model.dart'; + import '../widget/plone_back_button.dart'; import '../widget/plone_bottom.dart'; +import 'call_list_page.dart'; + +typedef NumList = Function(List content); 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 _AddressBookState createState() => _AddressBookState(); @@ -22,12 +27,20 @@ class AddressBook extends StatefulWidget { class _AddressBookState extends State { final EasyRefreshController _easyRefreshController = EasyRefreshController(); String phoneName = ""; - List massList = []; - List phoneList = []; + List massList = []; + List phoneList = []; + List NumList = []; + bool state=false; @override void initState() { - a(); + // print("这是我的第二个类型${massList.runtimeType}"); + // print(HiveStore.dataBox?.get("ml")); + massList = HiveStore.dataBox?.get("ml").cast(); + // UserTool.phoneNumProvider.init(); + // massList=HiveStore.dataBox?.get("ml").cast(); +// List list + // massList= HiveStore.dataBox?.get("ml"); super.initState(); } @@ -37,179 +50,195 @@ class _AddressBookState extends State { super.dispose(); } - a() async { - final SharedPreferences prefs = await SharedPreferences.getInstance(); - List numbers = []; - List? nameList = []; - List? 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 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: 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(() {}); - }, - ), + 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(MassListModel( - state: false, - list: [], - title: phoneName, - time: nowTime)); - // await - Navigator.pop(context); - _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 { - setState(() {}); - }, - child: ListView.builder( - itemBuilder: (context, index) { - return _getBox(massList[index], index, massList[index].list.length); + 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(); + // massList=HiveStore.dataBox?.get("ml").cast>(); + 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) { - return GestureDetector( - child: 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)) ; - } - }); + _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()); }, - value: item.state, - title: Text( + child: Text( "${item.title}($num)", style: TextStyle(fontSize: 32.w, fontWeight: FontWeight.bold), ), - subtitle: Row( - children: [ - Text( - index == 0 ? "本机通讯录" : 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), - // ) - ], - ), + ), + 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), + // ) + ], ), ); } diff --git a/lib/ui/TextMe/call_list_page.dart b/lib/ui/TextMe/call_list_page.dart new file mode 100644 index 0000000..8874df2 --- /dev/null +++ b/lib/ui/TextMe/call_list_page.dart @@ -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; +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 { + final EasyRefreshController _refreshController = EasyRefreshController(); + List messList = []; + List 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 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(); + // numList = HiveStore.dataBox?.get("pl").cast(); + // 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, + ); + } +} diff --git a/lib/ui/TextMe/text_me_page.dart b/lib/ui/TextMe/text_me_page.dart index e9a91e3..0f6b331 100644 --- a/lib/ui/TextMe/text_me_page.dart +++ b/lib/ui/TextMe/text_me_page.dart @@ -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/utils/headers.dart'; import 'package:project_telephony/utils/toast/cloud_toast.dart'; -import 'package:telephony/telephony.dart'; import 'package:velocity_x/velocity_x.dart'; import '../widget/plone_back_button.dart'; @@ -25,6 +24,7 @@ class _TextMePageState extends State { String signatureText = ""; late TextEditingController _controller; late TextEditingController _phoneController; + List list = []; @override void initState() { @@ -58,7 +58,8 @@ class _TextMePageState extends State { body: ListView( children: [ _getBox('短信内容', "选择短信模版", () { - Get.to(() => TextTemplate( + Get.to(() => + TextTemplate( callback: (String content) { _controller.text = content; }, @@ -66,7 +67,12 @@ class _TextMePageState extends State { }, "请输入短信内容...", _controller), 32.hb, _getBox('收信号码', "通讯录中选择", () { - Get.to(() => const AddressBook()); + Get.to(() => + AddressBook(number: (List content) { + for(int i=0;i { print(_phoneController.text); print(signatureText); await sendSMS( - message:"【$signatureText】${_controller.text}", - recipients: [ - "13395740386", - "13486828191", - // "18815060992", - // "18294841148" - ], + 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}" @@ -104,8 +105,8 @@ class _TextMePageState extends State { _phoneController.text.isEmpty || signatureText.isEmpty, opacity: _controller.text.isEmpty || - _phoneController.text.isEmpty || - signatureText.isEmpty + _phoneController.text.isEmpty || + signatureText.isEmpty ? 0.4 : 1, text: "发送", @@ -170,11 +171,12 @@ class _TextMePageState extends State { // } // setState(() {}); // }, - onSubmitted: (text){ + onSubmitted: (text) { if (title == "短信内容") { _controller.text = text; } else { _phoneController.text = text; + } setState(() {}); }, diff --git a/lib/ui/TextMe/text_template.dart b/lib/ui/TextMe/text_template.dart index c50c19d..dcd08af 100644 --- a/lib/ui/TextMe/text_template.dart +++ b/lib/ui/TextMe/text_template.dart @@ -73,7 +73,7 @@ class _TextTemplateState extends State { footer: MaterialFooter(), onRefresh: () async { final prefs = await SharedPreferences.getInstance(); - textList = prefs.getStringList("dxText")!; + textList = prefs.getStringList("dxText") ?? []; textList.add("自定义短信模版"); setState(() {}); }, diff --git a/lib/ui/exclude/exclude_contacts_page.dart b/lib/ui/exclude/exclude_contacts_page.dart index 21d95bc..8f7676f 100644 --- a/lib/ui/exclude/exclude_contacts_page.dart +++ b/lib/ui/exclude/exclude_contacts_page.dart @@ -4,16 +4,18 @@ import 'package:flutter_contacts/flutter_contacts.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.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 '../../model/exclude_phone_model.dart'; +import '../../model/hive/phone_model.dart'; import '../../model/network/api_client.dart'; import '../../model/network/base_model.dart'; +import '../../utils/hive_store.dart'; 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 _ExcludeContactsPageState createState() => _ExcludeContactsPageState(); @@ -25,6 +27,8 @@ class _ExcludeContactsPageState extends State { List numbers1 = []; List status = []; var flag = true; + List messList = []; + List numList = []; @override void initState() { @@ -37,15 +41,15 @@ class _ExcludeContactsPageState extends State { contacts = await FlutterContacts.getContacts(); for (var element in contacts!) { final full = await FlutterContacts.getContact(element.id); - if(full?.phones.length==0){ + if (full?.phones.length == 0) { numbers.add('无'); - }else{ + } else { numbers.add(full!.phones.first.number); } status.add(false); } // await prefs.setStringList("addressList", numbers); - print(contacts?.length); + // print(contacts?.length); setState(() {}); } @@ -58,11 +62,9 @@ class _ExcludeContactsPageState extends State { flag = false; return Container(); } else { - return ListView.builder( itemCount: contacts!.length, itemBuilder: (context, i) { - return ListTile( title: Text( contacts![i].displayName, @@ -106,15 +108,31 @@ class _ExcludeContactsPageState extends State { if (status[i] == true) { excludeList.add( Exclude(phone: numbers[i], remark: contacts![i].displayName)); + // numList.add(PhoneNum(phone: numbers[i],name: contacts![i].displayName,state: false)); } } if (status.contains(true)) { - BaseModel res = await apiClient - .request(API.exclude.add, data: {'exclude': excludeList}); - if (res.code == 0) { - BotToast.showText(text: res.msg); - Get.back(); + if (widget.qf) { + messList = await HiveStore.dataBox?.get("ml").cast(); + // numList = HiveStore.dataBox?.get("pl").cast(); + for (int i = 0; i < status.length; i++) { + 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(); + // _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 { BotToast.showText(text: "还未选中手机号"); diff --git a/lib/ui/exclude/exclude_single_page.dart b/lib/ui/exclude/exclude_single_page.dart index c0b1070..58fbc9a 100644 --- a/lib/ui/exclude/exclude_single_page.dart +++ b/lib/ui/exclude/exclude_single_page.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.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/model/hive/phone_model.dart'; import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; import 'package:velocity_x/velocity_x.dart'; @@ -11,9 +12,12 @@ import '../../constants/api.dart'; import '../../model/exclude_phone_model.dart'; import '../../model/network/api_client.dart'; import '../../model/network/base_model.dart'; +import '../../utils/hive_store.dart'; 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 _ExcludeSinglePageState createState() => _ExcludeSinglePageState(); @@ -47,6 +51,30 @@ class _ExcludeSinglePageState extends State { if (_phoneController.text.isEmpty) { BotToast.showText(text: "未输入手机号"); } else { + if(widget.qf){ + List messList=[]; + messList = await HiveStore.dataBox?.get("ml").cast(); + // numList = HiveStore.dataBox?.get("pl").cast(); + // 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( API.exclude.add, data: { @@ -58,10 +86,10 @@ class _ExcludeSinglePageState extends State { ); BotToast.showText(text: res.msg); if (res.code == 0) { - Get.back(); + // Get.back(); Get.back(); } - } + }} }, isOpacity: _phoneController.text.isNotEmpty || _nameController.text.isNotEmpty, diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index 868020c..7904b86 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -60,8 +60,8 @@ void onStart(ServiceInstance service) async { bool? callSw = prefs.getBool('callSwitch'); bool? idleSw = prefs.getBool('idleSwitch'); int? numberSet = prefs.getInt("numIndex") ?? 0; - List? numberList = prefs.getStringList("addressList") ; - List? noNumberList = prefs.getStringList("specified"); + List? numberList = prefs.getStringList("addressList") ??[] ; + List? noNumberList = prefs.getStringList("specified") ??[]; print("号码设置$numberSet 通讯列表$numberList 指定不发送$noNumberList"); if (callState == "IDLE") { if (flag != 0) { @@ -72,13 +72,13 @@ void onStart(ServiceInstance service) async { // if() switch (numberSet) { case 0: - if (!(noNumberList!.contains(phoneNum))) { + if (!(noNumberList.contains(phoneNum))) { if (flag > 0) { - print("来电拒接/未接"); + // print("来电拒接/未接"); print("${phoneNum!}:${ref!}"); Telephony.backgroundInstance .sendSms(to: phoneNum!, message: ref); - print("发送成功"); + // print("发送成功"); } else if (flag == -1) { print("来电接听"); print("${phoneNum!}:${con!}"); @@ -110,8 +110,8 @@ void onStart(ServiceInstance service) async { } break; case 1: - if ((numberList!.contains(phoneNum)) && - !(noNumberList!.contains(phoneNum))) { + if ((numberList.contains(phoneNum)) && + !(noNumberList.contains(phoneNum))) { if (flag > 0) { print("来电拒接/未接"); print("${phoneNum!}:${ref!}"); @@ -149,8 +149,8 @@ void onStart(ServiceInstance service) async { } break; case 2: - if (!(numberList!.contains(phoneNum)) && - !(noNumberList!.contains(phoneNum))) { + if (!(numberList.contains(phoneNum)) && + !(noNumberList.contains(phoneNum))) { if (flag > 0) { print("来电拒接/未接"); print("${phoneNum!}:${ref!}"); diff --git a/lib/ui/loading.dart b/lib/ui/loading.dart index 30b89b6..353affa 100644 --- a/lib/ui/loading.dart +++ b/lib/ui/loading.dart @@ -6,7 +6,6 @@ import 'dart:async'; import 'package:project_telephony/utils/headers.dart'; import 'package:provider/provider.dart'; -import '../constants/environment/environment.dart'; import '../providers/user_provider.dart'; import '../utils/hive_store.dart'; @@ -19,10 +18,9 @@ class Loading extends StatefulWidget { } class _LoadingState extends State { - Future initialAll() async { - await HiveStore.init(); - } - + // Future initialAll() async { + // + // } @override void initState() { super.initState(); @@ -36,7 +34,7 @@ class _LoadingState extends State { // environment: env == 'dev', // ); Future.delayed(const Duration(milliseconds: 1000), () async { - await initialAll(); + // await initialAll(); if (!await userProvider.init()) { await Get.offAll(() => const TabNavigator()); // await Get.offAll(() => const LoginPage()); diff --git a/lib/ui/login/login_page.dart b/lib/ui/login/login_page.dart index e2404c9..72bd5e8 100644 --- a/lib/ui/login/login_page.dart +++ b/lib/ui/login/login_page.dart @@ -54,7 +54,7 @@ class _LoginPageState extends State { _smsCodeFocusNode = FocusNode(); _phoneController = TextEditingController(); _smsCodeController = TextEditingController(); - final userProvider = Provider.of(context, listen: false); + // final userProvider = Provider.of(context, listen: false); var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); if (kDebugMode) { print('env :$env'); diff --git a/lib/ui/tab_navigator.dart b/lib/ui/tab_navigator.dart index 0bf8f17..8ed0926 100644 --- a/lib/ui/tab_navigator.dart +++ b/lib/ui/tab_navigator.dart @@ -30,10 +30,10 @@ class _TabNavigatorState extends State void initState() { super.initState(); //页面加载调用 - Future.delayed(const Duration(milliseconds: 0), () async { - //Hive.initFlutter; - await HiveStore.init(); - }); + // Future.delayed(const Duration(milliseconds: 0), () async { + // //Hive.initFlutter; + // await HiveStore.init(); + // }); _pages = [const HomePage(), const TextMePage(),const UserPage()]; _tabController = TabController( length: _pages.length, vsync: this, initialIndex: widget.index ?? 0); diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index ad9c810..5e41f39 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -28,8 +28,6 @@ import '../home/call.dart'; import '../widget/appdialog.dart'; import 'content_details_page.dart'; - - class UserPage extends StatefulWidget { const UserPage({Key? key}) : super(key: key); @@ -65,6 +63,7 @@ class _UserPageState extends State { @override void initState() { super.initState(); + // showDialog(context: context, builder: (context){ // return const AppDialog(); // }); @@ -91,6 +90,25 @@ class _UserPageState extends State { // } } + @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{ // var res=await apiClient.request(API.app.trialVip); // if(res.code==0){ @@ -122,16 +140,8 @@ class _UserPageState extends State { _getRequests(); // await UserTool.userProvider.updateUserInfo(); if (UserTool.userProvider.isLogin) { - // var res=await apiClient.request(API.app.trialVip); //没领过0领过1 - 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(DateTime.now().millisecondsSinceEpoch); if (UserTool.userProvider.userInfo.isVip != 1) { @@ -147,7 +157,7 @@ class _UserPageState extends State { // format: DateFormats.y_mo_d); } else { vle = false; - Get.to(()=>const LoginPage()); + Get.to(() => const LoginPage()); } setState(() {}); }, @@ -164,7 +174,7 @@ class _UserPageState extends State { _getSwitch(Assets.icons.sms.path, "短信标签", false), _getSwitch(Assets.icons.card.path, "卡密兑换", false), // const Spacer(), - 100.hb, + 100.hb, UserTool.userProvider.isLogin ? PloneBottom( border: false, @@ -444,6 +454,7 @@ class _UserPageState extends State { // service.invoke("stopService"); // }); service.invoke("stopService"); + ///有问题?? // exit(0); // UserTool.userProvider.setKg(vle); @@ -488,22 +499,19 @@ class _UserPageState extends State { case "卡密兑换": Navigator.of(context) .push( - MaterialPageRoute(builder: (_) => const UserCardPage()), - ) + MaterialPageRoute(builder: (_) => const UserCardPage()), + ) .then((val) => _getRequests() + // _easyRefreshController.callRefresh() - // _easyRefreshController.callRefresh() - - - ); + ); break; default: break; } } }, - child: Container( padding: EdgeInsets.symmetric(horizontal: 32.w), child: ListTile( diff --git a/lib/ui/widget/appdialog.dart b/lib/ui/widget/appdialog.dart index d0d025f..2d527c0 100644 --- a/lib/ui/widget/appdialog.dart +++ b/lib/ui/widget/appdialog.dart @@ -74,8 +74,8 @@ _getBotton(String bContent, context) { var res = await apiClient.request(API.app.trialVip); if (res.code == 0) { CloudToast.show(res.msg); - UserTool.userProvider.updateUserInfo(); - Navigator.pop(context); + Get.back(); + // Navigator.pop(context); } else { CloudToast.show(res.msg); diff --git a/lib/ui/widget/scaffold_theme_widget.dart b/lib/ui/widget/scaffold_theme_widget.dart index 86e79fb..b6b0159 100644 --- a/lib/ui/widget/scaffold_theme_widget.dart +++ b/lib/ui/widget/scaffold_theme_widget.dart @@ -48,6 +48,7 @@ class _ScaffoldThemeWidgetState extends State { resizeToAvoidBottomInset: false, appBar: AppBar( elevation: 0, + centerTitle: true, title: Text( widget.title, style: TextStyle( @@ -55,7 +56,7 @@ class _ScaffoldThemeWidgetState extends State { color: BaseStyle.color333333, fontWeight: FontWeight.bold), ), - titleSpacing: widget.wid.w, + // titleSpacing: widget.wid.w, leading: const CloudBackButton(isSpecial: true), backgroundColor: kForeGroundColor), backgroundColor: Colors.white, diff --git a/lib/utils/hive_store.dart b/lib/utils/hive_store.dart index 75f1058..cd5d81a 100644 --- a/lib/utils/hive_store.dart +++ b/lib/utils/hive_store.dart @@ -2,7 +2,9 @@ import 'package:flutter/foundation.dart'; import 'package:hive/hive.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 { static Box? _appBox; @@ -20,7 +22,9 @@ class HiveStore { var dir = await getApplicationDocumentsDirectory(); Hive.init(dir.path); // 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'); _userBox = await Hive.openBox('userBox'); _dataBox = await Hive.openBox('dataBox'); diff --git a/lib/utils/user_tool.dart b/lib/utils/user_tool.dart index 8ed08cb..1d5d233 100644 --- a/lib/utils/user_tool.dart +++ b/lib/utils/user_tool.dart @@ -7,10 +7,12 @@ import 'headers.dart'; class UserTool { static UserProvider userProvider = Provider.of(Get.context!, listen: false); -// static PhoneProvider phoneProvider=Provider.of(Get.context!, listen: false); -} - -class PhoneTool { static PhoneNumProvider phoneNumProvider = - Provider.of(Get.context!, listen: false); + Provider.of(Get.context!, listen: false); +// static PhoneProvider phoneProvider=Provider.of(Get.context!, listen: false); } +// +// class PhoneTool { +// static PhoneNumProvider phoneNumProvider = +// Provider.of(Get.context!, listen: false); +// }