2022-05-31 14:30:44 +00:00
|
|
|
import 'package:cubit_form/cubit_form.dart';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/devices/devices_cubit.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_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-31 14:30:44 +00:00
|
|
|
|
|
|
|
class NewDeviceScreen extends StatelessWidget {
|
2022-10-26 16:26:09 +00:00
|
|
|
const NewDeviceScreen({super.key});
|
2022-05-31 14:30:44 +00:00
|
|
|
|
|
|
|
@override
|
2022-06-05 19:36:32 +00:00
|
|
|
Widget build(final BuildContext context) => BrandHeroScreen(
|
2022-06-05 22:40:34 +00:00
|
|
|
heroTitle: 'devices.add_new_device_screen.header'.tr(),
|
|
|
|
heroSubtitle: 'devices.add_new_device_screen.description'.tr(),
|
|
|
|
hasBackButton: true,
|
|
|
|
hasFlashButton: false,
|
|
|
|
children: [
|
|
|
|
FutureBuilder(
|
|
|
|
future: context.read<ApiDevicesCubit>().getNewDeviceKey(),
|
|
|
|
builder: (
|
|
|
|
final BuildContext context,
|
|
|
|
final AsyncSnapshot<Object?> snapshot,
|
|
|
|
) {
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
return _KeyDisplay(
|
|
|
|
newDeviceKey: snapshot.data.toString(),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return const Center(child: CircularProgressIndicator());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
2022-05-31 14:30:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class _KeyDisplay extends StatelessWidget {
|
2022-06-05 22:40:34 +00:00
|
|
|
const _KeyDisplay({required this.newDeviceKey});
|
2022-05-31 14:30:44 +00:00
|
|
|
final String newDeviceKey;
|
|
|
|
|
|
|
|
@override
|
2022-06-05 19:36:32 +00:00
|
|
|
Widget build(final BuildContext context) => Column(
|
2022-06-05 22:40:34 +00:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
const Divider(),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
Text(
|
|
|
|
newDeviceKey,
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
|
|
|
|
fontSize: 24,
|
|
|
|
fontFamily: 'RobotoMono',
|
|
|
|
),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
const Divider(),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Icon(
|
|
|
|
Icons.info_outline,
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
2022-05-31 14:30:44 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
Text(
|
|
|
|
'devices.add_new_device_screen.tip'.tr(),
|
2022-06-09 21:13:06 +00:00
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
2023-02-05 13:24:37 +00:00
|
|
|
BrandButton.filled(
|
2022-06-05 22:40:34 +00:00
|
|
|
child: Text(
|
|
|
|
'basis.done'.tr(),
|
2022-05-31 14:30:44 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
2022-05-31 14:30:44 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
const SizedBox(height: 24),
|
|
|
|
],
|
|
|
|
);
|
2022-05-31 14:30:44 +00:00
|
|
|
}
|