Fix missing OrganizationBloc provider and add OrgApi to DI
This commit is contained in:
@@ -7,6 +7,7 @@ import 'repositories/http_auth_repository.dart';
|
||||
import 'repositories/http_file_repository.dart';
|
||||
import 'services/auth_service.dart';
|
||||
import 'services/file_service.dart';
|
||||
import 'services/org_api.dart';
|
||||
import 'viewmodels/login_view_model.dart';
|
||||
import 'viewmodels/file_explorer_view_model.dart';
|
||||
|
||||
@@ -26,6 +27,7 @@ void configureDependencies(SessionBloc sessionBloc) {
|
||||
// Register services
|
||||
getIt.registerSingleton<AuthService>(AuthService(getIt<AuthRepository>()));
|
||||
getIt.registerSingleton<FileService>(FileService(getIt<ApiClient>()));
|
||||
getIt.registerSingleton<OrgApi>(OrgApi(getIt<ApiClient>()));
|
||||
|
||||
// Register viewmodels
|
||||
getIt.registerSingleton<LoginViewModel>(LoginViewModel(getIt<AuthService>()));
|
||||
|
||||
@@ -12,6 +12,7 @@ import '../blocs/permission/permission_bloc.dart';
|
||||
import '../blocs/upload/upload_bloc.dart';
|
||||
import '../repositories/file_repository.dart';
|
||||
import '../services/file_service.dart';
|
||||
import '../services/org_api.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../theme/modern_glass_button.dart';
|
||||
import 'login_form.dart' show LoginForm;
|
||||
@@ -212,19 +213,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
orgId = '';
|
||||
}
|
||||
|
||||
// Wrap FileExplorer with required BlocProviders
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<FileBrowserBloc>(
|
||||
create: (context) => FileBrowserBloc(getIt<FileService>()),
|
||||
),
|
||||
BlocProvider<PermissionBloc>(create: (context) => PermissionBloc()),
|
||||
BlocProvider<UploadBloc>(
|
||||
create: (context) => UploadBloc(getIt<FileRepository>()),
|
||||
),
|
||||
],
|
||||
child: FileExplorer(orgId: orgId),
|
||||
);
|
||||
return FileExplorer(orgId: orgId);
|
||||
}
|
||||
|
||||
Widget _buildNavButton(String label, IconData icon, {bool isAvatar = false}) {
|
||||
@@ -269,14 +258,21 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppTheme.primaryBackground,
|
||||
body: Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: BlocBuilder<AuthBloc, AuthState>(
|
||||
builder: (context, state) {
|
||||
final isLoggedIn = state is AuthAuthenticated;
|
||||
return BlocProvider(
|
||||
create: (context) => OrganizationBloc(
|
||||
PermissionBloc(),
|
||||
FileBrowserBloc(getIt<FileService>()),
|
||||
UploadBloc(getIt<FileRepository>()),
|
||||
getIt<OrgApi>(),
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: AppTheme.primaryBackground,
|
||||
body: Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: BlocBuilder<AuthBloc, AuthState>(
|
||||
builder: (context, state) {
|
||||
final isLoggedIn = state is AuthAuthenticated;
|
||||
if (isLoggedIn && !_animationController.isAnimating) {
|
||||
_animationController.forward();
|
||||
} else if (!isLoggedIn) {
|
||||
@@ -550,6 +546,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user