selfprivacy.org.app/lib/ui/pages/setup/recovering/recovery_confirm_cloudflare.dart

81 lines
3.2 KiB
Dart
Raw Normal View History

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';
import 'package:selfprivacy/config/brand_theme.dart';
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';
import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart';
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
import 'package:selfprivacy/ui/components/brand_md/brand_md.dart';
class RecoveryConfirmCloudflare extends StatelessWidget {
const RecoveryConfirmCloudflare({final 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) {
final ServerInstallationCubit appConfig =
context.watch<ServerInstallationCubit>();
2022-05-24 07:55:51 +00:00
return BlocProvider(
create: (final BuildContext context) => DnsProviderFormCubit(appConfig),
child: Builder(
builder: (final BuildContext context) {
final FormCubitState formCubitState =
context.watch<DnsProviderFormCubit>().state;
2022-05-24 07:55:51 +00:00
return BrandHeroScreen(
heroTitle: 'recovering.confirm_cloudflare'.tr(),
heroSubtitle: 'recovering.confirm_cloudflare_description'.tr(
args: [appConfig.state.serverDomain?.domainName ?? 'your domain'],
2022-05-24 07:55:51 +00:00
),
hasBackButton: true,
hasFlashButton: false,
2022-06-15 03:23:54 +00:00
onBackButtonPressed:
context.read<ServerInstallationCubit>().revertRecoveryStep,
children: [
CubitFormTextField(
formFieldCubit: context.read<DnsProviderFormCubit>().apiKey,
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: 'initializing.cloudflare_api_token'.tr(),
),
),
const SizedBox(height: 16),
BrandButton.rised(
onPressed: formCubitState.isSubmitting
? null
: () => context.read<DnsProviderFormCubit>().trySubmit(),
text: 'basis.connect'.tr(),
),
const SizedBox(height: 16),
BrandButton.text(
onPressed: () => showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
2022-06-09 21:13:06 +00:00
builder: (final BuildContext context) => BrandBottomSheet(
2022-05-24 07:55:51 +00:00
isExpended: true,
child: Padding(
padding: paddingH15V0,
2022-06-09 21:13:06 +00:00
child: ListView(
padding: const EdgeInsets.symmetric(vertical: 16),
children: const [
BrandMarkdown(
fileName: 'how_cloudflare',
),
],
2022-05-24 07:55:51 +00:00
),
),
2022-06-05 19:36:32 +00:00
),
),
title: 'initializing.how'.tr(),
2022-05-24 07:55:51 +00:00
),
],
);
},
),
2022-05-24 07:55:51 +00:00
);
}
}