| 
									
										
										
										
											2022-05-17 20:25:35 +02:00
										 |  |  | import 'package:app_flowy/generated/locale_keys.g.dart'; | 
					
						
							| 
									
										
										
										
											2022-08-09 10:35:27 +08:00
										 |  |  | import 'package:app_flowy/startup/plugin/plugin.dart'; | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  | import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; | 
					
						
							| 
									
										
										
										
											2022-08-09 10:35:27 +08:00
										 |  |  | import 'package:app_flowy/workspace/presentation/widgets/left_bar_item.dart'; | 
					
						
							| 
									
										
										
										
											2022-05-17 20:25:35 +02:00
										 |  |  | import 'package:easy_localization/easy_localization.dart'; | 
					
						
							| 
									
										
										
										
											2022-07-04 15:00:54 +08:00
										 |  |  | import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-09 10:35:27 +08:00
										 |  |  | import 'presentation/grid_page.dart'; | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-06 09:03:02 +08:00
										 |  |  | class GridPluginBuilder implements PluginBuilder { | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   Plugin build(dynamic data) { | 
					
						
							| 
									
										
										
										
											2022-07-19 14:11:29 +08:00
										 |  |  |     if (data is ViewPB) { | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  |       return GridPlugin(pluginType: pluginType, view: data); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       throw FlowyPluginException.invalidData; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-05-17 20:25:35 +02:00
										 |  |  |   String get menuName => LocaleKeys.grid_menuName.tr(); | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   PluginType get pluginType => DefaultPlugin.grid.type(); | 
					
						
							| 
									
										
										
										
											2022-03-06 09:03:02 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-08-10 17:59:28 +08:00
										 |  |  |   ViewDataTypePB get dataType => ViewDataTypePB.Database; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   SubViewDataTypePB? get subDataType => SubViewDataTypePB.Grid; | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class GridPluginConfig implements PluginConfig { | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-04-08 14:31:33 +08:00
										 |  |  |   bool get creatable => true; | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class GridPlugin extends Plugin { | 
					
						
							| 
									
										
										
										
											2022-07-19 14:11:29 +08:00
										 |  |  |   final ViewPB _view; | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  |   final PluginType _pluginType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   GridPlugin({ | 
					
						
							| 
									
										
										
										
											2022-07-19 14:11:29 +08:00
										 |  |  |     required ViewPB view, | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  |     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 { | 
					
						
							| 
									
										
										
										
											2022-07-19 14:11:29 +08:00
										 |  |  |   final ViewPB _view; | 
					
						
							|  |  |  |   GridPluginDisplay({required ViewPB view, Key? key}) : _view = view; | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-03-20 17:17:06 +08:00
										 |  |  |   Widget get leftBarItem => ViewLeftBarItem(view: _view); | 
					
						
							| 
									
										
										
										
											2022-03-04 08:22:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget buildWidget() => GridPage(view: _view); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   List<NavigationItem> get navigationItems => [this]; | 
					
						
							|  |  |  | } |