Skip to content

Instantly share code, notes, and snippets.

@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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calendar</title>
<style>
* {
margin: 0;