Skip to content
Closed
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
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
}
}

Expand Down
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.47-local"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be replaced by version of supabase-kt-plugins once it support spm4kmp for Google OAuth iOS


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

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

fun resetPassword(email: String) {
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,10 @@ val supabaseModule = module {
flowType = FlowType.PKCE
}
install(Realtime)
install(ComposeAuth) {
googleNativeLogin(serverClientId = "YOUR_WEB_CLIENT_ID")
appleNativeLogin()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Mail
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
Expand All @@ -30,17 +29,21 @@ import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import io.github.jan.supabase.annotations.SupabaseExperimental
import co.touchlab.kermit.Logger
import io.github.jan.supabase.auth.providers.Google
import io.github.jan.supabase.common.ChatViewModel
import io.github.jan.supabase.common.ui.components.OTPDialog
import io.github.jan.supabase.common.ui.components.OTPDialogState
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.composable.NativeSignInResult
import io.github.jan.supabase.compose.auth.composable.rememberSignInWithGoogle
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

@OptIn(ExperimentalMaterial3Api::class, SupabaseExperimental::class, AuthUiExperimental::class)
@OptIn(AuthUiExperimental::class)
@Composable
fun LoginScreen(viewModel: ChatViewModel) {
var signUp by remember { mutableStateOf(false) }
Expand All @@ -49,6 +52,29 @@ fun LoginScreen(viewModel: ChatViewModel) {
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,6 +120,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
21 changes: 9 additions & 12 deletions sample/chat-demo-mpp/ios/chatdemoios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objectVersion = 60;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -23,21 +23,19 @@
65E1CD792E79AA2500DACC1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
6581F14B2B36C0CF00BA34A9 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
/* Begin PBXGroup section */
657152FA2EAFC4B20046C115 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
runOnlyForDeploymentPostprocessing = 0;
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
6581F1452B36C0CF00BA34A9 = {
isa = PBXGroup;
children = (
6581F1502B36C0CF00BA34A9 /* chatdemoios */,
657152FA2EAFC4B20046C115 /* Frameworks */,
6581F14F2B36C0CF00BA34A9 /* Products */,
);
sourceTree = "<group>";
Expand Down Expand Up @@ -80,7 +78,6 @@
buildPhases = (
656500D42B3962F0005F97B4 /* ShellScript */,
6581F14A2B36C0CF00BA34A9 /* Sources */,
6581F14B2B36C0CF00BA34A9 /* Frameworks */,
6581F14C2B36C0CF00BA34A9 /* Resources */,
);
buildRules = (
Expand Down Expand Up @@ -320,7 +317,7 @@
MACOSX_DEPLOYMENT_TARGET = 14.1;
MARKETING_VERSION = 1.0;
OTHER_LDFLAGS = "\"$(inherited) -framework common\"";
"OTHER_LDFLAGS[arch=*]" = "";
"OTHER_LDFLAGS[arch=*]" = "\"-ObjC -fObjC\"";
PRODUCT_BUNDLE_IDENTIFIER = com.chatdemo.chatdemoios;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>Promises (Playground).xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<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_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_CLIENT_ID</string>
</array>
</dict>
</array>
</dict>
</plist>
Loading