mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: become editing when creating a new card
This commit is contained in:
parent
4e8308b834
commit
af3bfebb64
@ -142,7 +142,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
|||||||
for (final group in groups) {
|
for (final group in groups) {
|
||||||
final delegate = GroupControllerDelegateImpl(
|
final delegate = GroupControllerDelegateImpl(
|
||||||
controller: boardController,
|
controller: boardController,
|
||||||
didAddColumnItem: (groupId, row) {
|
onNewColumnItem: (groupId, row) {
|
||||||
add(BoardEvent.didCreateRow(groupId, row));
|
add(BoardEvent.didCreateRow(groupId, row));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -313,11 +313,11 @@ class BoardColumnItem extends AFColumnItem {
|
|||||||
|
|
||||||
class GroupControllerDelegateImpl extends GroupControllerDelegate {
|
class GroupControllerDelegateImpl extends GroupControllerDelegate {
|
||||||
final AFBoardDataController controller;
|
final AFBoardDataController controller;
|
||||||
final void Function(String, RowPB) didAddColumnItem;
|
final void Function(String, RowPB) onNewColumnItem;
|
||||||
|
|
||||||
GroupControllerDelegateImpl({
|
GroupControllerDelegateImpl({
|
||||||
required this.controller,
|
required this.controller,
|
||||||
required this.didAddColumnItem,
|
required this.onNewColumnItem,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -329,10 +329,8 @@ class GroupControllerDelegateImpl extends GroupControllerDelegate {
|
|||||||
final item = BoardColumnItem(
|
final item = BoardColumnItem(
|
||||||
row: row,
|
row: row,
|
||||||
fieldId: group.fieldId,
|
fieldId: group.fieldId,
|
||||||
requestFocus: true,
|
|
||||||
);
|
);
|
||||||
controller.addColumnItem(group.groupId, item);
|
controller.addColumnItem(group.groupId, item);
|
||||||
didAddColumnItem(group.groupId, row);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,6 +349,17 @@ class GroupControllerDelegateImpl extends GroupControllerDelegate {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void addNewRow(GroupPB group, RowPB row) {
|
||||||
|
final item = BoardColumnItem(
|
||||||
|
row: row,
|
||||||
|
fieldId: group.fieldId,
|
||||||
|
requestFocus: true,
|
||||||
|
);
|
||||||
|
controller.addColumnItem(group.groupId, item);
|
||||||
|
onNewColumnItem(group.groupId, row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BoardEditingRow {
|
class BoardEditingRow {
|
||||||
|
@ -9,6 +9,7 @@ abstract class GroupControllerDelegate {
|
|||||||
void removeRow(GroupPB group, String rowId);
|
void removeRow(GroupPB group, String rowId);
|
||||||
void insertRow(GroupPB group, RowPB row, int? index);
|
void insertRow(GroupPB group, RowPB row, int? index);
|
||||||
void updateRow(GroupPB group, RowPB row);
|
void updateRow(GroupPB group, RowPB row);
|
||||||
|
void addNewRow(GroupPB group, RowPB row);
|
||||||
}
|
}
|
||||||
|
|
||||||
class GroupController {
|
class GroupController {
|
||||||
@ -48,7 +49,11 @@ class GroupController {
|
|||||||
group.rows.add(insertedRow.row);
|
group.rows.add(insertedRow.row);
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate.insertRow(group, insertedRow.row, index);
|
if (insertedRow.isNew) {
|
||||||
|
delegate.addNewRow(group, insertedRow.row);
|
||||||
|
} else {
|
||||||
|
delegate.insertRow(group, insertedRow.row, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final updatedRow in changeset.updatedRows) {
|
for (final updatedRow in changeset.updatedRows) {
|
||||||
|
@ -196,10 +196,8 @@ class _BoardContentState extends State<BoardContent> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final cellBuilder = BoardCellBuilder(cardController);
|
final cellBuilder = BoardCellBuilder(cardController);
|
||||||
final isEditing = context.read<BoardBloc>().state.editingRow.fold(
|
|
||||||
() => false,
|
final isEditing = context.read<BoardBloc>().state.editingRow.isSome();
|
||||||
(editingRow) => editingRow.row.id == rowPB.id,
|
|
||||||
);
|
|
||||||
|
|
||||||
return AppFlowyColumnItemCard(
|
return AppFlowyColumnItemCard(
|
||||||
key: ValueKey(columnItem.id),
|
key: ValueKey(columnItem.id),
|
||||||
@ -212,9 +210,6 @@ class _BoardContentState extends State<BoardContent> {
|
|||||||
isEditing: isEditing,
|
isEditing: isEditing,
|
||||||
cellBuilder: cellBuilder,
|
cellBuilder: cellBuilder,
|
||||||
dataController: cardController,
|
dataController: cardController,
|
||||||
onEditEditing: (rowId) {
|
|
||||||
context.read<BoardBloc>().add(BoardEvent.endEditRow(rowId));
|
|
||||||
},
|
|
||||||
openCard: (context) => _openCard(
|
openCard: (context) => _openCard(
|
||||||
gridId,
|
gridId,
|
||||||
fieldCache,
|
fieldCache,
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
abstract class FocusableBoardCell {
|
||||||
|
set becomeFocus(bool isFocus);
|
||||||
|
}
|
@ -1,16 +1,19 @@
|
|||||||
import 'package:app_flowy/plugins/board/application/card/board_text_cell_bloc.dart';
|
import 'package:app_flowy/plugins/board/application/card/board_text_cell_bloc.dart';
|
||||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
||||||
import 'package:app_flowy/plugins/grid/presentation/widgets/cell/cell_builder.dart';
|
import 'package:app_flowy/plugins/grid/presentation/widgets/cell/cell_builder.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class BoardTextCell extends StatefulWidget {
|
class BoardTextCell extends StatefulWidget {
|
||||||
final String groupId;
|
final String groupId;
|
||||||
|
final bool isFocus;
|
||||||
|
|
||||||
final GridCellControllerBuilder cellControllerBuilder;
|
final GridCellControllerBuilder cellControllerBuilder;
|
||||||
|
|
||||||
const BoardTextCell({
|
const BoardTextCell({
|
||||||
required this.groupId,
|
required this.groupId,
|
||||||
required this.cellControllerBuilder,
|
required this.cellControllerBuilder,
|
||||||
|
this.isFocus = false,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@ -30,6 +33,10 @@ class _BoardTextCellState extends State<BoardTextCell> {
|
|||||||
_cellBloc = BoardTextCellBloc(cellController: cellController)
|
_cellBloc = BoardTextCellBloc(cellController: cellController)
|
||||||
..add(const BoardTextCellEvent.initial());
|
..add(const BoardTextCellEvent.initial());
|
||||||
_controller = TextEditingController(text: _cellBloc.state.content);
|
_controller = TextEditingController(text: _cellBloc.state.content);
|
||||||
|
|
||||||
|
if (widget.isFocus) {
|
||||||
|
focusNode.requestFocus();
|
||||||
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'card_cell_builder.dart';
|
import 'card_cell_builder.dart';
|
||||||
import 'card_container.dart';
|
import 'card_container.dart';
|
||||||
|
|
||||||
typedef OnEndEditing = void Function(String rowId);
|
|
||||||
|
|
||||||
class BoardCard extends StatefulWidget {
|
class BoardCard extends StatefulWidget {
|
||||||
final String gridId;
|
final String gridId;
|
||||||
final String groupId;
|
final String groupId;
|
||||||
@ -19,7 +17,6 @@ class BoardCard extends StatefulWidget {
|
|||||||
final bool isEditing;
|
final bool isEditing;
|
||||||
final CardDataController dataController;
|
final CardDataController dataController;
|
||||||
final BoardCellBuilder cellBuilder;
|
final BoardCellBuilder cellBuilder;
|
||||||
final OnEndEditing onEditEditing;
|
|
||||||
final void Function(BuildContext) openCard;
|
final void Function(BuildContext) openCard;
|
||||||
|
|
||||||
const BoardCard({
|
const BoardCard({
|
||||||
@ -29,7 +26,6 @@ class BoardCard extends StatefulWidget {
|
|||||||
required this.isEditing,
|
required this.isEditing,
|
||||||
required this.dataController,
|
required this.dataController,
|
||||||
required this.cellBuilder,
|
required this.cellBuilder,
|
||||||
required this.onEditEditing,
|
|
||||||
required this.openCard,
|
required this.openCard,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
@ -87,18 +83,27 @@ class _BoardCardState extends State<BoardCard> {
|
|||||||
final List<Widget> children = [];
|
final List<Widget> children = [];
|
||||||
cells.asMap().forEach(
|
cells.asMap().forEach(
|
||||||
(int index, GridCellIdentifier cellId) {
|
(int index, GridCellIdentifier cellId) {
|
||||||
final child = widget.cellBuilder.buildCell(widget.groupId, cellId);
|
Widget child = widget.cellBuilder.buildCell(
|
||||||
|
widget.groupId,
|
||||||
|
cellId,
|
||||||
|
widget.isEditing,
|
||||||
|
);
|
||||||
|
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
children.add(Padding(
|
child = Padding(
|
||||||
|
key: cellId.key(),
|
||||||
padding: const EdgeInsets.only(left: 4, right: 4, top: 8),
|
padding: const EdgeInsets.only(left: 4, right: 4, top: 8),
|
||||||
child: child,
|
child: child,
|
||||||
));
|
);
|
||||||
} else {
|
} else {
|
||||||
children.add(Padding(
|
child = Padding(
|
||||||
|
key: UniqueKey(),
|
||||||
padding: const EdgeInsets.only(left: 4, right: 4),
|
padding: const EdgeInsets.only(left: 4, right: 4),
|
||||||
child: child,
|
child: child,
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
children.add(child);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return children;
|
return children;
|
||||||
|
@ -19,7 +19,11 @@ class BoardCellBuilder {
|
|||||||
|
|
||||||
BoardCellBuilder(this.delegate);
|
BoardCellBuilder(this.delegate);
|
||||||
|
|
||||||
Widget buildCell(String groupId, GridCellIdentifier cellId) {
|
Widget buildCell(
|
||||||
|
String groupId,
|
||||||
|
GridCellIdentifier cellId,
|
||||||
|
bool isEditing,
|
||||||
|
) {
|
||||||
final cellControllerBuilder = GridCellControllerBuilder(
|
final cellControllerBuilder = GridCellControllerBuilder(
|
||||||
delegate: delegate,
|
delegate: delegate,
|
||||||
cellId: cellId,
|
cellId: cellId,
|
||||||
@ -62,6 +66,7 @@ class BoardCellBuilder {
|
|||||||
return BoardTextCell(
|
return BoardTextCell(
|
||||||
groupId: groupId,
|
groupId: groupId,
|
||||||
cellControllerBuilder: cellControllerBuilder,
|
cellControllerBuilder: cellControllerBuilder,
|
||||||
|
isFocus: isEditing,
|
||||||
key: key,
|
key: key,
|
||||||
);
|
);
|
||||||
case FieldType.URL:
|
case FieldType.URL:
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# 0.0.6
|
||||||
|
* Support scroll to bottom
|
||||||
|
* Fix some bugs
|
||||||
|
|
||||||
# 0.0.5
|
# 0.0.5
|
||||||
* Optimize insert card animation
|
* Optimize insert card animation
|
||||||
* Enable insert card at the end of the column
|
* Enable insert card at the end of the column
|
||||||
|
@ -381,7 +381,6 @@ class ReorderFlexState extends State<ReorderFlex>
|
|||||||
dragState.currentIndex,
|
dragState.currentIndex,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
dragState.endDragging();
|
dragState.endDragging();
|
||||||
widget.onDragEnded?.call();
|
widget.onDragEnded?.call();
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,6 @@ import 'package:appflowy_board/appflowy_board.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import '../../utils/log.dart';
|
import '../../utils/log.dart';
|
||||||
import '../board_column/board_column_data.dart';
|
|
||||||
import '../reorder_flex/drag_state.dart';
|
import '../reorder_flex/drag_state.dart';
|
||||||
import '../reorder_flex/drag_target.dart';
|
import '../reorder_flex/drag_target.dart';
|
||||||
import '../reorder_flex/drag_target_interceptor.dart';
|
import '../reorder_flex/drag_target_interceptor.dart';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: appflowy_board
|
name: appflowy_board
|
||||||
description: AppFlowy board implementation.
|
description: AppFlowy board implementation.
|
||||||
version: 0.0.5
|
version: 0.0.6
|
||||||
homepage: https://github.com/AppFlowy-IO/AppFlowy
|
homepage: https://github.com/AppFlowy-IO/AppFlowy
|
||||||
repository: https://github.com/AppFlowy-IO/AppFlowy/tree/main/frontend/app_flowy/packages/appflowy_board
|
repository: https://github.com/AppFlowy-IO/AppFlowy/tree/main/frontend/app_flowy/packages/appflowy_board
|
||||||
|
|
||||||
|
@ -120,17 +120,28 @@ pub struct InsertedRowPB {
|
|||||||
|
|
||||||
#[pb(index = 2, one_of)]
|
#[pb(index = 2, one_of)]
|
||||||
pub index: Option<i32>,
|
pub index: Option<i32>,
|
||||||
|
|
||||||
|
#[pb(index = 3)]
|
||||||
|
pub is_new: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InsertedRowPB {
|
impl InsertedRowPB {
|
||||||
pub fn new(row: RowPB) -> Self {
|
pub fn new(row: RowPB) -> Self {
|
||||||
Self { row, index: None }
|
Self {
|
||||||
|
row,
|
||||||
|
index: None,
|
||||||
|
is_new: false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::From<RowPB> for InsertedRowPB {
|
impl std::convert::From<RowPB> for InsertedRowPB {
|
||||||
fn from(row: RowPB) -> Self {
|
fn from(row: RowPB) -> Self {
|
||||||
Self { row, index: None }
|
Self {
|
||||||
|
row,
|
||||||
|
index: None,
|
||||||
|
is_new: false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +164,7 @@ impl GridBlockManager {
|
|||||||
let insert_row = InsertedRowPB {
|
let insert_row = InsertedRowPB {
|
||||||
index: Some(to as i32),
|
index: Some(to as i32),
|
||||||
row: make_row_from_row_rev(row_rev),
|
row: make_row_from_row_rev(row_rev),
|
||||||
|
is_new: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let notified_changeset = GridBlockChangesetPB {
|
let notified_changeset = GridBlockChangesetPB {
|
||||||
|
@ -98,6 +98,7 @@ impl GridViewRevisionEditor {
|
|||||||
let inserted_row = InsertedRowPB {
|
let inserted_row = InsertedRowPB {
|
||||||
row: row_pb.clone(),
|
row: row_pb.clone(),
|
||||||
index: None,
|
index: None,
|
||||||
|
is_new: true,
|
||||||
};
|
};
|
||||||
let changeset = GroupChangesetPB::insert(group_id.clone(), vec![inserted_row]);
|
let changeset = GroupChangesetPB::insert(group_id.clone(), vec![inserted_row]);
|
||||||
self.notify_did_update_group(changeset).await;
|
self.notify_did_update_group(changeset).await;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user