diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index 499485c..9636e7b 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -195,7 +195,7 @@ 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 ?? [] as List); service.invoke("stopService"); if (prefs.getBool('kg') ?? false) { Future.delayed(const Duration(seconds: 1), () async { diff --git a/lib/ui/TextMe/address_book.dart b/lib/ui/TextMe/address_book.dart index e5b46ba..6ac25fa 100644 --- a/lib/ui/TextMe/address_book.dart +++ b/lib/ui/TextMe/address_book.dart @@ -221,6 +221,7 @@ class _AddressBookState extends State { title: item.title ?? "", index: index, ))).then((value) => _easyRefreshController.callRefresh()); + print(index); }, child: Text( "${item.title}($num)", diff --git a/lib/ui/TextMe/call_list_page.dart b/lib/ui/TextMe/call_list_page.dart index 895dc75..07fdd21 100644 --- a/lib/ui/TextMe/call_list_page.dart +++ b/lib/ui/TextMe/call_list_page.dart @@ -8,7 +8,7 @@ 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 { @@ -80,7 +80,7 @@ class _CallListPageState extends State { _getBottom("号码添加", const Color(0xFF1890FF), () { Navigator.of(context) .push( - MaterialPageRoute(builder: (_) => const ExcludeSinglePage( qf: true,)), + MaterialPageRoute(builder: (_) => ExcludeSinglePage( qf: true,index: widget.index,)), ) .then((value) => _refreshController.callRefresh()); }, Colors.white, Colors.white, 2, const Color(0xFF1890FF), 58, 24), diff --git a/lib/ui/home/answer_idle.dart b/lib/ui/home/answer_idle.dart index 7431fa1..8e052b2 100644 --- a/lib/ui/home/answer_idle.dart +++ b/lib/ui/home/answer_idle.dart @@ -38,7 +38,7 @@ class _AnswerIdleListState extends State List textListSMS = []; List smsIdList = []; int isCheck = 0; - bool val = false; + bool val = true; // final EasyRefreshController _easyRefreshController = EasyRefreshController(); @override diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index 891d8c5..c573fd2 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -57,8 +57,8 @@ void onStart(ServiceInstance service) async { String? con = prefs.getString('conSms'); String? call = prefs.getString('callSms'); String? idle = prefs.getString('idleSms'); - bool? callSw = prefs.getBool('callSwitch'); - bool? idleSw = prefs.getBool('idleSwitch'); + bool? callSw = prefs.getBool('callSwitch') ?? true; + bool? idleSw = prefs.getBool('idleSwitch') ?? true; int? numberSet = prefs.getInt("numIndex") ?? 0; List? numberList = prefs.getStringList("addressList") ??[] ; List? noNumberList = prefs.getStringList("specified") ??[]; @@ -86,7 +86,7 @@ void onStart(ServiceInstance service) async { .sendSms(to: phoneNum!, message: con); } else { if (entry.first.duration! > 0) { - if (callSw!) { + if (callSw) { print(callSw); print("${phoneNum!}:${call!}"); Telephony.backgroundInstance @@ -94,7 +94,7 @@ void onStart(ServiceInstance service) async { } print("去电接听"); } else { - if (idleSw!) { + if (idleSw) { print(idleSw); print("${phoneNum!}:${idle!}"); Telephony.backgroundInstance @@ -125,7 +125,7 @@ void onStart(ServiceInstance service) async { .sendSms(to: phoneNum!, message: con); } else { if (entry.first.duration! > 0) { - if (callSw!) { + if (callSw) { print(callSw); print("${phoneNum!}:${call!}"); Telephony.backgroundInstance @@ -133,7 +133,7 @@ void onStart(ServiceInstance service) async { } print("去电接听"); } else { - if (idleSw!) { + if (idleSw) { print(idleSw); print("${phoneNum!}:${idle!}"); Telephony.backgroundInstance @@ -164,7 +164,7 @@ void onStart(ServiceInstance service) async { .sendSms(to: phoneNum!, message: con); } else { if (entry.first.duration! > 0) { - if (callSw!) { + if (callSw) { print(callSw); print("${phoneNum!}:${call!}"); Telephony.backgroundInstance @@ -172,7 +172,7 @@ void onStart(ServiceInstance service) async { } print("去电接听"); } else { - if (idleSw!) { + if (idleSw) { print(idleSw); print("${phoneNum!}:${idle!}"); Telephony.backgroundInstance diff --git a/lib/ui/home/calling_idle_list.dart b/lib/ui/home/calling_idle_list.dart index e83d3e0..d3a78a6 100644 --- a/lib/ui/home/calling_idle_list.dart +++ b/lib/ui/home/calling_idle_list.dart @@ -49,7 +49,7 @@ class _CallingIdleListState extends State List textListSMS = []; List smsIdList = []; int isCheck = 0; - late bool val = false; + late bool val = true; @override void initState() { diff --git a/lib/ui/loading.dart b/lib/ui/loading.dart index 5397724..d44c146 100644 --- a/lib/ui/loading.dart +++ b/lib/ui/loading.dart @@ -29,7 +29,8 @@ class _LoadingState extends State { Future.delayed(const Duration(milliseconds: 1000), () async { // await initialAll(); if (!await userProvider.init()) { - await Get.offAll(() => const LoginPage()); + // await Get.offAll(() => const LoginPage()); + await Get.offAll(() => const TabNavigator()); // await Get.offAll(() => const LoginPage()); } else { Navigator.of(context).pushReplacementNamed("/TabNavigator"); diff --git a/lib/ui/login/login_page.dart b/lib/ui/login/login_page.dart index 72bd5e8..f24b7b5 100644 --- a/lib/ui/login/login_page.dart +++ b/lib/ui/login/login_page.dart @@ -23,7 +23,8 @@ import '../widget/image_scaffold.dart'; import '../widget/plone_bottom.dart'; class LoginPage extends StatefulWidget { - const LoginPage({Key? key}) : super(key: key); + const + LoginPage({Key? key}) : super(key: key); @override _LoginPageState createState() => _LoginPageState(); @@ -133,6 +134,7 @@ class _LoginPageState extends State { } else if (!_chooseAgreement) { BotToast.showText(text: "请同意并勾选隐私政策"); } else { + if (_lastTap != null && DateTime.now().difference(_lastTap!).inSeconds < 2) { // BotToast.showText(text: "过快"); return; @@ -143,7 +145,7 @@ class _LoginPageState extends State { 'code': _smsCodeController.text }); if (base.code == 0) { - await UserTool.userProvider.setToken(base.data['token']); + await UserTool.userProvider.setToken(base.data['token']); Get.offAll(const TabNavigator()); } else { CloudToast.show(base.msg); diff --git a/lib/ui/tab_navigator.dart b/lib/ui/tab_navigator.dart index 8ed0926..bb10aad 100644 --- a/lib/ui/tab_navigator.dart +++ b/lib/ui/tab_navigator.dart @@ -34,7 +34,8 @@ class _TabNavigatorState extends State // //Hive.initFlutter; // await HiveStore.init(); // }); - _pages = [const HomePage(), const TextMePage(),const UserPage()]; + // , const TextMePage() + _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 5e41f39..9006a9b 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -1,9 +1,12 @@ +import 'dart:async'; + import 'package:bot_toast/bot_toast.dart'; import 'package:flustars/flustars.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:flutter_update_dialog/update_dialog.dart'; import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/ui/login/login_page.dart'; @@ -26,6 +29,7 @@ import '../../utils/toast/cloud_toast.dart'; import '../../utils/user_tool.dart'; import '../home/call.dart'; import '../widget/appdialog.dart'; + import 'content_details_page.dart'; class UserPage extends StatefulWidget { @@ -179,6 +183,7 @@ class _UserPageState extends State { ? PloneBottom( border: false, onTap: () async { + // showDialog(context: context, builder: (_)=>UpdateDialog()); var cancel = CloudToast.loading; var base = await apiClient.request( API.app.logout, diff --git a/lib/ui/widget/update_dialog.dart b/lib/ui/widget/update_dialog.dart index 285bc5d..f6ef08f 100644 --- a/lib/ui/widget/update_dialog.dart +++ b/lib/ui/widget/update_dialog.dart @@ -1,42 +1,62 @@ -// import 'package:flutter/material.dart'; -// import 'package:flutter_screenutil/flutter_screenutil.dart'; -// import 'package:project_telephony/utils/headers.dart'; -// -// class UpdateDialog extends Dialog { -// @override -// Widget build(BuildContext context) { -// final String upDateContent; -// final bool isForce; -// return Center( -// child: Column( -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// SizedBox( -// width: 640.w, -// height: 740.w, -// child: Stack( -// children: [ -// Image.asset( -// Assets.images.cardbg.path, -// fit: BoxFit.cover, -// ), -// Container( -// child: Column( -// children: [ -// Container( -// child: Text( -// "发现新版本", -// style: TextStyle(fontSize: 32.w,color: Colors.), -// ), -// ) -// ], -// ), -// ) -// ], -// ), -// ) -// ], -// ), -// ); +// import 'dart:async'; +// import 'dart:ui'; +// +// +// import 'package:flutter_update_dialog/flutter_update_dialog.dart'; +// +// import '../../utils/toast/cloud_toast.dart'; +// +// UpdateDialog? dialog; +// +// double progress = 0.0; +// +// void onUpdate() { +// CloudToast.show('开始升级...'); +// Timer.periodic(const Duration(milliseconds: 50), (Timer timer) { +// progress = progress + 0.02; +// if (progress > 1.0001) { +// timer.cancel(); +// dialog!.dismiss(); +// progress = 0; +// CloudToast.show('升级成功!'); +// } else { +// dialog!.update(progress); +// } +// }); +// } +// +// void defaultStyle() { +// if (dialog != null && dialog!.isShowing()) { +// return; +// } +// dialog = UpdateDialog.showUpdate(context, +// title: '是否升级到4.1.4版本?', +// updateContent: '新版本大小:2.0M\n1.xxxxxxx\n2.xxxxxxx\n3.xxxxxxx', +// onUpdate: onUpdate); +// } +// +// void customStyle() { +// if (dialog != null && dialog!.isShowing()) { +// return; // } +// dialog = UpdateDialog.showUpdate(context, +// width: 250, +// title: '是否升级到4.1.4版本?', +// updateContent: '新版本大小:2.0M\n1.xxxxxxx\n2.xxxxxxx\n3.xxxxxxx', +// titleTextSize: 14, +// contentTextSize: 12, +// buttonTextSize: 12, +// topImage: Image.asset('assets/bg_update_top.png'), +// extraHeight: 5, +// radius: 8, +// themeColor: const Color(0xFFFFAC5D), +// progressBackgroundColor: const Color(0x5AFFAC5D), +// isForce: true, +// updateButtonText: '升级', +// ignoreButtonText: '忽略此版本', +// enableIgnore: true, onIgnore: () { +// CloudToast.show('忽略'); +// dialog!.dismiss(); +// }, onUpdate: onUpdate); // } +// } \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 9d94742..90052e4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -435,6 +435,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_update_dialog: + dependency: "direct main" + description: + name: flutter_update_dialog + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" flutter_web_plugins: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index b3ecc48..31056bb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -99,6 +99,8 @@ dependencies: common_utils: ^2.1.0 # 群发号码 flutter_sms: ^2.3.3 +# 弹出框 + flutter_update_dialog: ^2.0.0 ## 生成适配器 # hive_generator: ^1.1.3 # # jdk