| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  | import 'package:appflowy/generated/locale_keys.g.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/util.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/startup/plugin/plugin.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/workspace/presentation/home/home_stack.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/workspace/presentation/widgets/left_bar_item.dart'; | 
					
						
							| 
									
										
										
										
											2023-01-08 12:10:53 +08:00
										 |  |  | import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; | 
					
						
							| 
									
										
										
										
											2023-01-30 12:22:13 +07:00
										 |  |  | import 'package:easy_localization/easy_localization.dart'; | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-09 10:35:27 +08:00
										 |  |  | import 'presentation/board_page.dart'; | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class BoardPluginBuilder implements PluginBuilder { | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Plugin build(dynamic data) { | 
					
						
							| 
									
										
										
										
											2022-07-19 14:11:29 +08:00
										 |  |  |     if (data is ViewPB) { | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  |       return BoardPlugin(pluginType: pluginType, view: data); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       throw FlowyPluginException.invalidData; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2023-01-30 12:22:13 +07:00
										 |  |  |   String get menuName => LocaleKeys.board_menuName.tr(); | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-15 11:45:23 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   String get menuIcon => "editor/board"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-08-18 19:32:08 +08:00
										 |  |  |   PluginType get pluginType => PluginType.board; | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-10 17:59:28 +08:00
										 |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-10-16 16:51:21 +08:00
										 |  |  |   ViewLayoutTypePB? get layoutType => ViewLayoutTypePB.Board; | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class BoardPluginConfig implements PluginConfig { | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-08-25 14:58:08 +08:00
										 |  |  |   bool get creatable => true; | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class BoardPlugin extends Plugin { | 
					
						
							| 
									
										
										
										
											2022-09-22 13:08:48 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   final ViewPluginNotifier notifier; | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  |   final PluginType _pluginType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   BoardPlugin({ | 
					
						
							| 
									
										
										
										
											2022-07-19 14:11:29 +08:00
										 |  |  |     required ViewPB view, | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  |     required PluginType pluginType, | 
					
						
							|  |  |  |   })  : _pluginType = pluginType, | 
					
						
							| 
									
										
										
										
											2022-09-22 13:08:48 +08:00
										 |  |  |         notifier = ViewPluginNotifier(view: view); | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-09-22 13:08:48 +08:00
										 |  |  |   PluginDisplay get display => GridPluginDisplay(notifier: notifier); | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-09-22 13:08:48 +08:00
										 |  |  |   PluginId get id => notifier.view.id; | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   PluginType get ty => _pluginType; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class GridPluginDisplay extends PluginDisplay { | 
					
						
							| 
									
										
										
										
											2022-09-22 13:08:48 +08:00
										 |  |  |   final ViewPluginNotifier notifier; | 
					
						
							|  |  |  |   GridPluginDisplay({required this.notifier, Key? key}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ViewPB get view => notifier.view; | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-09-22 13:08:48 +08:00
										 |  |  |   Widget get leftBarItem => ViewLeftBarItem(view: view); | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-09-22 13:08:48 +08:00
										 |  |  |   Widget buildWidget(PluginContext context) { | 
					
						
							|  |  |  |     notifier.isDeleted.addListener(() { | 
					
						
							| 
									
										
										
										
											2022-09-26 16:59:58 +08:00
										 |  |  |       notifier.isDeleted.value.fold(() => null, (deletedView) { | 
					
						
							|  |  |  |         if (deletedView.hasIndex()) { | 
					
						
							|  |  |  |           context.onDeleted(view, deletedView.index); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2022-09-22 13:08:48 +08:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return BoardPage(key: ValueKey(view.id), view: view); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-06-11 15:51:53 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   List<NavigationItem> get navigationItems => [this]; | 
					
						
							|  |  |  | } |