mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-19 05:23:43 +02:00
fix: remove alert dialog from module
This commit is contained in:
parent
6f7ec0b0e6
commit
08532d368a
3 changed files with 9 additions and 31 deletions
|
@ -5,8 +5,8 @@ import 'package:flutter_registration/flutter_registration.dart';
|
||||||
|
|
||||||
class ExampleRegistrationRepository with RegistrationRepository {
|
class ExampleRegistrationRepository with RegistrationRepository {
|
||||||
@override
|
@override
|
||||||
Future<void> register(HashMap values) {
|
Future<bool> register(HashMap values) {
|
||||||
debugPrint('register: $values');
|
debugPrint('register: $values');
|
||||||
return Future.value(null);
|
return Future.value(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,34 +14,12 @@ class RegistrationScreen extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var translations = registrationOptions.registrationTranslations;
|
var translations = registrationOptions.registrationTranslations;
|
||||||
|
|
||||||
void showError(String error) => showDialog<String>(
|
void register(values) =>
|
||||||
context: context,
|
registrationOptions.registrationRepository.register(values).then(
|
||||||
builder: (BuildContext context) => AlertDialog(
|
(response) {
|
||||||
content: Text(error),
|
if (response) {
|
||||||
actions: <Widget>[
|
registrationOptions.afterRegistration();
|
||||||
TextButton(
|
}
|
||||||
onPressed: () => Navigator.pop(
|
|
||||||
context,
|
|
||||||
translations.closeBtn,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
translations.closeBtn,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
void register(values) => registrationOptions.registrationRepository
|
|
||||||
.register(values)
|
|
||||||
.then(
|
|
||||||
(_) => registrationOptions.afterRegistration(),
|
|
||||||
)
|
|
||||||
.catchError(
|
|
||||||
(error) {
|
|
||||||
showError(
|
|
||||||
error.toString(),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
|
||||||
mixin RegistrationRepository {
|
mixin RegistrationRepository {
|
||||||
Future<void> register(HashMap values);
|
Future<bool> register(HashMap values);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue