From 124a48712e4e8657129c5a840cecc9636ea5265b Mon Sep 17 00:00:00 2001 From: wylyl22 <2373073266@qq.com> Date: Thu, 25 Aug 2022 16:03:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/providers/user_provider.dart | 7 +++- lib/ui/home/call.dart | 4 +- lib/ui/loading.dart | 10 ++--- lib/ui/login/login_page.dart | 16 ++++---- lib/ui/tab_navigator.dart | 3 +- lib/ui/user/content_details_page.dart | 2 + lib/ui/user/privacy_rights_page.dart | 23 ++++++++++- pubspec.lock | 58 ++++++++++++++++++++++++++- pubspec.yaml | 3 +- 9 files changed, 104 insertions(+), 22 deletions(-) diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index ae301d9..071d523 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_background_service/flutter_background_service.dart'; +import 'package:project_telephony/utils/user_tool.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../constants/api.dart'; @@ -78,7 +79,8 @@ class UserProvider extends ChangeNotifier { var base = await apiClient.request(API.app.find, data: {'status': 1}); if (base.code == 0) { await prefs.remove('conSms'); - await prefs.setString('conSms', base.data['content']); + await prefs.setString('conSms', "[${UserTool.userProvider.userInfo.tag}]${base + .data['content']}"); service.invoke("stopService"); if(prefs.getBool('kg')!){ Future.delayed(const Duration(seconds: 1), () async { @@ -98,7 +100,8 @@ class UserProvider extends ChangeNotifier { var base = await apiClient.request(API.app.find, data: {'status': 2}); if (base.code == 0) { await prefs.remove('refSms'); - await prefs.setString('refSms', base.data['content']); + await prefs.setString('refSms', "[${UserTool.userProvider.userInfo.tag}]${base + .data['content']}" ); service.invoke("stopService"); if(prefs.getBool('kg')!){ Future.delayed(const Duration(seconds: 1), () async { diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index 8d12466..c67ec28 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -60,10 +60,10 @@ void onStart(ServiceInstance service) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); CallState state = await Telephony.instance.callState; callState = state.name; - print(callState+"$flag"); + // print(callState+"$flag"); String? ref = prefs.getString('refSms'); String? con = prefs.getString('conSms'); - print(con); + // print(con); if (callState == "IDLE") { if (flag != 0) { diff --git a/lib/ui/loading.dart b/lib/ui/loading.dart index b4007e8..fe4e10c 100644 --- a/lib/ui/loading.dart +++ b/lib/ui/loading.dart @@ -28,11 +28,11 @@ class _LoadingState extends State { void initState() { super.initState(); final userProvider = Provider.of(context, listen: false); - var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); - if (kDebugMode) { - print('env :$env'); - } - DevEV.instance.setEnvironment( context, environment: env == 'dev',); + // var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); + // if (kDebugMode) { + // print('env :$env'); + // } + // DevEV.instance.setEnvironment( context, environment: env == 'dev',); Future.delayed(const Duration(milliseconds: 1000), () async { await initialAll(); if (!await userProvider.init()) { diff --git a/lib/ui/login/login_page.dart b/lib/ui/login/login_page.dart index e6fcc92..dfa594f 100644 --- a/lib/ui/login/login_page.dart +++ b/lib/ui/login/login_page.dart @@ -51,14 +51,14 @@ class _LoginPageState extends State { _phoneController = TextEditingController(); _smsCodeController = TextEditingController(); final userProvider = Provider.of(context, listen: false); - var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); - if (kDebugMode) { - print('env :$env'); - } - DevEV.instance.setEnvironment( - context, - environment: env == 'dev', - ); + // var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); + // if (kDebugMode) { + // print('env :$env'); + // } + // DevEV.instance.setEnvironment( + // context, + // environment: env == 'dev', + // ); } @override diff --git a/lib/ui/tab_navigator.dart b/lib/ui/tab_navigator.dart index 0bcf46b..0a259c4 100644 --- a/lib/ui/tab_navigator.dart +++ b/lib/ui/tab_navigator.dart @@ -72,10 +72,9 @@ class _TabNavigatorState extends State const Duration(seconds: 1)) { //两次点击间隔超过1秒重新计算 _lastPressed = DateTime.now(); - BotToast.showText(text: '再点击一次返回退出'); + BotToast.showText(text: '再按一次即可退出程序(退出不回影响短信自动回复,但是不要在后台关闭本应用)'); return false; } - // 否则关闭APP return true; }, diff --git a/lib/ui/user/content_details_page.dart b/lib/ui/user/content_details_page.dart index c7a69b6..7a84d38 100644 --- a/lib/ui/user/content_details_page.dart +++ b/lib/ui/user/content_details_page.dart @@ -111,6 +111,8 @@ final FocusNode verifyNode=FocusNode(); setState(() {}); widget.ploneBack(_controller.text); UserTool.userProvider.updateUserInfo(); + UserTool.userProvider.updateConSms(); + UserTool.userProvider.updateRefSms(); Get.back(); } else { CloudToast.show(res.msg); diff --git a/lib/ui/user/privacy_rights_page.dart b/lib/ui/user/privacy_rights_page.dart index 6d365b5..d849bde 100644 --- a/lib/ui/user/privacy_rights_page.dart +++ b/lib/ui/user/privacy_rights_page.dart @@ -4,6 +4,8 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/ui/widget/plone_back_button.dart'; import 'package:project_telephony/utils/headers.dart'; +import 'package:url_launcher/url_launcher.dart'; +import 'package:url_launcher/url_launcher_string.dart'; class PrivacyRightsPage extends StatefulWidget { @@ -14,7 +16,7 @@ class PrivacyRightsPage extends StatefulWidget { @override _PrivacyRightsPageState createState() => _PrivacyRightsPageState(); } - +final Uri _url = Uri.parse('http://www.dxbs.vip/explain.html'); // final Telephony telephony = Telephony.instance; // late final bool permissionsGranted; // String body = ""; @@ -58,6 +60,20 @@ class _PrivacyRightsPageState extends State { backgroundColor: kForeGroundColor), backgroundColor: Colors.white, body: _getRights(), + bottomNavigationBar: GestureDetector( + onTap:()async{ + // await _launchUrl(); + // await launchUrlString("tel:13111111111"); + } , + // onTap: () async{ + // + // }, + child: + Container(margin: + EdgeInsets.symmetric(horizontal: 64.w,vertical: 24.w), + padding: EdgeInsets.symmetric(horizontal: 214.w,vertical: 26.w) , + decoration: BoxDecoration(color:const Color(0xFFF9F9F9),borderRadius: BorderRadius.circular(8.w) ), + child: Text("查看使用说明",style: TextStyle(color: const Color(0xFF1890FF),fontSize: 28.sp),),),), ); } // Color getPermissionColor() { @@ -75,6 +91,11 @@ class _PrivacyRightsPageState extends State { // return "已允许"; // } // } + Future _launchUrl() async { + if (!await launchUrl(_url)) { + throw 'Could not launch $_url'; + } + } _getRights(){ return ListTile( onTap: ()async{ diff --git a/pubspec.lock b/pubspec.lock index e4dc2ce..4776abf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1087,6 +1087,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.4" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.5" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.17" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.17" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.13" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" vector_math: dependency: transitive description: @@ -1152,4 +1208,4 @@ packages: version: "3.1.1" sdks: dart: ">=2.17.0 <3.0.0" - flutter: ">=2.8.1" + flutter: ">=2.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index dfa968e..d5dc671 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -81,7 +81,8 @@ dependencies: shared_preferences: ^2.0.15 #刷新组件 flutter_easyrefresh: ^2.2.1 - +# 链接 + url_launcher: ^6.1.5 # # jdk # jverify: ^2.2.5