2022-05-19 17:43:25 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:selfprivacy/config/brand_theme.dart';
|
2022-07-13 11:58:23 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/provider_form_cubit.dart';
|
2022-05-19 17:43:25 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.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-19 17:43:25 +00:00
|
|
|
import 'package:cubit_form/cubit_form.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/brand_md/brand_md.dart';
|
|
|
|
|
2022-11-17 07:14:34 +00:00
|
|
|
class RecoveryServerProviderConnected extends StatelessWidget {
|
|
|
|
const RecoveryServerProviderConnected({super.key});
|
2022-05-24 18:55:39 +00:00
|
|
|
|
2022-05-19 17:43:25 +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-19 17:43:25 +00:00
|
|
|
|
|
|
|
return BlocProvider(
|
2022-07-12 12:54:16 +00:00
|
|
|
create: (final BuildContext context) => ProviderFormCubit(appConfig),
|
2022-05-19 17:43:25 +00:00
|
|
|
child: Builder(
|
2022-06-05 19:36:32 +00:00
|
|
|
builder: (final BuildContext context) {
|
2022-06-05 22:40:34 +00:00
|
|
|
final FormCubitState formCubitState =
|
2022-07-12 12:54:16 +00:00
|
|
|
context.watch<ProviderFormCubit>().state;
|
2022-05-19 17:43:25 +00:00
|
|
|
|
|
|
|
return BrandHeroScreen(
|
2022-11-17 07:14:34 +00:00
|
|
|
heroTitle: 'recovering.server_provider_connected'.tr(),
|
|
|
|
heroSubtitle: 'recovering.server_provider_connected_description'.tr(
|
2022-06-05 22:40:34 +00:00
|
|
|
args: [appConfig.state.serverDomain?.domainName ?? 'your domain'],
|
|
|
|
),
|
2022-05-19 17:43:25 +00:00
|
|
|
hasBackButton: true,
|
|
|
|
hasFlashButton: false,
|
2022-06-15 04:51:32 +00:00
|
|
|
onBackButtonPressed: () {
|
|
|
|
Navigator.of(context).popUntil((final route) => route.isFirst);
|
|
|
|
},
|
2022-05-19 17:43:25 +00:00
|
|
|
children: [
|
|
|
|
CubitFormTextField(
|
2022-07-12 12:54:16 +00:00
|
|
|
formFieldCubit: context.read<ProviderFormCubit>().apiKey,
|
2022-05-19 17:43:25 +00:00
|
|
|
decoration: InputDecoration(
|
2022-05-24 18:55:39 +00:00
|
|
|
border: const OutlineInputBorder(),
|
2022-11-17 07:14:34 +00:00
|
|
|
labelText:
|
|
|
|
'recovering.server_provider_connected_placeholder'.tr(),
|
2022-05-19 17:43:25 +00:00
|
|
|
),
|
|
|
|
),
|
2022-05-24 18:55:39 +00:00
|
|
|
const SizedBox(height: 16),
|
2023-02-05 13:24:37 +00:00
|
|
|
BrandButton.filled(
|
2022-05-19 17:43:25 +00:00
|
|
|
onPressed: formCubitState.isSubmitting
|
|
|
|
? null
|
2022-07-12 12:54:16 +00:00
|
|
|
: () => context.read<ProviderFormCubit>().trySubmit(),
|
2023-02-05 13:24:37 +00:00
|
|
|
child: Text('basis.continue'.tr()),
|
2022-05-19 17:43:25 +00:00
|
|
|
),
|
2022-05-24 18:55:39 +00:00
|
|
|
const SizedBox(height: 16),
|
2022-05-19 17:43:25 +00:00
|
|
|
BrandButton.text(
|
|
|
|
title: 'initializing.how'.tr(),
|
|
|
|
onPressed: () => showModalBottomSheet<void>(
|
|
|
|
context: context,
|
|
|
|
isScrollControlled: true,
|
|
|
|
backgroundColor: Colors.transparent,
|
2022-06-09 21:13:06 +00:00
|
|
|
builder: (final BuildContext context) => BrandBottomSheet(
|
2022-06-05 22:40:34 +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_hetzner',
|
|
|
|
),
|
|
|
|
],
|
2022-05-19 17:43:25 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
),
|
2022-05-19 17:43:25 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|