From 04eea26a554f799579a6161b8e40fec7974ca312 Mon Sep 17 00:00:00 2001 From: Richard Shiue <71320345+richardshiue@users.noreply.github.com> Date: Tue, 5 Dec 2023 17:24:21 +0800 Subject: [PATCH] fix: hidden board card cannot open as page (#4090) * fix: card open in board * style: super.key and remove unused variables * chore: more code cleanup --- .../widgets/board_hidden_groups.dart | 2 +- .../mobile_checklist_cell_editor.dart | 110 ++++++++---------- .../cells/select_option_cell/extension.dart | 1 - .../select_option_editor.dart | 12 +- .../cells/select_option_cell/text_field.dart | 34 ++---- 5 files changed, 64 insertions(+), 95 deletions(-) diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/board/presentation/widgets/board_hidden_groups.dart b/frontend/appflowy_flutter/lib/plugins/database_view/board/presentation/widgets/board_hidden_groups.dart index 7d1f451341..f6a95943e2 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/board/presentation/widgets/board_hidden_groups.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/board/presentation/widgets/board_hidden_groups.dart @@ -418,7 +418,7 @@ class HiddenGroupPopupItemList extends StatelessWidget { onPressed: () { FlowyOverlay.show( context: context, - builder: (BuildContext context) { + builder: (_) { return RowDetailPage( fieldController: context.read().fieldController, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/mobile_checklist_cell_editor.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/mobile_checklist_cell_editor.dart index 0cd965fc31..1f35865302 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/mobile_checklist_cell_editor.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/mobile_checklist_cell_editor.dart @@ -47,10 +47,10 @@ class _MobileChecklistCellEditScreenState child: _buildHeader(context), ), const Divider(), - Expanded( + const Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 0.0), - child: _buildBody(context), + padding: EdgeInsets.symmetric(horizontal: 0.0), + child: _TaskList(), ), ), ], @@ -91,20 +91,10 @@ class _MobileChecklistCellEditScreenState ].map((e) => SizedBox(height: height, child: e)).toList(), ); } - - Widget _buildBody(BuildContext context) { - return _TaskList( - onCreateOption: (optionName) {}, - ); - } } class _TaskList extends StatelessWidget { - const _TaskList({ - required this.onCreateOption, - }); - - final void Function(String optionName) onCreateOption; + const _TaskList(); @override Widget build(BuildContext context) { @@ -180,6 +170,7 @@ class _ChecklistItemState extends State<_ChecklistItem> { Widget build(BuildContext context) { return Container( padding: const EdgeInsets.only(left: 5, right: 16), + height: 44, child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -205,10 +196,7 @@ class _ChecklistItemState extends State<_ChecklistItem> { child: TextField( controller: _textController, focusNode: _focusNode, - style: Theme.of(context) - .textTheme - .bodyMedium - ?.copyWith(fontSize: 15), + style: Theme.of(context).textTheme.bodyMedium, maxLines: 1, decoration: InputDecoration( border: InputBorder.none, @@ -227,47 +215,7 @@ class _ChecklistItemState extends State<_ChecklistItem> { ), InkWell( borderRadius: BorderRadius.circular(22), - onTap: () => showMobileBottomSheet( - context, - padding: const EdgeInsets.only(top: 8, bottom: 32), - builder: (_) => Column( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: InkWell( - onTap: () { - context.read().add( - ChecklistCellEvent.deleteTask(widget.task.data), - ); - context.pop(); - }, - borderRadius: BorderRadius.circular(12), - child: Container( - height: 44, - padding: const EdgeInsets.symmetric(horizontal: 8), - child: Row( - children: [ - FlowySvg( - FlowySvgs.m_delete_m, - size: const Size.square(20), - color: Theme.of(context).colorScheme.error, - ), - const HSpace(8), - FlowyText( - LocaleKeys.button_delete.tr(), - fontSize: 15, - color: Theme.of(context).colorScheme.error, - ), - ], - ), - ), - ), - ), - const Divider(height: 9), - ], - ), - ), + onTap: _showDeleteTaskBottomSheet, child: SizedBox.square( dimension: 44, child: Center( @@ -298,6 +246,50 @@ class _ChecklistItemState extends State<_ChecklistItem> { ), ); } + + void _showDeleteTaskBottomSheet() { + showMobileBottomSheet( + context, + padding: const EdgeInsets.only(top: 8, bottom: 32), + builder: (_) => Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: InkWell( + onTap: () { + context.read().add( + ChecklistCellEvent.deleteTask(widget.task.data), + ); + context.pop(); + }, + borderRadius: BorderRadius.circular(12), + child: Container( + height: 44, + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Row( + children: [ + FlowySvg( + FlowySvgs.m_delete_m, + size: const Size.square(20), + color: Theme.of(context).colorScheme.error, + ), + const HSpace(8), + FlowyText( + LocaleKeys.button_delete.tr(), + fontSize: 15, + color: Theme.of(context).colorScheme.error, + ), + ], + ), + ), + ), + ), + const Divider(height: 9), + ], + ), + ); + } } class _NewTaskButton extends StatelessWidget { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/extension.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/extension.dart index fe6c8a56a8..5c837fff8f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/extension.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/extension.dart @@ -148,7 +148,6 @@ class SelectOptionTagCell extends StatelessWidget { padding: const EdgeInsets.all(5.0), child: SelectOptionTag( option: option, - fontSize: 11, padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 1), ), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor.dart index 1f396aced3..bbe902bcbd 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor.dart @@ -27,8 +27,7 @@ class SelectOptionCellEditor extends StatefulWidget { final SelectOptionCellController cellController; static double editorPanelWidth = 300; - const SelectOptionCellEditor({required this.cellController, Key? key}) - : super(key: key); + const SelectOptionCellEditor({super.key, required this.cellController}); @override State createState() => _SelectOptionCellEditorState(); @@ -82,8 +81,7 @@ class _OptionList extends StatelessWidget { const _OptionList({ required this.popoverMutex, required this.tagController, - Key? key, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -138,8 +136,7 @@ class _TextField extends StatelessWidget { const _TextField({ required this.popoverMutex, required this.tagController, - Key? key, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -290,8 +287,7 @@ class _SelectOptionCell extends StatefulWidget { required this.option, required this.isSelected, required this.popoverMutex, - Key? key, - }) : super(key: key); + }); @override State<_SelectOptionCell> createState() => _SelectOptionCellState(); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/text_field.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/text_field.dart index f88249e921..bd6650c62f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/text_field.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/text_field.dart @@ -6,7 +6,6 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:appflowy/generated/locale_keys.g.dart'; -import 'package:flutter/services.dart'; import 'package:textfield_tags/textfield_tags.dart'; import 'extension.dart'; @@ -17,15 +16,16 @@ class SelectOptionTextField extends StatefulWidget { final LinkedHashMap selectedOptionMap; final double distanceToText; final List textSeparators; + final TextEditingController? textController; final Function(String) onSubmitted; final Function(String) newText; final Function(List, String) onPaste; final Function(String) onRemove; final VoidCallback? onClick; - final int? maxLength; const SelectOptionTextField({ + super.key, required this.options, required this.selectedOptionMap, required this.distanceToText, @@ -35,38 +35,25 @@ class SelectOptionTextField extends StatefulWidget { required this.onRemove, required this.newText, required this.textSeparators, + this.textController, this.onClick, - this.maxLength, - TextEditingController? textController, - FocusNode? focusNode, - Key? key, - }) : super(key: key); + }); @override State createState() => _SelectOptionTextFieldState(); } class _SelectOptionTextFieldState extends State { - late FocusNode focusNode; - late TextEditingController controller; + final FocusNode focusNode = FocusNode(); + late final TextEditingController controller; @override void initState() { - focusNode = FocusNode(); - controller = TextEditingController(); - + super.initState(); + controller = widget.textController ?? TextEditingController(); WidgetsBinding.instance.addPostFrameCallback((_) { focusNode.requestFocus(); }); - super.initState(); - } - - String? _suffixText() { - if (widget.maxLength != null) { - return ' ${controller.text.length}/${widget.maxLength}'; - } else { - return null; - } } @override @@ -107,9 +94,6 @@ class _SelectOptionTextFieldState extends State { } }, maxLines: 1, - maxLength: widget.maxLength, - maxLengthEnforcement: - MaxLengthEnforcement.truncateAfterCompositionEnds, style: Theme.of(context).textTheme.bodyMedium, decoration: InputDecoration( enabledBorder: OutlineInputBorder( @@ -126,8 +110,6 @@ class _SelectOptionTextFieldState extends State { .textTheme .bodySmall! .copyWith(color: Theme.of(context).hintColor), - suffixText: _suffixText(), - counterText: "", prefixIconConstraints: BoxConstraints(maxWidth: widget.distanceToText), focusedBorder: OutlineInputBorder(