From 79c515c903f6577426c028b45dabf357a12e23fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lollipopkit=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7?= =?UTF-8?q?=EF=B8=8F?= <10864310+lollipopkit@users.noreply.github.com> Date: Thu, 5 Jun 2025 09:07:28 +0800 Subject: [PATCH] new: `bio_auth` -> `local_auth` (#776) Fixes #722 --- lib/view/page/home.dart | 6 +- lib/view/page/setting/entries/app.dart | 3 +- lib/view/page/setting/entry.dart | 1 + lib/view/page/setting/platform/android.dart | 2 - lib/view/page/setting/platform/ios.dart | 28 +++------ .../page/setting/platform/platform_pub.dart | 16 +++-- pubspec.lock | 4 +- pubspec.yaml | 62 +------------------ 8 files changed, 24 insertions(+), 98 deletions(-) diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index 984e431a..168a04fc 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -215,10 +215,10 @@ class _HomePageState extends State void _goAuth() { if (Stores.setting.useBioAuth.fetch()) { - if (BioAuthPage.route.alreadyIn) return; - BioAuthPage.route.go( + if (LocalAuthPage.route.alreadyIn) return; + LocalAuthPage.route.go( context, - args: BioAuthPageArgs(onAuthSuccess: () => _shouldAuth = false), + args: LocalAuthPageArgs(onAuthSuccess: () => _shouldAuth = false), ); } } diff --git a/lib/view/page/setting/entries/app.dart b/lib/view/page/setting/entries/app.dart index 8b73e926..73c7221e 100644 --- a/lib/view/page/setting/entries/app.dart +++ b/lib/view/page/setting/entries/app.dart @@ -8,8 +8,9 @@ extension _App on _AppSettingsPageState { _buildThemeMode(), _buildAppColor(), _buildCheckUpdate(), - if (specific != null) specific, + PlatformPublicSettings.buildBioAuth(), _buildAppMore(), + if (specific != null) specific, ]; return Column(children: children.map((e) => e.cardx).toList()); diff --git a/lib/view/page/setting/entry.dart b/lib/view/page/setting/entry.dart index 83aa70e6..d4bdca44 100644 --- a/lib/view/page/setting/entry.dart +++ b/lib/view/page/setting/entry.dart @@ -18,6 +18,7 @@ import 'package:server_box/view/page/backup.dart'; import 'package:server_box/view/page/private_key/list.dart'; import 'package:server_box/view/page/setting/platform/android.dart'; import 'package:server_box/view/page/setting/platform/ios.dart'; +import 'package:server_box/view/page/setting/platform/platform_pub.dart'; import 'package:server_box/view/page/setting/seq/srv_detail_seq.dart'; import 'package:server_box/view/page/setting/seq/srv_func_seq.dart'; import 'package:server_box/view/page/setting/seq/srv_seq.dart'; diff --git a/lib/view/page/setting/platform/android.dart b/lib/view/page/setting/platform/android.dart index 0c5f3c55..99a398e7 100644 --- a/lib/view/page/setting/platform/android.dart +++ b/lib/view/page/setting/platform/android.dart @@ -2,7 +2,6 @@ import 'package:fl_lib/fl_lib.dart'; import 'package:flutter/material.dart'; import 'package:server_box/core/extension/context/locale.dart'; import 'package:server_box/data/res/store.dart'; -import 'package:server_box/view/page/setting/platform/platform_pub.dart'; class AndroidSettingsPage extends StatefulWidget { const AndroidSettingsPage({super.key}); @@ -29,7 +28,6 @@ class _AndroidSettingsPageState extends State { // _buildFgService(), _buildBgRun(), _buildAndroidWidgetSharedPreference(), - if (BioAuth.isPlatformSupported) PlatformPublicSettings.buildBioAuth(), ].map((e) => CardX(child: e)).toList(), ), ); diff --git a/lib/view/page/setting/platform/ios.dart b/lib/view/page/setting/platform/ios.dart index ecb5dae4..7cd9a436 100644 --- a/lib/view/page/setting/platform/ios.dart +++ b/lib/view/page/setting/platform/ios.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:server_box/core/extension/context/locale.dart'; import 'package:server_box/core/utils/misc.dart'; import 'package:server_box/data/res/store.dart'; -import 'package:server_box/view/page/setting/platform/platform_pub.dart'; import 'package:watch_connectivity/watch_connectivity.dart'; class IosSettingsPage extends StatefulWidget { @@ -12,10 +11,7 @@ class IosSettingsPage extends StatefulWidget { @override State createState() => _IosSettingsPageState(); - static const route = AppRouteNoArg( - page: IosSettingsPage.new, - path: '/settings/ios', - ); + static const route = AppRouteNoArg(page: IosSettingsPage.new, path: '/settings/ios'); } class _IosSettingsPageState extends State { @@ -39,8 +35,6 @@ class _IosSettingsPageState extends State { _buildPushToken(), _buildAutoUpdateHomeWidget(), _buildWatchApp(), - if (BioAuth.isPlatformSupported) - PlatformPublicSettings.buildBioAuth(), ].map((e) => CardX(child: e)).toList(), ), ); @@ -69,12 +63,7 @@ class _IosSettingsPageState extends State { error: (error, trace) => Text('${libL10n.error}: $error'), success: (text) { _pushToken.value = text; - return Text( - text ?? 'null', - style: UIs.textGrey, - overflow: TextOverflow.ellipsis, - maxLines: 1, - ); + return Text(text ?? 'null', style: UIs.textGrey, overflow: TextOverflow.ellipsis, maxLines: 1); }, ), ); @@ -120,15 +109,14 @@ class _IosSettingsPageState extends State { void _onTapWatchApp(Map map) async { final urls = Map.from(map['urls'] as Map? ?? {}); - final result = await KvEditor.route.go( - context, - KvEditorArgs(data: urls), - ); + final result = await KvEditor.route.go(context, KvEditorArgs(data: urls)); if (result == null) return; - final (_, err) = await context.showLoadingDialog(fn: () async { - await wc.updateApplicationContext({'urls': result}); - }); + final (_, err) = await context.showLoadingDialog( + fn: () async { + await wc.updateApplicationContext({'urls': result}); + }, + ); if (err == null) { context.showSnackBar(libL10n.success); } diff --git a/lib/view/page/setting/platform/platform_pub.dart b/lib/view/page/setting/platform/platform_pub.dart index bb0b6c20..a061fcb6 100644 --- a/lib/view/page/setting/platform/platform_pub.dart +++ b/lib/view/page/setting/platform/platform_pub.dart @@ -5,8 +5,9 @@ import 'package:server_box/data/res/store.dart'; abstract final class PlatformPublicSettings { static Widget buildBioAuth() { return FutureWidget( - future: BioAuth.isAvail, + future: LocalAuth.isAvail, loading: ListTile( + leading: const Icon(Icons.fingerprint), title: Text(libL10n.bioAuth), subtitle: const Text('...', style: UIs.textGrey), ), @@ -15,15 +16,12 @@ abstract final class PlatformPublicSettings { subtitle: Text('${libL10n.fail}: $e', style: UIs.textGrey), ), success: (can) { + can ??= false; return ListTile( + leading: const Icon(Icons.fingerprint), title: Text(libL10n.bioAuth), - subtitle: can == true - ? null - : Text( - libL10n.notExistFmt(libL10n.bioAuth), - style: UIs.textGrey, - ), - trailing: can == true + subtitle: can ? null : Text(libL10n.notExistFmt(libL10n.bioAuth), style: UIs.textGrey), + trailing: can ? StoreSwitch( prop: Stores.setting.useBioAuth, callback: (val) async { @@ -32,7 +30,7 @@ abstract final class PlatformPublicSettings { return; } // Only auth when turn off (val == false) - final result = await BioAuth.goWithResult(); + final result = await LocalAuth.goWithResult(); // If failed, turn on again if (result != AuthResult.success) { Stores.setting.useBioAuth.put(true); diff --git a/pubspec.lock b/pubspec.lock index 93b21f27..a41e99ca 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -497,8 +497,8 @@ packages: dependency: "direct main" description: path: "." - ref: "v1.0.316" - resolved-ref: "93da3ff5e042f9f0d29ace7b1ffeff5716fe2c81" + ref: "v1.0.317" + resolved-ref: "5fa0db6b5ebf3818a487696ff737c1d0fecce5c5" url: "https://github.com/lppcg/fl_lib" source: git version: "0.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index 607cf36a..324af979 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,7 +62,7 @@ dependencies: fl_lib: git: url: https://github.com/lppcg/fl_lib - ref: v1.0.316 + ref: v1.0.317 dependency_overrides: # webdav_client_plus: @@ -106,15 +106,6 @@ flutter: - assets/app_icon.png # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: # fonts: # - family: Schyler # fonts: @@ -126,71 +117,20 @@ flutter: # - asset: fonts/TrajanPro.ttf # - asset: fonts/TrajanPro_Bold.ttf # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages flutter_native_splash: - # This package generates native code to customize Flutter's default white native splash screen - # with background color and splash image. - # Customize the parameters below, and run the following command in the terminal: - # flutter pub run flutter_native_splash:create - # To restore Flutter's default white splash screen, run the following command in the terminal: - # flutter pub run flutter_native_splash:remove - # color or background_image is the only required parameter. Use color to set the background - # of your splash screen to a solid color. Use background_image to set the background of your - # splash screen to a png image. This is useful for gradients. The image will be stretch to the - # size of the app. Only one parameter can be used, color and background_image cannot both be set. color: "#ffffff" - #background_image: "assets/background.png" - # Optional parameters are listed below. To enable a parameter, uncomment the line by removing - # the leading # character. - # The image parameter allows you to specify an image used in the splash screen. It must be a - # png file and should be sized for 4x pixel density. image: assets/app_icon.png - - # The color_dark, background_image_dark, and image_dark are parameters that set the background - # and image when the device is in dark mode. If they are not specified, the app will use the - # parameters from above. If the image_dark parameter is specified, color_dark or - # background_image_dark must be specified. color_dark and background_image_dark cannot both be - # set. color_dark: "#121212" #background_image_dark: "assets/dark-background.png" #image_dark: assets/splash-invert.png - # The android, ios and web parameters can be used to disable generating a splash screen on a given - # platform. #android: false #ios: false #web: false - # The position of the splash image can be set with android_gravity, ios_content_mode, and - # web_image_mode parameters. All default to center. - # - # android_gravity can be one of the following Android Gravity (see - # https://developer.android.com/reference/android/view/Gravity): bottom, center, - # center_horizontal, center_vertical, clip_horizontal, clip_vertical, end, fill, fill_horizontal, - # fill_vertical, left, right, start, or top. #android_gravity: center - # - # ios_content_mode can be one of the following iOS UIView.ContentMode (see - # https://developer.apple.com/documentation/uikit/uiview/contentmode): scaleToFill, - # scaleAspectFit, scaleAspectFill, center, top, bottom, left, right, topLeft, topRight, - # bottomLeft, or bottomRight. #ios_content_mode: center - # - # web_image_mode can be one of the following modes: center, contain, stretch, and cover. - #web_image_mode: center - # To hide the notification bar, use the fullscreen parameter. Has no affect in web since web - # has no notification bar. Defaults to false. - # NOTE: Unlike Android, iOS will not automatically show the notification bar when the app loads. - # To show the notification bar, add the following code to your Flutter app: - # WidgetsFlutterBinding.ensureInitialized(); - # SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom, SystemUiOverlay.top]); #fullscreen: true - # If you have changed the name(s) of your info.plist file(s), you can specify the filename(s) - # with the info_plist_files parameter. Remove only the # characters in the three lines below, - # do not remove any spaces: info_plist_files: - "ios/Runner/Info-Debug.plist" - "ios/Runner/Info-Profile.plist" - "ios/Runner/Info-Release.plist" - # To enable support for Android 12, set the following parameter to true. Defaults to false. android12: true