mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 15:54:35 +01:00
@@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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(),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user