Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public void configure(ReadableMap configObject) {
: true;
String rawNonce = "";
String nonce = "";
Boolean fullScreen = configObject.hasKey("fullScreen")
? configObject.getBoolean("fullScreen")
: true;

if (configObject.hasKey("clientId")) {
clientId = configObject.getString("clientId");
Expand Down Expand Up @@ -154,6 +157,7 @@ public void configure(ReadableMap configObject) {
.state(state)
.rawNonce(rawNonce)
.nonce(nonce)
.fullScreen(fullScreen)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ data class SignInWithAppleConfiguration private constructor(
val responseType: String,
val state: String,
val rawNonce: String,
val nonce: String
val nonce: String,
val fullScreen: Boolean = true
) {
class Builder {
private lateinit var clientId: String
Expand All @@ -17,6 +18,7 @@ data class SignInWithAppleConfiguration private constructor(
private lateinit var state: String
private lateinit var rawNonce: String
private lateinit var nonce: String
private var fullScreen: Boolean = true

fun clientId(clientId: String) = apply {
this.clientId = clientId
Expand Down Expand Up @@ -46,7 +48,11 @@ data class SignInWithAppleConfiguration private constructor(
this.nonce = nonce
}

fun build() = SignInWithAppleConfiguration(clientId, redirectUri, scope, responseType, state, rawNonce, nonce)
fun fullScreen(fullScreen: Boolean) = apply {
this.fullScreen = fullScreen
}

fun build() = SignInWithAppleConfiguration(clientId, redirectUri, scope, responseType, state, rawNonce, nonce, fullScreen)
}

enum class ResponseType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class SignInWithAppleService(
}

fun show() {
val fragment = SignInWebViewDialogFragment.newInstance(AuthenticationAttempt.create(configuration))
val fragment = SignInWebViewDialogFragment.newInstance(AuthenticationAttempt.create(configuration), configuration.fullScreen)
fragment.configure(callback)
fragment.show(fragmentManager, fragmentTag)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import com.RNAppleAuthentication.SignInWithAppleService
internal class SignInWebViewDialogFragment : DialogFragment() {
companion object {
private const val AUTHENTICATION_ATTEMPT_KEY = "authenticationAttempt"
private const val FULL_SCREEN_KEY = "fullScreen"
private const val WEB_VIEW_KEY = "webView"

fun newInstance(authenticationAttempt: SignInWithAppleService.AuthenticationAttempt): SignInWebViewDialogFragment {
fun newInstance(authenticationAttempt: SignInWithAppleService.AuthenticationAttempt, fullScreen: Boolean): SignInWebViewDialogFragment {
val fragment = SignInWebViewDialogFragment()
fragment.arguments = Bundle().apply {
putParcelable(AUTHENTICATION_ATTEMPT_KEY, authenticationAttempt)
putBoolean(FULL_SCREEN_KEY, fullScreen)
}
return fragment
}
Expand All @@ -40,7 +42,13 @@ internal class SignInWebViewDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
authenticationAttempt = arguments?.getParcelable(AUTHENTICATION_ATTEMPT_KEY)!!
setStyle(STYLE_NORMAL, R.style.sign_in_with_apple_button_DialogTheme)
val fullScreen = arguments?.getBoolean(FULL_SCREEN_KEY, true) ?: true
setStyle(STYLE_NORMAL, R.style.sign_in_with_apple_button_DialogTheme);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This becomes redundant if fullScreen is false. It could go in the else block for the condition below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough 👍


// If fullScreen mode is disabled, use floating dialog theme
if (!fullScreen) {
setStyle(STYLE_NO_TITLE, R.style.sign_in_with_apple_button_DialogTheme_Floating);
}
}

override fun onCreateView(
Expand Down
5 changes: 4 additions & 1 deletion android/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
<style name="sign_in_with_apple_button_DialogTheme" parent="android:Theme.DeviceDefault.NoActionBar">
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
</style>
</resources>
<style name="sign_in_with_apple_button_DialogTheme_Floating" parent="android:Theme.DeviceDefault.NoActionBar">
<item name="android:windowIsFloating">true</item>
</style>
</resources>
11 changes: 11 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,17 @@ export interface AndroidConfig {
* Defaults to true.
*/
nonceEnabled?: boolean;

/**
* Full screen mode
*
* When true, it covers the entire screen including the status bar.
*
* When false, the dialog fits within the app window only.
*
* Defaults to true
*/
fullScreen?: boolean;
}

export interface AndroidSigninResponse {
Expand Down
16 changes: 16 additions & 0 deletions typedocs/interfaces/AndroidConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ The developer’s client identifier, as provided by WWDR.

***

### fullScreen?

> `optional` **fullScreen**: `boolean`

Defined in: [index.d.ts:557](https://github.com/NJ-2020/react-native-apple-authentication/blob/b0991056e27c66a368684bc0fba99637aa01122a/lib/index.d.ts#L557)

Full screen mode

When true, it covers the entire screen including the status bar.

When false, the dialog fits within the app window only.

Defaults to true

***

### nonce?

> `optional` **nonce**: `string`
Expand Down
Loading