Skip to content

Instantly share code, notes, and snippets.


Brandon McAnsh bmc08gt

View GitHub Profile
View AnimatedSwipeDismiss.kt
import androidx.compose.animation.*
import androidx.compose.animation.core.tween
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.onCommit
import androidx.compose.ui.Modifier
@OptIn(ExperimentalAnimationApi::class, ExperimentalMaterialApi::class)
fun <T> AnimatedSwipeDismiss(
bmc08gt / Grid.kt
Last active Aug 23, 2020
Jetpack Compose dynamic grid
View Grid.kt
import androidx.compose.runtime.Composable
import androidx.compose.runtime.key
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
fun <T>Grid(
bmc08gt / DataStore.kt
Created Aug 12, 2020
Firebase Real-time Database value event listener via Kotlin callbackFlow{} updating Jetpack Compose list
View DataStore.kt
fun locationsFlowable(): Flow<PantryResult<List<ItemLocation>>> {
return getLocationsChange()
View ActivityResultsRegistry.kt
fun ActivityResultRegistry.googleSignIn(userPrefs: UserPreferences): GoogleSignInState {
val context = ContextAmbient.current
val options: GoogleSignInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).apply {
val signInState: MutableState<UserState<*>> = remember {
bmc08gt / TransientSnackbar.kt
Last active Aug 22, 2020
Auto-dismissing Snackbar for Jetpack Compose
View TransientSnackbar.kt
class SnackbarState {
var show by mutableStateOf(false)
fun TransientSnackbar(
modifier: Modifier = Modifier,
snackbarState: SnackbarState,
text: String,
actionLabel: String,
bmc08gt / SwipeToDelete.kt
Last active Oct 2, 2020
Jetpack Compose Modifier extension to implement swipe-to-delete via Modifier.draggable
View SwipeToDelete.kt
import androidx.animation.IntToVectorConverter
import androidx.animation.tween
import androidx.compose.Composable
import androidx.compose.mutableStateOf
import androidx.compose.remember
import androidx.ui.animation.animatedFloat
import androidx.ui.animation.animatedValue
import androidx.ui.core.*
import androidx.ui.core.gesture.scrollorientationlocking.Orientation
bmc08gt / App.kt
Last active Jul 28, 2020
DIY DI delegate acess
View App.kt
class App : Application() {
override fun onCreate() {
ComponentRouter.init(this) {

Keybase proof

I hereby claim:

To claim this, I am signing this object:

bmc08gt / DateExtensions.kt
Last active Oct 11, 2019
Helpful extensions for java.util.Date
View DateExtensions.kt
import java.text.SimpleDateFormat
import java.util.*
import java.util.concurrent.TimeUnit
import kotlin.math.round
val now: Date = Date()
val Date.daysFromToday: Long
get() {
val msDiff = now.time - this.time
bmc08gt /
Created Mar 9, 2019
Toolbar subclass to allow custom gravity and coloring for various elements
* Created by bmcansh on 3/3/17.
public class Toolbar extends {
private String mGraphikRegular;
private String mGraphikLight;
private ActionMenuView mActionMenuView;
You can’t perform that action at this time.