mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: rename classes
This commit is contained in:
parent
383925ba55
commit
84afc50cd3
@ -3,27 +3,43 @@ library flowy_plugin;
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
export "./src/sandbox.dart";
|
||||
|
||||
enum DefaultPlugin {
|
||||
quillEditor,
|
||||
blank,
|
||||
trash,
|
||||
}
|
||||
|
||||
extension FlowyDefaultPluginExt on DefaultPlugin {
|
||||
int type() {
|
||||
switch (this) {
|
||||
case DefaultPlugin.quillEditor:
|
||||
return 0;
|
||||
case DefaultPlugin.blank:
|
||||
return 1;
|
||||
case DefaultPlugin.trash:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef PluginType = int;
|
||||
|
||||
typedef PluginDataType = ViewDataType;
|
||||
|
||||
typedef PluginId = String;
|
||||
|
||||
abstract class Plugin {
|
||||
PluginId get pluginId;
|
||||
PluginId get id;
|
||||
|
||||
PluginDisplay get pluginDisplay;
|
||||
PluginDisplay get display;
|
||||
|
||||
PluginType get pluginType;
|
||||
PluginType get ty;
|
||||
|
||||
ChangeNotifier? get displayNotifier => null;
|
||||
|
||||
void dispose();
|
||||
void dispose() {}
|
||||
}
|
||||
|
||||
abstract class PluginBuilder {
|
||||
@ -37,10 +53,11 @@ abstract class PluginBuilder {
|
||||
}
|
||||
|
||||
abstract class PluginConfig {
|
||||
// Return false will disable the user to create it. For example, a trash plugin shouldn't be created by the user,
|
||||
bool get creatable => true;
|
||||
}
|
||||
|
||||
abstract class PluginDisplay with NavigationItem {
|
||||
abstract class PluginDisplay<T> with NavigationItem {
|
||||
@override
|
||||
Widget get leftBarItem;
|
||||
|
||||
@ -49,6 +66,8 @@ abstract class PluginDisplay with NavigationItem {
|
||||
|
||||
List<NavigationItem> get navigationItems;
|
||||
|
||||
PublishNotifier<T>? get notifier => null;
|
||||
|
||||
Widget buildWidget();
|
||||
}
|
||||
|
||||
|
@ -4,25 +4,6 @@ import 'package:app_flowy/workspace/presentation/plugins/blank/blank.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/doc/document.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/trash/trash.dart';
|
||||
|
||||
enum DefaultPlugin {
|
||||
quillEditor,
|
||||
blank,
|
||||
trash,
|
||||
}
|
||||
|
||||
extension FlowyDefaultPluginExt on DefaultPlugin {
|
||||
int type() {
|
||||
switch (this) {
|
||||
case DefaultPlugin.quillEditor:
|
||||
return 0;
|
||||
case DefaultPlugin.blank:
|
||||
return 1;
|
||||
case DefaultPlugin.trash:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PluginLoadTask extends LaunchTask {
|
||||
@override
|
||||
LaunchTaskType get type => LaunchTaskType.dataProcessing;
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:app_flowy/startup/tasks/load_plugin.dart';
|
||||
import 'package:app_flowy/workspace/application/workspace/workspace_listener.dart';
|
||||
import 'package:app_flowy/workspace/application/workspace/workspace_service.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
|
@ -8,7 +8,6 @@ import 'package:time/time.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:app_flowy/startup/tasks/load_plugin.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/blank/blank.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/navigation.dart';
|
||||
@ -108,20 +107,20 @@ class HomeStackNotifier extends ChangeNotifier {
|
||||
Plugin _plugin;
|
||||
PublishNotifier<bool> collapsedNotifier = PublishNotifier();
|
||||
|
||||
Widget get titleWidget => _plugin.pluginDisplay.leftBarItem;
|
||||
Widget get titleWidget => _plugin.display.leftBarItem;
|
||||
|
||||
HomeStackNotifier({Plugin? plugin}) : _plugin = plugin ?? makePlugin(pluginType: DefaultPlugin.blank.type());
|
||||
|
||||
set plugin(Plugin newPlugin) {
|
||||
if (newPlugin.pluginId == _plugin.pluginId) {
|
||||
if (newPlugin.id == _plugin.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
_plugin.displayNotifier?.removeListener(notifyListeners);
|
||||
_plugin.display.notifier?.removeListener(notifyListeners);
|
||||
_plugin.dispose();
|
||||
|
||||
_plugin = newPlugin;
|
||||
_plugin.displayNotifier?.addListener(notifyListeners);
|
||||
_plugin.display.notifier?.addListener(notifyListeners);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@ -134,7 +133,7 @@ class HomeStackManager {
|
||||
HomeStackManager();
|
||||
|
||||
Widget title() {
|
||||
return _notifier.plugin.pluginDisplay.leftBarItem;
|
||||
return _notifier.plugin.display.leftBarItem;
|
||||
}
|
||||
|
||||
PublishNotifier<bool> get collapsedNotifier => _notifier.collapsedNotifier;
|
||||
@ -166,10 +165,10 @@ class HomeStackManager {
|
||||
],
|
||||
child: Consumer(builder: (ctx, HomeStackNotifier notifier, child) {
|
||||
return FadingIndexedStack(
|
||||
index: getIt<PluginSandbox>().indexOf(notifier.plugin.pluginType),
|
||||
index: getIt<PluginSandbox>().indexOf(notifier.plugin.ty),
|
||||
children: getIt<PluginSandbox>().supportPluginTypes.map((pluginType) {
|
||||
if (pluginType == notifier.plugin.pluginType) {
|
||||
return notifier.plugin.pluginDisplay.buildWidget();
|
||||
if (pluginType == notifier.plugin.ty) {
|
||||
return notifier.plugin.display.buildWidget();
|
||||
} else {
|
||||
return const BlankStackPage();
|
||||
}
|
||||
@ -198,7 +197,7 @@ class HomeTopBar extends StatelessWidget {
|
||||
value: Provider.of<HomeStackNotifier>(context, listen: false),
|
||||
child: Consumer(
|
||||
builder: (BuildContext context, HomeStackNotifier notifier, Widget? child) {
|
||||
return notifier.plugin.pluginDisplay.rightBarItem ?? const SizedBox();
|
||||
return notifier.plugin.display.rightBarItem ?? const SizedBox();
|
||||
},
|
||||
),
|
||||
) // _renderMoreButton(),
|
||||
|
@ -55,7 +55,7 @@ class HomeMenu extends StatelessWidget {
|
||||
child: MultiBlocListener(
|
||||
listeners: [
|
||||
BlocListener<MenuBloc, MenuState>(
|
||||
listenWhen: (p, c) => p.plugin.pluginId != c.plugin.pluginId,
|
||||
listenWhen: (p, c) => p.plugin.id != c.plugin.id,
|
||||
listener: (context, state) {
|
||||
getIt<HomeStackManager>().setPlugin(state.plugin);
|
||||
},
|
||||
|
@ -17,8 +17,8 @@ class NavigationNotifier with ChangeNotifier {
|
||||
|
||||
void update(HomeStackNotifier notifier) {
|
||||
bool shouldNotify = false;
|
||||
if (navigationItems != notifier.plugin.pluginDisplay.navigationItems) {
|
||||
navigationItems = notifier.plugin.pluginDisplay.navigationItems;
|
||||
if (navigationItems != notifier.plugin.display.navigationItems) {
|
||||
navigationItems = notifier.plugin.display.navigationItems;
|
||||
shouldNotify = true;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class FlowyNavigation extends StatelessWidget {
|
||||
create: (_) {
|
||||
final notifier = Provider.of<HomeStackNotifier>(context, listen: false);
|
||||
return NavigationNotifier(
|
||||
navigationItems: notifier.plugin.pluginDisplay.navigationItems,
|
||||
navigationItems: notifier.plugin.display.navigationItems,
|
||||
collapasedNotifier: notifier.collapsedNotifier,
|
||||
);
|
||||
},
|
||||
|
@ -1,4 +1,3 @@
|
||||
import 'package:app_flowy/startup/tasks/load_plugin.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||
@ -32,16 +31,13 @@ class BlankPagePlugin extends Plugin {
|
||||
}) : _pluginType = pluginType;
|
||||
|
||||
@override
|
||||
void dispose() {}
|
||||
PluginDisplay get display => BlankPagePluginDisplay();
|
||||
|
||||
@override
|
||||
PluginDisplay get pluginDisplay => BlankPagePluginDisplay();
|
||||
PluginId get id => "BlankStack";
|
||||
|
||||
@override
|
||||
PluginId get pluginId => "BlankStack";
|
||||
|
||||
@override
|
||||
PluginType get pluginType => _pluginType;
|
||||
PluginType get ty => _pluginType;
|
||||
}
|
||||
|
||||
class BlankPagePluginDisplay extends PluginDisplay {
|
||||
|
@ -7,7 +7,6 @@ export './src/widget/toolbar/tool_bar.dart';
|
||||
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/startup/tasks/load_plugin.dart';
|
||||
import 'package:app_flowy/workspace/application/appearance.dart';
|
||||
import 'package:app_flowy/workspace/application/doc/share_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/view/view_listener.dart';
|
||||
@ -16,6 +15,7 @@ import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:app_flowy/workspace/presentation/widgets/dialogs.dart';
|
||||
import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:flowy_infra/size.dart';
|
||||
import 'package:flowy_infra/theme.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
@ -56,7 +56,6 @@ class DocumentPluginBuilder extends PluginBuilder {
|
||||
class DocumentPlugin implements Plugin {
|
||||
late View _view;
|
||||
ViewListener? _listener;
|
||||
final ValueNotifier<int> _displayNotifier = ValueNotifier<int>(0);
|
||||
late PluginType _pluginType;
|
||||
|
||||
DocumentPlugin({required PluginType pluginType, required View view, Key? key}) : _view = view {
|
||||
@ -66,7 +65,7 @@ class DocumentPlugin implements Plugin {
|
||||
result.fold(
|
||||
(newView) {
|
||||
_view = newView;
|
||||
_displayNotifier.value = _view.hashCode;
|
||||
display.notifier!.value = _view.hashCode;
|
||||
},
|
||||
(error) {},
|
||||
);
|
||||
@ -81,19 +80,17 @@ class DocumentPlugin implements Plugin {
|
||||
}
|
||||
|
||||
@override
|
||||
PluginDisplay get pluginDisplay => DocumentPluginDisplay(view: _view);
|
||||
PluginDisplay<int> get display => DocumentPluginDisplay(view: _view);
|
||||
|
||||
@override
|
||||
PluginType get pluginType => _pluginType;
|
||||
PluginType get ty => _pluginType;
|
||||
|
||||
@override
|
||||
PluginId get pluginId => _view.id;
|
||||
|
||||
@override
|
||||
ChangeNotifier? get displayNotifier => _displayNotifier;
|
||||
PluginId get id => _view.id;
|
||||
}
|
||||
|
||||
class DocumentPluginDisplay extends PluginDisplay {
|
||||
class DocumentPluginDisplay extends PluginDisplay<int> {
|
||||
final PublishNotifier<int> _displayNotifier = PublishNotifier<int>();
|
||||
final View _view;
|
||||
|
||||
DocumentPluginDisplay({required View view, Key? key}) : _view = view;
|
||||
@ -110,6 +107,9 @@ class DocumentPluginDisplay extends PluginDisplay {
|
||||
@override
|
||||
List<NavigationItem> get navigationItems => _makeNavigationItems();
|
||||
|
||||
@override
|
||||
PublishNotifier<int>? get notifier => _displayNotifier;
|
||||
|
||||
List<NavigationItem> _makeNavigationItems() {
|
||||
return [
|
||||
this,
|
||||
@ -257,7 +257,7 @@ class DocumentShareButton extends StatelessWidget {
|
||||
context.read<DocShareBloc>().add(const DocShareEvent.shareMarkdown());
|
||||
break;
|
||||
case ShareAction.copyLink:
|
||||
showWorkInProgressDialog(context);
|
||||
FlowyAlertDialog(title: LocaleKeys.shareAction_workInProgress.tr()).show(context);
|
||||
break;
|
||||
}
|
||||
});
|
||||
@ -269,10 +269,6 @@ class DocumentShareButton extends StatelessWidget {
|
||||
anchorOffset: offset,
|
||||
);
|
||||
}
|
||||
|
||||
void showWorkInProgressDialog(BuildContext context) {
|
||||
FlowyAlertDialog(title: LocaleKeys.shareAction_workInProgress.tr()).show(context);
|
||||
}
|
||||
}
|
||||
|
||||
class ShareActions with ActionList<ShareActionWrapper> implements FlowyOverlayDelegate {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/startup/tasks/load_plugin.dart';
|
||||
import 'package:app_flowy/workspace/application/appearance.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
||||
|
@ -4,7 +4,6 @@ export "./src/trash_header.dart";
|
||||
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/startup/tasks/load_plugin.dart';
|
||||
import 'package:app_flowy/workspace/application/trash/trash_bloc.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
@ -49,16 +48,13 @@ class TrashPlugin extends Plugin {
|
||||
TrashPlugin({required PluginType pluginType}) : _pluginType = pluginType;
|
||||
|
||||
@override
|
||||
void dispose() {}
|
||||
PluginDisplay get display => TrashPluginDisplay();
|
||||
|
||||
@override
|
||||
PluginDisplay get pluginDisplay => TrashPluginDisplay();
|
||||
PluginId get id => "TrashStack";
|
||||
|
||||
@override
|
||||
PluginId get pluginId => "TrashStack";
|
||||
|
||||
@override
|
||||
PluginType get pluginType => _pluginType;
|
||||
PluginType get ty => _pluginType;
|
||||
}
|
||||
|
||||
class TrashPluginDisplay extends PluginDisplay {
|
||||
|
@ -76,7 +76,7 @@ fn crate_log_filter(level: String) -> String {
|
||||
filters.push(format!("dart_ffi={}", "info"));
|
||||
filters.push(format!("flowy_database={}", "info"));
|
||||
filters.push(format!("flowy_net={}", "info"));
|
||||
filters.push(format!("flowy_sync={}", "trace"));
|
||||
filters.push(format!("flowy_sync={}", "info"));
|
||||
filters.join(",")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user