mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-19 13:23:45 +02:00
feat: go back to first page on error - hide keyboard on nextStep
This commit is contained in:
parent
188a174cbd
commit
3242002182
2 changed files with 23 additions and 4 deletions
|
@ -15,7 +15,10 @@ class AuthScreen extends StatefulWidget {
|
||||||
}) : assert(steps.length > 0, 'At least one step is required');
|
}) : assert(steps.length > 0, 'At least one step is required');
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
final Function(HashMap<String, String>) onFinish;
|
final Function({
|
||||||
|
required HashMap<String, String> values,
|
||||||
|
required VoidCallback onError,
|
||||||
|
}) onFinish;
|
||||||
final List<AuthStep> steps;
|
final List<AuthStep> steps;
|
||||||
final String submitBtnTitle;
|
final String submitBtnTitle;
|
||||||
final String nextBtnTitle;
|
final String nextBtnTitle;
|
||||||
|
@ -119,6 +122,8 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
|
||||||
if (widget.steps.last == step) {
|
if (widget.steps.last == step) {
|
||||||
var values = HashMap<String, String>();
|
var values = HashMap<String, String>();
|
||||||
|
|
||||||
|
@ -128,7 +133,14 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.onFinish(values);
|
widget.onFinish(
|
||||||
|
values: values,
|
||||||
|
onError: () => _pageController.animateToPage(
|
||||||
|
0,
|
||||||
|
duration: _animationDuration,
|
||||||
|
curve: _animationCurve,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:collection';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_registration/flutter_registration.dart';
|
import 'package:flutter_registration/flutter_registration.dart';
|
||||||
import 'package:flutter_registration/src/auth_screen.dart';
|
import 'package:flutter_registration/src/auth_screen.dart';
|
||||||
|
@ -14,14 +16,19 @@ class RegistrationScreen extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var translations = registrationOptions.registrationTranslations;
|
var translations = registrationOptions.registrationTranslations;
|
||||||
|
|
||||||
void register(values) =>
|
void register({
|
||||||
|
required HashMap<String, String> values,
|
||||||
|
required VoidCallback onError,
|
||||||
|
}) =>
|
||||||
registrationOptions.registrationRepository.register(values).then(
|
registrationOptions.registrationRepository.register(values).then(
|
||||||
(response) {
|
(response) {
|
||||||
if (response) {
|
if (response) {
|
||||||
registrationOptions.afterRegistration();
|
registrationOptions.afterRegistration();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
).catchError((_) {
|
||||||
|
onError();
|
||||||
|
});
|
||||||
|
|
||||||
return AuthScreen(
|
return AuthScreen(
|
||||||
steps: registrationOptions.registrationSteps,
|
steps: registrationOptions.registrationSteps,
|
||||||
|
|
Loading…
Reference in a new issue