fix: desktop grid launch review (#4840)

* chore: disable changing the type of primary fields

* fix: don't persist text selection after text update in checklist

* chore: allow fn + backspace in macos to delete checklist item

* chore: shorten opacity fade between opacity shown and not shown

* fix: arrow key focus traversal
This commit is contained in:
Richard Shiue 2024-03-07 21:05:19 +08:00 committed by GitHub
parent cd245b5f0a
commit 2a65c193c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 73 additions and 53 deletions

View File

@ -257,7 +257,7 @@
"label": "AF: Tauri UI Dev", "label": "AF: Tauri UI Dev",
"type": "shell", "type": "shell",
"isBackground": true, "isBackground": true,
"command": "pnpm run tauri:dev", "command": "pnpm run sync:i18n && pnpm run dev",
"options": { "options": {
"cwd": "${workspaceFolder}/appflowy_tauri" "cwd": "${workspaceFolder}/appflowy_tauri"
} }

View File

@ -32,7 +32,7 @@ class _CalculationSelectorState extends State<CalculationSelector> {
onEnter: (_) => _setHovering(true), onEnter: (_) => _setHovering(true),
onExit: (_) => _setHovering(false), onExit: (_) => _setHovering(false),
child: AnimatedOpacity( child: AnimatedOpacity(
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 100),
opacity: widget.isSelected || _isHovering ? 1 : 0, opacity: widget.isSelected || _isHovering ? 1 : 0,
child: FlowyButton( child: FlowyButton(
radius: BorderRadius.zero, radius: BorderRadius.zero,

View File

@ -370,9 +370,6 @@ class _FieldDetailsEditorState extends State<FieldDetailsEditor> {
Widget _addDeleteFieldButton() { Widget _addDeleteFieldButton() {
return BlocBuilder<FieldEditorBloc, FieldEditorState>( return BlocBuilder<FieldEditorBloc, FieldEditorState>(
builder: (context, state) { builder: (context, state) {
if (state.field.isPrimary) {
return const SizedBox.shrink();
}
return Padding( return Padding(
padding: const EdgeInsets.fromLTRB(8.0, 4.0, 8.0, 0), padding: const EdgeInsets.fromLTRB(8.0, 4.0, 8.0, 0),
child: FieldActionCell( child: FieldActionCell(
@ -389,9 +386,6 @@ class _FieldDetailsEditorState extends State<FieldDetailsEditor> {
Widget _addDuplicateFieldButton() { Widget _addDuplicateFieldButton() {
return BlocBuilder<FieldEditorBloc, FieldEditorState>( return BlocBuilder<FieldEditorBloc, FieldEditorState>(
builder: (context, state) { builder: (context, state) {
if (state.field.isPrimary) {
return const SizedBox.shrink();
}
return Padding( return Padding(
padding: const EdgeInsets.fromLTRB(8.0, 4.0, 8.0, 0), padding: const EdgeInsets.fromLTRB(8.0, 4.0, 8.0, 0),
child: FieldActionCell( child: FieldActionCell(
@ -533,11 +527,14 @@ class _SwitchFieldButtonState extends State<SwitchFieldButton> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<FieldEditorBloc, FieldEditorState>(
builder: (context, state) {
final bool isPrimary = state.field.isPrimary;
return SizedBox( return SizedBox(
height: GridSize.popoverItemHeight, height: GridSize.popoverItemHeight,
child: AppFlowyPopover( child: AppFlowyPopover(
constraints: BoxConstraints.loose(const Size(460, 540)), constraints: BoxConstraints.loose(const Size(460, 540)),
triggerActions: PopoverTriggerFlags.hover, triggerActions: isPrimary ? 0 : PopoverTriggerFlags.hover,
mutex: widget.popoverMutex, mutex: widget.popoverMutex,
controller: _popoverController, controller: _popoverController,
offset: const Offset(8, 0), offset: const Offset(8, 0),
@ -553,21 +550,29 @@ class _SwitchFieldButtonState extends State<SwitchFieldButton> {
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: _buildMoreButton(context), child: FlowyButton(
onTap: () {
if (!isPrimary) {
_popoverController.show();
}
},
text: FlowyText.medium(
state.field.fieldType.i18n,
color: isPrimary ? Theme.of(context).disabledColor : null,
),
leftIcon: FlowySvg(
state.field.fieldType.svgData,
color: isPrimary ? Theme.of(context).disabledColor : null,
),
rightIcon: FlowySvg(
FlowySvgs.more_s,
color: isPrimary ? Theme.of(context).disabledColor : null,
),
),
), ),
), ),
); );
} },
Widget _buildMoreButton(BuildContext context) {
final bloc = context.read<FieldEditorBloc>();
return FlowyButton(
onTap: () => _popoverController.show(),
text: FlowyText.medium(
bloc.state.field.fieldType.i18n,
),
leftIcon: FlowySvg(bloc.state.field.fieldType.svgData),
rightIcon: const FlowySvg(FlowySvgs.more_s),
); );
} }
} }

View File

@ -191,7 +191,9 @@ class _ChecklistItemState extends State<ChecklistItem> {
void didUpdateWidget(ChecklistItem oldWidget) { void didUpdateWidget(ChecklistItem oldWidget) {
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (widget.task.data.name != oldWidget.task.data.name) { if (widget.task.data.name != oldWidget.task.data.name) {
final selection = _textController.selection;
_textController.text = widget.task.data.name; _textController.text = widget.task.data.name;
_textController.selection = selection;
} }
} }
@ -236,6 +238,10 @@ class _ChecklistItemState extends State<ChecklistItem> {
else else
const SingleActivator(LogicalKeyboardKey.enter, control: true): const SingleActivator(LogicalKeyboardKey.enter, control: true):
const _SelectTaskIntent(), const _SelectTaskIntent(),
const SingleActivator(LogicalKeyboardKey.arrowUp):
const PreviousFocusIntent(),
const SingleActivator(LogicalKeyboardKey.arrowDown):
const NextFocusIntent(),
}, },
descendantsAreTraversable: false, descendantsAreTraversable: false,
child: Container( child: Container(
@ -263,15 +269,24 @@ class _ChecklistItemState extends State<ChecklistItem> {
), ),
Expanded( Expanded(
child: Shortcuts( child: Shortcuts(
shortcuts: const { shortcuts: {
SingleActivator(LogicalKeyboardKey.space): const SingleActivator(LogicalKeyboardKey.space):
DoNothingAndStopPropagationIntent(), const DoNothingAndStopPropagationIntent(),
SingleActivator(LogicalKeyboardKey.delete): const SingleActivator(LogicalKeyboardKey.delete):
DoNothingAndStopPropagationIntent(), const DoNothingAndStopPropagationIntent(),
SingleActivator(LogicalKeyboardKey.enter): if (Platform.isMacOS)
DoNothingAndStopPropagationIntent(), LogicalKeySet(
SingleActivator(LogicalKeyboardKey.escape): LogicalKeyboardKey.fn,
_EndEditingTaskIntent(), LogicalKeyboardKey.backspace,
): const DoNothingAndStopPropagationIntent(),
const SingleActivator(LogicalKeyboardKey.enter):
const DoNothingAndStopPropagationIntent(),
const SingleActivator(LogicalKeyboardKey.escape):
const _EndEditingTaskIntent(),
const SingleActivator(LogicalKeyboardKey.arrowUp):
const DoNothingAndStopPropagationIntent(),
const SingleActivator(LogicalKeyboardKey.arrowDown):
const DoNothingAndStopPropagationIntent(),
}, },
child: TextField( child: TextField(
controller: _textController, controller: _textController,

View File

@ -1101,10 +1101,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: markdown name: markdown
sha256: "1b134d9f8ff2da15cb298efe6cd8b7d2a78958c1b00384ebcbdf13fe340a6c90" sha256: ef2a1298144e3f985cc736b22e0ccdaf188b5b3970648f2d9dc13efd1d9df051
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "7.2.1" version: "7.2.2"
matcher: matcher:
dependency: transitive dependency: transitive
description: description: