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,9 +1,13 @@
|
||||
import '../../shared/widgets/listenable_selector.dart';
|
||||
import '../../shared/widgets/presentation_list.dart';
|
||||
|
||||
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
||||
import 'package:cutdex/l10n/l10n.dart';
|
||||
import 'package:cutdex_sdk/editor.dart';
|
||||
import 'package:cutdex_sdk/timeline/model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
|
||||
@@ -187,15 +191,15 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
final matches = cues.indexed
|
||||
.where((entry) => entry.$2.text.toLowerCase().contains(_captionQuery))
|
||||
.toList();
|
||||
final actionSize = AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.action
|
||||
: 28.0;
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.panelContentHorizontal,
|
||||
vertical: AppSpacing.small,
|
||||
),
|
||||
padding: AppTheme.propertySectionPadding(context),
|
||||
child: SizedBox(
|
||||
height: 28,
|
||||
height: AppTheme.propertyInputHeight(context),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@@ -203,7 +207,7 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
child: TextField(
|
||||
key: const ValueKey('caption-search'),
|
||||
controller: _captionSearch,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
style: AppTheme.inputTextStyle(context),
|
||||
cursorHeight: AppTheme.inputCursorHeight(context),
|
||||
textAlignVertical: TextAlignVertical.center,
|
||||
textInputAction: TextInputAction.search,
|
||||
@@ -212,12 +216,16 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
context.l10n.captions,
|
||||
),
|
||||
isDense: true,
|
||||
constraints: const BoxConstraints.tightFor(height: 28),
|
||||
constraints: BoxConstraints.tightFor(
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.input
|
||||
: 28,
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 0,
|
||||
),
|
||||
prefixIcon: const Icon(Icons.search, size: 14),
|
||||
prefixIcon: const Icon(AppIcons.search, size: 14),
|
||||
prefixIconConstraints: const BoxConstraints(
|
||||
minWidth: 28,
|
||||
minHeight: 28,
|
||||
@@ -229,27 +237,29 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
IconButton(
|
||||
key: const ValueKey('caption-wrap-toggle'),
|
||||
tooltip: _wrapCaptions
|
||||
? context.l10n.captionSingleLine
|
||||
: context.l10n.captionWrapLines,
|
||||
isSelected: _wrapCaptions,
|
||||
color: _wrapCaptions
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: null,
|
||||
icon: const Icon(Icons.wrap_text, size: 16),
|
||||
padding: EdgeInsets.zero,
|
||||
style: IconButton.styleFrom(
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
visualDensity: VisualDensity.standard,
|
||||
Align(
|
||||
child: IconButton(
|
||||
key: const ValueKey('caption-wrap-toggle'),
|
||||
tooltip: _wrapCaptions
|
||||
? context.l10n.captionSingleLine
|
||||
: context.l10n.captionWrapLines,
|
||||
isSelected: _wrapCaptions,
|
||||
color: _wrapCaptions
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: null,
|
||||
icon: const Icon(AppIcons.textWrap, size: 16),
|
||||
padding: EdgeInsets.zero,
|
||||
style: IconButton.styleFrom(
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
visualDensity: VisualDensity.standard,
|
||||
),
|
||||
constraints: BoxConstraints.tightFor(
|
||||
width: actionSize,
|
||||
height: actionSize,
|
||||
),
|
||||
onPressed: () =>
|
||||
setState(() => _wrapCaptions = !_wrapCaptions),
|
||||
),
|
||||
constraints: const BoxConstraints.tightFor(
|
||||
width: 28,
|
||||
height: 28,
|
||||
),
|
||||
onPressed: () =>
|
||||
setState(() => _wrapCaptions = !_wrapCaptions),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -273,8 +283,10 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
children: [
|
||||
for (final (index, cue) in matches)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.panelContentHorizontal,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.padding
|
||||
: AppSpacing.panelContentHorizontal,
|
||||
vertical: AppSpacing.hairline,
|
||||
),
|
||||
child: Material(
|
||||
@@ -332,21 +344,20 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
SizedBox(
|
||||
width: 28,
|
||||
height: 28,
|
||||
width: actionSize,
|
||||
height: actionSize,
|
||||
child: IconButton(
|
||||
key: ValueKey(
|
||||
'caption-action-${cue.id}',
|
||||
),
|
||||
tooltip: context.l10n.select,
|
||||
padding: EdgeInsets.zero,
|
||||
constraints:
|
||||
const BoxConstraints.tightFor(
|
||||
width: 28,
|
||||
height: 28,
|
||||
),
|
||||
constraints: BoxConstraints.tightFor(
|
||||
width: actionSize,
|
||||
height: actionSize,
|
||||
),
|
||||
icon: const Icon(
|
||||
Icons.chevron_right,
|
||||
AppIcons.chevronRight,
|
||||
size: 14,
|
||||
),
|
||||
onPressed: () => _selectCue(cue.id),
|
||||
@@ -368,8 +379,42 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ListenableBuilder(
|
||||
Widget build(BuildContext context) => ListenableSelector<Object>(
|
||||
listenable: widget.session,
|
||||
select: () {
|
||||
final query = widget.session.persistence
|
||||
.timeline(widget.sequence)
|
||||
.current
|
||||
.query();
|
||||
final handle = query.elementById(ElementId(widget.clipId));
|
||||
if (handle == null) return (null, widget.session.acceptsEdits);
|
||||
final clip = query.element(handle);
|
||||
final role = clip.containerStoryline != null
|
||||
? handle
|
||||
: widget.session.captionRole(widget.sequence);
|
||||
final child = role == null
|
||||
? null
|
||||
: query.element(role).containerStoryline;
|
||||
return (
|
||||
clip,
|
||||
clip.payloadRef == null
|
||||
? null
|
||||
: widget.session.payloadFor(clip.payloadRef!),
|
||||
query.localContext(handle).start,
|
||||
widget.session.acceptsEdits,
|
||||
widget.session.version,
|
||||
PresentationList([
|
||||
if (child != null)
|
||||
for (final cue in query.storylineElements(child))
|
||||
(
|
||||
query.element(cue),
|
||||
query.element(cue).payloadRef == null
|
||||
? null
|
||||
: widget.session.payloadFor(query.element(cue).payloadRef!),
|
||||
),
|
||||
]),
|
||||
);
|
||||
},
|
||||
builder: (context, _) {
|
||||
final q = widget.session.persistence
|
||||
.timeline(widget.sequence)
|
||||
@@ -402,7 +447,9 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
final selected = isRole ? _CaptionPropertyCategory.captions : _selected;
|
||||
Widget panel(Widget content) => WorkspacePanel(
|
||||
paintBackground: false,
|
||||
headerHeight: CompactPanelTabs.height,
|
||||
headerHeight: AppTheme.isDesktop(context)
|
||||
? AppDesktopMetrics.panelHeader
|
||||
: CompactPanelTabs.height,
|
||||
headerPadding: EdgeInsets.zero,
|
||||
showHeaderDivider: false,
|
||||
controls: CompactPanelTabs<_CaptionPropertyCategory>(
|
||||
@@ -421,6 +468,12 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
|
||||
final caption = widget.session.caption(widget.sequence, widget.clipId);
|
||||
final version = widget.session.version;
|
||||
final editContext = (
|
||||
widget.session,
|
||||
widget.sequence,
|
||||
widget.clipId,
|
||||
version,
|
||||
);
|
||||
final start = RationalTime.timelineTicks(q.localContext(handle).start)
|
||||
.seconds;
|
||||
final duration = RationalTime.timelineTicks(clip.duration).seconds;
|
||||
@@ -436,17 +489,21 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
required double scale,
|
||||
String? unit,
|
||||
int decimalPlaces = 2,
|
||||
bool inlineLabel = false,
|
||||
String? prefix,
|
||||
required SetCaption Function(double, String) command,
|
||||
}) => PropertyNumberInput(
|
||||
key: ValueKey('caption-$field'),
|
||||
label: label,
|
||||
inlineLabel: inlineLabel,
|
||||
prefix: prefix,
|
||||
unit: unit,
|
||||
decimalPlaces: decimalPlaces,
|
||||
value: shown(field, value),
|
||||
enabled: true,
|
||||
readOnly: _scrubField != null,
|
||||
scrubbing: _scrubField == field,
|
||||
editContext: (widget.clipId, version),
|
||||
editContext: editContext,
|
||||
submit: (next) async {
|
||||
if (!next.isFinite || next < min || next > max) return false;
|
||||
return _save(command(next, version));
|
||||
@@ -457,6 +514,51 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
onScrubCancel: _cancelScrub,
|
||||
);
|
||||
|
||||
final baselineInput = number(
|
||||
field: 'positionY',
|
||||
inlineLabel: AppTheme.isDesktop(context),
|
||||
prefix: AppTheme.isDesktop(context) ? 'Y' : null,
|
||||
label: context.l10n.vertical,
|
||||
value: caption.positionY,
|
||||
min: -.5,
|
||||
max: .5,
|
||||
scale: .002,
|
||||
decimalPlaces: 3,
|
||||
command: (value, expected) => SetCaption(
|
||||
captionId: widget.clipId,
|
||||
positionY: value,
|
||||
expectedVersion: expected,
|
||||
),
|
||||
);
|
||||
final contentInput = _CaptionTextInput(
|
||||
key: ValueKey(('caption-text', widget.clipId)),
|
||||
editContext: editContext,
|
||||
value: caption.text,
|
||||
maxLines: 3,
|
||||
onSubmit: (text) => _save(
|
||||
SetCaption(
|
||||
captionId: widget.clipId,
|
||||
text: text,
|
||||
expectedVersion: version,
|
||||
),
|
||||
),
|
||||
);
|
||||
final deleteAction = IconButton(
|
||||
tooltip: context.l10n.deleteCaption,
|
||||
icon: const Icon(AppIcons.delete),
|
||||
onPressed: () {
|
||||
try {
|
||||
widget.session.commands.applyEdit(
|
||||
widget.sequence,
|
||||
DeleteClip(widget.clipId, expectedVersion: version),
|
||||
);
|
||||
} on CommandRejected {
|
||||
ErrorNotificationHost.maybeOf(context)?.show(
|
||||
ErrorNotification(content: Text(context.l10n.captionChanged)),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
return panel(
|
||||
ScrollEdgeFadeBuilder(
|
||||
key: const ValueKey('caption-detail-scroll-fade'),
|
||||
@@ -465,58 +567,39 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
padding: const EdgeInsets.symmetric(vertical: AppSpacing.small),
|
||||
children:
|
||||
[
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
context.l10n.textClip,
|
||||
style: AppTheme.propertySectionTitleStyle(
|
||||
context,
|
||||
if (AppTheme.isDesktop(context))
|
||||
AppPropertyGroup(
|
||||
label: context.l10n.content,
|
||||
actions: [deleteAction],
|
||||
child: contentInput,
|
||||
)
|
||||
else ...[
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
context.l10n.textClip,
|
||||
style: AppTheme.propertySectionTitleStyle(
|
||||
context,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: context.l10n.deleteCaption,
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
onPressed: () {
|
||||
try {
|
||||
widget.session.commands.applyEdit(
|
||||
widget.sequence,
|
||||
DeleteClip(
|
||||
widget.clipId,
|
||||
expectedVersion: version,
|
||||
),
|
||||
);
|
||||
} on CommandRejected {
|
||||
ErrorNotificationHost.maybeOf(context)?.show(
|
||||
ErrorNotification(
|
||||
content: Text(context.l10n.captionChanged),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
Text(
|
||||
context.l10n.content,
|
||||
style: AppTheme.propertySectionTitleStyle(context),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
_CaptionTextInput(
|
||||
key: ValueKey(('caption-text', widget.clipId)),
|
||||
value: caption.text,
|
||||
maxLines: 3,
|
||||
onSubmit: (text) => _save(
|
||||
SetCaption(
|
||||
captionId: widget.clipId,
|
||||
text: text,
|
||||
expectedVersion: version,
|
||||
),
|
||||
deleteAction,
|
||||
],
|
||||
),
|
||||
SizedBox(height: AppTheme.propertyRowGap(context)),
|
||||
Text(
|
||||
context.l10n.content,
|
||||
style: AppTheme.propertySectionTitleStyle(context),
|
||||
),
|
||||
SizedBox(height: AppTheme.propertyRowGap(context)),
|
||||
contentInput,
|
||||
],
|
||||
SizedBox(
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.groupGap
|
||||
: AppSpacing.small,
|
||||
),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
number(
|
||||
field: 'fontSize',
|
||||
label: context.l10n.fontSize,
|
||||
@@ -531,9 +614,14 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
expectedVersion: expected,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
SizedBox(
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.groupGap
|
||||
: AppSpacing.small,
|
||||
),
|
||||
_CaptionColorInput(
|
||||
key: ValueKey(('caption-color', widget.clipId)),
|
||||
editContext: editContext,
|
||||
value: caption.color,
|
||||
label: context.l10n.color,
|
||||
onSubmit: (color) => _save(
|
||||
@@ -544,9 +632,14 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
SizedBox(
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.groupGap
|
||||
: AppSpacing.small,
|
||||
),
|
||||
_CaptionColorInput(
|
||||
key: ValueKey(('caption-strokeColor', widget.clipId)),
|
||||
editContext: editContext,
|
||||
value: caption.strokeColor,
|
||||
label: context.l10n.outlineColor,
|
||||
onSubmit: (color) => _save(
|
||||
@@ -557,7 +650,11 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
SizedBox(
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.groupGap
|
||||
: AppSpacing.small,
|
||||
),
|
||||
number(
|
||||
field: 'strokeWidth',
|
||||
label: context.l10n.outlineWidth,
|
||||
@@ -573,42 +670,56 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
),
|
||||
),
|
||||
if (widget.transformProperties case final transform?) ...[
|
||||
const SizedBox(height: AppSpacing.medium),
|
||||
const Divider(height: 1),
|
||||
const SizedBox(height: AppSpacing.medium),
|
||||
Text(
|
||||
context.l10n.transform,
|
||||
style: AppTheme.propertySectionTitleStyle(context),
|
||||
SizedBox(
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.groupGap
|
||||
: AppSpacing.medium,
|
||||
),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
const Divider(height: 1),
|
||||
SizedBox(
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.groupGap
|
||||
: AppSpacing.medium,
|
||||
),
|
||||
if (!AppTheme.isDesktop(context)) ...[
|
||||
Text(
|
||||
context.l10n.transform,
|
||||
style: AppTheme.propertySectionTitleStyle(context),
|
||||
),
|
||||
SizedBox(height: AppTheme.propertyRowGap(context)),
|
||||
],
|
||||
transform,
|
||||
],
|
||||
const SizedBox(height: AppSpacing.medium),
|
||||
Text(
|
||||
context.l10n.captionBaseline,
|
||||
style: AppTheme.propertySectionTitleStyle(context),
|
||||
SizedBox(
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.groupGap
|
||||
: AppSpacing.medium,
|
||||
),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
number(
|
||||
field: 'positionY',
|
||||
label: context.l10n.vertical,
|
||||
value: caption.positionY,
|
||||
min: -.5,
|
||||
max: .5,
|
||||
scale: .002,
|
||||
decimalPlaces: 3,
|
||||
command: (value, expected) => SetCaption(
|
||||
captionId: widget.clipId,
|
||||
positionY: value,
|
||||
expectedVersion: expected,
|
||||
if (AppTheme.isDesktop(context))
|
||||
AppPropertyGroup(
|
||||
label: context.l10n.captionBaseline,
|
||||
child: baselineInput,
|
||||
)
|
||||
else ...[
|
||||
Text(
|
||||
context.l10n.captionBaseline,
|
||||
style: AppTheme.propertySectionTitleStyle(context),
|
||||
),
|
||||
SizedBox(height: AppTheme.propertyRowGap(context)),
|
||||
baselineInput,
|
||||
],
|
||||
SizedBox(
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.groupGap
|
||||
: AppSpacing.medium,
|
||||
),
|
||||
const SizedBox(height: AppSpacing.medium),
|
||||
Text(
|
||||
context.l10n.time,
|
||||
style: AppTheme.propertySectionTitleStyle(context),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
if (!AppTheme.isDesktop(context)) ...[
|
||||
Text(
|
||||
context.l10n.time,
|
||||
style: AppTheme.propertySectionTitleStyle(context),
|
||||
),
|
||||
SizedBox(height: AppTheme.propertyRowGap(context)),
|
||||
],
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
Widget startField() => number(
|
||||
@@ -641,19 +752,23 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
expectedVersion: expected,
|
||||
),
|
||||
);
|
||||
if (constraints.maxWidth < 240) {
|
||||
if (constraints.maxWidth <
|
||||
(AppTheme.isDesktop(context) ? 180 : 240)) {
|
||||
return Column(
|
||||
children: [
|
||||
startField(),
|
||||
const SizedBox(height: AppSpacing.small),
|
||||
SizedBox(
|
||||
height: AppTheme.propertyRowGap(context),
|
||||
),
|
||||
durationField(),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(child: startField()),
|
||||
const SizedBox(width: AppSpacing.small),
|
||||
SizedBox(width: AppTheme.propertyRowGap(context)),
|
||||
Expanded(child: durationField()),
|
||||
],
|
||||
);
|
||||
@@ -666,8 +781,10 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
|
||||
identical(item, widget.transformProperties)
|
||||
? item
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.panelContentHorizontal,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: AppTheme.isDesktop(context)
|
||||
? AppInspectorMetrics.padding
|
||||
: AppSpacing.panelContentHorizontal,
|
||||
),
|
||||
child: item,
|
||||
),
|
||||
@@ -684,11 +801,13 @@ class _CaptionTextInput extends StatefulWidget {
|
||||
const _CaptionTextInput({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.editContext,
|
||||
required this.onSubmit,
|
||||
this.label,
|
||||
this.maxLines = 1,
|
||||
});
|
||||
final String value;
|
||||
final Object editContext;
|
||||
final String? label;
|
||||
final int maxLines;
|
||||
final bool Function(String) onSubmit;
|
||||
@@ -727,6 +846,12 @@ class _CaptionTextInputState extends State<_CaptionTextInput> {
|
||||
@override
|
||||
void didUpdateWidget(covariant _CaptionTextInput oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
// A new callback carries the new authored version. Never let a draft from
|
||||
// the previous binding borrow that version and overwrite a newer edit.
|
||||
if (oldWidget.editContext != widget.editContext) {
|
||||
_dirty = false;
|
||||
_error = null;
|
||||
}
|
||||
if (!_dirty && _controller.text != widget.value) {
|
||||
_controller.text = widget.value;
|
||||
}
|
||||
@@ -763,34 +888,46 @@ class _CaptionColorInput extends StatelessWidget {
|
||||
const _CaptionColorInput({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.editContext,
|
||||
required this.label,
|
||||
required this.onSubmit,
|
||||
});
|
||||
|
||||
final String value;
|
||||
final Object editContext;
|
||||
final String label;
|
||||
final bool Function(String) onSubmit;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(int.parse('FF${value.substring(1)}', radix: 16)),
|
||||
border: Border.all(color: Theme.of(context).colorScheme.outline),
|
||||
borderRadius: BorderRadius.circular(AppRadius.extraSmall),
|
||||
Widget build(BuildContext context) {
|
||||
final desktop = AppTheme.isDesktop(context);
|
||||
final controls = Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(int.parse('FF${value.substring(1)}', radix: 16)),
|
||||
border: Border.all(color: Theme.of(context).colorScheme.outline),
|
||||
borderRadius: BorderRadius.circular(AppRadius.extraSmall),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.small),
|
||||
Expanded(
|
||||
child: _CaptionTextInput(
|
||||
value: value,
|
||||
label: label,
|
||||
onSubmit: onSubmit,
|
||||
const SizedBox(width: AppSpacing.small),
|
||||
Expanded(
|
||||
child: _CaptionTextInput(
|
||||
value: value,
|
||||
editContext: editContext,
|
||||
label: desktop ? null : label,
|
||||
onSubmit: onSubmit,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
],
|
||||
);
|
||||
return desktop
|
||||
? AppPropertyGroup(
|
||||
label: label,
|
||||
child: Semantics(label: label, child: controls),
|
||||
)
|
||||
: controls;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user