This file contains hidden or 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
| /** | |
| * A composable function that displays a vertical scrolling picker allowing users to choose | |
| * from a list of items. | |
| * | |
| * @param T The type of the items to be displayed in the picker. | |
| * @param selectedIndex The index of the currently selected item. This controls the initial | |
| * position of the picker and can be updated to animate a selection change. | |
| * @param items A list of items to display in the picker. | |
| * @param onItemSelect A callback invoked whenever an item is selected. Provides the selected | |
| * index and item. |
This file contains hidden or 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) } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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> |