chore: update appflowy_baord documentation

This commit is contained in:
appflowy 2022-09-06 14:25:39 +08:00
parent b5321319cc
commit a21050b594
6 changed files with 34 additions and 32 deletions

View File

@ -62,8 +62,7 @@ class BoardContent extends StatefulWidget {
} }
class _BoardContentState extends State<BoardContent> { class _BoardContentState extends State<BoardContent> {
late ScrollController scrollController; late AppFlowyBoardScrollController scrollManager;
late AppFlowyBoardScrollManager scrollManager;
final config = AppFlowyBoardConfig( final config = AppFlowyBoardConfig(
groupBackgroundColor: HexColor.fromHex('#F7F8FC'), groupBackgroundColor: HexColor.fromHex('#F7F8FC'),
@ -71,8 +70,7 @@ class _BoardContentState extends State<BoardContent> {
@override @override
void initState() { void initState() {
scrollController = ScrollController(); scrollManager = AppFlowyBoardScrollController();
scrollManager = AppFlowyBoardScrollManager();
super.initState(); super.initState();
} }
@ -102,8 +100,8 @@ class _BoardContentState extends State<BoardContent> {
Expanded _buildBoard(BuildContext context) { Expanded _buildBoard(BuildContext context) {
return Expanded( return Expanded(
child: AppFlowyBoard( child: AppFlowyBoard(
scrollManager: scrollManager, boardScrollController: scrollManager,
scrollController: scrollController, scrollController: ScrollController(),
controller: context.read<BoardBloc>().boardController, controller: context.read<BoardBloc>().boardController,
headerBuilder: _buildHeader, headerBuilder: _buildHeader,
footerBuilder: _buildFooter, footerBuilder: _buildFooter,
@ -143,7 +141,6 @@ class _BoardContentState extends State<BoardContent> {
@override @override
void dispose() { void dispose() {
scrollController.dispose();
super.dispose(); super.dispose();
} }

View File

@ -1,3 +1,6 @@
# 0.0.7
* Rename some classes
* Add documentation
# 0.0.6 # 0.0.6
* Support scroll to bottom * Support scroll to bottom
* Fix some bugs * Fix some bugs

View File

@ -120,7 +120,7 @@ First, run main.dart to play with the demo.
Second, let's delve into multi_board_list_example.dart to understand a few key components: Second, let's delve into multi_board_list_example.dart to understand a few key components:
* A Board widget is created via instantiating an `AppFlowyBoard` object. * A Board widget is created via instantiating an `AppFlowyBoard` object.
* In the `AppFlowyBoard` object, you can find the `AppFlowyBoardController`, which is defined in board_data.dart, is feeded with prepopulated mock data. It also contains callback functions to materialize future user data. * In the `AppFlowyBoard` object, you can find the `AppFlowyBoardController`, which is defined in board_data.dart, is fed with pre-populated mock data. It also contains callback functions to materialize future user data.
* Three builders: AppFlowyBoardHeaderBuilder, AppFlowyBoardFooterBuilder, AppFlowyBoardCardBuilder. See below image for what they are used for. * Three builders: AppFlowyBoardHeaderBuilder, AppFlowyBoardFooterBuilder, AppFlowyBoardCardBuilder. See below image for what they are used for.

View File

@ -10,7 +10,7 @@ import 'reorder_flex/reorder_flex.dart';
import 'reorder_phantom/phantom_controller.dart'; import 'reorder_phantom/phantom_controller.dart';
import '../rendering/board_overlay.dart'; import '../rendering/board_overlay.dart';
class AppFlowyBoardScrollManager { class AppFlowyBoardScrollController {
AppFlowyBoardState? _groupState; AppFlowyBoardState? _groupState;
void scrollToBottom(String groupId, VoidCallback? completed) { void scrollToBottom(String groupId, VoidCallback? completed) {
@ -79,19 +79,27 @@ class AppFlowyBoard extends StatelessWidget {
/// ///
final AppFlowyBoardController controller; final AppFlowyBoardController controller;
/// A constraints applied to [AppFlowyBoardGroup] widget.
final BoxConstraints groupConstraints; final BoxConstraints groupConstraints;
/// A controller is used by the [ReorderFlex].
/// ///
late final BoardPhantomController phantomController; /// The [ReorderFlex] will used the primary scrollController of the current
/// [BuildContext] by using PrimaryScrollController.of(context).
/// If the primary scrollController is null, we will assign a new [ScrollController].
final ScrollController? scrollController; final ScrollController? scrollController;
///
final AppFlowyBoardConfig config; final AppFlowyBoardConfig config;
final AppFlowyBoardScrollManager? scrollManager; /// A controller is used to control each group scroll actions.
///
final AppFlowyBoardScrollController? boardScrollController;
final AppFlowyBoardState _groupState = AppFlowyBoardState(); final AppFlowyBoardState _groupState = AppFlowyBoardState();
late final BoardPhantomController _phantomController;
AppFlowyBoard({ AppFlowyBoard({
required this.controller, required this.controller,
required this.cardBuilder, required this.cardBuilder,
@ -99,12 +107,12 @@ class AppFlowyBoard extends StatelessWidget {
this.footerBuilder, this.footerBuilder,
this.headerBuilder, this.headerBuilder,
this.scrollController, this.scrollController,
this.scrollManager, this.boardScrollController,
this.groupConstraints = const BoxConstraints(maxWidth: 200), this.groupConstraints = const BoxConstraints(maxWidth: 200),
this.config = const AppFlowyBoardConfig(), this.config = const AppFlowyBoardConfig(),
Key? key, Key? key,
}) : super(key: key) { }) : super(key: key) {
phantomController = BoardPhantomController( _phantomController = BoardPhantomController(
delegate: controller, delegate: controller,
groupsState: _groupState, groupsState: _groupState,
); );
@ -116,23 +124,23 @@ class AppFlowyBoard extends StatelessWidget {
value: controller, value: controller,
child: Consumer<AppFlowyBoardController>( child: Consumer<AppFlowyBoardController>(
builder: (context, notifier, child) { builder: (context, notifier, child) {
if (scrollManager != null) { if (boardScrollController != null) {
scrollManager!._groupState = _groupState; boardScrollController!._groupState = _groupState;
} }
return _AppFlowyBoardContent( return _AppFlowyBoardContent(
config: config, config: config,
dataController: controller, dataController: controller,
scrollController: scrollController, scrollController: scrollController,
scrollManager: scrollManager, scrollManager: boardScrollController,
columnsState: _groupState, columnsState: _groupState,
background: background, background: background,
delegate: phantomController, delegate: _phantomController,
columnConstraints: groupConstraints, groupConstraints: groupConstraints,
cardBuilder: cardBuilder, cardBuilder: cardBuilder,
footerBuilder: footerBuilder, footerBuilder: footerBuilder,
headerBuilder: headerBuilder, headerBuilder: headerBuilder,
phantomController: phantomController, phantomController: _phantomController,
onReorder: controller.moveGroup, onReorder: controller.moveGroup,
); );
}, },
@ -143,15 +151,13 @@ class AppFlowyBoard extends StatelessWidget {
class _AppFlowyBoardContent extends StatefulWidget { class _AppFlowyBoardContent extends StatefulWidget {
final ScrollController? scrollController; final ScrollController? scrollController;
final OnDragStarted? onDragStarted;
final OnReorder onReorder; final OnReorder onReorder;
final OnDragEnded? onDragEnded;
final AppFlowyBoardController dataController; final AppFlowyBoardController dataController;
final Widget? background; final Widget? background;
final AppFlowyBoardConfig config; final AppFlowyBoardConfig config;
final ReorderFlexConfig reorderFlexConfig; final ReorderFlexConfig reorderFlexConfig;
final BoxConstraints columnConstraints; final BoxConstraints groupConstraints;
final AppFlowyBoardScrollManager? scrollManager; final AppFlowyBoardScrollController? scrollManager;
final AppFlowyBoardState columnsState; final AppFlowyBoardState columnsState;
final AppFlowyBoardCardBuilder cardBuilder; final AppFlowyBoardCardBuilder cardBuilder;
final AppFlowyBoardHeaderBuilder? headerBuilder; final AppFlowyBoardHeaderBuilder? headerBuilder;
@ -166,11 +172,9 @@ class _AppFlowyBoardContent extends StatefulWidget {
required this.dataController, required this.dataController,
required this.scrollManager, required this.scrollManager,
required this.columnsState, required this.columnsState,
this.onDragStarted,
this.onDragEnded,
this.scrollController, this.scrollController,
this.background, this.background,
required this.columnConstraints, required this.groupConstraints,
required this.cardBuilder, required this.cardBuilder,
this.footerBuilder, this.footerBuilder,
this.headerBuilder, this.headerBuilder,
@ -204,9 +208,7 @@ class _AppFlowyBoardContentState extends State<_AppFlowyBoardContent> {
final reorderFlex = ReorderFlex( final reorderFlex = ReorderFlex(
config: widget.reorderFlexConfig, config: widget.reorderFlexConfig,
scrollController: widget.scrollController, scrollController: widget.scrollController,
onDragStarted: widget.onDragStarted,
onReorder: widget.onReorder, onReorder: widget.onReorder,
onDragEnded: widget.onDragEnded,
dataSource: widget.dataController, dataSource: widget.dataController,
direction: Axis.horizontal, direction: Axis.horizontal,
interceptor: interceptor, interceptor: interceptor,
@ -285,7 +287,7 @@ class _AppFlowyBoardContentState extends State<_AppFlowyBoardContent> {
widget.columnsState.addGroup(columnData.id, boardColumn); widget.columnsState.addGroup(columnData.id, boardColumn);
return ConstrainedBox( return ConstrainedBox(
constraints: widget.columnConstraints, constraints: widget.groupConstraints,
child: boardColumn, child: boardColumn,
); );
}, },

View File

@ -1,6 +1,6 @@
name: appflowy_board name: appflowy_board
description: AppFlowyBoard is a board-style widget that consists of multi-groups. It supports drag and drop between different groups. description: AppFlowyBoard is a board-style widget that consists of multi-groups. It supports drag and drop between different groups.
version: 0.0.6 version: 0.0.7
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

View File

@ -28,7 +28,7 @@ packages:
path: "packages/appflowy_board" path: "packages/appflowy_board"
relative: true relative: true
source: path source: path
version: "0.0.6" version: "0.0.7"
appflowy_editor: appflowy_editor:
dependency: "direct main" dependency: "direct main"
description: description: