@@ -2,9 +2,19 @@ package expo.modules.clerk
22
33import android.content.Context
44import android.util.Log
5+ import androidx.compose.foundation.isSystemInDarkTheme
6+ import androidx.compose.foundation.layout.Box
7+ import androidx.compose.foundation.layout.BoxWithConstraints
58import androidx.compose.foundation.layout.fillMaxSize
9+ import androidx.compose.foundation.layout.fillMaxWidth
10+ import androidx.compose.foundation.layout.height
11+ import androidx.compose.material3.ExperimentalMaterial3Api
12+ import androidx.compose.material3.ModalBottomSheet
13+ import androidx.compose.material3.SheetValue
14+ import androidx.compose.material3.rememberModalBottomSheetState
615import androidx.compose.runtime.Composable
716import androidx.compose.ui.Modifier
17+ import androidx.compose.ui.graphics.Color
818import androidx.compose.ui.unit.dp
919import androidx.lifecycle.ViewModelStore
1020import androidx.lifecycle.ViewModelStoreOwner
@@ -30,6 +40,7 @@ class ClerkAuthNativeView(context: Context, appContext: AppContext) : ClerkCompo
3040 var isDismissible: Boolean = true
3141 var logoMaxHeight: Float? = null
3242 var mode: String? = null
43+ var presentation: String = " inline"
3344
3445 private val onAuthEvent by EventDispatcher ()
3546
@@ -61,9 +72,37 @@ class ClerkAuthNativeView(context: Context, appContext: AppContext) : ClerkCompo
6172 }
6273
6374 @Composable
75+ @OptIn(ExperimentalMaterial3Api ::class )
6476 override fun Content () {
65- debugLog(TAG , " setupView - mode: $mode , isDismissible: $isDismissible , activity: $activity " )
77+ debugLog(
78+ TAG ,
79+ " setupView - mode: $mode , presentation: $presentation , isDismissible: $isDismissible , activity: $activity " ,
80+ )
81+
82+ if (presentation != " bottomSheet" ) {
83+ ClerkAuthView ()
84+ return
85+ }
86+
87+ val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = false )
88+ ModalBottomSheet (
89+ onDismissRequest = ::sendDismissEvent,
90+ sheetState = sheetState,
91+ containerColor = clerkBackgroundColor(),
92+ ) {
93+ BoxWithConstraints (modifier = Modifier .fillMaxSize()) {
94+ val authHeight =
95+ if (sheetState.currentValue == SheetValue .Expanded ) maxHeight else maxHeight / 2
96+
97+ Box (modifier = Modifier .fillMaxWidth().height(authHeight)) {
98+ ClerkAuthView ()
99+ }
100+ }
101+ }
102+ }
66103
104+ @Composable
105+ private fun ClerkAuthView () {
67106 AuthView (
68107 modifier = Modifier .fillMaxSize(),
69108 clerkTheme = authTheme(),
@@ -76,6 +115,17 @@ class ClerkAuthNativeView(context: Context, appContext: AppContext) : ClerkCompo
76115 )
77116 }
78117
118+ @Composable
119+ private fun clerkBackgroundColor (): Color {
120+ val isDarkMode = isSystemInDarkTheme()
121+ val customTheme = Clerk .customTheme
122+ val modeColors = if (isDarkMode) customTheme?.darkColors else customTheme?.lightColors
123+
124+ return modeColors?.background
125+ ? : customTheme?.colors?.background
126+ ? : if (isDarkMode) Color (0xFF131316 ) else Color .White
127+ }
128+
79129 private fun authTheme (): ClerkTheme ? {
80130 val maxHeight = logoMaxHeight ? : return Clerk .customTheme
81131 val theme = Clerk .customTheme ? : ClerkTheme ()
@@ -119,6 +169,10 @@ class ClerkAuthViewModule : Module() {
119169 view.logoMaxHeight = logoMaxHeight
120170 }
121171
172+ Prop (" presentation" ) { view: ClerkAuthNativeView , presentation: String? ->
173+ view.presentation = presentation ? : " inline"
174+ }
175+
122176 OnViewDidUpdateProps { view: ClerkAuthNativeView ->
123177 view.setupView()
124178 }
0 commit comments