Replies: 1 comment
|
The issue is Fix@Composable
fun PopupToolTipWithText(
text: String,
display: Boolean,
alignType: PopupToolTipAlignType,
onDismiss: () -> Unit,
anchorComposable: @Composable () -> Unit,
) {
// In @Preview, LocalLifecycleOwner is not available — bail out early
val isInPreview = LocalInspectionMode.current
if (isInPreview) {
// Just render the anchor so the Preview is meaningful
anchorComposable()
return
}
val lifeCycleOwner = LocalLifecycleOwner.current
val backgroundColor = MaterialTheme.colorScheme.secondary
val builder = rememberBalloonBuilder {
// ... your existing builder code ...
setLifecycleOwner(lifeCycleOwner)
}
Balloon(
builder = builder,
balloonContent = { Text(text = text, ...) }
) { balloonWindow ->
if (display) {
when (alignType) {
PopupToolTipAlignType.TOP -> balloonWindow.showAlignTop()
PopupToolTipAlignType.BOTTOM -> balloonWindow.showAlignBottom()
}
}
anchorComposable()
}
}Why
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello I'm not sure how to write Composable @Preview, as my Composable Balloon works fine on my real device, but can't be displayed in @Preview
here is my code :
All reactions