2022-11-01 09:19:20 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022 Iconica
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
2022-09-28 09:23:41 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-09-26 10:35:53 +02:00
|
|
|
import 'package:flutter_registration/flutter_registration.dart';
|
|
|
|
|
|
|
|
class RegistrationOptions {
|
|
|
|
RegistrationOptions({
|
|
|
|
required this.registrationRepository,
|
|
|
|
required this.registrationSteps,
|
|
|
|
required this.afterRegistration,
|
|
|
|
this.registrationTranslations = const RegistrationTranslations(),
|
2022-09-28 09:23:41 +02:00
|
|
|
this.customAppbarBuilder,
|
2022-09-26 10:35:53 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
final RegistrationTranslations registrationTranslations;
|
|
|
|
final List<AuthStep> registrationSteps;
|
|
|
|
final VoidCallback afterRegistration;
|
|
|
|
final RegistrationRepository registrationRepository;
|
2022-09-28 09:23:41 +02:00
|
|
|
final AppBar Function(String title)? customAppbarBuilder;
|
2022-09-26 10:35:53 +02:00
|
|
|
|
2022-11-04 11:38:16 +01:00
|
|
|
static List<AuthStep> getDefaultSteps({
|
|
|
|
RegistrationTranslations translations = const RegistrationTranslations(),
|
|
|
|
}) =>
|
|
|
|
[
|
2022-09-26 10:35:53 +02:00
|
|
|
AuthStep(
|
|
|
|
fields: [
|
|
|
|
AuthTextField(
|
|
|
|
name: 'email',
|
2022-11-04 11:38:16 +01:00
|
|
|
title: translations.defaultEmailTitle,
|
|
|
|
hintText: translations.defaultEmailHint,
|
2022-09-26 10:35:53 +02:00
|
|
|
validators: [
|
|
|
|
(email) => (email == null || email.isEmpty)
|
2022-11-04 11:38:16 +01:00
|
|
|
? translations.defaultEmailEmpty
|
2022-09-26 10:35:53 +02:00
|
|
|
: null,
|
|
|
|
(email) =>
|
2022-11-04 11:38:16 +01:00
|
|
|
RegExp(r"""(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])""")
|
2022-09-26 10:35:53 +02:00
|
|
|
.hasMatch(email!)
|
|
|
|
? null
|
2022-11-04 11:38:16 +01:00
|
|
|
: translations.defaultEmailValidatorMessage,
|
2022-09-26 10:35:53 +02:00
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
AuthStep(
|
|
|
|
fields: [
|
|
|
|
AuthTextField(
|
|
|
|
name: 'password',
|
2022-11-04 11:38:16 +01:00
|
|
|
title: translations.defaultPasswordTitle,
|
|
|
|
hintText: translations.defaultPasswordHint,
|
2022-09-26 10:35:53 +02:00
|
|
|
obscureText: true,
|
|
|
|
validators: [
|
|
|
|
(value) => (value == null || value.isEmpty)
|
2022-11-04 11:38:16 +01:00
|
|
|
? translations.defaultPasswordValidatorMessage
|
2022-09-26 10:35:53 +02:00
|
|
|
: null,
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
];
|
|
|
|
}
|