Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Allow the OAuth provider labels to be overridden on SupaSocialsAuth #101

Merged
merged 6 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/src/components/supa_socials_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extension on OAuthProvider {
_ => Colors.black,
};

String get capitalizedName => name[0].toUpperCase() + name.substring(1);
String get labelText => '${name[0].toUpperCase()}${name.substring(1)}';
}

enum SocialButtonVariant {
Expand Down Expand Up @@ -383,8 +383,8 @@ class _SupaSocialsAuthState extends State<SupaSocialsAuth> {
icon: iconWidget,
style: authButtonStyle,
onPressed: onAuthButtonPressed,
label: Text(
'${localization.continueWith} ${socialProvider.capitalizedName}'),
label: Text(localization.oAuthButtonLabels[socialProvider] ??
'${localization.continueWith} ${socialProvider.labelText}'),
),
);
},
Expand Down
28 changes: 24 additions & 4 deletions lib/src/localizations/supa_socials_auth_localization.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
import 'package:supabase_auth_ui/supabase_auth_ui.dart';

class SupaSocialsAuthLocalization {
final String updatePassword;
final String continueWith;
final String successSignInMessage;
final String unexpectedError;
final String continueWith;

/// Overrides the name of the OAuth provider shown on the sign-in button.
///
/// Defaults to `Continue with [ProviderName]`
///
/// ```dart
/// SupaSocialsAuth(
/// socialProviders: const [OAuthProvider.azure],
/// localization: const SupaSocialsAuthLocalization(
/// oAuthButtonLabels: {
/// OAuthProvider.azure: 'Microsoft (Azure)'
/// },
/// ),
/// onSuccess: (session) {
/// // sHandle success
/// },
/// ),
/// ```
final Map<OAuthProvider, String> oAuthButtonLabels;

const SupaSocialsAuthLocalization({
this.updatePassword = 'Update Password',
this.continueWith = 'Continue with',
this.successSignInMessage = 'Successfully signed in!',
this.unexpectedError = 'An unexpected error occurred',
this.continueWith = 'Continue with',
this.oAuthButtonLabels = const {},
});
}
Loading