Skip to content

Commit ba8c91c

Browse files
committed
fix status bar color
1 parent 536a68e commit ba8c91c

File tree

2 files changed

+39
-41
lines changed

2 files changed

+39
-41
lines changed

app/src/main/java/com/firebase/uidemo/auth/compose/AuthComposeActivity.kt

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,34 @@ import android.os.Bundle
66
import androidx.activity.ComponentActivity
77
import androidx.activity.compose.setContent
88
import androidx.compose.foundation.layout.fillMaxSize
9-
import androidx.compose.material3.MaterialTheme
109
import androidx.compose.material3.Surface
1110
import androidx.compose.ui.Modifier
12-
import com.firebase.ui.auth.AuthUI
11+
import androidx.compose.ui.graphics.Color
12+
import androidx.compose.ui.graphics.toArgb
13+
import androidx.core.view.WindowCompat
1314
import com.firebase.ui.auth.data.model.FirebaseAuthUIAuthenticationResult
14-
import com.firebase.uidemo.R
1515
import com.firebase.uidemo.auth.SignedInActivity
1616
import com.firebase.uidemo.ui.theme.FirebaseUIDemoTheme
1717

1818
class AuthComposeActivity : ComponentActivity() {
1919
override fun onCreate(savedInstanceState: Bundle?) {
2020
super.onCreate(savedInstanceState)
21+
22+
// Configure system UI
23+
window.apply {
24+
statusBarColor = Color.White.toArgb()
25+
navigationBarColor = Color.White.toArgb()
26+
27+
WindowCompat.getInsetsController(this, decorView).apply {
28+
isAppearanceLightStatusBars = true
29+
isAppearanceLightNavigationBars = true
30+
}
31+
}
32+
2133
setContent {
2234
FirebaseUIDemoTheme {
23-
Surface(
24-
modifier = Modifier.fillMaxSize(),
25-
color = MaterialTheme.colorScheme.background
26-
) {
27-
AuthScreen { result ->
28-
handleSignInResponse(result)
29-
}
35+
Surface(modifier = Modifier.fillMaxSize(), color = Color.White) {
36+
AuthScreen { result -> handleSignInResponse(result) }
3037
}
3138
}
3239
}
@@ -35,20 +42,16 @@ class AuthComposeActivity : ComponentActivity() {
3542
private fun handleSignInResponse(result: FirebaseAuthUIAuthenticationResult) {
3643
when (result.resultCode) {
3744
RESULT_OK -> {
38-
// Successfully signed in
3945
val response = result.idpResponse
4046
startActivity(SignedInActivity.createIntent(this, response))
4147
finish()
4248
}
4349
else -> {
44-
// Sign in failed
4550
val response = result.idpResponse
4651
if (response == null) {
47-
// User pressed back button
4852
finish()
4953
return
5054
}
51-
// Handle other error cases
5255
}
5356
}
5457
}
@@ -58,4 +61,4 @@ class AuthComposeActivity : ComponentActivity() {
5861
return Intent(context, AuthComposeActivity::class.java)
5962
}
6063
}
61-
}
64+
}
Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
11
package com.firebase.uidemo.auth.compose
22

3+
import androidx.compose.foundation.background
34
import androidx.compose.foundation.layout.Box
45
import androidx.compose.foundation.layout.fillMaxSize
5-
import androidx.compose.material3.CircularProgressIndicator
66
import androidx.compose.runtime.Composable
7-
import androidx.compose.ui.Alignment
87
import androidx.compose.ui.Modifier
9-
import com.firebase.ui.auth.AuthUI
8+
import androidx.compose.ui.graphics.Color
109
import com.firebase.ui.auth.AuthUI.IdpConfig
11-
import com.firebase.ui.auth.data.model.FirebaseAuthUIAuthenticationResult
1210
import com.firebase.ui.auth.compose.FirebaseAuthUI
11+
import com.firebase.ui.auth.data.model.FirebaseAuthUIAuthenticationResult
1312
import com.firebase.uidemo.R
1413

1514
@Composable
16-
fun AuthScreen(
17-
onSignInResult: (FirebaseAuthUIAuthenticationResult) -> Unit
18-
) {
19-
val providers = listOf(
20-
IdpConfig.GoogleBuilder().build(),
21-
IdpConfig.EmailBuilder().build(),
22-
)
23-
24-
FirebaseAuthUI(
25-
providers = providers,
26-
onSignInResult = { result -> /* optional logging */ },
27-
28-
signedInContent = {
29-
SignedInScreen(idpResponse = null) {
30-
}
31-
},
15+
fun AuthScreen(onSignInResult: (FirebaseAuthUIAuthenticationResult) -> Unit) {
16+
val providers =
17+
listOf(
18+
IdpConfig.GoogleBuilder().build(),
19+
IdpConfig.EmailBuilder().build(),
20+
)
3221

33-
theme = R.style.AppTheme,
34-
logo = R.drawable.firebase_auth_120dp,
35-
tosUrl = "https://www.google.com/policies/terms/",
36-
privacyPolicyUrl = "https://www.google.com/policies/privacy/"
37-
)
38-
}
22+
Box(modifier = Modifier.fillMaxSize().background(Color.White)) {
23+
FirebaseAuthUI(
24+
providers = providers,
25+
onSignInResult = { result -> /* optional logging */ },
26+
signedInContent = { SignedInScreen(idpResponse = null) {} },
27+
theme = R.style.AppTheme,
28+
logo = R.drawable.firebase_auth_120dp,
29+
tosUrl = "https://www.google.com/policies/terms/",
30+
privacyPolicyUrl = "https://www.google.com/policies/privacy/"
31+
)
32+
}
33+
}

0 commit comments

Comments
 (0)