chore: add AF prefix to appflowy_board classes

This commit is contained in:
appflowy 2022-08-11 13:33:36 +08:00
parent 08b9930510
commit 8b535720ef
11 changed files with 83 additions and 82 deletions

View File

@ -18,12 +18,12 @@ part 'board_bloc.freezed.dart';
class BoardBloc extends Bloc<BoardEvent, BoardState> {
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<BoardEvent, BoardState> {
typeOptionContext.loadTypeOptionData(
onCompleted: (singleSelect) {
List<BoardColumnData> columns = singleSelect.options.map((option) {
return BoardColumnData(
List<AFBoardColumnData> columns = singleSelect.options.map((option) {
return AFBoardColumnData(
id: option.id,
desc: option.name,
customData: option,

View File

@ -12,13 +12,8 @@
// typedef OnFieldsChanged = void Function(UnmodifiableListView<FieldPB>);
// typedef OnGridChanged = void Function(GridPB);
// typedef OnRowsChanged = void Function(
// List<GridRowInfo> rowInfos,
// GridRowChangeReason,
// );
// typedef ListenONRowChangedCondition = bool Function();
// class GridDataController {
// class ridDataController {
// final String gridId;
// final GridService _gridFFIService;
// final GridFieldCache fieldCache;

View File

@ -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<BoardBloc>().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'),

View File

@ -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),
);
}

View File

@ -9,7 +9,7 @@ class MultiBoardListExample extends StatefulWidget {
}
class _MultiBoardListExampleState extends State<MultiBoardListExample> {
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<MultiBoardListExample> {
@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<MultiBoardListExample> {
@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<MultiBoardListExample> {
);
},
columnConstraints: const BoxConstraints.tightFor(width: 240),
config: BoardConfig(
config: AFBoardConfig(
columnBackgroundColor: HexColor.fromHex('#F7F8FC'),
),
),

View File

@ -9,11 +9,11 @@ class SingleBoardListExample extends StatefulWidget {
}
class _SingleBoardListExampleState extends State<SingleBoardListExample> {
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<SingleBoardListExample> {
@override
Widget build(BuildContext context) {
return Board(
return AFBoard(
dataController: boardData,
cardBuilder: (context, item) {
return _RowWidget(item: item as TextItem, key: ObjectKey(item));

View File

@ -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<BoardDataController>(
child: Consumer<AFBoardDataController>(
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<BoardContent> {
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<BoardContent> {
}
}
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

View File

@ -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<String> get acceptedColumnIds;
@ -49,7 +49,7 @@ abstract class BoardColumnDataDataSource extends ReoderFlextDataSource {
UnmodifiableListView<ColumnItem> 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<BoardColumnWidget> createState() => _BoardColumnWidgetState();
State<AFBoardColumnWidget> createState() => _AFBoardColumnWidgetState();
}
class _BoardColumnWidgetState extends State<BoardColumnWidget> {
class _AFBoardColumnWidgetState extends State<AFBoardColumnWidget> {
final GlobalKey _columnOverlayKey =
GlobalKey(debugLabel: '$BoardColumnWidget overlay key');
GlobalKey(debugLabel: '$AFBoardColumnWidget overlay key');
late BoardOverlayEntry _overlayEntry;

View File

@ -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<CustomData> extends ReoderFlexItem with EquatableMixin {
/// [AFBoardColumnData] represents the data of each Column of the Board.
class AFBoardColumnData<CustomData> extends ReoderFlexItem with EquatableMixin {
@override
final String id;
final String desc;
final List<ColumnItem> _items;
final CustomData? customData;
BoardColumnData({
AFBoardColumnData({
this.customData,
required this.id,
this.desc = "",

View File

@ -23,14 +23,14 @@ typedef OnMoveColumnItemToColumn = void Function(
int toIndex,
);
class BoardDataController extends ChangeNotifier
class AFBoardDataController extends ChangeNotifier
with EquatableMixin, BoardPhantomControllerDelegate, ReoderFlextDataSource {
final List<BoardColumnData> _columnDatas = [];
final List<AFBoardColumnData> _columnDatas = [];
final OnMoveColumn? onMoveColumn;
final OnMoveColumnItem? onMoveColumnItem;
final OnMoveColumnItemToColumn? onMoveColumnItemToColumn;
List<BoardColumnData> get columnDatas => _columnDatas;
List<AFBoardColumnData> get columnDatas => _columnDatas;
List<String> get columnIds =>
_columnDatas.map((columnData) => columnData.id).toList();
@ -38,13 +38,13 @@ class BoardDataController extends ChangeNotifier
final LinkedHashMap<String, BoardColumnDataController> _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<BoardColumnData> columns, {bool notify = true}) {
void addColumns(List<AFBoardColumnData> 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<ReoderFlexItem> 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;
}

View File

@ -39,6 +39,7 @@ pub struct GridSettingRevision {
pub filters: GridFilters,
#[serde(default)]
pub groups: GridGroups,
#[serde(skip)]