mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: config board view plugin
This commit is contained in:
parent
093c637cc0
commit
7366acb58e
@ -14,6 +14,7 @@ enum DefaultPlugin {
|
||||
blank,
|
||||
trash,
|
||||
grid,
|
||||
board,
|
||||
}
|
||||
|
||||
extension FlowyDefaultPluginExt on DefaultPlugin {
|
||||
@ -27,6 +28,8 @@ extension FlowyDefaultPluginExt on DefaultPlugin {
|
||||
return 2;
|
||||
case DefaultPlugin.grid:
|
||||
return 3;
|
||||
case DefaultPlugin.board:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/blank/blank.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/board/board.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/doc/document.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/grid/grid.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/trash/trash.dart';
|
||||
@ -15,5 +16,6 @@ class PluginLoadTask extends LaunchTask {
|
||||
registerPlugin(builder: TrashPluginBuilder(), config: TrashPluginConfig());
|
||||
registerPlugin(builder: DocumentPluginBuilder());
|
||||
registerPlugin(builder: GridPluginBuilder(), config: GridPluginConfig());
|
||||
registerPlugin(builder: BoardPluginBuilder(), config: BoardPluginConfig());
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
final workspaceSetting = state.workspaceSetting;
|
||||
if (initialView == null && workspaceSetting.hasLatestView()) {
|
||||
initialView = workspaceSetting.latestView;
|
||||
final plugin = makePlugin(pluginType: initialView!.pluginType, data: initialView);
|
||||
final plugin = makePlugin(
|
||||
pluginType: initialView!.pluginType,
|
||||
data: initialView,
|
||||
);
|
||||
getIt<HomeStackManager>().setPlugin(plugin);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,66 @@
|
||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'src/board_page.dart';
|
||||
|
||||
class BoardPluginBuilder implements PluginBuilder {
|
||||
@override
|
||||
Plugin build(dynamic data) {
|
||||
if (data is View) {
|
||||
return BoardPlugin(pluginType: pluginType, view: data);
|
||||
} else {
|
||||
throw FlowyPluginException.invalidData;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String get menuName => "Board";
|
||||
|
||||
@override
|
||||
PluginType get pluginType => DefaultPlugin.board.type();
|
||||
|
||||
@override
|
||||
ViewDataType get dataType => ViewDataType.Grid;
|
||||
}
|
||||
|
||||
class BoardPluginConfig implements PluginConfig {
|
||||
@override
|
||||
bool get creatable => true;
|
||||
}
|
||||
|
||||
class BoardPlugin extends Plugin {
|
||||
final View _view;
|
||||
final PluginType _pluginType;
|
||||
|
||||
BoardPlugin({
|
||||
required View view,
|
||||
required PluginType pluginType,
|
||||
}) : _pluginType = pluginType,
|
||||
_view = view;
|
||||
|
||||
@override
|
||||
PluginDisplay get display => GridPluginDisplay(view: _view);
|
||||
|
||||
@override
|
||||
PluginId get id => _view.id;
|
||||
|
||||
@override
|
||||
PluginType get ty => _pluginType;
|
||||
}
|
||||
|
||||
class GridPluginDisplay extends PluginDisplay {
|
||||
final View _view;
|
||||
GridPluginDisplay({required View view, Key? key}) : _view = view;
|
||||
|
||||
@override
|
||||
Widget get leftBarItem => ViewLeftBarItem(view: _view);
|
||||
|
||||
@override
|
||||
Widget buildWidget() => BoardPage(view: _view);
|
||||
|
||||
@override
|
||||
List<NavigationItem> get navigationItems => [this];
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BoardPage extends StatelessWidget {
|
||||
final View _view;
|
||||
|
||||
const BoardPage({required View view, Key? key})
|
||||
: _view = view,
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user