Skip to content

Commit 3d51af3

Browse files
committed
TMP trigger actions
1 parent b517216 commit 3d51af3

File tree

3 files changed

+40
-56
lines changed

3 files changed

+40
-56
lines changed

packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ class StateMachineBloc
377377
final result = await _authService.signIn(data.username, data.password);
378378
await _processSignInResult(result, isSocialSignIn: false);
379379
} else if (data is AuthSocialSignInData) {
380+
// Do not await a social sign-in since multiple sign-in attempts
381+
// can occur.
380382
await _authService
381383
.signInWithProvider(
382384
data.provider,
@@ -390,13 +392,6 @@ class StateMachineBloc
390392
? logger.info
391393
: logger.error;
392394
log('Error signing in', error, stackTrace);
393-
// Emit exception so that the UI can exit loading state
394-
_exceptionController.add(
395-
AuthenticatorException(
396-
error,
397-
showBanner: error is! UserCancelledException,
398-
),
399-
);
400395
});
401396
} else {
402397
throw StateError('Bad sign in data: $data');

packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,15 +529,10 @@ class AuthenticatorState extends ChangeNotifier {
529529
_setIsBusy(false);
530530
}
531531

532-
/// Perform social sign in with the given provider
532+
/// Perform sicial sign in with the given provider
533533
Future<void> signInWithProvider(AuthProvider provider) async {
534-
_setIsBusy(true);
535534
final signInData = AuthSocialSignInData(provider: provider);
536535
_authBloc.add(AuthSignIn(signInData));
537-
// Wait for either a state change (sign-in success/failure) or an exception
538-
// (including user cancellation)
539-
await nextBlocEvent();
540-
_setIsBusy(false);
541536
}
542537

543538
/// Sign out the currecnt user

packages/authenticator/amplify_authenticator/lib/src/widgets/social/social_button.dart

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -193,53 +193,47 @@ class _SocialSignInButtonState
193193
@override
194194
Widget build(BuildContext context) {
195195
final resolver = stringResolver.buttons;
196-
final isBusy = state.isBusy;
197-
return Opacity(
198-
opacity: isBusy ? 0.5 : 1.0,
199-
child: ConstrainedBox(
200-
constraints: const BoxConstraints(minHeight: 40),
201-
child: OutlinedButton(
202-
focusNode: focusNode,
203-
style: ButtonStyle(
204-
foregroundColor: getButtonForegroundColor(context),
205-
),
206-
onPressed: isBusy
207-
? null
208-
: () => state.signInWithProvider(widget.provider),
209-
child: LayoutBuilder(
210-
builder: (context, constraints) {
211-
final padding = calculatePadding(constraints);
212-
return Padding(
213-
padding: EdgeInsets.symmetric(horizontal: padding),
214-
child: Row(
215-
mainAxisAlignment: padding == 0
216-
? MainAxisAlignment.center
217-
: MainAxisAlignment.start,
218-
children: [
219-
SizedBox.square(
220-
dimension: logoSize,
221-
child: Padding(
222-
padding: widget.provider.logoInsets,
223-
child: icon,
224-
),
196+
return ConstrainedBox(
197+
constraints: const BoxConstraints(minHeight: 40),
198+
child: OutlinedButton(
199+
focusNode: focusNode,
200+
style: ButtonStyle(foregroundColor: getButtonForegroundColor(context)),
201+
onPressed: state.isBusy
202+
? null
203+
: () => state.signInWithProvider(widget.provider),
204+
child: LayoutBuilder(
205+
builder: (context, constraints) {
206+
final padding = calculatePadding(constraints);
207+
return Padding(
208+
padding: EdgeInsets.symmetric(horizontal: padding),
209+
child: Row(
210+
mainAxisAlignment: padding == 0
211+
? MainAxisAlignment.center
212+
: MainAxisAlignment.start,
213+
children: [
214+
SizedBox.square(
215+
dimension: logoSize,
216+
child: Padding(
217+
padding: widget.provider.logoInsets,
218+
child: icon,
225219
),
226-
const SizedBox(width: spacing),
227-
Expanded(
228-
child: Padding(
229-
padding: const EdgeInsets.symmetric(vertical: 4),
230-
child: Text(
231-
resolver.resolve(
232-
context,
233-
ButtonResolverKey.signInWith(widget.provider),
234-
),
220+
),
221+
const SizedBox(width: spacing),
222+
Expanded(
223+
child: Padding(
224+
padding: const EdgeInsets.symmetric(vertical: 4),
225+
child: Text(
226+
resolver.resolve(
227+
context,
228+
ButtonResolverKey.signInWith(widget.provider),
235229
),
236230
),
237231
),
238-
],
239-
),
240-
);
241-
},
242-
),
232+
),
233+
],
234+
),
235+
);
236+
},
243237
),
244238
),
245239
);

0 commit comments

Comments
 (0)