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

This commit was merged in pull request #13.
This commit is contained in:
lingjhf committed 2026-10-08 18:17:12 +00:00
1 parent aa5255d1e4
commit abc1868550
260 files changed
+43964 -5591

No files matched your search

@@ -2,7 +2,10 @@ import 'package:cutdex/l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../shared/state/operation_scope.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:cutdex_ui/theme.dart';
class PropertyNumberInput extends StatefulWidget {
const PropertyNumberInput({
@@ -13,6 +16,10 @@ class PropertyNumberInput extends StatefulWidget {
required this.readOnly,
required this.submit,
this.unit,
this.inlineLabel = false,
this.prefix,
this.prefixIcon,
this.labelActions = const [],
this.decimalPlaces = 2,
this.onScrubStart,
required this.onScrubUpdate,
@@ -23,6 +30,10 @@ class PropertyNumberInput extends StatefulWidget {
}) : assert(decimalPlaces >= 0 && decimalPlaces <= 20);
final String? label;
final String? unit;
final bool inlineLabel;
final String? prefix;
final IconData? prefixIcon;
final List<Widget> labelActions;
final int decimalPlaces;
final bool Function()? onScrubStart;
final ValueChanged<double> onScrubUpdate;
@@ -42,6 +53,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
late final _text = TextEditingController(text: _format(widget.value));
final _focus = FocusNode();
bool _dirty = false;
late final _operations = OperationScope<Object>(widget.editContext);
String? _error;
String _format(double value) {
var text = value.toStringAsFixed(widget.decimalPlaces);
@@ -67,8 +79,9 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
return;
}
_dirty = false;
final isCurrent = _operations.begin();
final accepted = await widget.submit(value);
if (!mounted) return;
if (!mounted || !isCurrent()) return;
setState(() {
_error = accepted ? null : context.l10n.notApplied;
_text.text = _format(widget.value);
@@ -78,6 +91,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
@override
void didUpdateWidget(covariant PropertyNumberInput oldWidget) {
super.didUpdateWidget(oldWidget);
_operations.bind(widget.editContext);
if ((oldWidget.enabled && !widget.enabled) ||
oldWidget.editContext != widget.editContext ||
(!oldWidget.readOnly && widget.readOnly)) {
@@ -92,6 +106,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
@override
void dispose() {
_operations.dispose();
_focus.removeListener(_blur);
_focus.dispose();
_text.dispose();
@@ -99,21 +114,34 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
}
@override
Widget build(BuildContext context) => Focus(
onKeyEvent: (_, event) {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.escape) {
setState(() {
_dirty = false;
_error = null;
_text.text = _format(widget.value);
});
_focus.unfocus();
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
},
child: AppTextField(
Widget build(BuildContext context) {
final labelAbove =
AppTheme.isCompactInspector(context) && !widget.inlineLabel;
final label = widget.onScrubStart == null
? Text(widget.label ?? '', style: AppTheme.propertyLabelStyle(context))
: AppScrubLabel(
label: widget.prefix ?? widget.label!,
icon: widget.prefixIcon,
style: labelAbove
? AppTheme.propertySectionTitleStyle(context)
: null,
alignment: labelAbove ? Alignment.centerLeft : Alignment.center,
padding: labelAbove
? EdgeInsets.zero
: const EdgeInsets.symmetric(horizontal: AppSpacing.small),
enabled: widget.enabled && (!widget.readOnly || widget.scrubbing),
onStart: () {
_operations.invalidate();
_dirty = false;
_error = null;
_text.text = _format(widget.value);
return widget.onScrubStart!();
},
onUpdate: widget.onScrubUpdate,
onEnd: widget.onScrubEnd,
onCancel: widget.onScrubCancel,
);
final input = AppTextField(
controller: _text,
focusNode: _focus,
enabled: widget.enabled,
@@ -124,29 +152,35 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
signed: true,
),
label: widget.label,
leading: widget.onScrubStart == null
? null
: AppScrubLabel(
label: widget.label!,
enabled: widget.enabled && (!widget.readOnly || widget.scrubbing),
onStart: () {
_dirty = false;
_error = null;
_text.text = _format(widget.value);
return widget.onScrubStart!();
},
onUpdate: widget.onScrubUpdate,
onEnd: widget.onScrubEnd,
onCancel: widget.onScrubCancel,
),
labelAbove: labelAbove,
labelActions: widget.labelActions,
leading: widget.onScrubStart == null ? null : label,
unit: widget.unit,
errorText: _error,
onChanged: (_) {
_operations.invalidate();
_dirty = true;
if (_error != null) setState(() => _error = null);
},
onEditingComplete: () {},
onSubmitted: (_) => _submit(),
),
);
);
return Focus(
onKeyEvent: (_, event) {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.escape) {
setState(() {
_operations.invalidate();
_dirty = false;
_error = null;
_text.text = _format(widget.value);
});
_focus.unfocus();
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
},
child: input,
);
}
}