2020-12-01 19:08:19 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2024-01-29 13:54:09 +00:00
|
|
|
import 'package:selfprivacy/logic/bloc/backups/backups_bloc.dart';
|
2024-01-31 10:57:12 +00:00
|
|
|
import 'package:selfprivacy/logic/bloc/server_jobs/server_jobs_bloc.dart';
|
2024-01-29 15:57:22 +00:00
|
|
|
import 'package:selfprivacy/logic/bloc/services/services_bloc.dart';
|
2024-02-01 14:30:06 +00:00
|
|
|
import 'package:selfprivacy/logic/bloc/volumes/volumes_bloc.dart';
|
2024-01-31 10:57:12 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart';
|
2024-01-26 10:49:36 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/connection_status/connection_status_bloc.dart';
|
2022-05-31 14:30:44 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/devices/devices_cubit.dart';
|
2024-01-31 10:57:12 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/provider_volumes/provider_volume_cubit.dart';
|
2022-05-24 17:45:13 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/recovery_key/recovery_key_cubit.dart';
|
2022-09-16 08:11:03 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart';
|
2022-05-17 13:31:34 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2023-02-23 14:36:26 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/support_system/support_system_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
|
|
|
|
2024-01-31 14:06:49 +00:00
|
|
|
class BlocAndProviderConfig extends StatefulWidget {
|
2022-10-26 16:26:09 +00:00
|
|
|
const BlocAndProviderConfig({super.key, this.child});
|
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
|
|
|
|
2024-01-31 14:06:49 +00:00
|
|
|
@override
|
|
|
|
BlocAndProviderConfigState createState() => BlocAndProviderConfigState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class BlocAndProviderConfigState extends State<BlocAndProviderConfig> {
|
|
|
|
late final ServerInstallationCubit serverInstallationCubit;
|
|
|
|
late final SupportSystemCubit supportSystemCubit;
|
|
|
|
late final UsersCubit usersCubit;
|
|
|
|
late final ServicesBloc servicesBloc;
|
|
|
|
late final BackupsBloc backupsBloc;
|
|
|
|
late final DnsRecordsCubit dnsRecordsCubit;
|
|
|
|
late final RecoveryKeyCubit recoveryKeyCubit;
|
|
|
|
late final ApiDevicesCubit apiDevicesCubit;
|
2024-02-01 14:30:06 +00:00
|
|
|
late final ProviderVolumeCubit apiVolumesCubit;
|
2024-01-31 14:06:49 +00:00
|
|
|
late final ServerJobsBloc serverJobsBloc;
|
|
|
|
late final ConnectionStatusBloc connectionStatusBloc;
|
|
|
|
late final ServerDetailsCubit serverDetailsCubit;
|
2024-02-01 14:30:06 +00:00
|
|
|
late final VolumesBloc volumesBloc;
|
2024-01-31 14:06:49 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
serverInstallationCubit = ServerInstallationCubit()..load();
|
|
|
|
supportSystemCubit = SupportSystemCubit();
|
|
|
|
usersCubit = UsersCubit();
|
|
|
|
servicesBloc = ServicesBloc();
|
|
|
|
backupsBloc = BackupsBloc();
|
|
|
|
dnsRecordsCubit = DnsRecordsCubit();
|
|
|
|
recoveryKeyCubit = RecoveryKeyCubit();
|
|
|
|
apiDevicesCubit = ApiDevicesCubit();
|
2024-02-01 14:30:06 +00:00
|
|
|
apiVolumesCubit = ProviderVolumeCubit();
|
2024-01-31 14:06:49 +00:00
|
|
|
serverJobsBloc = ServerJobsBloc();
|
|
|
|
connectionStatusBloc = ConnectionStatusBloc();
|
|
|
|
serverDetailsCubit = ServerDetailsCubit();
|
2024-02-01 14:30:06 +00:00
|
|
|
volumesBloc = VolumesBloc();
|
2024-01-31 14:06:49 +00:00
|
|
|
}
|
|
|
|
|
2020-12-01 19:08:19 +00:00
|
|
|
@override
|
2022-06-05 19:36:32 +00:00
|
|
|
Widget build(final BuildContext context) {
|
2022-06-05 22:40:34 +00:00
|
|
|
const isDark = false;
|
2023-02-23 14:36:26 +00:00
|
|
|
const isAutoDark = true;
|
2022-08-26 16:46:30 +00:00
|
|
|
|
2020-12-01 19:08:19 +00:00
|
|
|
return MultiProvider(
|
|
|
|
providers: [
|
2021-01-06 17:35:57 +00:00
|
|
|
BlocProvider(
|
2022-06-05 19:36:32 +00:00
|
|
|
create: (final _) => AppSettingsCubit(
|
2021-01-06 17:35:57 +00:00
|
|
|
isDarkModeOn: isDark,
|
2023-02-23 14:36:26 +00:00
|
|
|
isAutoDarkModeOn: isAutoDark,
|
2022-05-17 20:08:28 +00:00
|
|
|
isOnboardingShowing: true,
|
2021-01-06 17:35:57 +00:00
|
|
|
)..load(),
|
|
|
|
),
|
2023-02-23 14:36:26 +00:00
|
|
|
BlocProvider(
|
|
|
|
create: (final _) => supportSystemCubit,
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
BlocProvider(
|
|
|
|
create: (final _) => serverInstallationCubit,
|
|
|
|
lazy: false,
|
|
|
|
),
|
|
|
|
BlocProvider(
|
2024-01-31 14:06:49 +00:00
|
|
|
create: (final _) => usersCubit,
|
2022-06-05 22:40:34 +00:00
|
|
|
lazy: false,
|
|
|
|
),
|
|
|
|
BlocProvider(
|
2024-01-29 15:57:22 +00:00
|
|
|
create: (final _) => servicesBloc,
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
BlocProvider(
|
2024-01-29 13:54:09 +00:00
|
|
|
create: (final _) => backupsBloc,
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
BlocProvider(
|
2024-01-26 14:46:09 +00:00
|
|
|
create: (final _) => dnsRecordsCubit,
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
BlocProvider(
|
2024-01-31 14:06:49 +00:00
|
|
|
create: (final _) => recoveryKeyCubit,
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
BlocProvider(
|
2024-01-31 14:06:49 +00:00
|
|
|
create: (final _) => apiDevicesCubit,
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2022-08-24 05:35:49 +00:00
|
|
|
BlocProvider(
|
2024-01-31 14:06:49 +00:00
|
|
|
create: (final _) => apiVolumesCubit,
|
2022-08-24 05:35:49 +00:00
|
|
|
),
|
2022-08-30 03:09:09 +00:00
|
|
|
BlocProvider(
|
2024-01-26 14:46:09 +00:00
|
|
|
create: (final _) => serverJobsBloc,
|
2022-08-30 03:09:09 +00:00
|
|
|
),
|
2024-01-26 14:46:09 +00:00
|
|
|
BlocProvider(create: (final _) => connectionStatusBloc),
|
2022-09-16 08:06:27 +00:00
|
|
|
BlocProvider(
|
2024-01-31 14:06:49 +00:00
|
|
|
create: (final _) => serverDetailsCubit,
|
2022-09-16 08:06:27 +00:00
|
|
|
),
|
2024-02-01 14:30:06 +00:00
|
|
|
BlocProvider(create: (final _) => volumesBloc),
|
2022-08-26 16:46:30 +00:00
|
|
|
BlocProvider(
|
|
|
|
create: (final _) => JobsCubit(
|
|
|
|
usersCubit: usersCubit,
|
2024-01-29 15:57:22 +00:00
|
|
|
servicesBloc: servicesBloc,
|
2022-08-26 16:46:30 +00:00
|
|
|
),
|
2021-08-29 13:54:28 +00:00
|
|
|
),
|
2020-12-01 19:08:19 +00:00
|
|
|
],
|
2024-01-31 14:06:49 +00:00
|
|
|
child: widget.child,
|
2020-12-01 19:08:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|