From 8e2a3bf79d84ec1e252fbe744666bc52ecebfcb7 Mon Sep 17 00:00:00 2001 From: wanghongenpin Date: Mon, 14 Apr 2025 00:44:22 +0800 Subject: [PATCH] mobile check app version update --- ios/Runner.xcodeproj/project.pbxproj | 13 +++++- lib/ui/app_update/app_update_repository.dart | 2 +- lib/ui/component/app_dialog.dart | 4 +- lib/ui/configuration.dart | 2 +- lib/ui/mobile/mobile.dart | 4 ++ lib/ui/mobile/widgets/about.dart | 43 ++++++++++++++++---- 6 files changed, 55 insertions(+), 13 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 44a71f7..92d40ae 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 54; + objectVersion = 55; objects = { /* Begin PBXBuildFile section */ @@ -484,10 +484,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; @@ -539,10 +543,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; @@ -743,6 +751,7 @@ DEVELOPMENT_TEAM = DM3F8VR243; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -926,6 +935,7 @@ DEVELOPMENT_TEAM = DM3F8VR243; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -951,6 +961,7 @@ DEVELOPMENT_TEAM = DM3F8VR243; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/lib/ui/app_update/app_update_repository.dart b/lib/ui/app_update/app_update_repository.dart index 3ae68c0..138c19a 100644 --- a/lib/ui/app_update/app_update_repository.dart +++ b/lib/ui/app_update/app_update_repository.dart @@ -56,7 +56,7 @@ class AppUpdateRepository { } catch (e) { logger.e("Error checking for updates: $e"); if (showToast) { - AppAlertDialog(message: e.toString()).show(context); + CustomToast.error(e.toString()).show(context); } } } diff --git a/lib/ui/component/app_dialog.dart b/lib/ui/component/app_dialog.dart index 3401057..02c8aee 100644 --- a/lib/ui/component/app_dialog.dart +++ b/lib/ui/component/app_dialog.dart @@ -113,12 +113,12 @@ class CustomToast extends StatelessWidget { type: type._toastificationType, alignment: Alignment.bottomLeft, autoCloseDuration: duration, - style: ToastificationStyle.fillColored, + style: ToastificationStyle.flat, pauseOnHover: true, showProgressBar: false, dragToClose: true, closeOnClick: true, - closeButtonShowType: CloseButtonShowType.onHover, + closeButton: ToastCloseButton(showType: CloseButtonShowType.onHover), ); } } diff --git a/lib/ui/configuration.dart b/lib/ui/configuration.dart index c43b8e0..20d3144 100644 --- a/lib/ui/configuration.dart +++ b/lib/ui/configuration.dart @@ -50,7 +50,7 @@ class ColorMapping { class ThemeModel { ThemeMode mode; bool useMaterial3; - String color = "Blue"; + String color = "Pink"; ThemeModel({this.mode = ThemeMode.system, this.useMaterial3 = true}); diff --git a/lib/ui/mobile/mobile.dart b/lib/ui/mobile/mobile.dart index 25de14c..38aea23 100644 --- a/lib/ui/mobile/mobile.dart +++ b/lib/ui/mobile/mobile.dart @@ -49,6 +49,8 @@ import 'package:proxypin/utils/lang.dart'; import 'package:proxypin/utils/listenable_list.dart'; import 'package:proxypin/utils/navigator.dart'; +import '../app_update/app_update_repository.dart'; + ///移动端首页 ///@author wanghongen class MobileHomePage extends StatefulWidget { @@ -119,6 +121,8 @@ class MobileHomeState extends State implements EventListener, Li WidgetsBinding.instance.addPostFrameCallback((_) { showUpgradeNotice(); }); + } else if (Platform.isAndroid) { + AppUpdateRepository.checkUpdate(context); } } diff --git a/lib/ui/mobile/widgets/about.dart b/lib/ui/mobile/widgets/about.dart index e68bf2c..f361588 100644 --- a/lib/ui/mobile/widgets/about.dart +++ b/lib/ui/mobile/widgets/about.dart @@ -15,13 +15,25 @@ */ import 'package:flutter/material.dart'; +import 'package:proxypin/ui/configuration.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import '../../app_update/app_update_repository.dart'; + /// 关于 -class About extends StatelessWidget { +class About extends StatefulWidget { const About({super.key}); + @override + State createState() { + return _AboutState(); + } +} + +class _AboutState extends State { + bool checkUpdating = false; + @override Widget build(BuildContext context) { AppLocalizations localizations = AppLocalizations.of(context)!; @@ -39,26 +51,41 @@ class About extends StatelessWidget { padding: const EdgeInsets.only(left: 10, right: 10), child: Text(isCN ? "全平台开源免费抓包软件" : "Full platform open source free capture HTTP(S) traffic software")), const SizedBox(height: 10), - const Text("V1.1.7"), + Text("v${AppConfiguration.version}"), ListTile( title: const Text("GitHub"), - trailing: const Icon(Icons.arrow_right), + trailing: const Icon(Icons.open_in_new, size: 22), onTap: () { launchUrl(Uri.parse(gitHub), mode: LaunchMode.externalApplication); }), ListTile( title: Text(localizations.feedback), - trailing: const Icon(Icons.arrow_right), + trailing: const Icon(Icons.open_in_new, size: 22), onTap: () { launchUrl(Uri.parse("$gitHub/issues"), mode: LaunchMode.externalApplication); }), + ListTile( + title: Text(localizations.appUpdateCheckVersion), + trailing: checkUpdating + ? const SizedBox(width: 22, height: 22, child: CircularProgressIndicator()) + : const Icon(Icons.sync, size: 22), + onTap: () async { + if (checkUpdating) { + return; + } + setState(() { + checkUpdating = true; + }); + await AppUpdateRepository.checkUpdate(context, canIgnore: false, showToast: true); + setState(() { + checkUpdating = false; + }); + }), ListTile( title: Text(isCN ? "下载地址" : "Download"), - trailing: const Icon(Icons.arrow_right), + trailing: const Icon(Icons.open_in_new, size: 22), onTap: () { - launchUrl( - Uri.parse( - isCN ? "https://gitee.com/wanghongenpin/proxypin/releases" : "$gitHub/releases"), + launchUrl(Uri.parse(isCN ? "https://gitee.com/wanghongenpin/proxypin/releases" : "$gitHub/releases"), mode: LaunchMode.externalApplication); }) ],