This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RocketsListContentTest { | |
@get:Rule | |
val composeTestRule = createComposeRule() | |
private val testRockets = generateTestRocketsFromPresentation() | |
@Before | |
fun setUp() { | |
composeTestRule.setContent { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RocketsViewModelTest { | |
@JvmField | |
@RegisterExtension | |
val mainDispatcherExtension = MainDispatcherExtension() | |
@RelaxedMockK | |
private lateinit var getRocketsUseCase: GetRocketsUseCase | |
(...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun AndroidStarterTheme( | |
darkTheme: Boolean = isSystemInDarkTheme(), | |
content: @Composable () -> Unit | |
) { | |
val colorScheme = pickColorScheme(darkTheme) | |
(...) | |
MaterialTheme( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
inline fun <reified T> Flow<T>.collectWithLifecycle( | |
key: Any = Unit, | |
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, | |
minActiveState: Lifecycle.State = Lifecycle.State.STARTED, | |
noinline action: suspend (T) -> Unit | |
) { | |
val lifecycleAwareFlow = remember(this, lifecycleOwner) { | |
flowWithLifecycle( | |
lifecycle = lifecycleOwner.lifecycle, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun HandleEvents(events: Flow<RocketsEvent>) { | |
val uriHandler = LocalUriHandler.current | |
events.collectWithLifecycle { | |
when (it) { | |
is OpenWebBrowserWithDetails -> { | |
uriHandler.openUri(it.uri) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventDelegateImpl<EVENT> : EventDelegate<EVENT> { | |
private val eventChannel = Channel<EVENT>(Channel.BUFFERED) | |
override fun getEvents(): Flow<EVENT> = eventChannel.receiveAsFlow() | |
override suspend fun setEvent(event: EVENT) { | |
eventChannel.send(event) | |
} | |
} |