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
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
BorderPathTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
Box(
modifier = Modifier
.fillMaxSize()
@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)
}
@surajsau
surajsau / ParallaxScreen.kt
Last active June 28, 2024 21:14
Parallax effect with Jetpack Compose
@Composable
fun ParallaxScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
var data by remember { mutableStateOf<SensorData?>(null) }
DisposableEffect(Unit) {
val dataManager = SensorDataManager(context)
dataManager.init()
@objcode
objcode / ConcurrencyHelpers.kt
Last active May 31, 2024 13:31
Helpers to control concurrency for one shot requests using Kotlin coroutines.
/* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,