2023-02-23 14:49:14 +00:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2020-12-30 14:13:25 +00:00
|
|
|
import 'package:cubit_form/cubit_form.dart';
|
2022-02-08 06:59:19 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2020-12-10 20:33:19 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-12-30 03:25:18 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/server_provider_form_cubit.dart';
|
2022-05-17 13:31:34 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2022-05-04 16:58:47 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
2022-05-11 18:37:08 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/backblaze_form_cubit.dart';
|
2022-07-14 13:34:08 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/dns_provider_form_cubit.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/domain_setup_cubit.dart';
|
2022-05-11 18:37:08 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/root_user_form_cubit.dart';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/support_system/support_system_cubit.dart';
|
2023-03-27 17:02:44 +00:00
|
|
|
import 'package:selfprivacy/ui/components/buttons/brand_button.dart';
|
2021-02-16 18:48:15 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_timer/brand_timer.dart';
|
2023-05-30 17:52:42 +00:00
|
|
|
import 'package:selfprivacy/ui/components/buttons/outlined_button.dart';
|
2023-04-04 14:31:35 +00:00
|
|
|
import 'package:selfprivacy/ui/components/drawers/progress_drawer.dart';
|
2020-12-30 14:13:25 +00:00
|
|
|
import 'package:selfprivacy/ui/components/progress_bar/progress_bar.dart';
|
2023-04-04 14:31:35 +00:00
|
|
|
import 'package:selfprivacy/ui/components/drawers/support_drawer.dart';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/ui/layouts/responsive_layout_with_infobox.dart';
|
2022-12-30 03:25:18 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/setup/initializing/dns_provider_picker.dart';
|
2022-10-15 19:49:31 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/setup/initializing/server_provider_picker.dart';
|
|
|
|
import 'package:selfprivacy/ui/pages/setup/initializing/server_type_picker.dart';
|
2022-05-19 14:26:57 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_routing.dart';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/ui/router/router.dart';
|
|
|
|
import 'package:selfprivacy/utils/breakpoints.dart';
|
2020-12-10 20:33:19 +00:00
|
|
|
|
2023-03-22 11:38:18 +00:00
|
|
|
@RoutePage()
|
2021-01-06 17:35:57 +00:00
|
|
|
class InitializingPage extends StatelessWidget {
|
2022-10-26 16:26:09 +00:00
|
|
|
const InitializingPage({super.key});
|
2022-05-25 12:21:56 +00:00
|
|
|
|
2020-12-10 20:33:19 +00:00
|
|
|
@override
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
final cubit = context.watch<ServerInstallationCubit>();
|
2022-05-19 14:26:57 +00:00
|
|
|
|
2022-05-20 22:56:50 +00:00
|
|
|
if (cubit.state is ServerInstallationRecovery) {
|
2022-05-24 18:55:39 +00:00
|
|
|
return const RecoveryRouting();
|
2022-05-20 22:56:50 +00:00
|
|
|
} else {
|
2022-08-29 19:54:06 +00:00
|
|
|
Widget? actualInitializingPage;
|
|
|
|
if (cubit.state is! ServerInstallationFinished) {
|
|
|
|
actualInitializingPage = [
|
2022-10-15 19:49:31 +00:00
|
|
|
() => _stepServerProviderToken(cubit),
|
|
|
|
() => _stepServerType(cubit),
|
2022-12-30 03:25:18 +00:00
|
|
|
() => _stepDnsProviderToken(cubit),
|
2022-08-29 19:54:06 +00:00
|
|
|
() => _stepBackblaze(cubit),
|
|
|
|
() => _stepDomain(cubit),
|
|
|
|
() => _stepUser(cubit),
|
|
|
|
() => _stepServer(cubit),
|
|
|
|
() => _stepCheck(cubit),
|
|
|
|
() => _stepCheck(cubit),
|
|
|
|
() => _stepCheck(cubit),
|
|
|
|
() => _stepCheck(cubit)
|
|
|
|
][cubit.state.progress.index]();
|
|
|
|
}
|
2022-05-20 22:56:50 +00:00
|
|
|
|
2023-02-23 14:49:14 +00:00
|
|
|
const steps = [
|
|
|
|
'initializing.steps.hosting',
|
|
|
|
'initializing.steps.server_type',
|
|
|
|
'initializing.steps.dns_provider',
|
|
|
|
'initializing.steps.backups_provider',
|
|
|
|
'initializing.steps.domain',
|
|
|
|
'initializing.steps.master_account',
|
|
|
|
'initializing.steps.server',
|
|
|
|
'initializing.steps.dns_setup',
|
|
|
|
'initializing.steps.nixos_installation',
|
|
|
|
'initializing.steps.server_reboot',
|
|
|
|
'initializing.steps.final_checks',
|
|
|
|
];
|
|
|
|
|
2022-05-20 22:56:50 +00:00
|
|
|
return BlocListener<ServerInstallationCubit, ServerInstallationState>(
|
2022-06-05 22:40:34 +00:00
|
|
|
listener: (final context, final state) {
|
2022-05-20 22:56:50 +00:00
|
|
|
if (cubit.state is ServerInstallationFinished) {
|
2023-02-23 14:49:14 +00:00
|
|
|
context.router.popUntilRoot();
|
2022-05-20 22:56:50 +00:00
|
|
|
}
|
|
|
|
},
|
2022-12-31 04:16:10 +00:00
|
|
|
child: Scaffold(
|
2023-02-23 14:49:14 +00:00
|
|
|
endDrawer: const SupportDrawer(),
|
|
|
|
endDrawerEnableOpenDragGesture: false,
|
|
|
|
appBar: Breakpoints.large.isActive(context)
|
|
|
|
? null
|
|
|
|
: AppBar(
|
|
|
|
actions: [
|
|
|
|
if (cubit.state is ServerInstallationFinished)
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.check),
|
|
|
|
onPressed: () {
|
|
|
|
context.router.popUntilRoot();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
const SizedBox.shrink(),
|
2022-12-31 04:16:10 +00:00
|
|
|
],
|
2023-02-23 14:49:14 +00:00
|
|
|
title: Text(
|
|
|
|
'more_page.configuration_wizard'.tr(),
|
|
|
|
),
|
|
|
|
bottom: PreferredSize(
|
|
|
|
preferredSize: const Size.fromHeight(28),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
|
|
|
child: ProgressBar(
|
|
|
|
steps: const [
|
|
|
|
'Hosting',
|
|
|
|
'Server Type',
|
|
|
|
'CloudFlare',
|
|
|
|
'Backblaze',
|
|
|
|
'Domain',
|
|
|
|
'User',
|
|
|
|
'Server',
|
|
|
|
'Installation',
|
|
|
|
],
|
|
|
|
activeIndex: cubit.state.porgressBar,
|
|
|
|
),
|
|
|
|
),
|
2021-04-22 18:04:24 +00:00
|
|
|
),
|
2022-12-31 04:16:10 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
body: LayoutBuilder(
|
|
|
|
builder: (final context, final constraints) => Row(
|
|
|
|
children: [
|
|
|
|
if (Breakpoints.large.isActive(context))
|
2023-04-04 14:31:35 +00:00
|
|
|
ProgressDrawer(
|
2023-02-23 14:49:14 +00:00
|
|
|
steps: steps,
|
2023-04-04 14:31:35 +00:00
|
|
|
currentStep: cubit.state.progress.index,
|
|
|
|
title: 'more_page.configuration_wizard'.tr(),
|
2023-02-23 14:49:14 +00:00
|
|
|
constraints: constraints,
|
2023-04-04 14:31:35 +00:00
|
|
|
trailing: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
if (cubit.state is ServerInstallationEmpty ||
|
|
|
|
cubit.state is ServerInstallationNotFinished)
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: BrandButton.filled(
|
|
|
|
text: 'basis.connect_to_existing'.tr(),
|
|
|
|
onPressed: () {
|
|
|
|
context.router.replace(const RecoveryRoute());
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2023-05-30 17:52:42 +00:00
|
|
|
// const SizedBox(height: 8),
|
|
|
|
BrandOutlinedButton(
|
|
|
|
child: Text(
|
|
|
|
cubit.state is ServerInstallationFinished
|
|
|
|
? 'basis.close'.tr()
|
|
|
|
: 'basis.later'.tr(),
|
2023-04-04 14:31:35 +00:00
|
|
|
),
|
2023-05-30 17:52:42 +00:00
|
|
|
onPressed: () {
|
|
|
|
context.router.popUntilRoot();
|
|
|
|
},
|
2023-04-04 14:31:35 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-05-20 22:56:50 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
SizedBox(
|
|
|
|
width: constraints.maxWidth -
|
|
|
|
(Breakpoints.large.isActive(context) ? 300 : 0),
|
|
|
|
height: constraints.maxHeight,
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: Breakpoints.large.isActive(context)
|
|
|
|
? const EdgeInsets.all(16.0)
|
|
|
|
: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0.0),
|
|
|
|
child: AnimatedSwitcher(
|
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
child: actualInitializingPage,
|
|
|
|
),
|
2022-12-31 04:16:10 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
if (!Breakpoints.large.isActive(context))
|
|
|
|
Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: BrandButton.text(
|
|
|
|
title:
|
|
|
|
cubit.state is ServerInstallationFinished
|
|
|
|
? 'basis.close'.tr()
|
|
|
|
: 'basis.later'.tr(),
|
|
|
|
onPressed: () {
|
|
|
|
context.router.popUntilRoot();
|
|
|
|
},
|
2022-12-31 04:16:10 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
),
|
|
|
|
if (cubit.state is ServerInstallationEmpty ||
|
|
|
|
cubit.state is ServerInstallationNotFinished)
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: BrandButton.text(
|
|
|
|
title: 'basis.connect_to_existing'.tr(),
|
|
|
|
onPressed: () {
|
|
|
|
context.router
|
|
|
|
.replace(const RecoveryRoute());
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
],
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2022-12-31 04:16:10 +00:00
|
|
|
),
|
|
|
|
],
|
2021-04-22 18:04:24 +00:00
|
|
|
),
|
2021-01-06 17:35:57 +00:00
|
|
|
),
|
2020-12-30 14:13:25 +00:00
|
|
|
),
|
2022-05-20 22:56:50 +00:00
|
|
|
);
|
|
|
|
}
|
2020-12-10 20:33:19 +00:00
|
|
|
}
|
|
|
|
|
2022-10-15 21:51:37 +00:00
|
|
|
Widget _stepServerProviderToken(
|
2022-10-18 05:38:26 +00:00
|
|
|
final ServerInstallationCubit serverInstallationCubit,
|
|
|
|
) =>
|
2022-10-19 14:43:01 +00:00
|
|
|
BlocProvider(
|
2022-12-30 03:25:18 +00:00
|
|
|
create: (final context) =>
|
|
|
|
ServerProviderFormCubit(serverInstallationCubit),
|
2022-10-19 14:43:01 +00:00
|
|
|
child: Builder(
|
|
|
|
builder: (final context) {
|
2022-12-30 03:25:18 +00:00
|
|
|
final providerCubit = context.watch<ServerProviderFormCubit>();
|
2022-10-19 14:43:01 +00:00
|
|
|
return ServerProviderPicker(
|
|
|
|
formCubit: providerCubit,
|
|
|
|
serverInstallationCubit: serverInstallationCubit,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2020-12-30 14:13:25 +00:00
|
|
|
|
2022-10-15 21:51:37 +00:00
|
|
|
Widget _stepServerType(
|
2022-10-18 05:38:26 +00:00
|
|
|
final ServerInstallationCubit serverInstallationCubit,
|
|
|
|
) =>
|
2022-10-19 14:43:01 +00:00
|
|
|
BlocProvider(
|
2022-12-30 03:25:18 +00:00
|
|
|
create: (final context) =>
|
|
|
|
ServerProviderFormCubit(serverInstallationCubit),
|
2022-10-19 14:43:01 +00:00
|
|
|
child: Builder(
|
|
|
|
builder: (final context) => ServerTypePicker(
|
|
|
|
serverInstallationCubit: serverInstallationCubit,
|
|
|
|
),
|
|
|
|
),
|
2022-10-15 21:51:37 +00:00
|
|
|
);
|
2022-10-15 19:49:31 +00:00
|
|
|
|
2022-12-30 03:25:18 +00:00
|
|
|
Widget _stepDnsProviderToken(
|
|
|
|
final ServerInstallationCubit initializingCubit,
|
|
|
|
) =>
|
2022-06-05 22:40:34 +00:00
|
|
|
BlocProvider(
|
2022-07-14 13:34:08 +00:00
|
|
|
create: (final context) => DnsProviderFormCubit(initializingCubit),
|
2022-06-05 22:40:34 +00:00
|
|
|
child: Builder(
|
2022-12-30 03:25:18 +00:00
|
|
|
builder: (final context) {
|
|
|
|
final providerCubit = context.watch<DnsProviderFormCubit>();
|
|
|
|
return DnsProviderPicker(
|
|
|
|
formCubit: providerCubit,
|
|
|
|
serverInstallationCubit: initializingCubit,
|
|
|
|
);
|
|
|
|
},
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
);
|
2021-02-03 19:51:07 +00:00
|
|
|
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget _stepBackblaze(final ServerInstallationCubit initializingCubit) =>
|
|
|
|
BlocProvider(
|
|
|
|
create: (final context) => BackblazeFormCubit(initializingCubit),
|
|
|
|
child: Builder(
|
|
|
|
builder: (final context) {
|
|
|
|
final formCubitState = context.watch<BackblazeFormCubit>().state;
|
2023-02-23 14:49:14 +00:00
|
|
|
return ResponsiveLayoutWithInfobox(
|
|
|
|
topChild: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'${'initializing.connect_to_server_provider'.tr()}Backblaze',
|
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
primaryColumn: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
CubitFormTextField(
|
|
|
|
formFieldCubit: context.read<BackblazeFormCubit>().keyId,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
scrollPadding: const EdgeInsets.only(bottom: 70),
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
hintText: 'KeyID',
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
CubitFormTextField(
|
|
|
|
formFieldCubit:
|
|
|
|
context.read<BackblazeFormCubit>().applicationKey,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
scrollPadding: const EdgeInsets.only(bottom: 70),
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
hintText: 'Master Application Key',
|
2021-02-15 18:58:29 +00:00
|
|
|
),
|
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
const SizedBox(height: 32),
|
|
|
|
BrandButton.rised(
|
|
|
|
onPressed: formCubitState.isSubmitting
|
|
|
|
? null
|
|
|
|
: () => context.read<BackblazeFormCubit>().trySubmit(),
|
|
|
|
text: 'basis.connect'.tr(),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
BrandButton.text(
|
|
|
|
onPressed: () {
|
|
|
|
context.read<SupportSystemCubit>().showArticle(
|
|
|
|
article: 'how_backblaze',
|
|
|
|
context: context,
|
|
|
|
);
|
|
|
|
Scaffold.of(context).openEndDrawer();
|
|
|
|
},
|
|
|
|
title: 'initializing.how'.tr(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
Widget _stepDomain(final ServerInstallationCubit initializingCubit) =>
|
|
|
|
BlocProvider(
|
|
|
|
create: (final context) => DomainSetupCubit(initializingCubit)..load(),
|
|
|
|
child: Builder(
|
|
|
|
builder: (final context) {
|
|
|
|
final DomainSetupState state =
|
|
|
|
context.watch<DomainSetupCubit>().state;
|
2023-02-23 14:49:14 +00:00
|
|
|
return ResponsiveLayoutWithInfobox(
|
|
|
|
topChild: Column(
|
2022-12-31 04:16:10 +00:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'initializing.use_this_domain'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2022-12-31 04:16:10 +00:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
Text(
|
|
|
|
'initializing.use_this_domain_text'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
primaryColumn: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2022-12-31 04:16:10 +00:00
|
|
|
if (state is Empty)
|
|
|
|
Text(
|
|
|
|
'initializing.no_connected_domains'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
),
|
|
|
|
if (state is Loading)
|
|
|
|
Text(
|
|
|
|
state.type == LoadingTypes.loadingDomain
|
|
|
|
? 'initializing.loading_domain_list'.tr()
|
|
|
|
: 'basis.saving'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
),
|
|
|
|
if (state is MoreThenOne)
|
|
|
|
Text(
|
|
|
|
'initializing.found_more_domains'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
),
|
|
|
|
if (state is Loaded) ...[
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
2022-06-05 22:40:34 +00:00
|
|
|
state.domain,
|
2022-12-31 04:16:10 +00:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.headlineMedium
|
|
|
|
?.copyWith(
|
|
|
|
color:
|
|
|
|
Theme.of(context).colorScheme.onBackground,
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
2022-12-31 04:16:10 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
if (state is Empty) ...[
|
|
|
|
const SizedBox(height: 30),
|
2023-02-23 14:49:14 +00:00
|
|
|
BrandButton.filled(
|
2022-12-31 04:16:10 +00:00
|
|
|
onPressed: () => context.read<DomainSetupCubit>().load(),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
const Icon(
|
|
|
|
Icons.refresh,
|
|
|
|
color: Colors.white,
|
2021-02-15 18:58:29 +00:00
|
|
|
),
|
2022-12-31 04:16:10 +00:00
|
|
|
const SizedBox(width: 10),
|
2023-03-27 17:02:44 +00:00
|
|
|
Text(
|
|
|
|
'domain.update_list'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
|
|
),
|
2022-12-31 04:16:10 +00:00
|
|
|
],
|
2021-02-15 18:58:29 +00:00
|
|
|
),
|
|
|
|
),
|
2022-12-31 04:16:10 +00:00
|
|
|
],
|
|
|
|
if (state is Loaded) ...[
|
|
|
|
const SizedBox(height: 32),
|
2023-02-23 14:49:14 +00:00
|
|
|
BrandButton.filled(
|
2022-12-31 04:16:10 +00:00
|
|
|
onPressed: () =>
|
|
|
|
context.read<DomainSetupCubit>().saveDomain(),
|
|
|
|
text: 'initializing.save_domain'.tr(),
|
|
|
|
),
|
|
|
|
],
|
2022-06-05 22:40:34 +00:00
|
|
|
],
|
2022-12-31 04:16:10 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2020-12-30 14:13:25 +00:00
|
|
|
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget _stepUser(final ServerInstallationCubit initializingCubit) =>
|
|
|
|
BlocProvider(
|
|
|
|
create: (final context) =>
|
|
|
|
RootUserFormCubit(initializingCubit, FieldCubitFactory(context)),
|
|
|
|
child: Builder(
|
|
|
|
builder: (final context) {
|
|
|
|
final formCubitState = context.watch<RootUserFormCubit>().state;
|
2021-01-06 17:35:57 +00:00
|
|
|
|
2023-02-23 14:49:14 +00:00
|
|
|
return ResponsiveLayoutWithInfobox(
|
|
|
|
topChild: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2022-10-08 19:28:07 +00:00
|
|
|
Text(
|
2023-02-23 14:49:14 +00:00
|
|
|
'initializing.create_master_account'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
2022-10-08 19:28:07 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
Text(
|
|
|
|
'initializing.enter_username_and_password'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
2021-02-15 18:58:29 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
primaryColumn: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
if (formCubitState.isErrorShown) const SizedBox(height: 16),
|
|
|
|
if (formCubitState.isErrorShown)
|
|
|
|
Text(
|
|
|
|
'users.username_rule'.tr(),
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).colorScheme.error,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 32),
|
|
|
|
CubitFormTextField(
|
|
|
|
formFieldCubit: context.read<RootUserFormCubit>().userName,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
scrollPadding: const EdgeInsets.only(bottom: 70),
|
|
|
|
decoration: InputDecoration(
|
|
|
|
hintText: 'basis.username'.tr(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
BlocBuilder<FieldCubit<bool>, FieldCubitState<bool>>(
|
|
|
|
bloc: context.read<RootUserFormCubit>().isVisible,
|
|
|
|
builder: (final context, final state) {
|
|
|
|
final bool isVisible = state.value;
|
|
|
|
return CubitFormTextField(
|
|
|
|
obscureText: !isVisible,
|
|
|
|
formFieldCubit:
|
|
|
|
context.read<RootUserFormCubit>().password,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
scrollPadding: const EdgeInsets.only(bottom: 70),
|
|
|
|
decoration: InputDecoration(
|
|
|
|
hintText: 'basis.password'.tr(),
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
icon: Icon(
|
|
|
|
isVisible
|
|
|
|
? Icons.visibility
|
|
|
|
: Icons.visibility_off,
|
|
|
|
),
|
|
|
|
onPressed: () => context
|
|
|
|
.read<RootUserFormCubit>()
|
|
|
|
.isVisible
|
|
|
|
.setValue(!isVisible),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
suffixIconConstraints:
|
|
|
|
const BoxConstraints(minWidth: 60),
|
|
|
|
prefixIconConstraints:
|
|
|
|
const BoxConstraints(maxWidth: 60),
|
|
|
|
prefixIcon: Container(),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
const SizedBox(height: 32),
|
|
|
|
BrandButton.filled(
|
|
|
|
onPressed: formCubitState.isSubmitting
|
|
|
|
? null
|
|
|
|
: () => context.read<RootUserFormCubit>().trySubmit(),
|
|
|
|
text: 'basis.connect'.tr(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2020-12-10 20:33:19 +00:00
|
|
|
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget _stepServer(final ServerInstallationCubit appConfigCubit) {
|
|
|
|
final bool isLoading =
|
2022-05-17 13:31:34 +00:00
|
|
|
(appConfigCubit.state as ServerInstallationNotFinished).isLoading;
|
2022-06-05 22:40:34 +00:00
|
|
|
return Builder(
|
2023-02-23 14:49:14 +00:00
|
|
|
builder: (final context) => ResponsiveLayoutWithInfobox(
|
|
|
|
topChild: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'initializing.final'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
Text(
|
|
|
|
'initializing.create_server'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
primaryColumn: BrandButton.filled(
|
|
|
|
onPressed:
|
|
|
|
isLoading ? null : appConfigCubit.createServerAndSetDnsRecords,
|
|
|
|
text: isLoading
|
|
|
|
? 'basis.loading'.tr()
|
|
|
|
: 'initializing.create_server'.tr(),
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
);
|
2021-01-06 17:35:57 +00:00
|
|
|
}
|
|
|
|
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget _stepCheck(final ServerInstallationCubit appConfigCubit) {
|
2022-05-17 13:31:34 +00:00
|
|
|
assert(
|
2022-06-05 22:40:34 +00:00
|
|
|
appConfigCubit.state is ServerInstallationNotFinished,
|
|
|
|
'wrong state',
|
|
|
|
);
|
|
|
|
final state = appConfigCubit.state as TimerState;
|
2021-06-20 21:08:52 +00:00
|
|
|
late int doneCount;
|
2021-03-23 19:50:11 +00:00
|
|
|
late String? text;
|
2021-03-31 11:37:39 +00:00
|
|
|
if (state.isServerResetedSecondTime) {
|
2022-10-03 23:32:35 +00:00
|
|
|
text = 'initializing.server_rebooted'.tr();
|
2021-06-20 21:08:52 +00:00
|
|
|
doneCount = 3;
|
2021-03-31 11:37:39 +00:00
|
|
|
} else if (state.isServerResetedFirstTime) {
|
2022-10-03 23:32:35 +00:00
|
|
|
text = 'initializing.one_more_restart'.tr();
|
2021-06-20 21:08:52 +00:00
|
|
|
doneCount = 2;
|
2021-03-23 19:50:11 +00:00
|
|
|
} else if (state.isServerStarted) {
|
2022-10-03 23:32:35 +00:00
|
|
|
text = 'initializing.server_started'.tr();
|
2021-06-20 21:08:52 +00:00
|
|
|
doneCount = 1;
|
2021-02-16 18:48:15 +00:00
|
|
|
} else if (state.isServerCreated) {
|
2022-10-03 23:32:35 +00:00
|
|
|
text = 'initializing.server_created'.tr();
|
2021-06-20 21:08:52 +00:00
|
|
|
doneCount = 0;
|
2021-02-16 18:48:15 +00:00
|
|
|
}
|
2022-06-05 22:40:34 +00:00
|
|
|
return Builder(
|
2022-12-31 04:16:10 +00:00
|
|
|
builder: (final context) => SizedBox(
|
|
|
|
width: double.infinity,
|
2023-02-23 14:49:14 +00:00
|
|
|
child: ResponsiveLayoutWithInfobox(
|
|
|
|
topChild: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2022-12-31 04:16:10 +00:00
|
|
|
Text(
|
2023-02-23 14:49:14 +00:00
|
|
|
'initializing.checks'.tr(args: [doneCount.toString(), '4']),
|
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
2022-12-31 04:16:10 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
if (text != null)
|
|
|
|
Text(
|
|
|
|
text,
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
primaryColumn: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2022-06-09 21:13:06 +00:00
|
|
|
children: [
|
2023-02-23 14:49:14 +00:00
|
|
|
const SizedBox(height: 128),
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
if (doneCount == 0 && state.dnsMatches != null)
|
|
|
|
Column(
|
|
|
|
children: state.dnsMatches!.entries.map((final entry) {
|
|
|
|
final String domain = entry.key;
|
|
|
|
final bool isCorrect = entry.value;
|
|
|
|
return Row(
|
|
|
|
children: [
|
|
|
|
if (isCorrect)
|
|
|
|
const Icon(Icons.check, color: Colors.green),
|
|
|
|
if (!isCorrect)
|
|
|
|
const Icon(Icons.schedule, color: Colors.amber),
|
|
|
|
const SizedBox(width: 10),
|
|
|
|
Text(domain),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}).toList(),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
if (!state.isLoading)
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'initializing.until_the_next_check'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
),
|
|
|
|
BrandTimer(
|
|
|
|
startDateTime: state.timerStart!,
|
|
|
|
duration: state.duration!,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
if (state.isLoading)
|
|
|
|
Text(
|
|
|
|
'initializing.check'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
),
|
2022-06-09 21:13:06 +00:00
|
|
|
],
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2021-06-20 21:08:52 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2020-12-30 14:13:25 +00:00
|
|
|
);
|
2020-12-10 20:33:19 +00:00
|
|
|
}
|
|
|
|
}
|