generated from JetBrains/compose-multiplatform-ios-android-template
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
688340d
commit 1b559e1
Showing
9 changed files
with
302 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package domain.model | ||
|
||
enum class AuthProvider { | ||
GOOGLE, APPLE, GITHUB | ||
} |
137 changes: 137 additions & 0 deletions
137
shared/src/commonMain/kotlin/presentation/components/AuthUiHelperButtonsAndFirebaseAuth.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
package presentation.components | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.Shape | ||
import androidx.compose.ui.unit.TextUnit | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.mmk.kmpauth.core.KMPAuthInternalApi | ||
import com.mmk.kmpauth.core.di.isAndroidPlatform | ||
import com.mmk.kmpauth.firebase.apple.AppleButtonUiContainer | ||
import com.mmk.kmpauth.firebase.github.GithubButtonUiContainer | ||
import com.mmk.kmpauth.firebase.google.GoogleButtonUiContainerFirebase | ||
import com.mmk.kmpauth.uihelper.apple.AppleSignInButton | ||
import com.mmk.kmpauth.uihelper.google.GoogleButtonMode | ||
import com.mmk.kmpauth.uihelper.google.GoogleSignInButton | ||
import dev.gitlive.firebase.auth.FirebaseUser | ||
import domain.model.AuthProvider | ||
import org.jetbrains.compose.resources.ExperimentalResourceApi | ||
import org.jetbrains.compose.resources.painterResource | ||
import presentation.theme.strings.Strings | ||
|
||
@Composable | ||
fun AuthUiHelperButtonsAndFirebaseAuth( | ||
modifier: Modifier = Modifier, | ||
authProviders: List<AuthProvider> = AuthProvider.values().asList(), | ||
onFirebaseResult: (Result<FirebaseUser?>) -> Unit, | ||
) { | ||
Column( | ||
modifier = modifier, | ||
verticalArrangement = Arrangement.spacedBy(14.dp) | ||
) { | ||
val shape = RoundedCornerShape(8.dp) | ||
val height = 56.dp | ||
val textFontSize = 24.sp | ||
|
||
if (authProviders.contains(AuthProvider.GOOGLE)) { | ||
//Google Sign-In Button and authentication with Firebase | ||
GoogleButtonUiContainerFirebase(onResult = onFirebaseResult) { | ||
GoogleSignInButton( | ||
modifier = Modifier.fillMaxWidth().height(height), | ||
text = Strings.btn_sign_in_with_google, | ||
mode = GoogleButtonMode.Light, | ||
fontSize = textFontSize, | ||
shape = shape | ||
) { this.onClick() } | ||
} | ||
} | ||
|
||
if (authProviders.contains(AuthProvider.APPLE)) { | ||
//Apple Sign-In Button and authentication with Firebase | ||
AppleButtonUiContainer(onResult = onFirebaseResult) { | ||
AppleSignInButton( | ||
modifier = Modifier.fillMaxWidth().height(height), | ||
text = Strings.btn_sign_in_with_apple, | ||
shape = shape | ||
) { this.onClick() } | ||
} | ||
} | ||
|
||
if (authProviders.contains(AuthProvider.GITHUB)) { | ||
//Github Sign-In Button and authentication with Firebase | ||
GithubButtonUiContainer(onResult = onFirebaseResult) { | ||
GithubSignInButton( | ||
modifier = Modifier.fillMaxWidth().height(height), | ||
text = Strings.btn_sign_in_with_github, | ||
fontSize = textFontSize, | ||
shape = shape | ||
) { this.onClick() } | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
@OptIn(ExperimentalResourceApi::class, KMPAuthInternalApi::class) | ||
@Composable | ||
private fun GithubSignInButton( | ||
modifier: Modifier = Modifier, | ||
text: String = "Sign in with Github", | ||
fontSize: TextUnit = 14.sp, | ||
shape: Shape = ButtonDefaults.shape, | ||
onClick: () -> Unit, | ||
) { | ||
|
||
val horizontalPadding = if (isAndroidPlatform()) 12.dp else 16.dp | ||
val iconTextPadding = if (isAndroidPlatform()) 10.dp else 12.dp | ||
val containerColor = Color.White | ||
val contentColor = Color(0xFF1F1F1F) | ||
val buttonColor = | ||
ButtonDefaults.buttonColors(containerColor = containerColor, contentColor = contentColor) | ||
Button( | ||
modifier = modifier, | ||
contentPadding = PaddingValues(horizontal = horizontalPadding), | ||
onClick = onClick, | ||
shape = shape, | ||
colors = buttonColor, | ||
border = BorderStroke( | ||
width = 1.dp, | ||
color = Color(0xFF747775), | ||
), | ||
) { | ||
Row(verticalAlignment = Alignment.CenterVertically) { | ||
Image( | ||
modifier = Modifier.size(20.dp), | ||
painter = painterResource("drawable/ic_github.xml"), | ||
contentDescription = "githubicon" | ||
) | ||
Spacer(modifier = Modifier.width(iconTextPadding)) | ||
Text( | ||
text = text, | ||
maxLines = 1, | ||
fontSize = fontSize, | ||
) | ||
} | ||
|
||
} | ||
|
||
|
||
} |
63 changes: 63 additions & 0 deletions
63
shared/src/commonMain/kotlin/presentation/components/DeleteUserConfirmationDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package presentation.components | ||
|
||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Delete | ||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import presentation.theme.Black_22 | ||
import presentation.theme.strings.Strings | ||
|
||
@Composable | ||
fun DeleteUserConfirmationDialog( | ||
modifier: Modifier = Modifier, | ||
onConfirm: () -> Unit, | ||
onDismiss: () -> Unit, | ||
) { | ||
AlertDialog( | ||
modifier = modifier, | ||
onDismissRequest = {onDismiss() }, | ||
icon = { Icon(imageVector = Icons.Filled.Delete, contentDescription = "Delete") }, | ||
title = { | ||
Text(text = Strings.title_delete_user_dialog, color = Black_22) | ||
}, | ||
text = { | ||
Text( | ||
text = Strings.description_delete_user_dialog, | ||
color = Black_22 | ||
) | ||
}, | ||
confirmButton = { | ||
TextButton( | ||
onClick = { onConfirm() }, | ||
) { | ||
Text( | ||
text = Strings.btn_delete, | ||
color = MaterialTheme.colorScheme.secondary, | ||
style = MaterialTheme.typography.titleSmall | ||
) | ||
} | ||
|
||
}, | ||
dismissButton = { | ||
Button( | ||
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.secondary), | ||
onClick = { onDismiss() }, | ||
) { | ||
Text( | ||
text = Strings.btn_cancel, | ||
color = Color.White, | ||
style = MaterialTheme.typography.titleSmall | ||
) | ||
} | ||
} | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.