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 / SelectableItem.kt
Last active April 2, 2024 01:58
Custom Animated Selectable Item - Jetpack Compose
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.animation.core.tween
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
@stevdza-san
stevdza-san / HyperlinkText.kt
Last active May 6, 2024 11:14
Embedd a Hyperlink within a Text using Jetpack Compose.
import androidx.compose.foundation.text.ClickableText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.TextUnit
@stevdza-san
stevdza-san / WebBrowser.kt
Created June 22, 2022 10:16
Web Browser Application using Jetpack Compose
// Using WebView Accompanist library
// implementation "com.google.accompanist:accompanist-webview:<version>"
import android.graphics.Bitmap
import android.util.Log
import android.webkit.WebView
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
@stevdza-san
stevdza-san / StopwatchAnimation.kt
Created June 29, 2022 18:54
Create a Stopwatch Animation on a Text with Jetpack Compose
import androidx.compose.animation.*
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@stevdza-san
stevdza-san / MainActivity.kt
Created July 2, 2022 06:32
collectAsStateWithLifecycle() example
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
@stevdza-san
stevdza-san / Game.kt
Last active March 26, 2024 21:47
Tic-Tac-Toe Game with Kotlin
import kotlin.system.exitProcess
class Game {
private val board = MutableList<Cell>(size = 9) { Cell.Empty }
private var status: Status = Status.Idle
private lateinit var player: Player
fun start() {
status = Status.Running
println(" ------------------------------ ")
@stevdza-san
stevdza-san / HomeScreen.kt
Created September 8, 2022 12:08
isScrolled extension property for the LazyListState
import android.annotation.SuppressLint
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ContentAlpha
import androidx.compose.material.MaterialTheme
@stevdza-san
stevdza-san / MainScreen.kt
Created September 16, 2022 09:18
Disappearing and Animated Top Bar - Jetpack Compose
import android.annotation.SuppressLint
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
@stevdza-san
stevdza-san / MainScreen.kt
Created October 20, 2022 06:31
New Photo Picker on Android 13/API Level 33 - Backwards Compatible
// Coil
// implementation("io.coil-kt:coil-compose:2.2.2")
import android.util.Log
import android.widget.Toast
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
@stevdza-san
stevdza-san / AnimatedBorderCard.kt
Last active April 3, 2024 14:01
Card with Animated Border built with Jetpack Compose.
@Composable
fun AnimatedBorderCard(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(size = 0.dp),
borderWidth: Dp = 2.dp,
gradient: Brush = Brush.sweepGradient(listOf(Color.Gray, Color.White)),
animationDuration: Int = 10000,
onCardClick: () -> Unit = {},
content: @Composable () -> Unit
) {