2024-12-06 15:59:10 +00:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
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';
|
2024-02-09 11:07:03 +00:00
|
|
|
import 'package:selfprivacy/logic/bloc/devices/devices_bloc.dart';
|
2022-05-31 14:30:44 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
2024-12-06 15:59:10 +00:00
|
|
|
import 'package:selfprivacy/ui/organisms/displays/key_display.dart';
|
2022-05-31 14:30:44 +00:00
|
|
|
|
2024-12-06 15:59:10 +00:00
|
|
|
@RoutePage()
|
|
|
|
class NewDevicePage extends StatelessWidget {
|
|
|
|
const NewDevicePage({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(
|
2024-02-09 11:07:03 +00:00
|
|
|
future: context.read<DevicesBloc>().getNewDeviceKey(),
|
2022-06-05 22:40:34 +00:00
|
|
|
builder: (
|
|
|
|
final BuildContext context,
|
|
|
|
final AsyncSnapshot<Object?> snapshot,
|
|
|
|
) {
|
|
|
|
if (snapshot.hasData) {
|
2024-12-06 15:59:10 +00:00
|
|
|
return KeyDisplay(
|
|
|
|
keyToDisplay: snapshot.data.toString(),
|
|
|
|
canCopy: true,
|
|
|
|
infoboxText: 'devices.add_new_device_screen.tip'.tr(),
|
2022-06-05 22:40:34 +00:00
|
|
|
);
|
|
|
|
} else {
|
2024-03-13 15:20:50 +00:00
|
|
|
return const Center(
|
|
|
|
child: CircularProgressIndicator.adaptive(),
|
|
|
|
);
|
2022-06-05 22:40:34 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
2022-05-31 14:30:44 +00:00
|
|
|
}
|