Skip to content

Commit

Permalink
fix(authenticator): Fit social button text
Browse files Browse the repository at this point in the history
Prevent overflow of social button text in constrained layouts by shrinking the text to fit the available width.
  • Loading branch information
Dillon Nys committed Sep 5, 2023
1 parent 802c7c8 commit a1dc8d2
Show file tree
Hide file tree
Showing 212 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

import 'dart:math';

import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_authenticator/src/l10n/auth_strings_resolver.dart';
import 'package:amplify_authenticator/src/state/authenticator_state.dart';
import 'package:amplify_authenticator/src/utils/list.dart';
import 'package:amplify_authenticator/src/widgets/button.dart';
import 'package:amplify_authenticator/src/widgets/component.dart';
import 'package:amplify_authenticator/src/widgets/social/social_icons.dart';
import 'package:aws_common/aws_common.dart';
import 'package:flutter/foundation.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:flutter/foundation.dart' hide Category;
import 'package:flutter/material.dart';

class SocialSignInButtons extends StatelessAuthenticatorComponent {
Expand Down Expand Up @@ -133,6 +132,9 @@ class SocialSignInButton extends AuthenticatorButton<SocialSignInButton> {
class _SocialSignInButtonState
extends AuthenticatorButtonState<SocialSignInButton> {
static const _spacing = 5.0;
static final logger = AmplifyLogger.category(Category.auth)
.createChild('Authenticator')
.createChild('SocialSignInButton');

Widget get icon {
final isDark = Theme.of(context).brightness == Brightness.dark;
Expand Down Expand Up @@ -164,7 +166,7 @@ class _SocialSignInButtonState
],
);
}
safePrint('Unsupported provider: ${widget.provider}');
logger.error('Unsupported provider: ${widget.provider}');
return const SizedBox.shrink();
}

Expand Down Expand Up @@ -219,10 +221,15 @@ class _SocialSignInButtonState
),
),
const SizedBox(width: _spacing),
Text(
resolver.resolve(
context,
ButtonResolverKey.signInWith(widget.provider),
Flexible(
child: FittedBox(
fit: BoxFit.fitWidth,
child: Text(
resolver.resolve(
context,
ButtonResolverKey.signInWith(widget.provider),
),
),
),
),
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ enum TestConfig {
}

enum ScreenGeometry {
/// Geometry for an abitrarily constrained screen width, e.g. when
/// using a `ConstrainedBox` widget.
constrainedWidth(size: Size(200, 1000), pixelRatio: 1),

// Geometry based off of an iPhone SE 2022
mini(size: Size(750, 1334), pixelRatio: 2),

Expand Down

0 comments on commit a1dc8d2

Please sign in to comment.