Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.example.cahier.R
import com.example.cahier.core.ui.theme.CahierAppTheme

@Composable
fun ConfirmationDialog(
Expand All @@ -27,13 +28,16 @@ fun ConfirmationDialog(
)
}

@Preview
// Dialogs are drawn in their own window, so the preview needs an explicit size to show one.
@Preview(widthDp = 360, heightDp = 280)
@Composable
fun ConfirmationDialogPreview() {
ConfirmationDialog(
onConfirm = {},
onDismiss = {},
title = "Confirm",
text = "Confirm you want to perform this action.",
)
CahierAppTheme {
ConfirmationDialog(
onConfirm = {},
onDismiss = {},
title = "Confirm",
text = "Confirm you want to perform this action.",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,23 @@
package com.example.cahier.core.ui

import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.runtime.compositionLocalWithComputedDefaultOf
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import com.example.cahier.core.data.CahierTextureBitmapStore

/**
* Provides the [CahierTextureBitmapStore] for brush textures.
*
* In Compose previews ([LocalInspectionMode]), this falls back to a default store so `@Preview`
* composables can render without wrapping in a provider; at runtime, the app still fails fast with
* `"No TextureStore provided"` if nothing provides a store.
*/
val LocalTextureStore: ProvidableCompositionLocal<CahierTextureBitmapStore> =
staticCompositionLocalOf<CahierTextureBitmapStore> { error("No TextureStore provided") }
compositionLocalWithComputedDefaultOf<CahierTextureBitmapStore> {
if (LocalInspectionMode.currentValue) {
CahierTextureBitmapStore(LocalContext.currentValue)
} else {
error("No TextureStore provided")
}
}