Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: rename classes

appflowy84afc50cd30f
diff --git a/frontend/app_flowy/lib/plugin/plugin.dart b/frontend/app_flowy/lib/plugin/plugin.dart
index d46e14746f..d0effa0e6d 100644
--- a/frontend/app_flowy/lib/plugin/plugin.dart
+++ b/frontend/app_flowy/lib/plugin/plugin.dart
@@ -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";
-typedef PluginType = int;
+enum DefaultPlugin {
+ quillEditor,
+ blank,
+ trash,
+}
-typedef PluginDataType = ViewDataType;
+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;
-
- PluginDisplay get pluginDisplay;
+ PluginId get id;
- PluginType get pluginType;
+ PluginDisplay get display;
- ChangeNotifier? get displayNotifier => null;
+ PluginType get ty;
- 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();
}
diff --git a/frontend/app_flowy/lib/startup/tasks/load_plugin.dart b/frontend/app_flowy/lib/startup/tasks/load_plugin.dart
index 650dd49d22..266c6d1c09 100644
--- a/frontend/app_flowy/lib/startup/tasks/load_plugin.dart
+++ b/frontend/app_flowy/lib/startup/tasks/load_plugin.dart
@@ -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;
diff --git a/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart b/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart
index 0ea811711e..6ee18986b5 100644
--- a/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart
+++ b/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart
@@ -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';
diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart
index 6127440a89..3344b2793a 100644
--- a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.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(),
diff --git a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart
index eeebf2b145..73771596cb 100644
--- a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart
@@ -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);
},
diff --git a/frontend/app_flowy/lib/workspace/presentation/home/navigation.dart b/frontend/app_flowy/lib/workspace/presentation/home/navigation.dart
index e8a9c3d457..511b94db90 100644
--- a/frontend/app_flowy/lib/workspace/presentation/home/navigation.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/home/navigation.dart
@@ -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,
);
},
diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/blank/blank.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/blank/blank.dart
index 4534053ad8..6be2a788fb 100644
--- a/frontend/app_flowy/lib/workspace/presentation/plugins/blank/blank.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/plugins/blank/blank.dart
@@ -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 {
diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/document.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/doc/document.dart
index 021478866a..72465dd54b 100644
--- a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/document.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/plugins/doc/document.dart
@@ -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 {
diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/menu.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/trash/menu.dart
index 2053432264..ccd1c85188 100644
--- a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/menu.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/plugins/trash/menu.dart
@@ -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';
diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/trash.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/trash/trash.dart
index b0324a1138..4f9ef4c911 100644
--- a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/trash.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/plugins/trash/trash.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 {
diff --git a/frontend/rust-lib/flowy-sdk/src/lib.rs b/frontend/rust-lib/flowy-sdk/src/lib.rs
index 16e3c37def..83a38111e7 100644
--- a/frontend/rust-lib/flowy-sdk/src/lib.rs
+++ b/frontend/rust-lib/flowy-sdk/src/lib.rs
@@ -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(",")
}