2022-03-25 07:02:43 +00:00
|
|
|
import 'package:app_flowy/core/network_monitor.dart';
|
|
|
|
import 'package:app_flowy/user/application/user_listener.dart';
|
|
|
|
import 'package:app_flowy/user/application/user_service.dart';
|
|
|
|
import 'package:app_flowy/workspace/application/app/prelude.dart';
|
2022-08-09 02:35:27 +00:00
|
|
|
import 'package:app_flowy/plugins/doc/application/prelude.dart';
|
|
|
|
import 'package:app_flowy/plugins/grid/application/prelude.dart';
|
2022-07-09 14:00:17 +00:00
|
|
|
import 'package:app_flowy/workspace/application/user/prelude.dart';
|
2022-03-25 07:02:43 +00:00
|
|
|
import 'package:app_flowy/workspace/application/workspace/prelude.dart';
|
2022-08-09 03:59:22 +00:00
|
|
|
import 'package:app_flowy/workspace/application/edit_panel/edit_panel_bloc.dart';
|
2022-03-25 07:02:43 +00:00
|
|
|
import 'package:app_flowy/workspace/application/view/prelude.dart';
|
|
|
|
import 'package:app_flowy/workspace/application/menu/prelude.dart';
|
2022-07-21 16:01:39 +00:00
|
|
|
import 'package:app_flowy/workspace/application/settings/prelude.dart';
|
2022-03-25 07:02:43 +00:00
|
|
|
import 'package:app_flowy/user/application/prelude.dart';
|
|
|
|
import 'package:app_flowy/user/presentation/router.dart';
|
2022-08-09 02:35:27 +00:00
|
|
|
import 'package:app_flowy/plugins/trash/application/prelude.dart';
|
2022-03-25 07:02:43 +00:00
|
|
|
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
2022-04-26 06:43:42 +00:00
|
|
|
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
2022-07-04 07:00:54 +00:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
|
|
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
2022-07-04 07:07:11 +00:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
2022-06-01 07:22:18 +00:00
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
2022-03-25 07:02:43 +00:00
|
|
|
import 'package:get_it/get_it.dart';
|
|
|
|
|
2022-09-04 07:33:07 +00:00
|
|
|
import '../plugins/grid/application/field/field_controller.dart';
|
2022-08-09 11:06:15 +00:00
|
|
|
|
2022-03-25 07:02:43 +00:00
|
|
|
class DependencyResolver {
|
|
|
|
static Future<void> resolve(GetIt getIt) async {
|
|
|
|
_resolveUserDeps(getIt);
|
|
|
|
|
|
|
|
_resolveHomeDeps(getIt);
|
|
|
|
|
|
|
|
_resolveFolderDeps(getIt);
|
|
|
|
|
|
|
|
_resolveDocDeps(getIt);
|
|
|
|
|
|
|
|
_resolveGridDeps(getIt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _resolveUserDeps(GetIt getIt) {
|
|
|
|
getIt.registerFactory<AuthService>(() => AuthService());
|
|
|
|
getIt.registerFactory<AuthRouter>(() => AuthRouter());
|
|
|
|
|
|
|
|
getIt.registerFactory<SignInBloc>(() => SignInBloc(getIt<AuthService>()));
|
|
|
|
getIt.registerFactory<SignUpBloc>(() => SignUpBloc(getIt<AuthService>()));
|
|
|
|
|
|
|
|
getIt.registerFactory<SplashRoute>(() => SplashRoute());
|
2022-08-09 03:59:22 +00:00
|
|
|
getIt.registerFactory<EditPanelBloc>(() => EditPanelBloc());
|
2022-03-25 07:02:43 +00:00
|
|
|
getIt.registerFactory<SplashBloc>(() => SplashBloc());
|
|
|
|
getIt.registerLazySingleton<NetworkListener>(() => NetworkListener());
|
|
|
|
}
|
|
|
|
|
|
|
|
void _resolveHomeDeps(GetIt getIt) {
|
2022-06-01 07:22:18 +00:00
|
|
|
getIt.registerSingleton(FToast());
|
|
|
|
|
2022-04-26 06:43:42 +00:00
|
|
|
getIt.registerSingleton(MenuSharedState());
|
|
|
|
|
2022-07-19 06:40:56 +00:00
|
|
|
getIt.registerFactoryParam<UserListener, UserProfilePB, void>(
|
2022-07-04 02:59:08 +00:00
|
|
|
(user, _) => UserListener(userProfile: user),
|
2022-03-25 07:02:43 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
getIt.registerLazySingleton<HomeStackManager>(() => HomeStackManager());
|
|
|
|
|
2022-07-19 06:40:56 +00:00
|
|
|
getIt.registerFactoryParam<WelcomeBloc, UserProfilePB, void>(
|
2022-03-25 07:02:43 +00:00
|
|
|
(user, _) => WelcomeBloc(
|
2022-07-03 08:52:06 +00:00
|
|
|
userService: UserService(userId: user.id),
|
2022-07-04 02:59:08 +00:00
|
|
|
userWorkspaceListener: UserWorkspaceListener(userProfile: user),
|
2022-03-25 07:02:43 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
// share
|
|
|
|
getIt.registerLazySingleton<ShareService>(() => ShareService());
|
2022-07-19 06:11:29 +00:00
|
|
|
getIt.registerFactoryParam<DocShareBloc, ViewPB, void>(
|
2022-03-25 07:02:43 +00:00
|
|
|
(view, _) => DocShareBloc(view: view, service: getIt<ShareService>()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void _resolveFolderDeps(GetIt getIt) {
|
|
|
|
//workspace
|
2022-07-19 06:40:56 +00:00
|
|
|
getIt.registerFactoryParam<WorkspaceListener, UserProfilePB, String>(
|
2022-08-09 02:35:27 +00:00
|
|
|
(user, workspaceId) =>
|
|
|
|
WorkspaceListener(user: user, workspaceId: workspaceId));
|
2022-03-25 07:02:43 +00:00
|
|
|
|
2022-07-19 06:11:29 +00:00
|
|
|
// ViewPB
|
|
|
|
getIt.registerFactoryParam<ViewListener, ViewPB, void>(
|
2022-03-25 07:02:43 +00:00
|
|
|
(view, _) => ViewListener(view: view),
|
|
|
|
);
|
|
|
|
|
2022-07-19 06:11:29 +00:00
|
|
|
getIt.registerFactoryParam<ViewBloc, ViewPB, void>(
|
2022-03-25 07:02:43 +00:00
|
|
|
(view, _) => ViewBloc(
|
|
|
|
view: view,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
//Menu
|
2022-07-19 06:40:56 +00:00
|
|
|
getIt.registerFactoryParam<MenuBloc, UserProfilePB, String>(
|
2022-03-25 07:02:43 +00:00
|
|
|
(user, workspaceId) => MenuBloc(
|
|
|
|
workspaceId: workspaceId,
|
|
|
|
listener: getIt<WorkspaceListener>(param1: user, param2: workspaceId),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2022-07-19 06:40:56 +00:00
|
|
|
getIt.registerFactoryParam<MenuUserBloc, UserProfilePB, void>(
|
2022-07-04 02:59:08 +00:00
|
|
|
(user, _) => MenuUserBloc(user),
|
2022-03-25 07:02:43 +00:00
|
|
|
);
|
|
|
|
|
2022-07-21 16:01:39 +00:00
|
|
|
//Settings
|
2022-07-21 16:21:07 +00:00
|
|
|
getIt.registerFactoryParam<SettingsDialogBloc, UserProfilePB, void>(
|
2022-07-21 16:01:39 +00:00
|
|
|
(user, _) => SettingsDialogBloc(user),
|
|
|
|
);
|
|
|
|
|
2022-07-09 14:00:17 +00:00
|
|
|
//User
|
2022-07-21 16:21:07 +00:00
|
|
|
getIt.registerFactoryParam<SettingsUserViewBloc, UserProfilePB, void>(
|
2022-07-09 14:00:17 +00:00
|
|
|
(user, _) => SettingsUserViewBloc(user),
|
|
|
|
);
|
|
|
|
|
2022-07-19 06:11:29 +00:00
|
|
|
// AppPB
|
|
|
|
getIt.registerFactoryParam<AppBloc, AppPB, void>(
|
2022-10-16 08:51:21 +00:00
|
|
|
(app, _) => AppBloc(app: app),
|
2022-03-25 07:02:43 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// trash
|
|
|
|
getIt.registerLazySingleton<TrashService>(() => TrashService());
|
|
|
|
getIt.registerLazySingleton<TrashListener>(() => TrashListener());
|
|
|
|
getIt.registerFactory<TrashBloc>(
|
|
|
|
() => TrashBloc(
|
|
|
|
service: getIt<TrashService>(),
|
|
|
|
listener: getIt<TrashListener>(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _resolveDocDeps(GetIt getIt) {
|
|
|
|
// Doc
|
2022-07-19 06:11:29 +00:00
|
|
|
getIt.registerFactoryParam<DocumentBloc, ViewPB, void>(
|
2022-03-25 07:02:43 +00:00
|
|
|
(view, _) => DocumentBloc(
|
|
|
|
view: view,
|
|
|
|
service: DocumentService(),
|
|
|
|
listener: getIt<ViewListener>(param1: view),
|
|
|
|
trashService: getIt<TrashService>(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _resolveGridDeps(GetIt getIt) {
|
2022-07-17 06:13:12 +00:00
|
|
|
// GridPB
|
2022-07-19 06:11:29 +00:00
|
|
|
getIt.registerFactoryParam<GridBloc, ViewPB, void>(
|
2022-04-10 00:25:01 +00:00
|
|
|
(view, _) => GridBloc(view: view),
|
2022-03-25 07:02:43 +00:00
|
|
|
);
|
|
|
|
|
2022-09-03 09:16:48 +00:00
|
|
|
getIt.registerFactoryParam<GridHeaderBloc, String, GridFieldController>(
|
|
|
|
(gridId, fieldController) => GridHeaderBloc(
|
2022-04-14 10:11:28 +00:00
|
|
|
gridId: gridId,
|
2022-09-03 09:16:48 +00:00
|
|
|
fieldController: fieldController,
|
2022-03-25 07:02:43 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2022-04-03 09:05:28 +00:00
|
|
|
getIt.registerFactoryParam<FieldActionSheetBloc, GridFieldCellContext, void>(
|
2022-10-23 08:44:10 +00:00
|
|
|
(data, _) => FieldActionSheetBloc(fieldCellContext: data),
|
2022-03-25 07:02:43 +00:00
|
|
|
);
|
|
|
|
|
2022-07-14 12:40:01 +00:00
|
|
|
getIt.registerFactoryParam<TextCellBloc, GridCellController, void>(
|
2022-04-22 14:13:51 +00:00
|
|
|
(context, _) => TextCellBloc(
|
2022-08-12 08:06:30 +00:00
|
|
|
cellController: context,
|
2022-03-25 07:02:43 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2022-08-09 02:35:27 +00:00
|
|
|
getIt.registerFactoryParam<SelectOptionCellBloc,
|
|
|
|
GridSelectOptionCellController, void>(
|
2022-05-15 09:13:01 +00:00
|
|
|
(context, _) => SelectOptionCellBloc(
|
2022-08-12 08:06:30 +00:00
|
|
|
cellController: context,
|
2022-03-25 07:02:43 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2022-07-14 12:40:01 +00:00
|
|
|
getIt.registerFactoryParam<NumberCellBloc, GridCellController, void>(
|
2022-04-22 14:13:51 +00:00
|
|
|
(context, _) => NumberCellBloc(
|
2022-08-12 08:06:30 +00:00
|
|
|
cellController: context,
|
2022-03-25 07:02:43 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2022-07-14 12:40:01 +00:00
|
|
|
getIt.registerFactoryParam<DateCellBloc, GridDateCellController, void>(
|
2022-04-22 14:13:51 +00:00
|
|
|
(context, _) => DateCellBloc(
|
2022-08-12 08:06:30 +00:00
|
|
|
cellController: context,
|
2022-03-25 07:02:43 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2022-07-14 12:40:01 +00:00
|
|
|
getIt.registerFactoryParam<CheckboxCellBloc, GridCellController, void>(
|
2022-03-26 12:27:32 +00:00
|
|
|
(cellData, _) => CheckboxCellBloc(
|
|
|
|
service: CellService(),
|
2022-08-12 08:06:30 +00:00
|
|
|
cellController: cellData,
|
2022-03-25 07:02:43 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2022-09-03 09:16:48 +00:00
|
|
|
getIt.registerFactoryParam<GridPropertyBloc, String, GridFieldController>(
|
|
|
|
(gridId, cache) => GridPropertyBloc(gridId: gridId, fieldController: cache),
|
2022-04-03 09:05:28 +00:00
|
|
|
);
|
2022-03-25 07:02:43 +00:00
|
|
|
}
|