Merge pull request #988 from AppFlowy-IO/feat/edit_multi_text_cell

This commit is contained in:
Nathan.fooo 2022-09-05 22:20:57 +08:00 committed by GitHub
commit f9235491fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

@ -14,33 +14,37 @@ class EditableCellNotifier {
}
class EditableRowNotifier {
Map<EditableCellId, EditableCellNotifier> cells = {};
final Map<EditableCellId, EditableCellNotifier> _cells = {};
void insertCell(
GridCellIdentifier cellIdentifier,
EditableCellNotifier notifier,
) {
cells[EditableCellId.from(cellIdentifier)] = notifier;
_cells[EditableCellId.from(cellIdentifier)] = notifier;
}
void becomeFirstResponder() {
for (final notifier in cells.values) {
for (final notifier in _cells.values) {
notifier.becomeFirstResponder.notify();
}
}
void resignFirstResponder() {
for (final notifier in cells.values) {
for (final notifier in _cells.values) {
notifier.resignFirstResponder.notify();
}
}
void clear() {
_cells.clear();
}
void dispose() {
for (final notifier in cells.values) {
for (final notifier in _cells.values) {
notifier.resignFirstResponder.notify();
}
cells.clear();
_cells.clear();
}
}

View File

@ -89,20 +89,20 @@ class _BoardCardState extends State<BoardCard> {
List<GridCellIdentifier> cells,
) {
final List<Widget> children = [];
rowNotifier.clear();
cells.asMap().forEach(
(int index, GridCellIdentifier cellId) {
final cellNotifier = EditableCellNotifier();
Widget child = widget.cellBuilder.buildCell(
widget.groupId,
cellId,
widget.isEditing,
index == 0 ? widget.isEditing : false,
cellNotifier,
);
if (index == 0) {
rowNotifier.insertCell(cellId, cellNotifier);
}
child = Padding(
key: cellId.key(),
padding: const EdgeInsets.only(left: 4, right: 4),