Skip to content
Open
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
2 changes: 1 addition & 1 deletion sample/chat-demo-mpp/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {

group = "io.github.jan.supabase"
version = "1.0-SNAPSHOT"
val pluginVersion = "3.2.0"
val pluginVersion = "3.2.7"

kotlin {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ class ChatViewModel(
}
}

fun handleSignInWithGoogleResult() {
alert.value = "Successfully signed in with Google!"
}

fun logout() {
coroutineScope.launch {
kotlin.runCatching {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package io.github.jan.supabase.common.di
import io.github.jan.supabase.auth.Auth
import io.github.jan.supabase.auth.AuthConfig
import io.github.jan.supabase.auth.FlowType
import io.github.jan.supabase.compose.auth.ComposeAuth
import io.github.jan.supabase.compose.auth.appleNativeLogin
import io.github.jan.supabase.compose.auth.googleNativeLogin
import io.github.jan.supabase.createSupabaseClient
import io.github.jan.supabase.logging.LogLevel
import io.github.jan.supabase.postgrest.Postgrest
Expand All @@ -24,6 +27,9 @@ val supabaseModule = module {
flowType = FlowType.PKCE
}
install(Realtime)
install(ComposeAuth) {
googleNativeLogin(serverClientId = "YOUR_WEB_CLIENT_ID")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ import io.github.jan.supabase.common.ui.components.PasswordField
import io.github.jan.supabase.common.ui.components.PasswordRecoveryDialog
import io.github.jan.supabase.compose.auth.ui.ProviderButtonContent
import io.github.jan.supabase.compose.auth.ui.annotations.AuthUiExperimental

import io.github.jan.supabase.compose.auth.composeAuth
import io.github.jan.supabase.compose.auth.ui.ProviderIcon
import io.github.jan.supabase.compose.auth.composable.NativeSignInResult
import io.github.jan.supabase.compose.auth.composable.rememberSignInWithGoogle
import co.touchlab.kermit.Logger
@OptIn(ExperimentalMaterial3Api::class, SupabaseExperimental::class, AuthUiExperimental::class)
@Composable
fun LoginScreen(viewModel: ChatViewModel) {
Expand All @@ -48,7 +52,28 @@ fun LoginScreen(viewModel: ChatViewModel) {
var email by remember { mutableStateOf("") }
var otpDialogState by remember { mutableStateOf<OTPDialogState>(OTPDialogState.Invisible) }
var showPasswordRecoveryDialog by remember { mutableStateOf(false) }
val action = viewModel.supabaseClient.composeAuth.rememberSignInWithGoogle(
onResult = { result ->
when (result) {
is NativeSignInResult.Success -> {
viewModel.handleSignInWithGoogleResult()
Logger.d("LoginScreen - Success")
}

is NativeSignInResult.ClosedByUser -> {
Logger.d("LoginScreen - ClosedByUser")
}

is NativeSignInResult.Error -> {
Logger.d("LoginScreen - Error")
}

is NativeSignInResult.NetworkError -> {
Logger.d("LoginScreen - Network Error")
}
}
},
)
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
Expand Down Expand Up @@ -94,7 +119,14 @@ fun LoginScreen(viewModel: ChatViewModel) {
) {
ProviderButtonContent(Google, text = if (signUp) "Sign Up with Google" else "Login with Google")
}

Button(
onClick = {
action.startFlow()
},
) {
ProviderIcon(Google, contentDescription = null)
Text("Native Sign In with Google")
}
TextButton(
onClick = { otpDialogState = OTPDialogState.Visible(email) }
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>chatdemoios.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
Expand Down
15 changes: 15 additions & 0 deletions sample/chat-demo-mpp/ios/chatdemoios/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>io.github.jan.supabase.ios</string>
<key>GIDClientID</key>
<string>YOUR_IOS_CLIENT_ID</string>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>YOUR_REVERSED_IOS_CLIENT_ID</string>
</array>
</dict>
</array>
</dict>
</plist>
Loading