Skip to content

Instantly share code, notes, and snippets.

View Sottti's full-sized avatar
🏠
Remote

Pablo Costa Sottti

🏠
Remote
View GitHub Profile
@Sottti
Sottti / ListItemAllRoundedSurfacePreview.kt
Created February 3, 2025 09:57
One of the trickiest cases to write previews
@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(
@Sottti
Sottti / ListItemPreview.kt
Created February 3, 2025 09:55
One of the trickiest cases to write previews
internal class ListItemAllRoundedSurfaceContentProvider :
PreviewParameterProvider<ListItemPreviewViewState> {
override val values: Sequence<ListItemPreviewViewState> =
listItemContentProviderValues(AllRounded)
}
internal class ListItemTopRoundedSurfaceContentProvider :
PreviewParameterProvider<ListItemPreviewViewState> {
override val values: Sequence<ListItemPreviewViewState> =
listItemContentProviderValues(TopRounded)
@Sottti
Sottti / ListItem.kt
Last active February 3, 2025 09:57
One of the trickiest cases to write previews
@Composable
public fun ListItem(
modifier: Modifier = Modifier,
primaryText: String,
primaryTextStyle: ListItemPrimaryTextStyle = ListItemPrimaryTextStyle.Default,
primaryTextColor: ListItemPrimaryTextColor = ListItemPrimaryTextColor.OnSurfaceOrBackground,
primaryTextDecoration: TextDecoration? = null,
secondaryText: String? = null,
secondarySlot: @Composable (() -> Unit)? = null,
startIcon: ListItemStartIcon? = null,
@Sottti
Sottti / EditVehicleAvailabilityPreviewParameterProvider.kt
Last active February 3, 2025 09:50
Typical example of how you wrote previews
internal class EditVehicleAvailabilityPreviewParameterProvider :
PreviewParameterProvider<EditVehicleAvailabilityViewState> {
override val values: Sequence<EditVehicleAvailabilityViewState> = sequenceOf(loadedViewState())
}
internal fun loadedViewState(): EditVehicleAvailabilityViewState =
EditVehicleAvailabilityViewState(
isLoading = false,
content = EditVehicleAvailabilityContentState(
title = ResId(ContentStringsR.motor_edit_availability_title),
@Sottti
Sottti / EditVehicleAvailabilityUi.kt
Last active February 3, 2025 09:50
Typical example of how you wrote previews
@Composable
@LightDarkPreview
internal fun EditVehicleAvailabilityUi(
@PreviewParameter(EditVehicleAvailabilityPreviewParameterProvider::class)
state: EditVehicleAvailabilityViewState,
) {
...
}
public data class TextStyles(
val navigationTitle: TextStyle = Typography().h6.copy(
fontFamily = FontFamily.SansSerif,
fontWeight = FontWeight.W500,
fontStyle = FontStyle.Normal,
fontSize = 20.sp,
lineHeight = 22.sp,
letterSpacing = 0.26.sp,
),
(...)

Keybase proof

I hereby claim:

  • I am sottti on github.
  • I am sotti (https://keybase.io/sotti) on keybase.
  • I have a public key ASDmWjXUmY2czLkcqzDKDpMZGSk-xr9eh3H0Ix8TgNMIrgo

To claim this, I am signing this object:

sotti

Keybase proof

I hereby claim:

  • I am sottti on github.
  • I am sotti (https://keybase.io/sotti) on keybase.
  • I have a public key ASDmWjXUmY2czLkcqzDKDpMZGSk-xr9eh3H0Ix8TgNMIrgo

To claim this, I am signing this object:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="137dp"
android:viewportWidth="307"
android:viewportHeight="210">
<path
android:fillColor="@color/primary_muted_4"
android:pathData="M3.015,159.555c4.818,23.351 13.56,39.078 26.396,48.946l125.117,0.499 147.05,-0.499c5.535,-15.043 5.422,-34.709 5.422,-54.631 0,-71.565 -45.381,-221.37 -159.71,-119.39C96.256,79.998 -20.046,47.787 3.015,159.554z" />
<path
android:fillColor="@color/primary_muted_4"
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="132dp"
android:height="85dp"
android:viewportWidth="132"
android:viewportHeight="85">
<path
android:fillAlpha="0.03"
android:fillColor="@color/primary"
android:pathData="M122.498,84.523L18.361,85c-5.271,0.024 -9.564,-4.268 -9.588,-9.587l-0.259,-57.55c-0.024,-5.318 4.23,-9.65 9.502,-9.674l104.137,-0.476c5.272,-0.024 9.564,4.268 9.588,9.587L132,74.849c0.024,5.319 -4.23,9.65 -9.502,9.674z"
android:strokeAlpha="0.3" />