new: bio_auth -> local_auth (#776)

Fixes #722
This commit is contained in:
lollipopkit🏳️‍⚧️
2025-06-05 09:07:28 +08:00
committed by GitHub
parent 4701757857
commit 79c515c903
8 changed files with 24 additions and 98 deletions

View File

@@ -215,10 +215,10 @@ class _HomePageState extends State<HomePage>
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),
);
}
}

View File

@@ -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());

View File

@@ -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';

View File

@@ -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<AndroidSettingsPage> {
// _buildFgService(),
_buildBgRun(),
_buildAndroidWidgetSharedPreference(),
if (BioAuth.isPlatformSupported) PlatformPublicSettings.buildBioAuth(),
].map((e) => CardX(child: e)).toList(),
),
);

View File

@@ -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<IosSettingsPage> 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<IosSettingsPage> {
@@ -39,8 +35,6 @@ class _IosSettingsPageState extends State<IosSettingsPage> {
_buildPushToken(),
_buildAutoUpdateHomeWidget(),
_buildWatchApp(),
if (BioAuth.isPlatformSupported)
PlatformPublicSettings.buildBioAuth(),
].map((e) => CardX(child: e)).toList(),
),
);
@@ -69,12 +63,7 @@ class _IosSettingsPageState extends State<IosSettingsPage> {
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<IosSettingsPage> {
void _onTapWatchApp(Map<String, dynamic> map) async {
final urls = Map<String, String>.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);
}

View File

@@ -5,8 +5,9 @@ import 'package:server_box/data/res/store.dart';
abstract final class PlatformPublicSettings {
static Widget buildBioAuth() {
return FutureWidget<bool>(
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);

View File

@@ -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"

View File

@@ -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