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 @@ -94,6 +94,7 @@ internal fun DecorView(
.padding(horizontal = CodeTheme.dimens.grid.x3)
.align(Alignment.TopStart)
.popoverTip(
visible = dataState.billState.bill == null,
tip = tips.downloadCodeTip,
alignment = Alignment.BottomStart
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ import kotlinx.coroutines.flow.onEach
* centered horizontally, whereas [Alignment.TopStart] implies that the tip will render above and to the left
* of the anchor.
* @param padding The space between the anchor and aligned tip.
* @param visible If the tip should be visible, this can be used to temporarily hide an active tip.
*/
fun Modifier.popoverTip(
tip: Tip,
visible: Boolean = true,
alignment: Alignment = TipDefaultAlignment,
padding: PaddingValues = TipDefaultPadding,
) = composed {
Expand Down Expand Up @@ -77,7 +79,12 @@ fun Modifier.popoverTip(
.filter { it }
.onEach { tipProvider.show(data) }
.launchIn(this)
}

LaunchedEffect(tip, visible) {
if (!visible) {
tipProvider.dismiss(eventDriven = false)
}
}

return@composed Modifier.onPlaced {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,13 @@ fun TipScaffold(
emission = data
}

override fun dismiss() {
override fun dismiss(eventDriven: Boolean) {
composeScope.launch {
val tip = emission?.tip
emission = null
tip?.dismiss()
if (eventDriven) {
tip?.dismiss()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ val LocalTipProvider =

abstract class TipProvider {
abstract fun show(data: TipPresentation)
abstract fun dismiss()
abstract fun dismiss(eventDriven: Boolean = true)
abstract fun onActionClicked(action: TipAction)

open val isTipShowing: Boolean = false
Expand All @@ -26,7 +26,7 @@ abstract class TipProvider {

class NoOpTipProvider : TipProvider() {
override fun show(data: TipPresentation) = Unit
override fun dismiss() = Unit
override fun dismiss(eventDriven: Boolean) = Unit

override fun onActionClicked(action: TipAction) = Unit
}