fix: more board fixes (#3821)

* fix: null check value

* refactor: remove unnecessary blocbuilder

* fix: missing checkbox icon at top of board column
This commit is contained in:
Richard Shiue 2023-10-29 12:51:34 +08:00 committed by GitHub
parent b9a25f449f
commit 18bd91936c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 69 deletions

View File

@ -235,11 +235,13 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
if (isClosed || !layoutSettings.hasBoard()) {
return;
}
if (layoutSettings.board.hideUngroupedColumn) {
boardController.removeGroup(ungroupedGroup!.fieldId);
} else if (ungroupedGroup != null) {
final newGroup = initializeGroupData(ungroupedGroup!);
boardController.addGroup(newGroup);
if (ungroupedGroup != null) {
if (layoutSettings.board.hideUngroupedColumn) {
boardController.removeGroup(ungroupedGroup!.fieldId);
} else {
final newGroup = initializeGroupData(ungroupedGroup!);
boardController.addGroup(newGroup);
}
}
add(BoardEvent.didUpdateLayoutSettings(layoutSettings.board));
},

View File

@ -62,77 +62,74 @@ class _BoardColumnHeaderState extends State<BoardColumnHeader> {
Widget build(BuildContext context) {
final boardCustomData = widget.groupData.customData as GroupData;
return BlocProvider<BoardBloc>.value(
value: context.read<BoardBloc>(),
child: BlocBuilder<BoardBloc, BoardState>(
builder: (context, state) {
if (state.isEditingHeader) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_focusNode.requestFocus();
});
}
return BlocBuilder<BoardBloc, BoardState>(
builder: (context, state) {
if (state.isEditingHeader) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_focusNode.requestFocus();
});
}
Widget title = Expanded(
child: FlowyText.medium(
widget.groupData.headerData.groupName,
fontSize: 14,
overflow: TextOverflow.clip,
),
);
Widget title = Expanded(
child: FlowyText.medium(
widget.groupData.headerData.groupName,
fontSize: 14,
overflow: TextOverflow.clip,
),
);
if (!boardCustomData.group.isDefault &&
boardCustomData.fieldType.canEditHeader) {
title = Flexible(
fit: FlexFit.tight,
child: FlowyTooltip(
message: LocaleKeys.board_column_renameGroupTooltip.tr(),
child: FlowyHover(
style: HoverStyle(
hoverColor: Colors.transparent,
foregroundColorOnHover:
AFThemeExtension.of(context).textColor,
),
child: GestureDetector(
onTap: () => context.read<BoardBloc>().add(
BoardEvent.startEditingHeader(
widget.groupData.id,
),
if (!boardCustomData.group.isDefault &&
boardCustomData.fieldType.canEditHeader) {
title = Flexible(
fit: FlexFit.tight,
child: FlowyTooltip(
message: LocaleKeys.board_column_renameGroupTooltip.tr(),
child: FlowyHover(
style: HoverStyle(
hoverColor: Colors.transparent,
foregroundColorOnHover:
AFThemeExtension.of(context).textColor,
),
child: GestureDetector(
onTap: () => context.read<BoardBloc>().add(
BoardEvent.startEditingHeader(
widget.groupData.id,
),
child: FlowyText.medium(
widget.groupData.headerData.groupName,
fontSize: 14,
overflow: TextOverflow.clip,
),
),
child: FlowyText.medium(
widget.groupData.headerData.groupName,
fontSize: 14,
overflow: TextOverflow.clip,
),
),
),
);
}
if (state.isEditingHeader &&
state.editingHeaderId == widget.groupData.id) {
title = _buildTextField(context);
}
return AppFlowyGroupHeader(
title: title,
icon: _buildHeaderIcon(boardCustomData),
addIcon: SizedBox(
height: 20,
width: 20,
child: FlowySvg(
FlowySvgs.add_s,
color: Theme.of(context).iconTheme.color,
),
),
onAddButtonClick: () => context
.read<BoardBloc>()
.add(BoardEvent.createHeaderRow(widget.groupData.id)),
height: 50,
margin: widget.margin ?? EdgeInsets.zero,
);
},
),
}
if (state.isEditingHeader &&
state.editingHeaderId == widget.groupData.id) {
title = _buildTextField(context);
}
return AppFlowyGroupHeader(
title: title,
icon: _buildHeaderIcon(boardCustomData),
addIcon: SizedBox(
height: 20,
width: 20,
child: FlowySvg(
FlowySvgs.add_s,
color: Theme.of(context).iconTheme.color,
),
),
onAddButtonClick: () => context
.read<BoardBloc>()
.add(BoardEvent.createHeaderRow(widget.groupData.id)),
height: 50,
margin: widget.margin ?? EdgeInsets.zero,
);
},
);
}
@ -224,5 +221,5 @@ Widget? _buildHeaderIcon(GroupData customData) {
);
}
return null;
return widget;
}