Skip to content

Commit 383dce7

Browse files
dshukertjrFatumaA
andauthored
feat!: Allow the OAuth provider labels to be overridden on SupaSocialsAuth (#101)
* feat: Allow the OAuth provider labels to be overridden on SocialLogin component * Remove continue with and merge it with oAuthButtonLabels * minor comment edit * fix: add 'Continue with' to localisation, make dynamic * refactor: remove 'update Password' for OAuth flow * remove continue with from social localization --------- Co-authored-by: FatumaA <[email protected]>
1 parent d8ef470 commit 383dce7

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

lib/src/components/supa_socials_auth.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ extension on OAuthProvider {
5454
_ => Colors.black,
5555
};
5656

57-
String get capitalizedName => name[0].toUpperCase() + name.substring(1);
57+
String get labelText =>
58+
'Continue with ${name[0].toUpperCase()}${name.substring(1)}';
5859
}
5960

6061
enum SocialButtonVariant {
@@ -384,7 +385,9 @@ class _SupaSocialsAuthState extends State<SupaSocialsAuth> {
384385
style: authButtonStyle,
385386
onPressed: onAuthButtonPressed,
386387
label: Text(
387-
'${localization.continueWith} ${socialProvider.capitalizedName}'),
388+
localization.oAuthButtonLabels[socialProvider] ??
389+
socialProvider.labelText,
390+
),
388391
),
389392
);
390393
},
Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1+
import 'package:supabase_auth_ui/supabase_auth_ui.dart';
2+
13
class SupaSocialsAuthLocalization {
2-
final String updatePassword;
34
final String successSignInMessage;
45
final String unexpectedError;
5-
final String continueWith;
6+
7+
/// Overrides the name of the OAuth provider shown on the sign-in button.
8+
///
9+
/// Defaults to `Continue with [ProviderName]`
10+
///
11+
/// ```dart
12+
/// SupaSocialsAuth(
13+
/// socialProviders: const [OAuthProvider.azure],
14+
/// localization: const SupaSocialsAuthLocalization(
15+
/// oAuthButtonLabels: {
16+
/// OAuthProvider.azure: 'Microsoft (Azure)'
17+
/// },
18+
/// ),
19+
/// onSuccess: (session) {
20+
/// // sHandle success
21+
/// },
22+
/// ),
23+
/// ```
24+
final Map<OAuthProvider, String> oAuthButtonLabels;
625

726
const SupaSocialsAuthLocalization({
8-
this.updatePassword = 'Update Password',
927
this.successSignInMessage = 'Successfully signed in!',
1028
this.unexpectedError = 'An unexpected error occurred',
11-
this.continueWith = 'Continue with',
29+
this.oAuthButtonLabels = const {},
1230
});
1331
}

0 commit comments

Comments
 (0)