Skip to content

Instantly share code, notes, and snippets.

View stevdza-san's full-sized avatar
💭
Kotlin Multiplatform Developer/Content Creator

Stefan Jovanovic stevdza-san

💭
Kotlin Multiplatform Developer/Content Creator
View GitHub Profile
@stevdza-san
stevdza-san / ChannelScreen.kt
Created October 15, 2025 15:39
Homework - REFACTORED
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.animation.togetherWith
@stevdza-san
stevdza-san / ConsumedVsReceived.kt
Created October 15, 2025 15:27
Kotlin Flows - Day 2
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@stevdza-san
stevdza-san / CancellationExample.kt
Created October 14, 2025 16:02
Kotlin Flows - Day 1
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.compose.viewModel
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
@stevdza-san
stevdza-san / Animations.kt
Last active October 9, 2025 14:46
Jetpack Compose - Day 2
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
@stevdza-san
stevdza-san / DerivedVsRemember.kt
Created October 6, 2025 16:18
Jetpack Compose - Day 1
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@Composable
fun DerivedVsRememberExample() {
Column(
@stevdza-san
stevdza-san / CompanionObject.kt
Created September 29, 2025 14:20
Kotlin Basics
class Config {
companion object {
const val APP_NAME = "MyApp"
const val VERSION = "1.0"
}
}
//object Config2 { // Error
// companion object {
// const val APP_NAME = "MyApp"
@stevdza-san
stevdza-san / DeviceType.kt
Created September 21, 2025 05:54
Adaptive layout in Compose Multiplatform.
import androidx.compose.material3.adaptive.HingeInfo
import androidx.compose.material3.adaptive.WindowAdaptiveInfo
import androidx.window.core.layout.WindowSizeClass
sealed class DeviceType : Comparable<DeviceType> {
abstract val minWidth: Int
abstract val minHeight: Int
abstract val rank: Int
override fun compareTo(other: DeviceType): Int = this.rank - other.rank
@stevdza-san
stevdza-san / RequestState.kt
Last active July 14, 2025 18:46
Useful wrapper class for handling the data in Jetpack Compose
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.runtime.Composable
sealed class RequestState<out T> {
data object Idle : RequestState<Nothing>()
data object Loading : RequestState<Nothing>()
@stevdza-san
stevdza-san / MainScreen.kt
Created December 24, 2023 22:33
TabRow with HorizontalPager - Jetpack Compose
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
@stevdza-san
stevdza-san / RichTextEditor.kt
Created October 14, 2023 14:08
Demo project of a Compose-Rich-Editor library
import android.annotation.SuppressLint
import android.util.Log
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi