chore: delete board card

This commit is contained in:
appflowy 2022-08-16 17:36:39 +08:00
parent c94c02b3c9
commit 162152916c
6 changed files with 27 additions and 14 deletions

View File

@ -138,14 +138,6 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
List<AFColumnItem> _buildRows(List<RowPB> rows) {
final items = rows.map((row) {
// final rowInfo = RowInfo(
// gridId: _dataController.gridId,
// blockId: row.blockId,
// id: row.id,
// fields: _dataController.fieldCache.unmodifiableFields,
// height: row.height.toDouble(),
// rawRow: row,
// );
return BoardColumnItem(row: row);
}).toList();

View File

@ -58,6 +58,17 @@ class BoardCardBloc extends Bloc<BoardCardEvent, BoardCardState> {
return super.close();
}
RowInfo rowInfo() {
return RowInfo(
gridId: _rowService.gridId,
blockId: _rowService.blockId,
fields: UnmodifiableListView(
state.cells.map((cell) => cell._field).toList(),
),
rowPB: state.rowPB,
);
}
Future<void> _startListening() async {
_dataController.addListener(
onRowChanged: (cells, reason) {

View File

@ -1,9 +1,10 @@
import 'package:app_flowy/plugins/board/application/card/card_bloc.dart';
import 'package:app_flowy/plugins/board/application/card/card_data_controller.dart';
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
import 'package:app_flowy/plugins/grid/presentation/widgets/row/row_action_sheet.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/theme.dart';
import 'package:flowy_sdk/log.dart';
import 'package:flowy_infra_ui/flowy_infra_ui_web.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'card_cell_builder.dart';
@ -85,6 +86,8 @@ class _CardMoreOption extends StatelessWidget with CardAccessory {
@override
void onTap(BuildContext context) {
Log.debug('show options');
GridRowActionSheet(
rowData: context.read<BoardCardBloc>().rowInfo(),
).show(context, direction: AnchorDirection.bottomWithCenterAligned);
}
}

View File

@ -53,7 +53,10 @@ class GridRowActionSheet extends StatelessWidget {
);
}
void show(BuildContext overlayContext) {
void show(
BuildContext overlayContext, {
AnchorDirection direction = AnchorDirection.leftWithCenterAligned,
}) {
FlowyOverlay.of(overlayContext).insertWithAnchor(
widget: OverlayContainer(
child: this,
@ -61,7 +64,7 @@ class GridRowActionSheet extends StatelessWidget {
),
identifier: GridRowActionSheet.identifier(),
anchorContext: overlayContext,
anchorDirection: AnchorDirection.leftWithCenterAligned,
anchorDirection: direction,
);
}

View File

@ -51,8 +51,11 @@ class AFBoardColumnDataController extends ChangeNotifier with EquatableMixin {
return item;
}
int removeWhere(bool Function(AFColumnItem) condition) {
return items.indexWhere(condition);
void removeWhere(bool Function(AFColumnItem) condition) {
final index = items.indexWhere(condition);
if (index != -1) {
removeAt(index);
}
}
/// Move the item from [fromIndex] to [toIndex]. It will do nothing if the

View File

@ -122,6 +122,7 @@ impl GridBlockManager {
Ok(())
}
#[tracing::instrument(level = "trace", skip_all, err)]
pub async fn delete_row(&self, row_id: &str) -> FlowyResult<()> {
let row_id = row_id.to_owned();
let block_id = self.persistence.get_block_id(&row_id)?;