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
| val isInitialLoad = items.loadState.refresh is Loading && items.itemCount == 0 | |
| val isError = items.loadState.refresh is Error && items.itemCount == 0 | |
| val isListEmpty = items.loadState.refresh is NotLoading && | |
| items.loadState.append.endOfPaginationReached && | |
| items.itemCount == 0 |
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
| internal class ChipStateProvider : PreviewParameterProvider<ChipState> { | |
| override val values: Sequence<ChipState> = sequence { | |
| leadingIconValues().forEach { leadingIcon -> | |
| selectedValues().forEach { enabled -> | |
| expandedValues().forEach { expanded -> | |
| labelResIdValues().forEach { checked -> | |
| yield( | |
| ChipState( | |
| expanded = expanded, | |
| labelResId = checked, |
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.ComponentCallbacks | |
| import android.content.Context | |
| import android.content.res.Configuration | |
| import kotlinx.coroutines.channels.awaitClose | |
| import kotlinx.coroutines.flow.Flow | |
| import kotlinx.coroutines.flow.callbackFlow | |
| import kotlinx.coroutines.flow.conflate | |
| import kotlinx.coroutines.flow.distinctUntilChanged | |
| public fun <T> Context.observeConfigurationChanges( |
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 | |
| @ReadOnlyComposable | |
| public fun colors( | |
| colorContrast: ResolvedColorContrast, | |
| darkTheme: Boolean, | |
| dynamicColor: ResolvedDynamicColor, | |
| ): ColorScheme = when { | |
| dynamicColor.enabled -> dynamicColorScheme(darkTheme) | |
| darkTheme -> colorContrast.darkColorScheme() | |
| else -> colorContrast.lightColorScheme() |
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
| public fun Modifier.centerInParent(): Modifier = | |
| this then layout { measurable, constraints -> | |
| val maxWidthAllowedByParent = constraints.maxWidth | |
| val maxHeightAllowedByTheParent = constraints.maxHeight | |
| val placeable = measurable.measure(constraints) | |
| val start = maxWidthAllowedByParent / 2 - placeable.width / 2 | |
| val top = maxHeightAllowedByTheParent / 2 - placeable.height / 2 | |
| layout(width = placeable.width, height = placeable.height) { | |
| placeable.placeRelative(x = start, y = top) | |
| } |
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
| context(viewModel: ViewModel) | |
| public fun <T> Flow<T>.stateInWhileSubscribed( | |
| initialValue: T, | |
| ): StateFlow<T> = stateIn( | |
| scope = viewModel.viewModelScope, | |
| started = WhileSubscribed(stopTimeoutMillis = 5_000), | |
| initialValue = initialValue, | |
| ) |
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 androidx.compose.foundation.shape.CornerSize | |
| import androidx.compose.foundation.shape.ZeroCornerSize | |
| import androidx.compose.ui.unit.Dp | |
| public sealed interface Corner { | |
| public val cornerSize: CornerSize | |
| public data class Concave(override val cornerSize: CornerSize) : Corner | |
| public data class Rounded(override val cornerSize: CornerSize) : Corner | |
| public data class Cut(override val cornerSize: CornerSize) : Corner |
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
| internal val PIXEL_10_PRO_XL: DeviceConfig = | |
| DeviceConfig( | |
| screenHeight = 2992, | |
| screenWidth = 1344, | |
| xdpi = 486, | |
| ydpi = 486, | |
| orientation = ScreenOrientation.PORTRAIT, | |
| uiMode = UiMode.NORMAL, | |
| nightMode = NightMode.NOTNIGHT, | |
| density = Density.create(560), |
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 | |
| @Preview( | |
| group = "Light Theme - All Rounded Surface", | |
| uiMode = Configuration.UI_MODE_NIGHT_NO, | |
| ) | |
| @Preview( | |
| group = "Dark Theme - All Rounded Surface", | |
| uiMode = Configuration.UI_MODE_NIGHT_YES, | |
| ) | |
| internal fun ListItemAllRoundedSurfacePreview( |
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
| internal class ListItemAllRoundedSurfaceContentProvider : | |
| PreviewParameterProvider<ListItemPreviewViewState> { | |
| override val values: Sequence<ListItemPreviewViewState> = | |
| listItemContentProviderValues(AllRounded) | |
| } | |
| internal class ListItemTopRoundedSurfaceContentProvider : | |
| PreviewParameterProvider<ListItemPreviewViewState> { | |
| override val values: Sequence<ListItemPreviewViewState> = | |
| listItemContentProviderValues(TopRounded) |
NewerOlder