mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-22 19:53:43 +08:00
optimization
This commit is contained in:
parent
56208e1909
commit
9789b9e1a9
@ -139,7 +139,7 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
context.pop();
|
||||
}),
|
||||
const SizedBox(width: 12),
|
||||
Text("社区输入法"),
|
||||
Text("社区输入法(实验性)"),
|
||||
Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
@ -183,7 +183,7 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
// ignore: use_build_context_synchronously
|
||||
await serverModel.startServer().unwrap(context: context);
|
||||
if (!context.mounted) return;
|
||||
showDialog(
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => ServerQrDialogUI(),
|
||||
);
|
||||
|
@ -7,7 +7,7 @@ part of 'input_method_dialog_ui_model.dart';
|
||||
// **************************************************************************
|
||||
|
||||
String _$inputMethodDialogUIModelHash() =>
|
||||
r'93440d8f9c5372d5350ceaa8cb00a1b0d3b0046e';
|
||||
r'1c7193891c609715b2c7ee1b34f67aa26b18d303';
|
||||
|
||||
/// See also [InputMethodDialogUIModel].
|
||||
@ProviderFor(InputMethodDialogUIModel)
|
||||
|
@ -9,6 +9,7 @@ import 'package:shelf/shelf.dart';
|
||||
import 'package:shelf/shelf_io.dart' as shelf_io;
|
||||
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
|
||||
import 'package:starcitizen_doctor/common/utils/log.dart';
|
||||
import 'package:starcitizen_doctor/ui/home/input_method/server_qr_dialog_ui.dart';
|
||||
import 'package:starcitizen_doctor/ui/home/localization/localization_ui_model.dart';
|
||||
|
||||
import 'input_method_dialog_ui_model.dart';
|
||||
@ -57,7 +58,6 @@ class InputMethodServer extends _$InputMethodServer {
|
||||
|
||||
Future<void> startServer() async {
|
||||
dPrint("[InputMethodServer] startServer");
|
||||
|
||||
var handler =
|
||||
const Pipeline().addMiddleware(logRequests()).addHandler(_onHandler);
|
||||
|
||||
@ -166,6 +166,10 @@ class InputMethodServer extends _$InputMethodServer {
|
||||
Future<Response> _onHandlerApi(Request request) async {
|
||||
final path = request.url.path;
|
||||
if (path == "api") {
|
||||
if (ref.exists(serverQrStateProvider)) {
|
||||
// ignore: avoid_manual_providers_as_generated_provider_dependency
|
||||
ref.read(serverQrStateProvider.notifier).popDialog();
|
||||
}
|
||||
return Response.ok(json.encode({
|
||||
"status": "ok",
|
||||
"appVersion": ConstConf.appVersion,
|
||||
|
@ -6,7 +6,7 @@ part of 'server.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$inputMethodServerHash() => r'4ea07de4bca3268933b78335b670c09e6fac61bc';
|
||||
String _$inputMethodServerHash() => r'227e0e32cd7b8895f3b108505cd524680afc4126';
|
||||
|
||||
/// See also [InputMethodServer].
|
||||
@ProviderFor(InputMethodServer)
|
||||
|
@ -3,9 +3,32 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'server.dart';
|
||||
|
||||
part 'server_qr_dialog_ui.g.dart';
|
||||
|
||||
|
||||
@riverpod
|
||||
class ServerQrState extends _$ServerQrState {
|
||||
@override
|
||||
bool build() {
|
||||
return true;
|
||||
}
|
||||
|
||||
BuildContext? _context;
|
||||
|
||||
// ignore: avoid_build_context_in_providers
|
||||
void setupContext(BuildContext context) {
|
||||
_context = context;
|
||||
}
|
||||
|
||||
popDialog() {
|
||||
_context?.pop();
|
||||
}
|
||||
}
|
||||
|
||||
class ServerQrDialogUI extends HookConsumerWidget {
|
||||
const ServerQrDialogUI({super.key});
|
||||
|
||||
@ -19,6 +42,10 @@ class ServerQrDialogUI extends HookConsumerWidget {
|
||||
|
||||
final index = useState(0);
|
||||
|
||||
final model = ref.watch(serverQrStateProvider.notifier);
|
||||
|
||||
model.setupContext(context);
|
||||
|
||||
return ContentDialog(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width * .4,
|
||||
@ -67,7 +94,7 @@ class ServerQrDialogUI extends HookConsumerWidget {
|
||||
SizedBox(height: 12),
|
||||
Text(
|
||||
hasMultipleUrls
|
||||
? "(${index.value + 1} / ${urls.length})"
|
||||
? "${urls[index.value]} (${index.value + 1} / ${urls.length})"
|
||||
: urls[index.value],
|
||||
style: TextStyle(fontSize: 13, color: Colors.white.withOpacity(.6)),
|
||||
),
|
||||
|
26
lib/ui/home/input_method/server_qr_dialog_ui.g.dart
Normal file
26
lib/ui/home/input_method/server_qr_dialog_ui.g.dart
Normal file
@ -0,0 +1,26 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'server_qr_dialog_ui.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$serverQrStateHash() => r'06f5ab53e1d6718f2a6eb0078a1adc3778787ed0';
|
||||
|
||||
/// See also [ServerQrState].
|
||||
@ProviderFor(ServerQrState)
|
||||
final serverQrStateProvider =
|
||||
AutoDisposeNotifierProvider<ServerQrState, bool>.internal(
|
||||
ServerQrState.new,
|
||||
name: r'serverQrStateProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$serverQrStateHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$ServerQrState = AutoDisposeNotifier<bool>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
Loading…
Reference in New Issue
Block a user