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
@Composable() | |
fun NumbersPanel(alpha: Int) { | |
Stack { | |
Row(modifier = Modifier.fillMaxSize()) { | |
numberColumns.forEach { numberColumn -> | |
Column(modifier = Modifier.weight(1f)) { | |
numberColumn.forEach { text -> | |
MainContentButton(text) | |
} | |
} |
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
@Composable | |
fun DimOverlay(alpha: Int) { | |
Box(modifier = Modifier.fillMaxSize(), backgroundColor = Color(50, 50, 50, alpha)) | |
} |
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
@Composable | |
fun TopView( | |
boxHeight: Dp, | |
drag: Drag | |
) { | |
val position = drag.position | |
val flingConfig = drag.flingConfig | |
val yOffset = with(DensityAmbient.current) { position.value.toDp() } | |
val scrollerPosition = ScrollerPosition() | |
// scroll the history list to bottom when dragging the top panel |
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
// Top drag | |
val topStart = -(constraints.maxHeight.value / 1.4f) | |
val topMax = 0.dp | |
val topMin = -(boxHeight / 1.4f) | |
val (topMinPx, topMaxPx) = with(DensityAmbient.current) { | |
topMin.toPx().value to topMax.toPx().value | |
} | |
val topFlingConfig = AnchorsFlingConfig(listOf(topMinPx, topMaxPx)) | |
val topPosition = animatedFloat(topStart) // for dragging state | |
topPosition.setBounds(topMinPx, topMaxPx) |
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
@Composable() | |
fun SideView( | |
boxHeight: Dp, | |
drag: Drag | |
) { | |
val position = drag.position | |
val flingConfig = drag.flingConfig | |
val yOffset = with(DensityAmbient.current) { position.value.toDp() } | |
val toggleAsset = state { R.drawable.ic_keyboard_arrow_left_24 } | |
Box( |
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
// Side drag | |
val sideMin = 90.dp | |
val sideMax = boxWidth - 30.dp | |
val (sideMinPx, sideMaxPx) = with(DensityAmbient.current) { | |
sideMin.toPx().value to sideMax.toPx().value | |
} | |
val sideFlingConfig = AnchorsFlingConfig(listOf(sideMinPx, sideMaxPx)) | |
val sidePosition = animatedFloat(sideMaxPx) | |
sidePosition.setBounds(sideMinPx, sideMaxPx) |
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 Drag( | |
val position: AnimatedFloat, | |
val flingConfig: FlingConfig | |
) |
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
setContent { | |
MaterialTheme(colors = lightThemeColors) { | |
WithConstraints { constraints, _ -> | |
val boxHeight = with(DensityAmbient.current) { constraints.maxHeight.toDp() } | |
val boxWidth = with(DensityAmbient.current) { constraints.maxWidth.toDp() } | |
Content( | |
constraints = constraints, | |
boxHeight = boxHeight, | |
boxWidth = boxWidth | |
) |
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
sealed class UIState<out R> { | |
object Loading : UIState<Nothing>() | |
object Retrying : UIState<Nothing>() | |
object SwipeRefreshing : UIState<Nothing>() | |
data class Success<T>(val data: T) : UIState<T>() | |
data class Failure(val exception: Exception) : UIState<Nothing>() | |
data class SwipeRefreshFailure(val exception: Exception) : UIState<Nothing>() | |
} |
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
sealed class Action { | |
object Load : Action() | |
object SwipeRefresh : Action() | |
object Retry : Action() | |
} |
NewerOlder