mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-09 18:10:29 +00:00
feat(ui): unify child surfaces and show web task creation in a modal (#1633)
This commit is contained in:
30 files changed
+618
-85
No files matched your search
@@ -4,6 +4,7 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
import '../../shared/theme/app_design_tokens.dart';
|
||||
import 'app_window_chrome.dart';
|
||||
import 'app_window_payload.dart';
|
||||
|
||||
@@ -46,7 +47,7 @@ class AppWindowBootstrap {
|
||||
|
||||
final options = switch (type) {
|
||||
AppWindowType.createTask => WindowOptions(
|
||||
size: Size(820, 620),
|
||||
size: AppDesignTokens.childWindowSize,
|
||||
center: true,
|
||||
skipTaskbar: false,
|
||||
backgroundColor: Colors.transparent,
|
||||
|
||||
@@ -2,22 +2,24 @@ import 'dart:io';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import '../../api/model/create_task.dart';
|
||||
import '../../util/log_util.dart';
|
||||
import '../capabilities/app_capabilities.dart';
|
||||
import 'app_window_payload.dart';
|
||||
import 'window_capability_transport.dart';
|
||||
|
||||
class AppWindowLauncher {
|
||||
static Future<bool> openCreateTaskWindow({CreateTask? createTask}) async {
|
||||
static Future<bool> open(AppWindowPayload payload) async {
|
||||
if (payload.type == AppWindowType.main) {
|
||||
throw ArgumentError.value(payload.type, 'payload.type', 'Expected a child window');
|
||||
}
|
||||
if (kIsWeb || !(Platform.isWindows || Platform.isMacOS || Platform.isLinux)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
await AppWindowCapabilityHost.instance.start(LocalAppCapabilities.instance.registry);
|
||||
final payload = AppWindowPayload.createTask(createTask: createTask?.toJson());
|
||||
// Every request deliberately creates a new child window. Create-task
|
||||
// windows are independent and are never reused.
|
||||
await WindowController.create(WindowConfiguration(arguments: payload.toRaw(), hiddenAtLaunch: true));
|
||||
@@ -27,10 +29,16 @@ class AppWindowLauncher {
|
||||
return true;
|
||||
} catch (error, stackTrace) {
|
||||
try {
|
||||
logger.w('create task window failed', error, stackTrace);
|
||||
logger.w('child window failed', error, stackTrace);
|
||||
} catch (_) {
|
||||
debugPrint('create task window failed: $error');
|
||||
debugPrint('child window failed: $error');
|
||||
}
|
||||
// A tray/deep-link request can arrive while the main window is hidden.
|
||||
// Bring the in-app fallback into view if the child engine cannot start.
|
||||
try {
|
||||
await windowManager.show();
|
||||
await windowManager.focus();
|
||||
} catch (_) {}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user