Skip to content

Instantly share code, notes, and snippets.

View dladukedev's full-sized avatar

Donovan LaDuke dladukedev

View GitHub Profile
@dladukedev
dladukedev / exhaustive-if.kt
Created December 20, 2023 20:02
Exhaustive if blocks in Kotlin
import kotlin.random.Random
val myInt = Random.nextInt()
val myBool = Random.nextBoolean()
// Expression - Exhaustive Required
val result = if (myInt == 1) {
"I'm #1"
} else {
"I'm something else"
@dladukedev
dladukedev / 0 - Compose Previews.kt
Last active May 1, 2024 15:15
Approaches to Compose Previews
package com.dladukedev.composepreviews.base
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Card
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
@dladukedev
dladukedev / UseCaseAsInterface.kt
Created August 15, 2024 02:35
An example of using Use Case interfaces without backing Use Case classes
package com.example.counterapplication
import android.app.Application
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column