From 8b535720ef5abc5725a0bf95d3a4ea5540f17f14 Mon Sep 17 00:00:00 2001 From: appflowy Date: Thu, 11 Aug 2022 13:33:36 +0800 Subject: [PATCH] chore: add AF prefix to appflowy_board classes --- .../plugins/board/application/board_bloc.dart | 8 ++-- .../application/board_data_controller.dart | 7 +--- .../board/presentation/board_page.dart | 10 ++--- .../header/type_option/multi_select.dart | 17 +++++--- .../example/lib/multi_board_list_example.dart | 14 +++---- .../lib/single_board_list_example.dart | 6 +-- .../appflowy_board/lib/src/widgets/board.dart | 40 +++++++++---------- .../widgets/board_column/board_column.dart | 36 ++++++++--------- .../board_column/board_column_data.dart | 10 ++--- .../lib/src/widgets/board_data.dart | 16 ++++---- .../src/revision/grid_setting_rev.rs | 1 + 11 files changed, 83 insertions(+), 82 deletions(-) diff --git a/frontend/app_flowy/lib/plugins/board/application/board_bloc.dart b/frontend/app_flowy/lib/plugins/board/application/board_bloc.dart index 5c2072d2f1..66eeddc76a 100644 --- a/frontend/app_flowy/lib/plugins/board/application/board_bloc.dart +++ b/frontend/app_flowy/lib/plugins/board/application/board_bloc.dart @@ -18,12 +18,12 @@ part 'board_bloc.freezed.dart'; class BoardBloc extends Bloc { final GridDataController _gridDataController; - late final BoardDataController boardDataController; + late final AFBoardDataController boardDataController; BoardBloc({required ViewPB view}) : _gridDataController = GridDataController(view: view), super(BoardState.initial(view.id)) { - boardDataController = BoardDataController( + boardDataController = AFBoardDataController( onMoveColumn: ( fromIndex, toIndex, @@ -120,8 +120,8 @@ class BoardBloc extends Bloc { typeOptionContext.loadTypeOptionData( onCompleted: (singleSelect) { - List columns = singleSelect.options.map((option) { - return BoardColumnData( + List columns = singleSelect.options.map((option) { + return AFBoardColumnData( id: option.id, desc: option.name, customData: option, diff --git a/frontend/app_flowy/lib/plugins/board/application/board_data_controller.dart b/frontend/app_flowy/lib/plugins/board/application/board_data_controller.dart index d52b516663..d5e72fa908 100644 --- a/frontend/app_flowy/lib/plugins/board/application/board_data_controller.dart +++ b/frontend/app_flowy/lib/plugins/board/application/board_data_controller.dart @@ -12,13 +12,8 @@ // typedef OnFieldsChanged = void Function(UnmodifiableListView); // typedef OnGridChanged = void Function(GridPB); -// typedef OnRowsChanged = void Function( -// List rowInfos, -// GridRowChangeReason, -// ); -// typedef ListenONRowChangedCondition = bool Function(); -// class GridDataController { +// class ridDataController { // final String gridId; // final GridService _gridFFIService; // final GridFieldCache fieldCache; diff --git a/frontend/app_flowy/lib/plugins/board/presentation/board_page.dart b/frontend/app_flowy/lib/plugins/board/presentation/board_page.dart index 60b788ae6d..56a2dfa5f5 100644 --- a/frontend/app_flowy/lib/plugins/board/presentation/board_page.dart +++ b/frontend/app_flowy/lib/plugins/board/presentation/board_page.dart @@ -37,7 +37,7 @@ class BoardPage extends StatelessWidget { } class BoardContent extends StatelessWidget { - final config = BoardConfig( + final config = AFBoardConfig( columnBackgroundColor: HexColor.fromHex('#F7F8FC'), ); @@ -51,13 +51,13 @@ class BoardContent extends StatelessWidget { color: Colors.white, child: Padding( padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 20), - child: Board( + child: AFBoard( dataController: context.read().boardDataController, headerBuilder: _buildHeader, footBuilder: _buildFooter, cardBuilder: _buildCard, columnConstraints: const BoxConstraints.tightFor(width: 240), - config: BoardConfig( + config: AFBoardConfig( columnBackgroundColor: HexColor.fromHex('#F7F8FC'), ), ), @@ -67,7 +67,7 @@ class BoardContent extends StatelessWidget { ); } - Widget _buildHeader(BuildContext context, BoardColumnData columnData) { + Widget _buildHeader(BuildContext context, AFBoardColumnData columnData) { return AppFlowyColumnHeader( icon: const Icon(Icons.lightbulb_circle), title: Text(columnData.desc), @@ -78,7 +78,7 @@ class BoardContent extends StatelessWidget { ); } - Widget _buildFooter(BuildContext context, BoardColumnData columnData) { + Widget _buildFooter(BuildContext context, AFBoardColumnData columnData) { return AppFlowyColumnFooter( icon: const Icon(Icons.add, size: 20), title: const Text('New'), diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart index 9c0f860055..ab8a628146 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart @@ -1,4 +1,5 @@ import 'package:app_flowy/plugins/grid/application/field/type_option/multi_select_type_option.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart'; import 'package:flutter/material.dart'; import '../field_type_option_editor.dart'; @@ -9,10 +10,14 @@ class MultiSelectTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { final MultiSelectTypeOptionWidget _widget; MultiSelectTypeOptionWidgetBuilder( - MultiSelectAction typeOptionContext, + MultiSelectTypeOptionContext typeOptionContext, TypeOptionOverlayDelegate overlayDelegate, ) : _widget = MultiSelectTypeOptionWidget( - typeOptionContext: typeOptionContext, + selectOptionAction: MultiSelectAction( + fieldId: typeOptionContext.fieldId, + gridId: typeOptionContext.gridId, + typeOptionContext: typeOptionContext, + ), overlayDelegate: overlayDelegate, ); @@ -21,11 +26,11 @@ class MultiSelectTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { } class MultiSelectTypeOptionWidget extends TypeOptionWidget { - final MultiSelectAction typeOptionContext; + final MultiSelectAction selectOptionAction; final TypeOptionOverlayDelegate overlayDelegate; const MultiSelectTypeOptionWidget({ - required this.typeOptionContext, + required this.selectOptionAction, required this.overlayDelegate, Key? key, }) : super(key: key); @@ -33,10 +38,10 @@ class MultiSelectTypeOptionWidget extends TypeOptionWidget { @override Widget build(BuildContext context) { return SelectOptionTypeOptionWidget( - options: typeOptionContext.typeOption.options, + options: selectOptionAction.typeOption.options, beginEdit: () => overlayDelegate.hideOverlay(context), overlayDelegate: overlayDelegate, - typeOptionAction: typeOptionContext, + typeOptionAction: selectOptionAction, // key: ValueKey(state.typeOption.hashCode), ); } diff --git a/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart b/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart index d692a6fe20..eb16ba09ba 100644 --- a/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart +++ b/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart @@ -9,7 +9,7 @@ class MultiBoardListExample extends StatefulWidget { } class _MultiBoardListExampleState extends State { - final BoardDataController boardDataController = BoardDataController( + final AFBoardDataController boardDataController = AFBoardDataController( onMoveColumn: (fromIndex, toIndex) { debugPrint('Move column from $fromIndex to $toIndex'); }, @@ -23,18 +23,18 @@ class _MultiBoardListExampleState extends State { @override void initState() { - final column1 = BoardColumnData(id: "To Do", items: [ + final column1 = AFBoardColumnData(id: "To Do", items: [ TextItem("Card 1"), TextItem("Card 2"), RichTextItem(title: "Card 3", subtitle: 'Aug 1, 2020 4:05 PM'), TextItem("Card 4"), ]); - final column2 = BoardColumnData(id: "In Progress", items: [ + final column2 = AFBoardColumnData(id: "In Progress", items: [ RichTextItem(title: "Card 5", subtitle: 'Aug 1, 2020 4:05 PM'), TextItem("Card 6"), ]); - final column3 = BoardColumnData(id: "Done", items: []); + final column3 = AFBoardColumnData(id: "Done", items: []); boardDataController.addColumn(column1); boardDataController.addColumn(column2); @@ -45,14 +45,14 @@ class _MultiBoardListExampleState extends State { @override Widget build(BuildContext context) { - final config = BoardConfig( + final config = AFBoardConfig( columnBackgroundColor: HexColor.fromHex('#F7F8FC'), ); return Container( color: Colors.white, child: Padding( padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 20), - child: Board( + child: AFBoard( dataController: boardDataController, footBuilder: (context, columnData) { return AppFlowyColumnFooter( @@ -79,7 +79,7 @@ class _MultiBoardListExampleState extends State { ); }, columnConstraints: const BoxConstraints.tightFor(width: 240), - config: BoardConfig( + config: AFBoardConfig( columnBackgroundColor: HexColor.fromHex('#F7F8FC'), ), ), diff --git a/frontend/app_flowy/packages/appflowy_board/example/lib/single_board_list_example.dart b/frontend/app_flowy/packages/appflowy_board/example/lib/single_board_list_example.dart index 655f1439c1..8c4226a65c 100644 --- a/frontend/app_flowy/packages/appflowy_board/example/lib/single_board_list_example.dart +++ b/frontend/app_flowy/packages/appflowy_board/example/lib/single_board_list_example.dart @@ -9,11 +9,11 @@ class SingleBoardListExample extends StatefulWidget { } class _SingleBoardListExampleState extends State { - final BoardDataController boardData = BoardDataController(); + final AFBoardDataController boardData = AFBoardDataController(); @override void initState() { - final column = BoardColumnData(id: "1", items: [ + final column = AFBoardColumnData(id: "1", items: [ TextItem("a"), TextItem("b"), TextItem("c"), @@ -26,7 +26,7 @@ class _SingleBoardListExampleState extends State { @override Widget build(BuildContext context) { - return Board( + return AFBoard( dataController: boardData, cardBuilder: (context, item) { return _RowWidget(item: item as TextItem, key: ObjectKey(item)); diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart index 3cd2a331f1..03d9ca1750 100644 --- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart @@ -8,13 +8,13 @@ import 'reorder_flex/reorder_flex.dart'; import 'reorder_phantom/phantom_controller.dart'; import '../rendering/board_overlay.dart'; -class BoardConfig { +class AFBoardConfig { final double cornerRadius; final EdgeInsets columnPadding; final EdgeInsets columnItemPadding; final Color columnBackgroundColor; - const BoardConfig({ + const AFBoardConfig({ this.cornerRadius = 6.0, this.columnPadding = const EdgeInsets.symmetric(horizontal: 8), this.columnItemPadding = const EdgeInsets.symmetric(horizontal: 10), @@ -22,7 +22,7 @@ class BoardConfig { }); } -class Board extends StatelessWidget { +class AFBoard extends StatelessWidget { /// The direction to use as the main axis. final Axis direction = Axis.vertical; @@ -30,32 +30,32 @@ class Board extends StatelessWidget { final Widget? background; /// - final BoardColumnCardBuilder cardBuilder; + final AFBoardColumnCardBuilder cardBuilder; /// - final BoardColumnHeaderBuilder? headerBuilder; + final AFBoardColumnHeaderBuilder? headerBuilder; /// - final BoardColumnFooterBuilder? footBuilder; + final AFBoardColumnFooterBuilder? footBuilder; /// - final BoardDataController dataController; + final AFBoardDataController dataController; final BoxConstraints columnConstraints; /// final BoardPhantomController phantomController; - final BoardConfig config; + final AFBoardConfig config; - Board({ + AFBoard({ required this.dataController, required this.cardBuilder, this.background, this.footBuilder, this.headerBuilder, this.columnConstraints = const BoxConstraints(maxWidth: 200), - this.config = const BoardConfig(), + this.config = const AFBoardConfig(), Key? key, }) : phantomController = BoardPhantomController(delegate: dataController), super(key: key); @@ -64,7 +64,7 @@ class Board extends StatelessWidget { Widget build(BuildContext context) { return ChangeNotifierProvider.value( value: dataController, - child: Consumer( + child: Consumer( builder: (context, notifier, child) { return BoardContent( config: config, @@ -89,20 +89,20 @@ class BoardContent extends StatefulWidget { final OnDragStarted? onDragStarted; final OnReorder onReorder; final OnDragEnded? onDragEnded; - final BoardDataController dataController; + final AFBoardDataController dataController; final Widget? background; - final BoardConfig config; + final AFBoardConfig config; final ReorderFlexConfig reorderFlexConfig; final BoxConstraints columnConstraints; /// - final BoardColumnCardBuilder cardBuilder; + final AFBoardColumnCardBuilder cardBuilder; /// - final BoardColumnHeaderBuilder? headerBuilder; + final AFBoardColumnHeaderBuilder? headerBuilder; /// - final BoardColumnFooterBuilder? footBuilder; + final AFBoardColumnFooterBuilder? footBuilder; final OverlapDragTargetDelegate delegate; @@ -206,7 +206,7 @@ class _BoardContentState extends State { builder: (context, value, child) { return ConstrainedBox( constraints: widget.columnConstraints, - child: BoardColumnWidget( + child: AFBoardColumnWidget( margin: _marginFromIndex(columnIndex), itemMargin: widget.config.columnItemPadding, headerBuilder: widget.headerBuilder, @@ -246,9 +246,9 @@ class _BoardContentState extends State { } } -class _BoardColumnDataSourceImpl extends BoardColumnDataDataSource { +class _BoardColumnDataSourceImpl extends AFBoardColumnDataDataSource { String columnId; - final BoardDataController dataController; + final AFBoardDataController dataController; _BoardColumnDataSourceImpl({ required this.columnId, @@ -256,7 +256,7 @@ class _BoardColumnDataSourceImpl extends BoardColumnDataDataSource { }); @override - BoardColumnData get columnData => + AFBoardColumnData get columnData => dataController.columnController(columnId).columnData; @override diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart index d8981096e3..09d441bc16 100644 --- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart @@ -22,23 +22,23 @@ typedef OnColumnDeleted = void Function(String listId, int deletedIndex); typedef OnColumnInserted = void Function(String listId, int insertedIndex); -typedef BoardColumnCardBuilder = Widget Function( +typedef AFBoardColumnCardBuilder = Widget Function( BuildContext context, ColumnItem item, ); -typedef BoardColumnHeaderBuilder = Widget Function( +typedef AFBoardColumnHeaderBuilder = Widget Function( BuildContext context, - BoardColumnData columnData, + AFBoardColumnData columnData, ); -typedef BoardColumnFooterBuilder = Widget Function( +typedef AFBoardColumnFooterBuilder = Widget Function( BuildContext context, - BoardColumnData columnData, + AFBoardColumnData columnData, ); -abstract class BoardColumnDataDataSource extends ReoderFlextDataSource { - BoardColumnData get columnData; +abstract class AFBoardColumnDataDataSource extends ReoderFlextDataSource { + AFBoardColumnData get columnData; List get acceptedColumnIds; @@ -49,7 +49,7 @@ abstract class BoardColumnDataDataSource extends ReoderFlextDataSource { UnmodifiableListView get items => columnData.items; void debugPrint() { - String msg = '[$BoardColumnDataDataSource] $columnData data: '; + String msg = '[$AFBoardColumnDataDataSource] $columnData data: '; for (var element in items) { msg = '$msg$element,'; } @@ -58,10 +58,10 @@ abstract class BoardColumnDataDataSource extends ReoderFlextDataSource { } } -/// [BoardColumnWidget] represents the column of the Board. +/// [AFBoardColumnWidget] represents the column of the Board. /// -class BoardColumnWidget extends StatefulWidget { - final BoardColumnDataDataSource dataSource; +class AFBoardColumnWidget extends StatefulWidget { + final AFBoardColumnDataDataSource dataSource; final ScrollController? scrollController; final ReorderFlexConfig config; @@ -73,11 +73,11 @@ class BoardColumnWidget extends StatefulWidget { String get columnId => dataSource.columnData.id; - final BoardColumnCardBuilder cardBuilder; + final AFBoardColumnCardBuilder cardBuilder; - final BoardColumnHeaderBuilder? headerBuilder; + final AFBoardColumnHeaderBuilder? headerBuilder; - final BoardColumnFooterBuilder? footBuilder; + final AFBoardColumnFooterBuilder? footBuilder; final EdgeInsets margin; @@ -87,7 +87,7 @@ class BoardColumnWidget extends StatefulWidget { final Color backgroundColor; - const BoardColumnWidget({ + const AFBoardColumnWidget({ Key? key, this.headerBuilder, this.footBuilder, @@ -106,12 +106,12 @@ class BoardColumnWidget extends StatefulWidget { super(key: key); @override - State createState() => _BoardColumnWidgetState(); + State createState() => _AFBoardColumnWidgetState(); } -class _BoardColumnWidgetState extends State { +class _AFBoardColumnWidgetState extends State { final GlobalKey _columnOverlayKey = - GlobalKey(debugLabel: '$BoardColumnWidget overlay key'); + GlobalKey(debugLabel: '$AFBoardColumnWidget overlay key'); late BoardOverlayEntry _overlayEntry; diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart index 97551ef350..b7ef467a23 100644 --- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart @@ -12,7 +12,7 @@ abstract class ColumnItem extends ReoderFlexItem { String toString() => id; } -/// [BoardColumnDataController] is used to handle the [BoardColumnData]. +/// [BoardColumnDataController] is used to handle the [AFBoardColumnData]. /// * Remove an item by calling [removeAt] method. /// * Move item to another position by calling [move] method. /// * Insert item to index by calling [insert] method @@ -21,7 +21,7 @@ abstract class ColumnItem extends ReoderFlexItem { /// All there operations will notify listeners by default. /// class BoardColumnDataController extends ChangeNotifier with EquatableMixin { - final BoardColumnData columnData; + final AFBoardColumnData columnData; BoardColumnDataController({ required this.columnData, @@ -112,15 +112,15 @@ class BoardColumnDataController extends ChangeNotifier with EquatableMixin { } } -/// [BoardColumnData] represents the data of each Column of the Board. -class BoardColumnData extends ReoderFlexItem with EquatableMixin { +/// [AFBoardColumnData] represents the data of each Column of the Board. +class AFBoardColumnData extends ReoderFlexItem with EquatableMixin { @override final String id; final String desc; final List _items; final CustomData? customData; - BoardColumnData({ + AFBoardColumnData({ this.customData, required this.id, this.desc = "", diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart index 37bae68121..60bde5bc79 100644 --- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart @@ -23,14 +23,14 @@ typedef OnMoveColumnItemToColumn = void Function( int toIndex, ); -class BoardDataController extends ChangeNotifier +class AFBoardDataController extends ChangeNotifier with EquatableMixin, BoardPhantomControllerDelegate, ReoderFlextDataSource { - final List _columnDatas = []; + final List _columnDatas = []; final OnMoveColumn? onMoveColumn; final OnMoveColumnItem? onMoveColumnItem; final OnMoveColumnItemToColumn? onMoveColumnItemToColumn; - List get columnDatas => _columnDatas; + List get columnDatas => _columnDatas; List get columnIds => _columnDatas.map((columnData) => columnData.id).toList(); @@ -38,13 +38,13 @@ class BoardDataController extends ChangeNotifier final LinkedHashMap _columnControllers = LinkedHashMap(); - BoardDataController({ + AFBoardDataController({ this.onMoveColumn, this.onMoveColumnItem, this.onMoveColumnItemToColumn, }); - void addColumn(BoardColumnData columnData, {bool notify = true}) { + void addColumn(AFBoardColumnData columnData, {bool notify = true}) { if (_columnControllers[columnData.id] != null) return; final controller = BoardColumnDataController(columnData: columnData); @@ -53,7 +53,7 @@ class BoardDataController extends ChangeNotifier if (notify) notifyListeners(); } - void addColumns(List columns, {bool notify = true}) { + void addColumns(List columns, {bool notify = true}) { for (final column in columns) { addColumn(column, notify: false); } @@ -158,7 +158,7 @@ class BoardDataController extends ChangeNotifier } @override - String get identifier => '$BoardDataController'; + String get identifier => '$AFBoardDataController'; @override UnmodifiableListView get items => @@ -175,7 +175,7 @@ class BoardDataController extends ChangeNotifier columnController.removeAt(index); Log.debug( - '[$BoardDataController] Column:[$columnId] remove phantom, current count: ${columnController.items.length}'); + '[$AFBoardDataController] Column:[$columnId] remove phantom, current count: ${columnController.items.length}'); } return isExist; } diff --git a/shared-lib/flowy-grid-data-model/src/revision/grid_setting_rev.rs b/shared-lib/flowy-grid-data-model/src/revision/grid_setting_rev.rs index 153ee10961..277de36d62 100644 --- a/shared-lib/flowy-grid-data-model/src/revision/grid_setting_rev.rs +++ b/shared-lib/flowy-grid-data-model/src/revision/grid_setting_rev.rs @@ -39,6 +39,7 @@ pub struct GridSettingRevision { pub filters: GridFilters, + #[serde(default)] pub groups: GridGroups, #[serde(skip)]