In the View system, ConstraintLayout was the recommended way to create large and complex layouts, as a flat view hierarchy was better for performance than nested views are. However, this is not a concern in Compose, which is able to efficiently handle deep layout hierarchies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.InternalComposeApi | |
import androidx.compose.runtime.NonRestartableComposable | |
import androidx.compose.runtime.RememberObserver | |
import androidx.compose.runtime.currentComposer | |
import androidx.compose.runtime.remember | |
import kotlin.coroutines.CoroutineContext | |
import kotlinx.coroutines.CancellationException | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Job |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Stable | |
fun Modifier.dropShadow( | |
borderRadius: Dp, | |
spreadRadius: Dp = 3.dp, | |
blurRadius: Dp = spreadRadius, | |
color: Color = Color.DarkGray.copy(alpha = 0.1f), | |
offsetX: Dp = 0.dp, | |
offsetY: Dp = 0.dp, | |
) = | |
drawBehind { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Stable | |
fun Modifier.drawHorizontalFadingEdges( | |
target: Color = Color.White, | |
width: Dp = 10.dp, | |
scrollState: ScrollableState, | |
) = | |
if (!scrollState.canScrollForward && !scrollState.canScrollBackward) this | |
else drawWithCache { | |
val gradientWidth = width.toPx() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Designed and developed by "옴마야" Team 2023. | |
* | |
* Licensed under the MIT. | |
* Please see full license: https://github.com/mash-up-kr/WeQuiz-Android/blob/main/LICENSE | |
*/ | |
package team.ommaya.wequiz.android | |
import android.os.Bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@file:OptIn(ExperimentalComposeUiApi::class) | |
@file:Suppress("unused") | |
@file:NoLiveLiterals | |
package land.sungbin.androidplayground.extension | |
import androidx.compose.animation.core.Animatable | |
import androidx.compose.animation.core.AnimationSpec | |
import androidx.compose.animation.core.AnimationVector2D | |
import androidx.compose.animation.core.Spring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@file:OptIn( | |
ExperimentalComposeUiApi::class, | |
ExperimentalMaterialApi::class | |
) | |
package land.sungbin.androidplayground.snippet.animation | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.foundation.layout.navigationBarsPadding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Boolean | |
* | |
* The most basic datatype is the simple true/false value, | |
* which JavaScript and TypeScript (as well as other languages) call a 'boolean' value. | |
*/ | |
var isDone: boolean = false; | |
/** | |
* Number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PlaygroundActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
Layout( | |
modifier = Modifier.fillMaxSize(), | |
content = { | |
Box( | |
modifier = Modifier | |
.layoutId("green") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <A, B> mutableStatePairOf(first: A, second: B): SnapshotMutablePair<A, B> { | |
return SnapshotMutablePairImpl(first, second) | |
} | |
fun <A, B> mutableStatePairOf(value: Pair<A, B>): SnapshotMutablePair<A, B> { | |
return SnapshotMutablePairImpl(value.first, value.second) | |
} | |
@Stable | |
interface SnapshotMutablePair<A, B> { |
NewerOlder