mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-26 18:39:52 +00:00
fix: more checklist multiline issues (#6229)
* fix: more checklist multiline issues * chore: add comment * chore: apply code style improvments
This commit is contained in:
parent
06c356c7a1
commit
ec799afb7d
@ -138,6 +138,10 @@ class _EndEditingTaskIntent extends Intent {
|
|||||||
const _EndEditingTaskIntent();
|
const _EndEditingTaskIntent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _UpdateTaskDescriptionIntent extends Intent {
|
||||||
|
const _UpdateTaskDescriptionIntent();
|
||||||
|
}
|
||||||
|
|
||||||
/// Represents an existing task
|
/// Represents an existing task
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
class ChecklistItem extends StatefulWidget {
|
class ChecklistItem extends StatefulWidget {
|
||||||
@ -175,7 +179,7 @@ class _ChecklistItemState extends State<ChecklistItem> {
|
|||||||
control: !Platform.isMacOS,
|
control: !Platform.isMacOS,
|
||||||
): const _SelectTaskIntent(),
|
): const _SelectTaskIntent(),
|
||||||
const SingleActivator(LogicalKeyboardKey.enter):
|
const SingleActivator(LogicalKeyboardKey.enter):
|
||||||
const _EndEditingTaskIntent(),
|
const _UpdateTaskDescriptionIntent(),
|
||||||
const SingleActivator(LogicalKeyboardKey.escape):
|
const SingleActivator(LogicalKeyboardKey.escape):
|
||||||
const _EndEditingTaskIntent(),
|
const _EndEditingTaskIntent(),
|
||||||
};
|
};
|
||||||
@ -282,6 +286,14 @@ class _ChecklistItemState extends State<ChecklistItem> {
|
|||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
_UpdateTaskDescriptionIntent:
|
||||||
|
CallbackAction<_UpdateTaskDescriptionIntent>(
|
||||||
|
onInvoke: (_UpdateTaskDescriptionIntent intent) {
|
||||||
|
textFieldFocusNode.unfocus();
|
||||||
|
widget.onSubmitted?.call();
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
),
|
||||||
_EndEditingTaskIntent: CallbackAction<_EndEditingTaskIntent>(
|
_EndEditingTaskIntent: CallbackAction<_EndEditingTaskIntent>(
|
||||||
onInvoke: (_EndEditingTaskIntent intent) {
|
onInvoke: (_EndEditingTaskIntent intent) {
|
||||||
textFieldFocusNode.unfocus();
|
textFieldFocusNode.unfocus();
|
||||||
@ -315,6 +327,7 @@ class NewTaskItem extends StatefulWidget {
|
|||||||
|
|
||||||
class _NewTaskItemState extends State<NewTaskItem> {
|
class _NewTaskItemState extends State<NewTaskItem> {
|
||||||
final _textEditingController = TextEditingController();
|
final _textEditingController = TextEditingController();
|
||||||
|
bool _isCreateButtonEnabled = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -339,45 +352,46 @@ class _NewTaskItemState extends State<NewTaskItem> {
|
|||||||
children: [
|
children: [
|
||||||
const HSpace(8),
|
const HSpace(8),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: CallbackShortcuts(
|
||||||
focusNode: widget.focusNode,
|
bindings: {
|
||||||
controller: _textEditingController,
|
const SingleActivator(LogicalKeyboardKey.enter): () =>
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
_createNewTask(context),
|
||||||
decoration: InputDecoration(
|
|
||||||
border: InputBorder.none,
|
|
||||||
isCollapsed: true,
|
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 6.0,
|
|
||||||
horizontal: 2.0,
|
|
||||||
),
|
|
||||||
hintText: LocaleKeys.grid_checklist_addNew.tr(),
|
|
||||||
),
|
|
||||||
onSubmitted: (taskDescription) {
|
|
||||||
if (taskDescription.isNotEmpty) {
|
|
||||||
context
|
|
||||||
.read<ChecklistCellBloc>()
|
|
||||||
.add(ChecklistCellEvent.createNewTask(taskDescription));
|
|
||||||
_textEditingController.clear();
|
|
||||||
}
|
|
||||||
widget.focusNode.requestFocus();
|
|
||||||
},
|
},
|
||||||
onChanged: (value) => setState(() {}),
|
child: TextField(
|
||||||
|
focusNode: widget.focusNode,
|
||||||
|
controller: _textEditingController,
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
maxLines: null,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: InputBorder.none,
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 6.0,
|
||||||
|
horizontal: 2.0,
|
||||||
|
),
|
||||||
|
hintText: LocaleKeys.grid_checklist_addNew.tr(),
|
||||||
|
),
|
||||||
|
onSubmitted: (_) => _createNewTask(context),
|
||||||
|
onChanged: (value) => setState(
|
||||||
|
() => _isCreateButtonEnabled =
|
||||||
|
_textEditingController.text.isNotEmpty,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
FlowyTextButton(
|
FlowyTextButton(
|
||||||
LocaleKeys.grid_checklist_submitNewTask.tr(),
|
LocaleKeys.grid_checklist_submitNewTask.tr(),
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
fillColor: _textEditingController.text.isEmpty
|
fillColor: _isCreateButtonEnabled
|
||||||
? Theme.of(context).disabledColor
|
? Theme.of(context).colorScheme.primary
|
||||||
: Theme.of(context).colorScheme.primary,
|
: Theme.of(context).disabledColor,
|
||||||
hoverColor: _textEditingController.text.isEmpty
|
hoverColor: _isCreateButtonEnabled
|
||||||
? Theme.of(context).disabledColor
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
: Theme.of(context).colorScheme.primaryContainer,
|
: Theme.of(context).disabledColor,
|
||||||
fontColor: Theme.of(context).colorScheme.onPrimary,
|
fontColor: Theme.of(context).colorScheme.onPrimary,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||||
onPressed: _textEditingController.text.isEmpty
|
onPressed: _isCreateButtonEnabled
|
||||||
? null
|
? () {
|
||||||
: () {
|
|
||||||
context.read<ChecklistCellBloc>().add(
|
context.read<ChecklistCellBloc>().add(
|
||||||
ChecklistCellEvent.createNewTask(
|
ChecklistCellEvent.createNewTask(
|
||||||
_textEditingController.text,
|
_textEditingController.text,
|
||||||
@ -385,10 +399,22 @@ class _NewTaskItemState extends State<NewTaskItem> {
|
|||||||
);
|
);
|
||||||
widget.focusNode.requestFocus();
|
widget.focusNode.requestFocus();
|
||||||
_textEditingController.clear();
|
_textEditingController.clear();
|
||||||
},
|
}
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _createNewTask(BuildContext context) {
|
||||||
|
final taskDescription = _textEditingController.text;
|
||||||
|
if (taskDescription.isNotEmpty) {
|
||||||
|
context
|
||||||
|
.read<ChecklistCellBloc>()
|
||||||
|
.add(ChecklistCellEvent.createNewTask(taskDescription));
|
||||||
|
_textEditingController.clear();
|
||||||
|
}
|
||||||
|
widget.focusNode.requestFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ SPEC CHECKSUMS:
|
|||||||
HotKey: e96d8a2ddbf4591131e2bb3f54e69554d90cdca6
|
HotKey: e96d8a2ddbf4591131e2bb3f54e69554d90cdca6
|
||||||
hotkey_manager: c32bf0bfe8f934b7bc17ab4ad5c4c142960b023c
|
hotkey_manager: c32bf0bfe8f934b7bc17ab4ad5c4c142960b023c
|
||||||
irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478
|
irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478
|
||||||
local_notifier: c6c371695f914641ab7bc8601944f7e358632d0b
|
local_notifier: e9506bc66fc70311e8bc7291fb70f743c081e4ff
|
||||||
package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c
|
package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c
|
||||||
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
|
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
|
||||||
ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979
|
ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979
|
||||||
|
Loading…
x
Reference in New Issue
Block a user