Skip to content

Instantly share code, notes, and snippets.

View erfansn's full-sized avatar
👷
Becoming pragmatic

Erfan Sadigh Nejati erfansn

👷
Becoming pragmatic
View GitHub Profile
@erfansn
erfansn / GoogleAuthScreen.kt
Last active October 11, 2023 03:43
Using the Google Sign-In Api in Compose with the least possible friction
@Composable
fun GoogleAuthScreen() {
val googleAuthState = rememberGoogleAuthState(
clientId = stringResource(R.string.web_client_id),
Scope(Scopes.PROFILE),
Scope(Scopes.EMAIL)
)
DisposableEffect(googleAuthState) {
googleAuthState.onSignInResult = {
when (it) {
@erfansn
erfansn / PermissionsRequest.kt
Last active August 8, 2023 11:33
Convenient handling of runtime permissions in Jetpack Compose
@Composable
fun PermissionsRequestButton(
permissions: List<String>,
onGranted: () -> Unit,
modifier: Modifier = Modifier,
onRationaleShow: (List<String>) -> Unit = { },
onPermanentlyDenied: (List<String>) -> Unit = { },
onPartiallyGranted: (List<String>) -> Unit = { },
content: @Composable RowScope.() -> Unit,
) {
@erfansn
erfansn / CircularRevealAnimation.kt
Last active June 7, 2024 09:31 — forked from bmonjoie/CircularRevealAnimation.kt
Compose Circular Reveal, like the Telegram theme changing animation.
@Composable
fun CircularReveal(
expanded: Boolean,
modifier: Modifier = Modifier,
animationSpec: FiniteAnimationSpec<Float> = tween(),
content: @Composable (Boolean) -> Unit,
) {
val transition = updateTransition(expanded, label = "Circular reveal")
transition.CircularReveal(modifier, animationSpec, content = content)
}