Skip to content

Commit 7ff9b7d

Browse files
committed
fix(tooltip): hide when bill is active
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 5d2319d commit 7ff9b7d

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

app/src/main/java/com/getcode/view/main/scanner/DecorView.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ internal fun DecorView(
9494
.padding(horizontal = CodeTheme.dimens.grid.x3)
9595
.align(Alignment.TopStart)
9696
.popoverTip(
97+
visible = dataState.billState.bill == null,
9798
tip = tips.downloadCodeTip,
9899
alignment = Alignment.BottomStart
99100
)

vendor/tipkit/tipkit-m2/src/main/kotlin/dev/bmcreations/tipkit/Modifier.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ import kotlinx.coroutines.flow.onEach
3232
* centered horizontally, whereas [Alignment.TopStart] implies that the tip will render above and to the left
3333
* of the anchor.
3434
* @param padding The space between the anchor and aligned tip.
35+
* @param visible If the tip should be visible, this can be used to temporarily hide an active tip.
3536
*/
3637
fun Modifier.popoverTip(
3738
tip: Tip,
39+
visible: Boolean = true,
3840
alignment: Alignment = TipDefaultAlignment,
3941
padding: PaddingValues = TipDefaultPadding,
4042
) = composed {
@@ -77,7 +79,12 @@ fun Modifier.popoverTip(
7779
.filter { it }
7880
.onEach { tipProvider.show(data) }
7981
.launchIn(this)
82+
}
8083

84+
LaunchedEffect(tip, visible) {
85+
if (!visible) {
86+
tipProvider.dismiss(eventDriven = false)
87+
}
8188
}
8289

8390
return@composed Modifier.onPlaced {

vendor/tipkit/tipkit-m2/src/main/kotlin/dev/bmcreations/tipkit/TipScaffold.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,13 @@ fun TipScaffold(
219219
emission = data
220220
}
221221

222-
override fun dismiss() {
222+
override fun dismiss(eventDriven: Boolean) {
223223
composeScope.launch {
224224
val tip = emission?.tip
225225
emission = null
226-
tip?.dismiss()
226+
if (eventDriven) {
227+
tip?.dismiss()
228+
}
227229
}
228230
}
229231

vendor/tipkit/tipkit/src/main/kotlin/dev/bmcreations/tipkit/TipProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ val LocalTipProvider =
99

1010
abstract class TipProvider {
1111
abstract fun show(data: TipPresentation)
12-
abstract fun dismiss()
12+
abstract fun dismiss(eventDriven: Boolean = true)
1313
abstract fun onActionClicked(action: TipAction)
1414

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

2727
class NoOpTipProvider : TipProvider() {
2828
override fun show(data: TipPresentation) = Unit
29-
override fun dismiss() = Unit
29+
override fun dismiss(eventDriven: Boolean) = Unit
3030

3131
override fun onActionClicked(action: TipAction) = Unit
3232
}

0 commit comments

Comments
 (0)