Skip to content

Instantly share code, notes, and snippets.

View erfansn's full-sized avatar
🔍
Life

Erfan Sadigh Nejati erfansn

🔍
Life
  • Freedom
View GitHub Profile
@KlassenKonstantin
KlassenKonstantin / AnimatedFocusIndicator.kt
Created May 28, 2024 10:27
Animated focus indicator
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 January 14, 2025 14:05
Convenient handling of runtime permissions in Jetpack Compose
import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import android.content.SharedPreferences
import androidx.activity.compose.ManagedActivityResultLauncher
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material3.Button
import androidx.compose.material3.Text
@erfansn
erfansn / CircularRevealAnimation.kt
Last active March 12, 2025 11:33 — 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 January 24, 2025 13:55
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 13, 2025 01:44
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,