selfprivacy.org.app/lib/config/bloc_config.dart

51 lines
2.2 KiB
Dart
Raw Normal View History

2020-12-01 19:08:19 +00:00
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:selfprivacy/logic/cubit/recovery_key/recovery_key_cubit.dart';
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
2022-02-16 07:09:53 +00:00
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
2021-12-06 18:31:19 +00:00
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
2022-02-16 07:09:53 +00:00
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
2021-05-25 21:53:54 +00:00
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
2020-12-10 20:33:19 +00:00
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
2021-08-29 13:54:28 +00:00
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
2020-12-03 16:52:53 +00:00
import 'package:selfprivacy/logic/cubit/users/users_cubit.dart';
2020-12-01 19:08:19 +00:00
class BlocAndProviderConfig extends StatelessWidget {
2021-03-15 15:39:44 +00:00
const BlocAndProviderConfig({Key? key, this.child}) : super(key: key);
2020-12-01 19:08:19 +00:00
2021-03-15 15:39:44 +00:00
final Widget? child;
2020-12-01 19:08:19 +00:00
@override
Widget build(BuildContext context) {
2021-01-06 17:35:57 +00:00
var isDark = false;
var serverInstallationCubit = ServerInstallationCubit()..load();
var usersCubit = UsersCubit(serverInstallationCubit);
var servicesCubit = ServicesCubit(serverInstallationCubit);
var backupsCubit = BackupsCubit(serverInstallationCubit);
var dnsRecordsCubit = DnsRecordsCubit(serverInstallationCubit);
var recoveryKeyCubit = RecoveryKeyCubit(serverInstallationCubit);
2020-12-01 19:08:19 +00:00
return MultiProvider(
providers: [
2021-01-06 17:35:57 +00:00
BlocProvider(
create: (_) => AppSettingsCubit(
isDarkModeOn: isDark,
isOnboardingShowing: true,
2021-01-06 17:35:57 +00:00
)..load(),
),
BlocProvider(create: (_) => serverInstallationCubit, lazy: false),
2020-12-10 20:33:19 +00:00
BlocProvider(create: (_) => ProvidersCubit()),
2021-07-29 05:24:42 +00:00
BlocProvider(create: (_) => usersCubit..load(), lazy: false),
2021-08-29 13:54:28 +00:00
BlocProvider(create: (_) => servicesCubit..load(), lazy: false),
2021-12-06 18:31:19 +00:00
BlocProvider(create: (_) => backupsCubit..load(), lazy: false),
2022-02-16 07:09:53 +00:00
BlocProvider(create: (_) => dnsRecordsCubit..load()),
BlocProvider(create: (_) => recoveryKeyCubit..load()),
2021-08-29 13:54:28 +00:00
BlocProvider(
create: (_) =>
JobsCubit(usersCubit: usersCubit, servicesCubit: servicesCubit),
2021-08-29 13:54:28 +00:00
),
2020-12-01 19:08:19 +00:00
],
child: child,
);
}
}