feat(workspace): 桌面工作区、主题与交互更新,发布 0.1.2
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
This commit was merged in pull request #13.
This commit is contained in:
1 parent
aa5255d1e4
commit
abc1868550
260 files changed
+43964
-5591
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
@@ -8,9 +9,24 @@ import '../../errors/app_failure.dart';
|
||||
import '../../l10n/l10n.dart';
|
||||
|
||||
class ErrorNotification {
|
||||
const ErrorNotification({required this.content, this.details});
|
||||
const ErrorNotification({required this.content, this.details})
|
||||
: isError = true,
|
||||
actionLabel = null,
|
||||
onAction = null;
|
||||
|
||||
const ErrorNotification.message({
|
||||
required this.content,
|
||||
this.actionLabel,
|
||||
this.onAction,
|
||||
}) : assert((actionLabel == null) == (onAction == null)),
|
||||
details = null,
|
||||
isError = false;
|
||||
|
||||
final Widget content;
|
||||
final String? details;
|
||||
final bool isError;
|
||||
final String? actionLabel;
|
||||
final VoidCallback? onAction;
|
||||
|
||||
String get copyText {
|
||||
String textOf(Widget widget) {
|
||||
@@ -33,7 +49,7 @@ class ErrorNotification {
|
||||
}
|
||||
}
|
||||
|
||||
/// One error queue above navigation and dialogs, independent of local scaffolds.
|
||||
/// One notification queue above navigation and dialogs, independent of scaffolds.
|
||||
class ErrorNotificationHost extends StatefulWidget {
|
||||
const ErrorNotificationHost({super.key, required this.child});
|
||||
final Widget child;
|
||||
@@ -61,6 +77,18 @@ class ErrorNotificationHostState extends State<ErrorNotificationHost> {
|
||||
if (_current == null) _next();
|
||||
}
|
||||
|
||||
void showMessage({
|
||||
required Widget content,
|
||||
String? actionLabel,
|
||||
VoidCallback? onAction,
|
||||
}) => show(
|
||||
ErrorNotification.message(
|
||||
content: content,
|
||||
actionLabel: actionLabel,
|
||||
onAction: onAction,
|
||||
),
|
||||
);
|
||||
|
||||
void showFailure(AppFailure failure, String message) => show(
|
||||
ErrorNotification(
|
||||
content: Text(message),
|
||||
@@ -75,7 +103,7 @@ class ErrorNotificationHostState extends State<ErrorNotificationHost> {
|
||||
void _startTimer() {
|
||||
_timer?.cancel();
|
||||
if (_current != null && !_hovered) {
|
||||
_timer = Timer(const Duration(seconds: 8), dismiss);
|
||||
_timer = Timer(Duration(seconds: _current!.isError ? 8 : 4), dismiss);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +111,7 @@ class ErrorNotificationHostState extends State<ErrorNotificationHost> {
|
||||
setState(() {
|
||||
_current = _pending.isEmpty ? null : _pending.removeFirst();
|
||||
_copied = false;
|
||||
_hovered = false;
|
||||
});
|
||||
_startTimer();
|
||||
}
|
||||
@@ -146,7 +175,11 @@ class ErrorNotificationHostState extends State<ErrorNotificationHost> {
|
||||
_startTimer();
|
||||
},
|
||||
child: Material(
|
||||
key: const Key('global-error-notification'),
|
||||
key: Key(
|
||||
current.isError
|
||||
? 'global-error-notification'
|
||||
: 'global-message-notification',
|
||||
),
|
||||
elevation: 8,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@@ -160,8 +193,10 @@ class ErrorNotificationHostState extends State<ErrorNotificationHost> {
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.error_outline,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
current.isError ? AppIcons.error : AppIcons.success,
|
||||
color: current.isError
|
||||
? Theme.of(context).colorScheme.error
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
@@ -173,22 +208,35 @@ class ErrorNotificationHostState extends State<ErrorNotificationHost> {
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
key: const Key('copy-error-button'),
|
||||
tooltip: MaterialLocalizations.of(context)
|
||||
.copyButtonLabel,
|
||||
onPressed: _copy,
|
||||
icon: Icon(
|
||||
_copied ? Icons.check : Icons.copy,
|
||||
size: 18,
|
||||
if (current.actionLabel case final label?)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
dismiss();
|
||||
current.onAction!();
|
||||
},
|
||||
child: Text(label),
|
||||
),
|
||||
if (current.isError)
|
||||
IconButton(
|
||||
key: const Key('copy-error-button'),
|
||||
tooltip: MaterialLocalizations.of(context)
|
||||
.copyButtonLabel,
|
||||
onPressed: _copy,
|
||||
icon: Icon(
|
||||
_copied ? AppIcons.check : AppIcons.copy,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
key: const Key('close-error-button'),
|
||||
key: Key(
|
||||
current.isError
|
||||
? 'close-error-button'
|
||||
: 'close-message-button',
|
||||
),
|
||||
tooltip: MaterialLocalizations.of(context)
|
||||
.closeButtonTooltip,
|
||||
onPressed: dismiss,
|
||||
icon: const Icon(Icons.close, size: 18),
|
||||
icon: const Icon(AppIcons.close, size: 18),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user