2022-09-22 05:08:48 +00:00
|
|
|
import 'package:app_flowy/plugins/util.dart';
|
2022-06-11 07:51:53 +00:00
|
|
|
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
2022-08-09 02:35:27 +00:00
|
|
|
import 'package:app_flowy/workspace/presentation/widgets/left_bar_item.dart';
|
2022-07-04 07:00:54 +00:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
2022-08-09 02:35:27 +00:00
|
|
|
import 'package:app_flowy/startup/plugin/plugin.dart';
|
2022-06-11 07:51:53 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2022-08-09 02:35:27 +00:00
|
|
|
import 'presentation/board_page.dart';
|
2022-06-11 07:51:53 +00:00
|
|
|
|
|
|
|
class BoardPluginBuilder implements PluginBuilder {
|
|
|
|
@override
|
|
|
|
Plugin build(dynamic data) {
|
2022-07-19 06:11:29 +00:00
|
|
|
if (data is ViewPB) {
|
2022-06-11 07:51:53 +00:00
|
|
|
return BoardPlugin(pluginType: pluginType, view: data);
|
|
|
|
} else {
|
|
|
|
throw FlowyPluginException.invalidData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String get menuName => "Board";
|
|
|
|
|
|
|
|
@override
|
2022-08-18 11:32:08 +00:00
|
|
|
PluginType get pluginType => PluginType.board;
|
2022-06-11 07:51:53 +00:00
|
|
|
|
|
|
|
@override
|
2022-08-10 09:59:28 +00:00
|
|
|
ViewDataTypePB get dataType => ViewDataTypePB.Database;
|
|
|
|
|
|
|
|
@override
|
2022-08-18 11:32:08 +00:00
|
|
|
ViewLayoutTypePB? get subDataType => ViewLayoutTypePB.Board;
|
2022-06-11 07:51:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class BoardPluginConfig implements PluginConfig {
|
|
|
|
@override
|
2022-08-25 06:58:08 +00:00
|
|
|
bool get creatable => true;
|
2022-06-11 07:51:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class BoardPlugin extends Plugin {
|
2022-09-22 05:08:48 +00:00
|
|
|
@override
|
|
|
|
final ViewPluginNotifier notifier;
|
2022-06-11 07:51:53 +00:00
|
|
|
final PluginType _pluginType;
|
|
|
|
|
|
|
|
BoardPlugin({
|
2022-07-19 06:11:29 +00:00
|
|
|
required ViewPB view,
|
2022-06-11 07:51:53 +00:00
|
|
|
required PluginType pluginType,
|
|
|
|
}) : _pluginType = pluginType,
|
2022-09-22 05:08:48 +00:00
|
|
|
notifier = ViewPluginNotifier(view: view);
|
2022-06-11 07:51:53 +00:00
|
|
|
|
|
|
|
@override
|
2022-09-22 05:08:48 +00:00
|
|
|
PluginDisplay get display => GridPluginDisplay(notifier: notifier);
|
2022-06-11 07:51:53 +00:00
|
|
|
|
|
|
|
@override
|
2022-09-22 05:08:48 +00:00
|
|
|
PluginId get id => notifier.view.id;
|
2022-06-11 07:51:53 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
PluginType get ty => _pluginType;
|
|
|
|
}
|
|
|
|
|
|
|
|
class GridPluginDisplay extends PluginDisplay {
|
2022-09-22 05:08:48 +00:00
|
|
|
final ViewPluginNotifier notifier;
|
|
|
|
GridPluginDisplay({required this.notifier, Key? key});
|
|
|
|
|
|
|
|
ViewPB get view => notifier.view;
|
2022-06-11 07:51:53 +00:00
|
|
|
|
|
|
|
@override
|
2022-09-22 05:08:48 +00:00
|
|
|
Widget get leftBarItem => ViewLeftBarItem(view: view);
|
2022-06-11 07:51:53 +00:00
|
|
|
|
|
|
|
@override
|
2022-09-22 05:08:48 +00:00
|
|
|
Widget buildWidget(PluginContext context) {
|
|
|
|
notifier.isDeleted.addListener(() {
|
|
|
|
if (notifier.isDeleted.value) {
|
|
|
|
context.onDeleted(view);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return BoardPage(key: ValueKey(view.id), view: view);
|
|
|
|
}
|
2022-06-11 07:51:53 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
List<NavigationItem> get navigationItems => [this];
|
|
|
|
}
|