chore: support create new field when editing the row

This commit is contained in:
appflowy
2022-08-31 20:21:06 +08:00
parent 942e966a25
commit a9f5f8d508
6 changed files with 112 additions and 65 deletions

View File

@ -65,7 +65,10 @@ class _BoardSelectOptionCellState extends State<BoardSelectOptionCell> {
alignment: AlignmentDirectional.center,
fit: StackFit.expand,
children: [
Wrap(spacing: 4, runSpacing: 2, children: children),
Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: Wrap(spacing: 4, runSpacing: 2, children: children),
),
_SelectOptionDialog(
controller: widget.cellControllerBuilder.build(),
),

View File

@ -78,36 +78,38 @@ class _BoardTextCellState extends State<BoardTextCell> {
child: BlocBuilder<BoardTextCellBloc, BoardTextCellState>(
builder: (context, state) {
Widget child;
if (state.enableEdit) {
child = TextField(
controller: _controller,
focusNode: focusNode,
onChanged: (value) => focusChanged(),
onEditingComplete: () => focusNode.unfocus(),
maxLines: 1,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
fontFamily: 'Mulish',
),
decoration: const InputDecoration(
// Magic number 4 makes the textField take up the same space as FlowyText
contentPadding: EdgeInsets.symmetric(vertical: 4),
border: InputBorder.none,
isDense: true,
),
);
if (state.content.isEmpty) {
child = const SizedBox();
} else {
child = FlowyText.medium(state.content, fontSize: 14);
if (state.enableEdit) {
child = TextField(
controller: _controller,
focusNode: focusNode,
onChanged: (value) => focusChanged(),
onEditingComplete: () => focusNode.unfocus(),
maxLines: 1,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
fontFamily: 'Mulish',
),
decoration: const InputDecoration(
// Magic number 4 makes the textField take up the same space as FlowyText
contentPadding: EdgeInsets.symmetric(vertical: 4),
border: InputBorder.none,
isDense: true,
),
);
} else {
child = FlowyText.medium(state.content, fontSize: 14);
child = Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: child,
);
}
}
return Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: child,
),
);
return Align(alignment: Alignment.centerLeft, child: child);
},
),
),

View File

@ -100,20 +100,11 @@ class _BoardCardState extends State<BoardCard> {
);
rowNotifier.insertCell(cellId, cellNotifier);
if (index != 0) {
child = Padding(
key: cellId.key(),
padding: const EdgeInsets.only(left: 4, right: 4, top: 8),
child: child,
);
} else {
child = Padding(
key: UniqueKey(),
padding: const EdgeInsets.only(left: 4, right: 4),
child: child,
);
}
child = Padding(
key: cellId.key(),
padding: const EdgeInsets.only(left: 4, right: 4),
child: child,
);
children.add(child);
},
);