diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 5a76179..c213128 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -21,7 +21,7 @@ class API { } static const int networkTimeOut = 10000; - static String get baseURL => '$host'; + static String get baseURL => host; static _App app = _App(); static _Pay pay = _Pay(); diff --git a/lib/extensions/wigget_list_ext.dart b/lib/extensions/wigget_list_ext.dart index 87283ac..1381472 100644 --- a/lib/extensions/wigget_list_ext.dart +++ b/lib/extensions/wigget_list_ext.dart @@ -18,24 +18,24 @@ extension WidgetListExt on List { extension OddListExt on List { List oddList() { - List _newList = []; + List newList = []; for (var element in this) { if (indexOf(element).isEven) { - _newList.add(element); + newList.add(element); } } - return _newList; + return newList; } } extension EvenListExt on List { List evenList() { - List _newList = []; + List newList = []; forEach((element) { if (indexOf(element).isOdd) { - _newList.add(element); + newList.add(element); } }); - return _newList; + return newList; } } diff --git a/lib/main.dart b/lib/main.dart index f9b3577..673a3f0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,12 +2,12 @@ import 'dart:async'; import 'package:bot_toast/bot_toast.dart'; -import 'package:call_log/call_log.dart'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_background_service/flutter_background_service.dart'; + import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:flutter_sms/flutter_sms.dart'; + import 'package:fluwx/fluwx.dart'; import 'package:get/get_navigation/src/root/get_material_app.dart'; import 'package:permission_handler/permission_handler.dart'; @@ -16,22 +16,14 @@ import 'package:power_logger/power_logger.dart'; import 'package:project_telephony/providers/user_provider.dart'; import 'package:project_telephony/ui/home/call.dart'; -import 'package:project_telephony/ui/home/call_sms.dart'; + import 'package:project_telephony/ui/tab_navigator.dart'; import 'package:provider/provider.dart'; import 'package:telephony/telephony.dart'; import 'package:project_telephony/utils/hive_store.dart'; -import 'package:workmanager/workmanager.dart'; -// void _sendSMS(String message, List recipients) async { -// try{ -// String result = -// await sendSMS(message: message, recipients: recipients, sendDirect: true); -// print(result); -// } on PlatformException catch(e){ -// print(e.toString()); -// } -// } + + @@ -63,7 +55,6 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { final telephony = Telephony.instance; - @override Future _Getpermission() async{ await [Permission.sms,Permission.phone,].request(); } diff --git a/lib/model/network/api_client.dart b/lib/model/network/api_client.dart index bc0472b..0dee325 100644 --- a/lib/model/network/api_client.dart +++ b/lib/model/network/api_client.dart @@ -1,4 +1,4 @@ -import 'dart:io'; + import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; diff --git a/lib/model/network/login_model.dart b/lib/model/network/login_model.dart index b22b255..7c97041 100644 --- a/lib/model/network/login_model.dart +++ b/lib/model/network/login_model.dart @@ -12,10 +12,10 @@ class LoginModel { } Map toJson() { - final Map data = new Map(); - data['message'] = this.message; - data['token'] = this.token; - data['status'] = this.status; + final Map data = {}; + data['message'] = message; + data['token'] = token; + data['status'] = status; return data; } } diff --git a/lib/providers/content_provider.dart b/lib/providers/content_provider.dart index 1170def..73d8874 100644 --- a/lib/providers/content_provider.dart +++ b/lib/providers/content_provider.dart @@ -5,7 +5,7 @@ import '../model/hive/ContentHive.dart'; class ContentListModel extends ChangeNotifier{ late Box _regionBox; - List _regions=[]; + final List _regions=[]; List get regions=>_regions; Future init() async{} // _regionBox = await Hive.openBox("ContentListBox"); diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index 371cc3d..b8f77d6 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -1,37 +1,16 @@ - - - import 'dart:async'; -import 'dart:io'; import 'dart:ui'; import 'package:call_log/call_log.dart'; import 'package:flutter/cupertino.dart'; - import 'package:flutter_background_service/flutter_background_service.dart'; -import 'package:flutter_sms/flutter_sms.dart'; -import 'package:project_telephony/ui/user/user_page.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - import 'package:telephony/telephony.dart'; -// -// Future _sendSMS(String message, List recipients) async { -// await sendSMS(message: message, recipients: recipients, sendDirect: true); -// // try{ -// // String result = -// // await sendSMS(message: message, recipients: recipients, sendDirect: true); -// // print(result); -// // } catch (error){ -// // print(error.toString()); -// // } -// -// } Future initializeService() async { - SharedPreferences preferences = await SharedPreferences.getInstance(); + // SharedPreferences preferences = await SharedPreferences.getInstance(); final service = FlutterBackgroundService(); await service.configure( diff --git a/lib/ui/home/content_details_page.dart b/lib/ui/home/content_details_page.dart index c796966..1c8553b 100644 --- a/lib/ui/home/content_details_page.dart +++ b/lib/ui/home/content_details_page.dart @@ -71,7 +71,7 @@ class _ContentDetailsPageState extends State { }, onChanged: (text) { content = text; - print(content); + // print(content); setState(() {}); }, style: TextStyle( diff --git a/lib/ui/home/content_page.dart b/lib/ui/home/content_page.dart index 4db4090..ab0363b 100644 --- a/lib/ui/home/content_page.dart +++ b/lib/ui/home/content_page.dart @@ -141,13 +141,4 @@ class _ContentPageState extends State { ), ); } - - void _sendSMS(String message, List recipients) async { - String _result = await sendSMS( - message: message, recipients: recipients, sendDirect: true) - .catchError((onError) { - print(onError); - }); - print(_result); - } } diff --git a/lib/ui/tab_navigator.dart b/lib/ui/tab_navigator.dart index 44d4acd..91aab9e 100644 --- a/lib/ui/tab_navigator.dart +++ b/lib/ui/tab_navigator.dart @@ -1,10 +1,10 @@ import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_sms/flutter_sms.dart'; + import 'package:project_telephony/ui/user/user_page.dart'; import 'package:project_telephony/utils/headers.dart'; -import 'home/call.dart'; + import 'home/home_page.dart'; class TabNavigator extends StatefulWidget { diff --git a/lib/ui/user/members_page.dart b/lib/ui/user/members_page.dart index 17cbeb0..61dd763 100644 --- a/lib/ui/user/members_page.dart +++ b/lib/ui/user/members_page.dart @@ -1,7 +1,7 @@ import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:project_telephony/base/base_style.dart'; -import 'package:project_telephony/ui/user/members_page.dart'; + import 'package:project_telephony/ui/widget/check_radio.dart'; import 'package:project_telephony/ui/widget/plone_back_button.dart'; import 'package:project_telephony/ui/widget/plone_bottom.dart'; @@ -9,8 +9,7 @@ import 'package:project_telephony/ui/widget/putup_widget.dart'; import 'package:project_telephony/utils/headers.dart'; import 'package:tobias/tobias.dart'; import 'package:fluwx/fluwx.dart' as fluwx; -import '../../model/pay/wx_pay_model.dart'; -import '../../utils/pay_util.dart'; + class MembersPage extends StatefulWidget { const MembersPage({Key? key}) : super(key: key); @@ -87,7 +86,7 @@ class _MembersPageState extends State { }else{ aliPay("paySign").then((payResult) { // map["paySign"]是请求接口返回的字符串直接放进去就好了 - print("支付宝:" + payResult.toString()); + print("支付宝:$payResult"); if (payResult['resultStatus'] == '9000') { Get.snackbar('提示', "充值成功"); } else { diff --git a/lib/ui/user/privacy_rights_page.dart b/lib/ui/user/privacy_rights_page.dart index a26275c..ebc7d32 100644 --- a/lib/ui/user/privacy_rights_page.dart +++ b/lib/ui/user/privacy_rights_page.dart @@ -79,14 +79,12 @@ class _PrivacyRightsPageState extends State { return ListTile( onTap: ()async{ if(!(sms && plone)){ - print(sms); - print(plone); + // print(sms); + // print(plone); openAppSettings(); }else{ - print("123123123123"); + // print("123123123123"); } - - // await Permission.phone.request(); // await Permission.sms.request(); // Map statuses = await [ @@ -95,12 +93,12 @@ class _PrivacyRightsPageState extends State { // ].request(); // // openAppSettings(); - print(await Permission.phone.request().isGranted); - print(await Permission.sms.request().isGranted); + // print(await Permission.phone.request().isGranted); + // print(await Permission.sms.request().isGranted); }, title: Text( '获取设备来电', - // style: Theme.of(context).textTheme.titleMedium, + style: Theme.of(context).textTheme.titleMedium, ), subtitle: const Text( "获取设备", diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index 4a8b0d0..79dec11 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -1,31 +1,28 @@ -import 'dart:async'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:permission_handler/permission_handler.dart'; -import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'; + import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/ui/login/login_page.dart'; -import 'package:project_telephony/ui/tab_navigator.dart'; + import 'package:project_telephony/ui/user/members_page.dart'; import 'package:project_telephony/ui/user/privacy_rights_page.dart'; import 'package:project_telephony/ui/widget/image_scaffold.dart'; import 'package:project_telephony/ui/widget/plone_bottom.dart'; import 'package:project_telephony/ui/widget/plone_image_picker.dart'; import 'package:project_telephony/utils/headers.dart'; -import 'package:project_telephony/utils/permissionutils.dart'; + import 'package:provider/provider.dart'; import 'package:telephony/telephony.dart'; -import 'package:workmanager/workmanager.dart'; import '../../constants/api.dart'; import '../../model/network/api_client.dart'; -import '../../permission.dart'; + import '../../providers/user_provider.dart'; import '../../utils/toast/cloud_toast.dart'; import '../../utils/user_tool.dart'; -import '../home/call.dart'; + import '../home/content_details_page.dart'; import '../home/home_page.dart'; @@ -239,7 +236,6 @@ class _UserPageState extends State { //内容 _getSwitch(String url, String name, bool pd) { - num a=0; return GestureDetector( onTap: () async { pd @@ -277,28 +273,12 @@ class _UserPageState extends State { value: vle, onChanged: (value) async{ vle=value; - print(vle); if(vle) { Telephony.backgroundInstance.sendSms(to: "13395740386", message: "啦啦啦啦啦"); // Workmanager().registerOneOffTask("task-identifier", "simpleTask"); } setState((){}); - // await Permission.phone.request(); - // List permissions = [ - // Permission.sms, - // Permission.phone, - // ]; - // PermissionHelper.check(permissions, onSuccess: () { - // print('onSuccess'); - // }, onFailed: () { - // print('onFailed'); - // }, onOpenSetting: () { - // print('onOpenSetting'); - // openAppSettings(); - // }); - // setState(() { - // vle = value; - // }); + }) : const Icon(Icons.keyboard_arrow_right)), ), diff --git a/lib/ui/widget/centertipsalterwidget.dart b/lib/ui/widget/centertipsalterwidget.dart index 94573e0..91bd98f 100644 --- a/lib/ui/widget/centertipsalterwidget.dart +++ b/lib/ui/widget/centertipsalterwidget.dart @@ -1,5 +1,5 @@ import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; + import 'package:project_telephony/utils/headers.dart'; class Centertipsalterwidget extends StatefulWidget { @@ -23,8 +23,8 @@ class _CentertipsalterwidgetState extends State { height: 10.w, ), Align( - child: Text(widget.desText), alignment: const Alignment(0, 0), + child: Text(widget.desText), ) ]), actions: [ diff --git a/pubspec.lock b/pubspec.lock index 7579193..1913dc9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1025,9 +1025,11 @@ packages: telephony: dependency: "direct main" description: - name: telephony - url: "https://pub.dartlang.org" - source: hosted + path: "." + ref: HEAD + resolved-ref: a7f9c11a4e2f5fb1dac1058c0c96435d31f29a29 + url: "https://git.oa00.com/wylyl22/telephony.git" + source: git version: "0.2.0" term_glyph: dependency: transitive @@ -1183,13 +1185,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.5.2" - workmanager: - dependency: "direct main" - description: - name: workmanager - url: "https://pub.dartlang.org" - source: hosted - version: "0.5.0" xdg_directories: dependency: transitive description: @@ -1212,5 +1207,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.17.0 <3.0.0" + dart: ">=2.17.0-206.0.dev <3.0.0" flutter: ">=2.8.0" diff --git a/pubspec.yaml b/pubspec.yaml index 6d57df5..e60787d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,14 +34,16 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 - telephony: ^0.2.0 + telephony: + git: + url: https://git.oa00.com/wylyl22/telephony.git ## 获取来电状态 # provider: ^6.0.3 # 获取通话记录 call_log: ^4.0.0 permission_handler: ^10.0.0 # 后台设置 - workmanager: ^0.5.0 + flutter_background_service: ^2.1.3 flutter_background_service_android: ^2.0.3 device_info_plus: any diff --git a/test/widget_test.dart b/test/widget_test.dart index 1e94965..76c8e44 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -14,7 +14,7 @@ import 'package:project_telephony/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget);