2022-11-01 09:19:20 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022 Iconica
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
2022-09-27 12:00:03 +02:00
|
|
|
import 'dart:collection';
|
|
|
|
|
2022-09-20 15:51:22 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_registration/flutter_registration.dart';
|
|
|
|
import 'package:flutter_registration/src/auth_screen.dart';
|
|
|
|
|
|
|
|
class RegistrationScreen extends StatelessWidget {
|
|
|
|
const RegistrationScreen({
|
2022-09-26 10:35:53 +02:00
|
|
|
required this.registrationOptions,
|
2022-09-20 15:51:22 +02:00
|
|
|
super.key,
|
|
|
|
});
|
|
|
|
|
2022-09-26 10:35:53 +02:00
|
|
|
final RegistrationOptions registrationOptions;
|
2022-09-20 15:51:22 +02:00
|
|
|
|
2023-03-31 11:15:48 +02:00
|
|
|
Future<void> register({
|
|
|
|
required HashMap<String, String> values,
|
|
|
|
required VoidCallback onError,
|
|
|
|
}) async {
|
|
|
|
try {
|
|
|
|
var registered =
|
|
|
|
await registrationOptions.registrationRepository.register(values);
|
|
|
|
if (registered) {
|
|
|
|
registrationOptions.afterRegistration();
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
onError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-20 15:51:22 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-26 10:35:53 +02:00
|
|
|
var translations = registrationOptions.registrationTranslations;
|
|
|
|
|
2022-09-20 15:51:22 +02:00
|
|
|
return AuthScreen(
|
2022-09-26 10:35:53 +02:00
|
|
|
steps: registrationOptions.registrationSteps,
|
2022-09-28 09:23:41 +02:00
|
|
|
customAppBar: registrationOptions.customAppbarBuilder?.call(
|
|
|
|
translations.title,
|
|
|
|
),
|
2022-09-22 11:48:04 +02:00
|
|
|
onFinish: register,
|
2022-09-26 10:35:53 +02:00
|
|
|
title: translations.title,
|
|
|
|
submitBtnTitle: translations.registerBtn,
|
|
|
|
nextBtnTitle: translations.nextStepBtn,
|
|
|
|
previousBtnTitle: translations.previousStepBtn,
|
2023-02-16 15:02:03 +01:00
|
|
|
nextButtonBuilder: registrationOptions.nextButtonBuilder,
|
|
|
|
previousButtonBuilder: registrationOptions.previousButtonBuilder,
|
2022-09-20 15:51:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|