mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
show app list on home screen
This commit is contained in:
parent
9b9d462f36
commit
83778635ae
@ -16,12 +16,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {
|
|||||||
AppEvent event,
|
AppEvent event,
|
||||||
) async* {
|
) async* {
|
||||||
yield* event.map(
|
yield* event.map(
|
||||||
initial: (e) async* {
|
initial: (e) async* {},
|
||||||
iAppImpl.startWatching(
|
|
||||||
updatedCallback: (name, desc) {},
|
|
||||||
addViewCallback: (views) {},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
viewsReceived: (e) async* {
|
viewsReceived: (e) async* {
|
||||||
yield state;
|
yield state;
|
||||||
},
|
},
|
||||||
|
@ -15,7 +15,7 @@ class AppWatchBloc extends Bloc<AppWatchEvent, AppWatchState> {
|
|||||||
Stream<AppWatchState> mapEventToState(
|
Stream<AppWatchState> mapEventToState(
|
||||||
AppWatchEvent event,
|
AppWatchEvent event,
|
||||||
) async* {
|
) async* {
|
||||||
yield* event.map(started: (_) {
|
yield* event.map(started: (_) async* {
|
||||||
watcher.startWatching(
|
watcher.startWatching(
|
||||||
addViewCallback: (viewsOrFail) => _handleViewsOrFail(viewsOrFail),
|
addViewCallback: (viewsOrFail) => _handleViewsOrFail(viewsOrFail),
|
||||||
);
|
);
|
||||||
|
@ -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_bloc.dart';
|
||||||
import 'package:app_flowy/home/application/menu/menu_watch.dart';
|
import 'package:app_flowy/home/application/menu/menu_watch.dart';
|
||||||
import 'package:app_flowy/home/infrastructure/i_app_impl.dart';
|
import 'package:app_flowy/home/infrastructure/i_app_impl.dart';
|
||||||
@ -36,6 +38,10 @@ class HomeDepsResolver {
|
|||||||
getIt.registerFactoryParam<MenuWatchBloc, String, void>((workspaceId, _) =>
|
getIt.registerFactoryParam<MenuWatchBloc, String, void>((workspaceId, _) =>
|
||||||
MenuWatchBloc(getIt<IWorkspaceWatch>(param1: 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
|
// AppWatchBloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(),
|
|
||||||
// ),
|
|
||||||
// ));
|
|
||||||
// }
|
|
||||||
}
|
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:app_flowy/home/application/app/app_bloc.dart';
|
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/home/presentation/widgets/menu/menu_size.dart';
|
||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
import 'package:expandable/expandable.dart';
|
import 'package:expandable/expandable.dart';
|
||||||
@ -15,23 +16,40 @@ class AppWidget extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
// providers: [
|
providers: [
|
||||||
// BlocProvider<AppBloc>(create: (context) => getIt<AppBloc>()),
|
BlocProvider<AppBloc>(
|
||||||
// ],
|
create: (context) => getIt<AppBloc>(param1: app.id)),
|
||||||
// child: BlocBuilder<AppBloc, AppState>(
|
BlocProvider<AppWatchBloc>(
|
||||||
// builder: (context, state) {
|
create: (context) => getIt<AppWatchBloc>(param1: app.id)),
|
||||||
// // final child = state.map(
|
],
|
||||||
// // initial: (_) => const CircularProgressIndicator.adaptive(),
|
child: BlocBuilder<AppWatchBloc, AppWatchState>(
|
||||||
// // loadViews: (s) => ViewList(s.views),
|
builder: (context, state) {
|
||||||
// // successOrFailure: (s) => FlowyErrorPage(s.error),
|
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());
|
// return expandableWrapper(context, Container());
|
||||||
// },
|
},
|
||||||
// ),
|
loadFail: (s) {
|
||||||
// );
|
return FlowyErrorPage(s.error.toString());
|
||||||
return Container();
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return expandableWrapper(context, child);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpandableNotifier expandableWrapper(BuildContext context, Widget child) {
|
ExpandableNotifier expandableWrapper(BuildContext context, Widget child) {
|
||||||
|
@ -77,9 +77,13 @@ class HomeMenu extends StatelessWidget {
|
|||||||
Widget _renderAppList(BuildContext context) {
|
Widget _renderAppList(BuildContext context) {
|
||||||
return BlocBuilder<MenuWatchBloc, MenuWatchState>(
|
return BlocBuilder<MenuWatchBloc, MenuWatchState>(
|
||||||
builder: (context, state) => state.map(
|
builder: (context, state) => state.map(
|
||||||
initial: (_) => AppList(apps: context.read<MenuBloc>().state.apps),
|
initial: (_) => BlocBuilder<MenuBloc, MenuState>(
|
||||||
loadApps: (event) => AppList(apps: some(event.apps)),
|
builder: (context, state) {
|
||||||
loadFail: (error) => FlowyErrorPage(error.toString()),
|
return AppList(apps: state.apps);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
loadApps: (s) => AppList(apps: some(s.apps)),
|
||||||
|
loadFail: (s) => FlowyErrorPage(s.error.toString()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user