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 android.content.Context; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.AttributeSet; | |
import android.view.View; | |
/** | |
* {@link GridLayoutManager} extension which introduces workaround for focus finding bug when | |
* navigating with dpad. | |
* | |
* @see <a href="http://stackoverflow.com/questions/31596801/recyclerview-focus-scrolling">http://stackoverflow.com/questions/31596801/recyclerview-focus-scrolling</a> |
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 android.app.Fragment | |
import android.os.Bundle | |
import kotlin.properties.ReadWriteProperty | |
import kotlin.reflect.KProperty | |
import android.support.v4.app.Fragment as SupportFragment | |
inline fun <reified T> Fragment.fragmentArg() | |
: ReadWriteProperty<Fragment, T> = required({ argumentsRequired }) | |
inline fun <reified T> SupportFragment.fragmentArg() | |
: ReadWriteProperty<SupportFragment, T> = required({ argumentsRequired }) |
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 NumberPicker( | |
state: MutableState<Int>, | |
modifier: Modifier = Modifier, | |
range: IntRange? = null, | |
textStyle: TextStyle = LocalTextStyle.current, | |
onStateChanged: (Int) -> Unit = {}, | |
) { | |
val coroutineScope = rememberCoroutineScope() | |
val numbersColumnHeight = 36.dp |
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
enum class ComposableTransitionState { | |
VISIBLE, ENTERING, EXITING, | |
} | |
@Composable | |
fun <Key, State> ComposableSwitcher( | |
key: Key, | |
state: State, | |
snapOnInitialComposition: Boolean = true, | |
content: @Composable (Key, State, Transition<ComposableTransitionState>) -> Unit, |
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 FlowRow( | |
horizontalGap: Dp = 0.dp, | |
verticalGap: Dp = 0.dp, | |
alignment: Alignment.Horizontal = Alignment.Start, | |
content: @Composable () -> Unit, | |
) = Layout(content = content) { measurables, constraints -> | |
val horizontalGapPx = horizontalGap.toPx().roundToInt() | |
val verticalGapPx = verticalGap.toPx().roundToInt() |
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 DurationPicker( | |
state: MutableState<Duration>, | |
modifier: Modifier = Modifier, | |
) { | |
DurationPicker( | |
value = state.value, | |
onValueChange = { state.value = it }, | |
modifier = modifier, | |
) |
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 animatePathAsState(path: String): State<List<PathNode>> { | |
return animatePathAsState(remember(path) { addPathNodes(path) }) | |
} | |
@Composable | |
fun animatePathAsState(path: List<PathNode>): State<List<PathNode>> { | |
var from by remember { mutableStateOf(path) } | |
var to by remember { mutableStateOf(path) } | |
val fraction = remember { Animatable(0f) } |