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.

[flutter]: dir refactor

appflowy544585383910
diff --git a/app_flowy/analysis_options.yaml b/app_flowy/analysis_options.yaml
index c4268a9269..dce1597967 100644
--- a/app_flowy/analysis_options.yaml
+++ b/app_flowy/analysis_options.yaml
@@ -15,6 +15,7 @@ analyzer:
- "**/*.g.dart"
- "**/*.freezed.dart"
- "packages/flowy_editor/**"
+ - "packages/editor/**"
# - "packages/flowy_infra_ui/**"
linter:
diff --git a/app_flowy/lib/workspace/application/doc/doc_bloc.dart b/app_flowy/lib/workspace/application/doc/doc_bloc.dart
index dccc95a10b..58945c08d9 100644
--- a/app_flowy/lib/workspace/application/doc/doc_bloc.dart
+++ b/app_flowy/lib/workspace/application/doc/doc_bloc.dart
@@ -1,11 +1,7 @@
-import 'dart:typed_data';
-
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:app_flowy/workspace/domain/i_doc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
-import 'package:flowy_editor/flowy_editor.dart';
-import 'dart:convert';
part 'doc_bloc.freezed.dart';
class DocBloc extends Bloc<DocEvent, DocState> {
@@ -37,17 +33,17 @@ class DocBloc extends Bloc<DocEvent, DocState> {
);
}
- Document _decodeListToDocument(Uint8List data) {
- final json = jsonDecode(utf8.decode(data));
- final document = Document.fromJson(json);
- return document;
- }
-
- Document _decodeJsonToDocument(String data) {
- final json = jsonDecode(data);
- final document = Document.fromJson(json);
- return document;
- }
+ // Document _decodeListToDocument(Uint8List data) {
+ // final json = jsonDecode(utf8.decode(data));
+ // final document = Document.fromJson(json);
+ // return document;
+ // }
+
+ // Document _decodeJsonToDocument(String data) {
+ // final json = jsonDecode(data);
+ // final document = Document.fromJson(json);
+ // return document;
+ // }
}
@freezed
diff --git a/app_flowy/lib/workspace/presentation/app/new_app.dart b/app_flowy/lib/workspace/presentation/app/new_app.dart
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/app_flowy/lib/workspace/presentation/home/home_screen.dart b/app_flowy/lib/workspace/presentation/home/home_screen.dart
index 2c5f62afb1..0db08a19c8 100644
--- a/app_flowy/lib/workspace/presentation/home/home_screen.dart
+++ b/app_flowy/lib/workspace/presentation/home/home_screen.dart
@@ -23,8 +23,7 @@ class HomeScreen extends StatelessWidget {
return MultiBlocProvider(
providers: [
BlocProvider<HomeAuthBloc>(
- create: (context) => getIt<HomeAuthBloc>(param1: user)
- ..add(const HomeAuthEvent.started()),
+ create: (context) => getIt<HomeAuthBloc>(param1: user)..add(const HomeAuthEvent.started()),
),
BlocProvider<HomeBloc>(create: (context) => getIt<HomeBloc>()),
],
@@ -46,8 +45,7 @@ class HomeScreen extends StatelessWidget {
return FlowyContainer(
Theme.of(context).colorScheme.surface,
// Colors.white,
- child: _buildBody(
- state, context.read<HomeBloc>().state.forceCollapse),
+ child: _buildBody(state, context.read<HomeBloc>().state.forceCollapse),
);
},
),
@@ -70,17 +68,12 @@ class HomeScreen extends StatelessWidget {
layout: layout,
context: context,
);
- return _layoutWidgets(
- layout: layout,
- homePage: homePage,
- homeMenu: menu,
- editPannel: editPannel);
+ return _layoutWidgets(layout: layout, homePage: homePage, homeMenu: menu, editPannel: editPannel);
},
);
}
- Widget _buildHomeMenu(
- {required HomeLayout layout, required BuildContext context}) {
+ Widget _buildHomeMenu({required HomeLayout layout, required BuildContext context}) {
final homeBloc = context.read<HomeBloc>();
Widget homeMenu = HomeMenu(
pageContextChanged: (pageContext) {
@@ -97,10 +90,7 @@ class HomeScreen extends StatelessWidget {
return homeMenu;
}
- Widget _buildEditPannel(
- {required HomeState homeState,
- required BuildContext context,
- required HomeLayout layout}) {
+ Widget _buildEditPannel({required HomeState homeState, required BuildContext context, required HomeLayout layout}) {
final homeBloc = context.read<HomeBloc>();
Widget editPannel = EditPannel(
context: homeState.editContext,
@@ -112,10 +102,7 @@ class HomeScreen extends StatelessWidget {
}
Widget _layoutWidgets(
- {required HomeLayout layout,
- required Widget homeMenu,
- required Widget homePage,
- required Widget editPannel}) {
+ {required HomeLayout layout, required Widget homeMenu, required Widget homePage, required Widget editPannel}) {
return Stack(
children: [
homeMenu
@@ -123,21 +110,11 @@ class HomeScreen extends StatelessWidget {
closeX: -layout.menuWidth,
isClosed: !layout.showMenu,
)
- .positioned(
- left: 0,
- top: 0,
- width: layout.menuWidth,
- bottom: 0,
- animate: true)
+ .positioned(left: 0, top: 0, width: layout.menuWidth, bottom: 0, animate: true)
.animate(layout.animDuration, Curves.easeOut),
homePage
.constrained(minWidth: 500)
- .positioned(
- left: layout.homePageLOffset,
- right: layout.homePageROffset,
- bottom: 0,
- top: 0,
- animate: true)
+ .positioned(left: layout.homePageLOffset, right: layout.homePageROffset, bottom: 0, top: 0, animate: true)
.animate(layout.animDuration, Curves.easeOut),
editPannel
.animatedPanelX(
@@ -145,8 +122,7 @@ class HomeScreen extends StatelessWidget {
closeX: layout.editPannelWidth,
isClosed: !layout.showEditPannel,
)
- .positioned(
- right: 0, top: 0, bottom: 0, width: layout.editPannelWidth),
+ .positioned(right: 0, top: 0, bottom: 0, width: layout.editPannelWidth),
],
);
}
diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_fav.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu_fav.dart
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_page.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu_page.dart
index 2453391d88..3615b3b44a 100644
--- a/app_flowy/lib/workspace/presentation/widgets/menu/menu_page.dart
+++ b/app_flowy/lib/workspace/presentation/widgets/menu/menu_page.dart
@@ -1,5 +1,4 @@
-import 'package:app_flowy/workspace/presentation/widgets/menu/menu_new_app.dart';
-import 'package:app_flowy/workspace/presentation/widgets/menu/menu_top_bar.dart';
+import 'package:app_flowy/workspace/presentation/widgets/menu/widget/top_bar.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/widget/error_page.dart';
@@ -14,11 +13,11 @@ import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
import 'package:app_flowy/workspace/application/menu/menu_watch.dart';
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
-import 'package:app_flowy/workspace/presentation/app/app_page.dart';
-import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
-import 'package:app_flowy/workspace/presentation/widgets/menu/menu_user.dart';
+import 'package:app_flowy/workspace/presentation/widgets/menu/widget/user.dart';
import 'menu_list.dart';
+import 'widget/app/app.dart';
+import 'widget/app/create_button.dart';
class HomeMenu extends StatelessWidget {
final Function(HomeStackView?) pageContextChanged;
diff --git a/app_flowy/lib/workspace/presentation/app/app_page.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/app.dart
similarity index 91%
rename from app_flowy/lib/workspace/presentation/app/app_page.dart
rename to app_flowy/lib/workspace/presentation/widgets/menu/widget/app/app.dart
index 7660ae0792..e85e05e437 100644
--- a/app_flowy/lib/workspace/presentation/app/app_page.dart
+++ b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/app.dart
@@ -1,18 +1,18 @@
+import 'package:app_flowy/workspace/presentation/widgets/menu/widget/app/header.dart';
import 'package:expandable/expandable.dart';
import 'package:flowy_infra_ui/widget/error_page.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
-
import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
import 'package:app_flowy/workspace/application/app/app_watch_bloc.dart';
-import 'package:app_flowy/workspace/presentation/app/view_list_page.dart';
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart';
import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart';
-import 'app_header.dart';
+
+import 'view/view_list.dart';
class AppPageSize {
static double expandedIconSize = 16;
@@ -21,18 +21,6 @@ class AppPageSize {
static double get expandedPadding => expandedIconSize * scale + expandedIconRightSpace;
}
-class ViewListData extends ChangeNotifier {
- List<View>? innerViews;
- ViewListData();
-
- set views(List<View> views) {
- innerViews = views;
- notifyListeners();
- }
-
- List<View> get views => innerViews ?? [];
-}
-
class AppPageContext {
final App app;
final viewListData = ViewListData();
diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/create_button.dart
similarity index 86%
rename from app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart
rename to app_flowy/lib/workspace/presentation/widgets/menu/widget/app/create_button.dart
index 8ca57ca230..34b4a40b4a 100644
--- a/app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart
+++ b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/create_button.dart
@@ -1,13 +1,12 @@
import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
-import 'package:app_flowy/workspace/presentation/widgets/menu/create_app_dialog.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/size.dart';
-import 'package:flowy_infra/theme.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
-import 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart';
import 'package:flutter/material.dart';
+import 'package:styled_widget/styled_widget.dart';
+import 'package:app_flowy/workspace/presentation/widgets/menu/widget/app/create_dialog.dart';
+import 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart';
import 'package:flowy_infra_ui/style_widget/extension.dart';
-import 'package:provider/provider.dart';
class NewAppButton extends StatelessWidget {
final Function(String)? press;
@@ -15,7 +14,7 @@ class NewAppButton extends StatelessWidget {
const NewAppButton({this.press, Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
- final theme = context.watch<AppTheme>();
+ // final theme = context.watch<AppTheme>();
return SizedBox(
height: HomeSizes.menuAddButtonHeight,
child: Row(
diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/create_app_dialog.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/create_dialog.dart
similarity index 100%
rename from app_flowy/lib/workspace/presentation/widgets/menu/create_app_dialog.dart
rename to app_flowy/lib/workspace/presentation/widgets/menu/widget/app/create_dialog.dart
diff --git a/app_flowy/lib/workspace/presentation/app/app_header.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/header.dart
similarity index 99%
rename from app_flowy/lib/workspace/presentation/app/app_header.dart
rename to app_flowy/lib/workspace/presentation/widgets/menu/widget/app/header.dart
index cd5db66e40..32204ed5b7 100644
--- a/app_flowy/lib/workspace/presentation/app/app_header.dart
+++ b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/header.dart
@@ -10,7 +10,7 @@ import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
-import 'app_page.dart';
+import 'app.dart';
class AppHeader extends StatelessWidget {
final App app;
diff --git a/app_flowy/lib/workspace/presentation/app/view_list_page.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/view/view_list.dart
similarity index 91%
rename from app_flowy/lib/workspace/presentation/app/view_list_page.dart
rename to app_flowy/lib/workspace/presentation/widgets/menu/widget/app/view/view_list.dart
index d793eeffc2..fdf2a7ebbf 100644
--- a/app_flowy/lib/workspace/presentation/app/view_list_page.dart
+++ b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/view/view_list.dart
@@ -1,4 +1,3 @@
-import 'package:app_flowy/workspace/presentation/app/app_page.dart';
import 'package:flowy_log/flowy_log.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
import 'package:flutter/foundation.dart';
@@ -7,7 +6,20 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';
import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
-import 'package:app_flowy/workspace/presentation/view/view_page.dart';
+
+import 'view_page.dart';
+
+class ViewListData extends ChangeNotifier {
+ List<View>? innerViews;
+ ViewListData();
+
+ set views(List<View> views) {
+ innerViews = views;
+ notifyListeners();
+ }
+
+ List<View> get views => innerViews ?? [];
+}
class ViewListNotifier with ChangeNotifier {
List<View> innerViews;
diff --git a/app_flowy/lib/workspace/presentation/view/view_page.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/view/view_page.dart
similarity index 96%
rename from app_flowy/lib/workspace/presentation/view/view_page.dart
rename to app_flowy/lib/workspace/presentation/widgets/menu/widget/app/view/view_page.dart
index 1c29a58061..f99d2d62a6 100644
--- a/app_flowy/lib/workspace/presentation/view/view_page.dart
+++ b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/view/view_page.dart
@@ -1,3 +1,4 @@
+import 'package:app_flowy/workspace/presentation/widgets/menu/widget/app/app.dart';
import 'package:flowy_infra/theme.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
@@ -6,7 +7,6 @@ import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
import 'package:flutter/material.dart';
import 'package:app_flowy/workspace/domain/image.dart';
-import 'package:app_flowy/workspace/presentation/app/app_page.dart';
import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart';
diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/widget/favorite.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/favorite.dart
new file mode 100644
index 0000000000..f69dbd92f1
--- /dev/null
+++ b/app_flowy/lib/workspace/presentation/widgets/menu/widget/favorite.dart
@@ -0,0 +1,14 @@
+import 'package:flutter/material.dart';
+import '../menu_list.dart';
+
+class MenuFav extends MenuItem {
+ @override
+ Widget build(BuildContext context) {
+ // TODO: implement build
+ throw UnimplementedError();
+ }
+
+ @override
+ // TODO: implement type
+ MenuItemType get type => throw UnimplementedError();
+}
diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_top_bar.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/top_bar.dart
similarity index 100%
rename from app_flowy/lib/workspace/presentation/widgets/menu/menu_top_bar.dart
rename to app_flowy/lib/workspace/presentation/widgets/menu/widget/top_bar.dart
diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_user.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/user.dart
similarity index 100%
rename from app_flowy/lib/workspace/presentation/widgets/menu/menu_user.dart
rename to app_flowy/lib/workspace/presentation/widgets/menu/widget/user.dart
diff --git a/app_flowy/packages/editor/example/lib/main.dart b/app_flowy/packages/editor/example/lib/main.dart
index 69e1dba469..afd93f4554 100644
--- a/app_flowy/packages/editor/example/lib/main.dart
+++ b/app_flowy/packages/editor/example/lib/main.dart
@@ -1,7 +1,4 @@
import 'package:flutter/material.dart';
-import 'dart:async';
-
-import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
@@ -15,8 +12,6 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State<MyApp> {
- String _platformVersion = 'Unknown';
-
@override
void initState() {
super.initState();
@@ -29,8 +24,8 @@ class _MyAppState extends State<MyApp> {
appBar: AppBar(
title: const Text('Plugin example app'),
),
- body: Center(
- child: Text('Running on: $_platformVersion\n'),
+ body: const Center(
+ child: Text(''),
),
),
);
diff --git a/app_flowy/packages/editor/lib/src/models/documents/attribute.dart b/app_flowy/packages/editor/lib/src/models/documents/attribute.dart
index db667ce107..2b50c04f0a 100644
--- a/app_flowy/packages/editor/lib/src/models/documents/attribute.dart
+++ b/app_flowy/packages/editor/lib/src/models/documents/attribute.dart
@@ -1,3 +1,5 @@
+// ignore_for_file: constant_identifier_names
+
import 'dart:collection';
import 'package:quiver/core.dart';
@@ -209,9 +211,7 @@ class Attribute<T> {
if (identical(this, other)) return true;
if (other is! Attribute) return false;
final typedOther = other;
- return key == typedOther.key &&
- scope == typedOther.scope &&
- value == typedOther.value;
+ return key == typedOther.key && scope == typedOther.scope && value == typedOther.value;
}
@override
@@ -264,8 +264,7 @@ class ColorAttribute extends Attribute<String?> {
}
class BackgroundAttribute extends Attribute<String?> {
- BackgroundAttribute(String? val)
- : super('background', AttributeScope.INLINE, val);
+ BackgroundAttribute(String? val) : super('background', AttributeScope.INLINE, val);
}
/// This is custom attribute for hint
diff --git a/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_overlay.dart b/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_overlay.dart
index b2e61501cf..992976c88a 100644
--- a/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_overlay.dart
+++ b/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_overlay.dart
@@ -1,3 +1,5 @@
+// ignore_for_file: unused_element
+
import 'package:dartz/dartz.dart' show Tuple3;
import 'package:flowy_infra_ui/src/flowy_overlay/overlay_layout_delegate.dart';
import 'package:flutter/material.dart';
diff --git a/app_flowy/packages/flowy_infra_ui/lib/widget/buttons/secondary_button.dart b/app_flowy/packages/flowy_infra_ui/lib/widget/buttons/secondary_button.dart
index 16570b8453..8b14e31ccf 100644
--- a/app_flowy/packages/flowy_infra_ui/lib/widget/buttons/secondary_button.dart
+++ b/app_flowy/packages/flowy_infra_ui/lib/widget/buttons/secondary_button.dart
@@ -12,15 +12,13 @@ class SecondaryTextButton extends StatelessWidget {
final String label;
final VoidCallback? onPressed;
- const SecondaryTextButton(this.label, {Key? key, this.onPressed})
- : super(key: key);
+ const SecondaryTextButton(this.label, {Key? key, this.onPressed}) : super(key: key);
@override
Widget build(BuildContext context) {
final theme = context.watch<AppTheme>();
TextStyle txtStyle = TextStyles.Footnote.textColor(theme.shader1);
- return SecondaryButton(
- onPressed: onPressed, child: Text(label, style: txtStyle));
+ return SecondaryButton(onPressed: onPressed, child: Text(label, style: txtStyle));
}
}
@@ -31,7 +29,7 @@ class SecondaryIconButton extends StatelessWidget {
final Color? color;
const SecondaryIconButton(this.icon, {Key? key, this.onPressed, this.color})
- : assert((icon is AssetImage) || (icon is IconData)),
+ : assert((icon is IconData)),
super(key: key);
@override