Skip to content

Commit

Permalink
Merge pull request AppFlowy-IO#861 from AppFlowy-IO/feat/delete_board…
Browse files Browse the repository at this point in the history
…_card

chore: delete board card
  • Loading branch information
appflowy authored Aug 16, 2022
2 parents c94c02b + 1621529 commit a0363e3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,18 @@ class GridRowActionSheet extends StatelessWidget {
);
}

void show(BuildContext overlayContext) {
void show(
BuildContext overlayContext, {
AnchorDirection direction = AnchorDirection.leftWithCenterAligned,
}) {
FlowyOverlay.of(overlayContext).insertWithAnchor(
widget: OverlayContainer(
child: this,
constraints: BoxConstraints.loose(const Size(140, 200)),
),
identifier: GridRowActionSheet.identifier(),
anchorContext: overlayContext,
anchorDirection: AnchorDirection.leftWithCenterAligned,
anchorDirection: direction,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions frontend/rust-lib/flowy-grid/src/services/block_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit a0363e3

Please sign in to comment.