2022-05-24 07:55:51 +00:00
|
|
|
import 'package:cubit_form/cubit_form.dart';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2022-07-14 13:34:08 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/dns_provider_form_cubit.dart';
|
2022-05-24 07:55:51 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2023-04-04 14:31:35 +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';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
2022-05-24 07:55:51 +00:00
|
|
|
|
2023-05-12 19:32:19 +00:00
|
|
|
class RecoveryConfirmDns extends StatelessWidget {
|
|
|
|
const RecoveryConfirmDns({super.key});
|
2022-05-24 18:55:39 +00:00
|
|
|
|
2022-05-24 07:55:51 +00:00
|
|
|
@override
|
2022-06-05 19:36:32 +00:00
|
|
|
Widget build(final BuildContext context) {
|
2022-06-05 22:40:34 +00:00
|
|
|
final ServerInstallationCubit appConfig =
|
|
|
|
context.watch<ServerInstallationCubit>();
|
2022-05-24 07:55:51 +00:00
|
|
|
|
|
|
|
return BlocProvider(
|
2022-07-14 13:34:08 +00:00
|
|
|
create: (final BuildContext context) => DnsProviderFormCubit(appConfig),
|
2022-06-05 22:40:34 +00:00
|
|
|
child: Builder(
|
|
|
|
builder: (final BuildContext context) {
|
|
|
|
final FormCubitState formCubitState =
|
2022-07-14 13:34:08 +00:00
|
|
|
context.watch<DnsProviderFormCubit>().state;
|
2023-07-28 23:42:41 +00:00
|
|
|
final String providerDisplayName =
|
|
|
|
appConfig.state.serverDomain?.provider.displayName ??
|
|
|
|
'DNS Provider';
|
2022-06-05 22:40:34 +00:00
|
|
|
return BrandHeroScreen(
|
2023-07-28 23:42:41 +00:00
|
|
|
heroTitle: 'recovering.provider_connected'.tr(
|
|
|
|
args: [providerDisplayName],
|
|
|
|
),
|
|
|
|
heroSubtitle: 'recovering.provider_connected_description'.tr(
|
2022-06-05 22:40:34 +00:00
|
|
|
args: [appConfig.state.serverDomain?.domainName ?? 'your domain'],
|
2022-05-24 07:55:51 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
hasBackButton: true,
|
|
|
|
hasFlashButton: false,
|
2023-04-04 14:31:35 +00:00
|
|
|
ignoreBreakpoints: true,
|
|
|
|
hasSupportDrawer: true,
|
2022-06-15 03:23:54 +00:00
|
|
|
onBackButtonPressed:
|
|
|
|
context.read<ServerInstallationCubit>().revertRecoveryStep,
|
2022-06-05 22:40:34 +00:00
|
|
|
children: [
|
|
|
|
CubitFormTextField(
|
2022-07-14 13:34:08 +00:00
|
|
|
formFieldCubit: context.read<DnsProviderFormCubit>().apiKey,
|
2022-06-05 22:40:34 +00:00
|
|
|
decoration: InputDecoration(
|
|
|
|
border: const OutlineInputBorder(),
|
2023-07-28 23:42:41 +00:00
|
|
|
labelText: 'recovering.provider_connected_placeholder'.tr(
|
|
|
|
args: [providerDisplayName],
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
BrandButton.rised(
|
|
|
|
onPressed: formCubitState.isSubmitting
|
|
|
|
? null
|
2022-07-14 13:34:08 +00:00
|
|
|
: () => context.read<DnsProviderFormCubit>().trySubmit(),
|
2022-06-05 22:40:34 +00:00
|
|
|
text: 'basis.connect'.tr(),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
2023-04-04 14:31:35 +00:00
|
|
|
Builder(
|
|
|
|
builder: (final context) => BrandButton.text(
|
|
|
|
onPressed: () =>
|
|
|
|
context.read<SupportSystemCubit>().showArticle(
|
|
|
|
article: 'how_cloudflare',
|
|
|
|
context: context,
|
|
|
|
),
|
|
|
|
title: 'initializing.how'.tr(),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2022-05-24 07:55:51 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2022-05-24 07:55:51 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|