File tree Expand file tree Collapse file tree
app/src/main/java/com/getcode/view/main/scanner
tipkit-m2/src/main/kotlin/dev/bmcreations/tipkit
tipkit/src/main/kotlin/dev/bmcreations/tipkit Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 */
3637fun 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 {
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ val LocalTipProvider =
99
1010abstract 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
2727class 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}
You can’t perform that action at this time.
0 commit comments