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
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-26 10:35:53 +02:00
|
|
|
var translations = registrationOptions.registrationTranslations;
|
|
|
|
|
2022-09-27 12:00:03 +02:00
|
|
|
void register({
|
|
|
|
required HashMap<String, String> values,
|
|
|
|
required VoidCallback onError,
|
|
|
|
}) =>
|
2022-09-26 12:00:03 +02:00
|
|
|
registrationOptions.registrationRepository.register(values).then(
|
|
|
|
(response) {
|
|
|
|
if (response) {
|
|
|
|
registrationOptions.afterRegistration();
|
|
|
|
}
|
2022-09-20 15:51:22 +02:00
|
|
|
},
|
2022-09-27 12:00:03 +02:00
|
|
|
).catchError((_) {
|
|
|
|
onError();
|
|
|
|
});
|
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,
|
2022-09-20 15:51:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|