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 / Corner.kt
Last active September 20, 2025 09:21
A Jetpack Compose Material 3 Card that allows concave corners on top of the normal convex/sharp corners.
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
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),
@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: