refactor(auth): update example with new listeners
This commit is contained in:
parent
38480d84f4
commit
762b9bcd11
@ -3,12 +3,11 @@
|
|||||||
// -----
|
// -----
|
||||||
// File: sign_in_form.dart
|
// File: sign_in_form.dart
|
||||||
// Created Date: 19/08/2022 15:24:37
|
// Created Date: 19/08/2022 15:24:37
|
||||||
// Last Modified: Thu Nov 10 2022
|
// Last Modified: Fri Nov 11 2022
|
||||||
// -----
|
// -----
|
||||||
// Copyright (c) 2022
|
// Copyright (c) 2022
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
|
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
|
||||||
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
|
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
|
||||||
|
|
||||||
@ -73,16 +72,12 @@ class SignInForm extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocListener<SignInCubit<int>, SignInState>(
|
return SignInListener(
|
||||||
listener: (context, state) {
|
onError: (context, status, errorMessage) => ScaffoldMessenger.of(context)
|
||||||
if (state.status.isSubmissionFailure) {
|
..hideCurrentSnackBar()
|
||||||
ScaffoldMessenger.of(context)
|
..showSnackBar(
|
||||||
..hideCurrentSnackBar()
|
SnackBar(content: Text(errorMessage ?? 'Sign In Failure')),
|
||||||
..showSnackBar(
|
),
|
||||||
SnackBar(content: Text(state.errorMessage ?? 'Sign In Failure')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
@ -3,13 +3,12 @@
|
|||||||
// -----
|
// -----
|
||||||
// File: sign_up_form.dart
|
// File: sign_up_form.dart
|
||||||
// Created Date: 19/08/2022 14:41:08
|
// Created Date: 19/08/2022 14:41:08
|
||||||
// Last Modified: Thu Nov 10 2022
|
// Last Modified: Fri Nov 11 2022
|
||||||
// -----
|
// -----
|
||||||
// Copyright (c) 2022
|
// Copyright (c) 2022
|
||||||
|
|
||||||
import 'package:example_router/core/constants/form_field.dart';
|
import 'package:example_router/core/constants/form_field.dart';
|
||||||
import 'package:flutter/material.dart' hide FormField;
|
import 'package:flutter/material.dart' hide FormField;
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
|
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
|
||||||
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
|
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
|
||||||
|
|
||||||
@ -110,29 +109,25 @@ class SignUpForm extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocListener<SignUpCubit<int>, SignUpState>(
|
return SignUpListener(
|
||||||
listener: (context, state) {
|
onError: (context, status, errorMessage) =>
|
||||||
if (state.status.isSubmissionFailure) {
|
ScaffoldMessenger.of(context)
|
||||||
ScaffoldMessenger.of(context)
|
..hideCurrentSnackBar()
|
||||||
..hideCurrentSnackBar()
|
..showSnackBar(
|
||||||
..showSnackBar(
|
SnackBar(content: Text(errorMessage ?? 'Sign Up Failure')),
|
||||||
SnackBar(content: Text(state.errorMessage ?? 'Sign Up Failure')),
|
),
|
||||||
);
|
child: SingleChildScrollView(
|
||||||
}
|
child: Column(
|
||||||
},
|
children: [
|
||||||
child: SingleChildScrollView(
|
_EmailInput(),
|
||||||
child: Column(
|
const SizedBox(height: 8),
|
||||||
children: [
|
_PasswordInput(),
|
||||||
_EmailInput(),
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 8),
|
_ConfirmPasswordInput(),
|
||||||
_PasswordInput(),
|
const SizedBox(height: 16),
|
||||||
const SizedBox(height: 8),
|
_SignUpButton(),
|
||||||
_ConfirmPasswordInput(),
|
],
|
||||||
const SizedBox(height: 16),
|
),
|
||||||
_SignUpButton(),
|
));
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user