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.

show app list on home screen

appflowy83778635ae51
diff --git a/app_flowy/lib/home/application/app/app_bloc.dart b/app_flowy/lib/home/application/app/app_bloc.dart
index b2e555d9e1..81929a6540 100644
--- a/app_flowy/lib/home/application/app/app_bloc.dart
+++ b/app_flowy/lib/home/application/app/app_bloc.dart
@@ -16,12 +16,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {
AppEvent event,
) async* {
yield* event.map(
- initial: (e) async* {
- iAppImpl.startWatching(
- updatedCallback: (name, desc) {},
- addViewCallback: (views) {},
- );
- },
+ initial: (e) async* {},
viewsReceived: (e) async* {
yield state;
},
diff --git a/app_flowy/lib/home/application/app/app_watch_bloc.dart b/app_flowy/lib/home/application/app/app_watch_bloc.dart
index 2edbb151dc..345d8984e0 100644
--- a/app_flowy/lib/home/application/app/app_watch_bloc.dart
+++ b/app_flowy/lib/home/application/app/app_watch_bloc.dart
@@ -15,7 +15,7 @@ class AppWatchBloc extends Bloc<AppWatchEvent, AppWatchState> {
Stream<AppWatchState> mapEventToState(
AppWatchEvent event,
) async* {
- yield* event.map(started: (_) {
+ yield* event.map(started: (_) async* {
watcher.startWatching(
addViewCallback: (viewsOrFail) => _handleViewsOrFail(viewsOrFail),
);
diff --git a/app_flowy/lib/home/infrastructure/deps_resolver.dart b/app_flowy/lib/home/infrastructure/deps_resolver.dart
index 8043e963d6..2403d8547c 100644
--- a/app_flowy/lib/home/infrastructure/deps_resolver.dart
+++ b/app_flowy/lib/home/infrastructure/deps_resolver.dart
@@ -1,3 +1,5 @@
+import 'package:app_flowy/home/application/app/app_bloc.dart';
+import 'package:app_flowy/home/application/app/app_watch_bloc.dart';
import 'package:app_flowy/home/application/menu/menu_bloc.dart';
import 'package:app_flowy/home/application/menu/menu_watch.dart';
import 'package:app_flowy/home/infrastructure/i_app_impl.dart';
@@ -36,6 +38,10 @@ class HomeDepsResolver {
getIt.registerFactoryParam<MenuWatchBloc, String, void>((workspaceId, _) =>
MenuWatchBloc(getIt<IWorkspaceWatch>(param1: workspaceId)));
+ getIt.registerFactoryParam<AppBloc, String, void>(
+ (appId, _) => AppBloc(getIt<IApp>(param1: appId)));
+ getIt.registerFactoryParam<AppWatchBloc, String, void>(
+ (appId, _) => AppWatchBloc(getIt<IAppWatch>(param1: appId)));
// AppWatchBloc
}
}
diff --git a/app_flowy/lib/home/presentation/widgets/app/app_list_widget.dart b/app_flowy/lib/home/presentation/widgets/app/app_list_widget.dart
deleted file mode 100644
index 0db1b2504c..0000000000
--- a/app_flowy/lib/home/presentation/widgets/app/app_list_widget.dart
+++ /dev/null
@@ -1,77 +0,0 @@
-import 'package:app_flowy/home/application/app/app_bloc.dart';
-import 'package:app_flowy/startup/startup.dart';
-// ignore: import_of_legacy_library_into_null_safe
-import 'package:expandable/expandable.dart';
-import 'package:flowy_infra/flowy_logger.dart';
-import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:flowy_infra_ui/widget/error_page.dart';
-
-import 'app_widget.dart';
-
-// class AppList extends StatelessWidget {
-// const AppList({Key? key}) : super(key: key);
-// @override
-// Widget build(BuildContext context) {
-// return MultiBlocProvider(
-// providers: [
-// BlocProvider(
-// create: (context) => getIt<AppBloc>()..add(const AppEvent.initial()),
-// ),
-// ],
-// child: BlocBuilder<AppBloc, AppState>(
-// buildWhen: (p, c) => p.apps != c.apps,
-// builder: (context, state) {
-// Log.info('AppList build');
-// if (state.isLoading) {
-// return const Center(
-// child: CircularProgressIndicator.adaptive(),
-// );
-// }
-
-// return state.apps.fold(
-// () => state.successOrFailure.fold(
-// (_) => const Text('You have no apps, create one?'),
-// (error) => FlowyErrorPage(error.toString()),
-// ),
-// (apps) => _buildBody(apps),
-// );
-// },
-// ),
-// );
-// }
-
-class AppList extends StatelessWidget {
- final List<App> apps;
- const AppList({required this.apps, Key? key}) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return ExpandableTheme(
- data: const ExpandableThemeData(
- iconColor: Colors.blue,
- useInkWell: true,
- ),
- child: Expanded(
- child: ListView(
- physics: const BouncingScrollPhysics(),
- children: apps.map((app) => AppWidget(app)).toList(),
- ),
- ));
- }
-
- // Widget _buildBody(List<App> apps) {
- // return ExpandableTheme(
- // data: const ExpandableThemeData(
- // iconColor: Colors.blue,
- // useInkWell: true,
- // ),
- // child: Expanded(
- // child: ListView(
- // physics: const BouncingScrollPhysics(),
- // children: apps.map((app) => AppWidget(app)).toList(),
- // ),
- // ));
- // }
-}
diff --git a/app_flowy/lib/home/presentation/widgets/app/app_widget.dart b/app_flowy/lib/home/presentation/widgets/app/app_widget.dart
index 7fc0b5dfc1..ef63c602aa 100644
--- a/app_flowy/lib/home/presentation/widgets/app/app_widget.dart
+++ b/app_flowy/lib/home/presentation/widgets/app/app_widget.dart
@@ -1,4 +1,5 @@
import 'package:app_flowy/home/application/app/app_bloc.dart';
+import 'package:app_flowy/home/application/app/app_watch_bloc.dart';
import 'package:app_flowy/home/presentation/widgets/menu/menu_size.dart';
import 'package:app_flowy/startup/startup.dart';
import 'package:expandable/expandable.dart';
@@ -15,23 +16,40 @@ class AppWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- // return MultiBlocProvider(
- // providers: [
- // BlocProvider<AppBloc>(create: (context) => getIt<AppBloc>()),
- // ],
- // child: BlocBuilder<AppBloc, AppState>(
- // builder: (context, state) {
- // // final child = state.map(
- // // initial: (_) => const CircularProgressIndicator.adaptive(),
- // // loadViews: (s) => ViewList(s.views),
- // // successOrFailure: (s) => FlowyErrorPage(s.error),
- // // );
+ return MultiBlocProvider(
+ providers: [
+ BlocProvider<AppBloc>(
+ create: (context) => getIt<AppBloc>(param1: app.id)),
+ BlocProvider<AppWatchBloc>(
+ create: (context) => getIt<AppWatchBloc>(param1: app.id)),
+ ],
+ child: BlocBuilder<AppWatchBloc, AppWatchState>(
+ builder: (context, state) {
+ final child = state.map(
+ initial: (_) => BlocBuilder<AppBloc, AppState>(
+ builder: (context, state) {
+ return Container();
+ },
+ ),
+ loadViews: (s) {
+ return Container();
+ // final child = state.map(
+ // initial: (_) => const CircularProgressIndicator.adaptive(),
+ // loadViews: (s) => ViewList(s.views),
+ // successOrFailure: (s) => FlowyErrorPage(s.error),
+ // );
+
+ // return expandableWrapper(context, Container());
+ },
+ loadFail: (s) {
+ return FlowyErrorPage(s.error.toString());
+ },
+ );
- // return expandableWrapper(context, Container());
- // },
- // ),
- // );
- return Container();
+ return expandableWrapper(context, child);
+ },
+ ),
+ );
}
ExpandableNotifier expandableWrapper(BuildContext context, Widget child) {
diff --git a/app_flowy/lib/home/presentation/widgets/app/view_list.dart b/app_flowy/lib/home/presentation/widgets/app/view_list.dart
index e69de29bb2..8b13789179 100644
--- a/app_flowy/lib/home/presentation/widgets/app/view_list.dart
+++ b/app_flowy/lib/home/presentation/widgets/app/view_list.dart
@@ -0,0 +1 @@
+
diff --git a/app_flowy/lib/home/presentation/widgets/menu/menu.dart b/app_flowy/lib/home/presentation/widgets/menu/menu.dart
index cdd2ca3e4d..f8a23a7a2c 100644
--- a/app_flowy/lib/home/presentation/widgets/menu/menu.dart
+++ b/app_flowy/lib/home/presentation/widgets/menu/menu.dart
@@ -77,9 +77,13 @@ class HomeMenu extends StatelessWidget {
Widget _renderAppList(BuildContext context) {
return BlocBuilder<MenuWatchBloc, MenuWatchState>(
builder: (context, state) => state.map(
- initial: (_) => AppList(apps: context.read<MenuBloc>().state.apps),
- loadApps: (event) => AppList(apps: some(event.apps)),
- loadFail: (error) => FlowyErrorPage(error.toString()),
+ initial: (_) => BlocBuilder<MenuBloc, MenuState>(
+ builder: (context, state) {
+ return AppList(apps: state.apps);
+ },
+ ),
+ loadApps: (s) => AppList(apps: some(s.apps)),
+ loadFail: (s) => FlowyErrorPage(s.error.toString()),
),
);
}