File tree Expand file tree Collapse file tree
app/src/main/java/com/getcode/ui/components
tipkit-m2/src/main/kotlin/dev/bmcreations/tipkit
tipkit/src/main/kotlin/dev/bmcreations/tipkit/engines Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import com.getcode.util.DeeplinkHandler
2323import com.getcode.util.DeeplinkResult
2424import com.getcode.ui.utils.getActivity
2525import com.getcode.utils.trace
26+ import dev.bmcreations.tipkit.engines.LocalTipsEngine
2627import kotlinx.coroutines.CoroutineScope
2728import kotlinx.coroutines.delay
2829import kotlinx.coroutines.flow.Flow
@@ -45,6 +46,7 @@ fun AuthCheck(
4546 onSwitchAccounts : (String ) -> Unit ,
4647) {
4748 val deeplinkHandler = LocalDeeplinks .current
49+ val tipsEngine = LocalTipsEngine .current
4850 val dataState by SessionManager .authState.collectAsState()
4951
5052 val isAuthenticated = dataState.isAuthenticated
@@ -139,6 +141,7 @@ fun AuthCheck(
139141 onNavigate(listOf (ScanScreen ()))
140142 }
141143 } else {
144+ tipsEngine?.invalidateAllTips()
142145 if (! deeplinkRouted) {
143146 trace(" Navigating to login" )
144147 onNavigate(listOf (LoginScreen ()))
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import androidx.compose.material.icons.Icons
2525import androidx.compose.material.icons.filled.Close
2626import androidx.compose.runtime.Composable
2727import androidx.compose.runtime.CompositionLocalProvider
28+ import androidx.compose.runtime.LaunchedEffect
2829import androidx.compose.runtime.getValue
2930import androidx.compose.runtime.mutableStateOf
3031import androidx.compose.runtime.remember
@@ -238,6 +239,10 @@ fun TipScaffold(
238239 get() = emission != null
239240 }
240241
242+ LaunchedEffect (tipsEngine, tipProvider) {
243+ tipsEngine.setProvider(tipProvider)
244+ }
245+
241246 val density = LocalDensity .current
242247 val ldr = LocalLayoutDirection .current
243248 CompositionLocalProvider (
Original file line number Diff line number Diff line change 11package dev.bmcreations.tipkit.engines
22
33import androidx.compose.runtime.staticCompositionLocalOf
4+ import dev.bmcreations.tipkit.NoOpTipProvider
45import dev.bmcreations.tipkit.Tip
6+ import dev.bmcreations.tipkit.TipProvider
57
68interface TipInterface
79
@@ -13,13 +15,20 @@ class TipsEngine(
1315 var tips: TipInterface = object : TipInterface {}
1416 private set
1517
18+ private var provider: TipProvider = NoOpTipProvider ()
19+
1620 val flows: MutableMap <String , List <Tip >> = mutableMapOf ()
1721
1822 fun configure (implementation : TipInterface ) {
1923 tips = implementation
2024 }
2125
26+ fun setProvider (provider : TipProvider ) {
27+ this .provider = provider
28+ }
29+
2230 fun invalidateAllTips () {
31+ provider.dismiss()
2332 eventsEngine.clearCompletions()
2433 eventsEngine.removeAllOccurrences()
2534 }
You can’t perform that action at this time.
0 commit comments