From c33f6b7b10229ab7a0d73457a04caad8b06e4fec Mon Sep 17 00:00:00 2001 From: Yang Date: Sat, 4 Jan 2025 22:38:20 +1100 Subject: [PATCH] Migrate from context receivers to extension receiver and explicit param. (#264) --- .../kstreamlined/android/KSActivity.kt | 4 ++ .../kstreamlined/android/MainScreen.kt | 70 ++++++++++--------- .../contentviewer/ContentViewerScreen.kt | 10 +-- .../android/feature/home/HomeScreen.kt | 46 ++++++------ .../KotlinWeeklyIssueScreen.kt | 13 ++-- .../savedforlater/SavedForLaterScreen.kt | 44 ++++++------ .../TalkingKotlinEpisodeScreen.kt | 20 +++--- .../commonui/feed/KotlinBlogCard.kt | 3 +- .../commonui/feed/KotlinYouTubeCard.kt | 3 +- .../commonui/feed/TalkingKotlinCard.kt | 3 +- .../designsystem/component/TopNavBar.kt | 6 +- .../buildlogic/languageSettings.kt | 2 +- 12 files changed, 115 insertions(+), 109 deletions(-) diff --git a/android/app/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/KSActivity.kt b/android/app/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/KSActivity.kt index 90c35117..e0e1a83c 100644 --- a/android/app/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/KSActivity.kt +++ b/android/app/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/KSActivity.kt @@ -77,6 +77,7 @@ class KSActivity : ComponentActivity() { when (it) { is NavDestination.Main -> { MainScreen( + animatedVisibilityScope = this@AnimatedContent, selectedNavItem = selectedNavItem, onSelectedNavItemChanged = { item -> selectedNavItem = item }, homeListState = homeListState, @@ -117,6 +118,7 @@ class KSActivity : ComponentActivity() { is NavDestination.ContentViewer -> { ContentViewerScreen( + animatedVisibilityScope = this@AnimatedContent, boundsKey = it.boundsKey, topBarBoundsKey = it.topBarBoundsKey, saveButtonElementKey = it.saveButtonElementKey, @@ -129,6 +131,7 @@ class KSActivity : ComponentActivity() { is NavDestination.KotlinWeeklyIssue -> { KotlinWeeklyIssueScreen( + animatedVisibilityScope = this@AnimatedContent, boundsKey = it.boundKey, topBarBoundsKey = it.topBarBoundsKey, titleElementKey = it.titleElementKey, @@ -142,6 +145,7 @@ class KSActivity : ComponentActivity() { is NavDestination.TalkingKotlinEpisode -> { TalkingKotlinEpisodeScreen( + animatedVisibilityScope = this@AnimatedContent, boundsKey = it.boundsKey, topBarBoundsKey = it.topBarBoundsKey, playerElementKey = it.playerElementKey, diff --git a/android/app/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/MainScreen.kt b/android/app/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/MainScreen.kt index 35810b02..1504e6e0 100644 --- a/android/app/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/MainScreen.kt +++ b/android/app/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/MainScreen.kt @@ -37,9 +37,9 @@ import io.github.reactivecircus.kstreamlined.android.foundation.designsystem.fou import io.github.reactivecircus.kstreamlined.kmp.model.feed.FeedItem import kotlin.math.absoluteValue -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -fun MainScreen( +fun SharedTransitionScope.MainScreen( + animatedVisibilityScope: AnimatedVisibilityScope, selectedNavItem: NavItemKey, onSelectedNavItemChanged: (NavItemKey) -> Unit, homeListState: LazyListState, @@ -61,6 +61,7 @@ fun MainScreen( when (it) { NavItemKey.Home.ordinal -> { HomeScreen( + animatedVisibilityScope = animatedVisibilityScope, listState = homeListState, onViewItem = { item -> onViewItem(item, NavItemKey.Home) }, modifier = Modifier.pagerScaleTransition(it, pagerState) @@ -69,6 +70,7 @@ fun MainScreen( NavItemKey.Saved.ordinal -> { SavedForLaterScreen( + animatedVisibilityScope = animatedVisibilityScope, listState = savedListState, onViewItem = { item -> onViewItem(item, NavItemKey.Saved) }, modifier = Modifier.pagerScaleTransition(it, pagerState) @@ -87,38 +89,40 @@ fun MainScreen( ) } - NavigationIsland( - modifier = Modifier - .navigationBarsPadding() - .padding(8.dp) - .align(Alignment.BottomCenter) - .renderInSharedTransitionScopeOverlay( - zIndexInOverlay = 1f + with(animatedVisibilityScope) { + NavigationIsland( + modifier = Modifier + .navigationBarsPadding() + .padding(8.dp) + .align(Alignment.BottomCenter) + .renderInSharedTransitionScopeOverlay( + zIndexInOverlay = 1f + ) + .animateEnterExit( + enter = fadeIn() + slideInVertically( + tween(delayMillis = 200, easing = LinearOutSlowInEasing) + ) { it * 2 }, + exit = fadeOut(), + ), + ) { + NavigationIslandItem( + selected = selectedNavItem == NavItemKey.Home, + icon = KSIcons.Kotlin, + contentDescription = "Home", + onClick = { + onSelectedNavItemChanged(NavItemKey.Home) + }, ) - .animateEnterExit( - enter = fadeIn() + slideInVertically( - tween(delayMillis = 200, easing = LinearOutSlowInEasing) - ) { it * 2 }, - exit = fadeOut(), - ), - ) { - NavigationIslandItem( - selected = selectedNavItem == NavItemKey.Home, - icon = KSIcons.Kotlin, - contentDescription = "Home", - onClick = { - onSelectedNavItemChanged(NavItemKey.Home) - }, - ) - NavigationIslandDivider() - NavigationIslandItem( - selected = selectedNavItem == NavItemKey.Saved, - icon = KSIcons.Bookmarks, - contentDescription = "Saved", - onClick = { - onSelectedNavItemChanged(NavItemKey.Saved) - }, - ) + NavigationIslandDivider() + NavigationIslandItem( + selected = selectedNavItem == NavItemKey.Saved, + icon = KSIcons.Bookmarks, + contentDescription = "Saved", + onClick = { + onSelectedNavItemChanged(NavItemKey.Saved) + }, + ) + } } } } diff --git a/android/feature/content-viewer/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/contentviewer/ContentViewerScreen.kt b/android/feature/content-viewer/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/contentviewer/ContentViewerScreen.kt index 39ef11fd..ec7ae402 100644 --- a/android/feature/content-viewer/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/contentviewer/ContentViewerScreen.kt +++ b/android/feature/content-viewer/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/contentviewer/ContentViewerScreen.kt @@ -59,9 +59,9 @@ import io.github.reactivecircus.kstreamlined.kmp.presentation.contentviewer.Cont import io.github.reactivecircus.kstreamlined.kmp.presentation.contentviewer.ContentViewerUiState import io.github.reactivecircus.kstreamlined.android.feature.common.R as commonR -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -public fun ContentViewerScreen( +public fun SharedTransitionScope.ContentViewerScreen( + animatedVisibilityScope: AnimatedVisibilityScope, boundsKey: String, topBarBoundsKey: String, saveButtonElementKey: String, @@ -85,12 +85,12 @@ public fun ContentViewerScreen( .background(KSTheme.colorScheme.background) .sharedBounds( rememberSharedContentState(key = boundsKey), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), ) { val context = LocalContext.current TopNavBar( - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, boundsKey = topBarBoundsKey, title = "", contentPadding = WindowInsets.statusBars.asPaddingValues(), @@ -122,7 +122,7 @@ public fun ContentViewerScreen( onClick = { eventSink(ContentViewerUiEvent.ToggleSavedForLater) }, modifier = Modifier.sharedElement( rememberSharedContentState(key = saveButtonElementKey), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, zIndexInOverlay = 1f, ), ) diff --git a/android/feature/home/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/home/HomeScreen.kt b/android/feature/home/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/home/HomeScreen.kt index 3372d273..a8780529 100644 --- a/android/feature/home/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/home/HomeScreen.kt +++ b/android/feature/home/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/home/HomeScreen.kt @@ -66,9 +66,9 @@ import io.github.reactivecircus.kstreamlined.kmp.presentation.home.HomeUiState import kotlinx.coroutines.delay import io.github.reactivecircus.kstreamlined.android.feature.common.R as commonR -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -public fun HomeScreen( +public fun SharedTransitionScope.HomeScreen( + animatedVisibilityScope: AnimatedVisibilityScope, listState: LazyListState, onViewItem: (FeedItem) -> Unit, modifier: Modifier = Modifier, @@ -77,6 +77,7 @@ public fun HomeScreen( val uiState by viewModel.uiState.collectAsStateWithLifecycle() val eventSink = viewModel.eventSink HomeScreen( + animatedVisibilityScope = animatedVisibilityScope, listState = listState, onViewItem = onViewItem, uiState = uiState, @@ -86,9 +87,9 @@ public fun HomeScreen( ReportDrawnWhen { uiState !is HomeUiState.Loading } } -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -internal fun HomeScreen( +internal fun SharedTransitionScope.HomeScreen( + animatedVisibilityScope: AnimatedVisibilityScope, listState: LazyListState, onViewItem: (FeedItem) -> Unit, uiState: HomeUiState, @@ -102,7 +103,7 @@ internal fun HomeScreen( .background(KSTheme.colorScheme.background), ) { TopNavBar( - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, boundsKey = "Bounds/Home/TopBar", titleElementKey = "Element/Home/TopBar/Title", title = stringResource(id = R.string.title_home), @@ -147,15 +148,14 @@ internal fun HomeScreen( } is HomeUiState.Content -> { - with(this@AnimatedVisibilityScope) { - ContentUi( - listState = listState, - items = state.feedItems, - showTransientError = state.hasTransientError, - onItemClick = onViewItem, - eventSink = eventSink, - ) - } + ContentUi( + animatedVisibilityScope = animatedVisibilityScope, + listState = listState, + items = state.feedItems, + showTransientError = state.hasTransientError, + onItemClick = onViewItem, + eventSink = eventSink, + ) } } } @@ -163,9 +163,9 @@ internal fun HomeScreen( } } -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -private fun ContentUi( +private fun SharedTransitionScope.ContentUi( + animatedVisibilityScope: AnimatedVisibilityScope, listState: LazyListState, items: List, showTransientError: Boolean, @@ -224,9 +224,9 @@ private fun ContentUi( .animateItem() .sharedBounds( rememberSharedContentState(key = "Bounds/Home/${item.id}"), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, saveButtonElementKey = "Element/Home/${item.id}/saveButton", ) } @@ -242,7 +242,7 @@ private fun ContentUi( .animateItem() .sharedBounds( rememberSharedContentState(key = "Bounds/Home/${item.id}"), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), ) } @@ -258,9 +258,9 @@ private fun ContentUi( .animateItem() .sharedBounds( rememberSharedContentState(key = "Bounds/Home/${item.id}"), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, saveButtonElementKey = "Element/Home/${item.id}/saveButton", ) } @@ -276,9 +276,9 @@ private fun ContentUi( .animateItem() .sharedBounds( rememberSharedContentState(key = "Bounds/Home/${item.id}"), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, cardElementKey = "Element/Home/${item.id}/player", ) } diff --git a/android/feature/kotlin-weekly-issue/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/kotlinweeklyissue/KotlinWeeklyIssueScreen.kt b/android/feature/kotlin-weekly-issue/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/kotlinweeklyissue/KotlinWeeklyIssueScreen.kt index 57b31124..3f686cc2 100644 --- a/android/feature/kotlin-weekly-issue/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/kotlinweeklyissue/KotlinWeeklyIssueScreen.kt +++ b/android/feature/kotlin-weekly-issue/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/kotlinweeklyissue/KotlinWeeklyIssueScreen.kt @@ -63,9 +63,9 @@ import io.github.reactivecircus.kstreamlined.kmp.presentation.kotlinweeklyissue. import io.github.reactivecircus.kstreamlined.kmp.presentation.kotlinweeklyissue.KotlinWeeklyIssueUiState import io.github.reactivecircus.kstreamlined.android.feature.common.R as commonR -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -public fun KotlinWeeklyIssueScreen( +public fun SharedTransitionScope.KotlinWeeklyIssueScreen( + animatedVisibilityScope: AnimatedVisibilityScope, boundsKey: String, topBarBoundsKey: String, titleElementKey: String, @@ -85,6 +85,7 @@ public fun KotlinWeeklyIssueScreen( val context = LocalContext.current val title = stringResource(id = R.string.title_kotlin_weekly_issue, issueNumber) KotlinWeeklyIssueScreen( + animatedVisibilityScope = animatedVisibilityScope, topBarBoundsKey = topBarBoundsKey, titleElementKey = titleElementKey, id = id, @@ -100,14 +101,14 @@ public fun KotlinWeeklyIssueScreen( eventSink = eventSink, modifier = modifier.sharedBounds( rememberSharedContentState(key = boundsKey), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), ) } -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -internal fun KotlinWeeklyIssueScreen( +internal fun SharedTransitionScope.KotlinWeeklyIssueScreen( + animatedVisibilityScope: AnimatedVisibilityScope, topBarBoundsKey: String, titleElementKey: String, id: String, @@ -126,7 +127,7 @@ internal fun KotlinWeeklyIssueScreen( .background(KSTheme.colorScheme.background), ) { TopNavBar( - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, boundsKey = topBarBoundsKey, titleElementKey = titleElementKey, title = title, diff --git a/android/feature/saved-for-later/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/savedforlater/SavedForLaterScreen.kt b/android/feature/saved-for-later/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/savedforlater/SavedForLaterScreen.kt index 03b00380..c4de54ec 100644 --- a/android/feature/saved-for-later/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/savedforlater/SavedForLaterScreen.kt +++ b/android/feature/saved-for-later/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/savedforlater/SavedForLaterScreen.kt @@ -52,9 +52,9 @@ import io.github.reactivecircus.kstreamlined.kmp.presentation.savedforlater.Save import io.github.reactivecircus.kstreamlined.kmp.presentation.savedforlater.SavedForLaterUiState import io.github.reactivecircus.kstreamlined.android.feature.common.R as commonR -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -public fun SavedForLaterScreen( +public fun SharedTransitionScope.SavedForLaterScreen( + animatedVisibilityScope: AnimatedVisibilityScope, listState: LazyListState, onViewItem: (FeedItem) -> Unit, modifier: Modifier = Modifier, @@ -63,6 +63,7 @@ public fun SavedForLaterScreen( val uiState by viewModel.uiState.collectAsStateWithLifecycle() val eventSink = viewModel.eventSink SavedForLaterScreen( + animatedVisibilityScope = animatedVisibilityScope, listState = listState, onViewItem = onViewItem, uiState = uiState, @@ -71,9 +72,9 @@ public fun SavedForLaterScreen( ) } -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -internal fun SavedForLaterScreen( +internal fun SharedTransitionScope.SavedForLaterScreen( + animatedVisibilityScope: AnimatedVisibilityScope, listState: LazyListState, onViewItem: (FeedItem) -> Unit, uiState: SavedForLaterUiState, @@ -87,7 +88,7 @@ internal fun SavedForLaterScreen( .background(KSTheme.colorScheme.background), ) { TopNavBar( - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, boundsKey = "Bounds/Saved/TopBar", titleElementKey = "Element/Saved/TopBar/Title", title = stringResource(id = R.string.title_saved_for_later), @@ -110,14 +111,13 @@ internal fun SavedForLaterScreen( label = "isEmpty", ) { isEmpty -> if (!isEmpty) { - with(this@AnimatedVisibilityScope) { - ContentUi( - listState = listState, - items = uiState.feedItems, - onItemClick = onViewItem, - eventSink = eventSink, - ) - } + ContentUi( + animatedVisibilityScope = animatedVisibilityScope, + listState = listState, + items = uiState.feedItems, + onItemClick = onViewItem, + eventSink = eventSink, + ) } else { EmptyUi() } @@ -127,10 +127,10 @@ internal fun SavedForLaterScreen( } } -context(SharedTransitionScope, AnimatedVisibilityScope) @Suppress("MaxLineLength") @Composable -private fun ContentUi( +private fun SharedTransitionScope.ContentUi( + animatedVisibilityScope: AnimatedVisibilityScope, listState: LazyListState, items: List>, onItemClick: (FeedItem) -> Unit, @@ -159,9 +159,9 @@ private fun ContentUi( .animateItem() .sharedBounds( rememberSharedContentState(key = "Bounds/Saved/${item.id}"), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, saveButtonElementKey = "Element/Saved/${item.id}/saveButton", ) } @@ -175,7 +175,7 @@ private fun ContentUi( .animateItem() .sharedBounds( rememberSharedContentState(key = "Bounds/Saved/${item.id}"), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), ) } @@ -189,9 +189,9 @@ private fun ContentUi( .animateItem() .sharedBounds( rememberSharedContentState(key = "Bounds/Saved/${item.id}"), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, saveButtonElementKey = "Element/Saved/${item.id}/saveButton", ) } @@ -205,9 +205,9 @@ private fun ContentUi( .animateItem() .sharedBounds( rememberSharedContentState(key = "Bounds/Saved/${item.id}"), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, cardElementKey = "Element/Saved/${item.id}/player", ) } diff --git a/android/feature/talking-kotlin-episode/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/talkingkotlinepisode/TalkingKotlinEpisodeScreen.kt b/android/feature/talking-kotlin-episode/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/talkingkotlinepisode/TalkingKotlinEpisodeScreen.kt index 9e8f48ef..3f7f1d3b 100644 --- a/android/feature/talking-kotlin-episode/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/talkingkotlinepisode/TalkingKotlinEpisodeScreen.kt +++ b/android/feature/talking-kotlin-episode/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/talkingkotlinepisode/TalkingKotlinEpisodeScreen.kt @@ -67,9 +67,9 @@ import io.github.reactivecircus.kstreamlined.kmp.presentation.talkingkotlinepiso import io.github.reactivecircus.kstreamlined.kmp.presentation.talkingkotlinepisode.TalkingKotlinEpisodeUiState import io.github.reactivecircus.kstreamlined.android.feature.common.R as commonR -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -public fun TalkingKotlinEpisodeScreen( +public fun SharedTransitionScope.TalkingKotlinEpisodeScreen( + animatedVisibilityScope: AnimatedVisibilityScope, topBarBoundsKey: String, boundsKey: String, playerElementKey: String, @@ -90,6 +90,7 @@ public fun TalkingKotlinEpisodeScreen( val context = LocalContext.current TalkingKotlinEpisodeScreen( + animatedVisibilityScope = animatedVisibilityScope, topBarBoundsKey = topBarBoundsKey, playerElementKey = playerElementKey, onNavigateUp = onNavigateUp, @@ -101,14 +102,14 @@ public fun TalkingKotlinEpisodeScreen( eventSink = eventSink, modifier = modifier.sharedBounds( rememberSharedContentState(key = boundsKey), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ), ) } -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -internal fun TalkingKotlinEpisodeScreen( +internal fun SharedTransitionScope.TalkingKotlinEpisodeScreen( + animatedVisibilityScope: AnimatedVisibilityScope, topBarBoundsKey: String, playerElementKey: String, onNavigateUp: () -> Unit, @@ -125,7 +126,7 @@ internal fun TalkingKotlinEpisodeScreen( .background(KSTheme.colorScheme.background), ) { TopNavBar( - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, boundsKey = topBarBoundsKey, title = "", modifier = Modifier.zIndex(1f), @@ -174,6 +175,7 @@ internal fun TalkingKotlinEpisodeScreen( is TalkingKotlinEpisodeUiState.Content -> { ContentUi( + animatedVisibilityScope = animatedVisibilityScope, playerElementKey = playerElementKey, episode = uiState.episode, eventSink = eventSink, @@ -186,9 +188,9 @@ internal fun TalkingKotlinEpisodeScreen( } } -context(SharedTransitionScope, AnimatedVisibilityScope) @Composable -private fun ContentUi( +private fun SharedTransitionScope.ContentUi( + animatedVisibilityScope: AnimatedVisibilityScope, playerElementKey: String, episode: TalkingKotlinEpisode, eventSink: (TalkingKotlinEpisodeUiEvent) -> Unit, @@ -302,7 +304,7 @@ private fun ContentUi( contentPadding = WindowInsets.navigationBars.asPaddingValues(), modifier = Modifier.sharedElement( rememberSharedContentState(key = playerElementKey), - animatedVisibilityScope = this@AnimatedVisibilityScope, + animatedVisibilityScope = animatedVisibilityScope, ) ) } diff --git a/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/KotlinBlogCard.kt b/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/KotlinBlogCard.kt index 36dc6b6e..5a6ef5f2 100644 --- a/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/KotlinBlogCard.kt +++ b/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/KotlinBlogCard.kt @@ -36,9 +36,8 @@ import io.github.reactivecircus.kstreamlined.kmp.model.feed.FeedItem import io.github.reactivecircus.kstreamlined.kmp.model.feed.toDisplayable import kotlinx.datetime.Instant -context(SharedTransitionScope) @Composable -public fun KotlinBlogCard( +public fun SharedTransitionScope.KotlinBlogCard( item: DisplayableFeedItem, onItemClick: (FeedItem.KotlinBlog) -> Unit, onSaveButtonClick: (FeedItem.KotlinBlog) -> Unit, diff --git a/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/KotlinYouTubeCard.kt b/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/KotlinYouTubeCard.kt index 36a15c4f..5266b6fb 100644 --- a/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/KotlinYouTubeCard.kt +++ b/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/KotlinYouTubeCard.kt @@ -44,9 +44,8 @@ import io.github.reactivecircus.kstreamlined.kmp.model.feed.FeedItem import io.github.reactivecircus.kstreamlined.kmp.model.feed.toDisplayable import kotlinx.datetime.Instant -context(SharedTransitionScope) @Composable -public fun KotlinYouTubeCard( +public fun SharedTransitionScope.KotlinYouTubeCard( item: DisplayableFeedItem, onItemClick: (FeedItem.KotlinYouTube) -> Unit, onSaveButtonClick: (FeedItem.KotlinYouTube) -> Unit, diff --git a/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/TalkingKotlinCard.kt b/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/TalkingKotlinCard.kt index 17a59052..9d0cb877 100644 --- a/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/TalkingKotlinCard.kt +++ b/android/foundation/common-ui/feed/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/commonui/feed/TalkingKotlinCard.kt @@ -51,9 +51,8 @@ import io.github.reactivecircus.kstreamlined.kmp.model.feed.FeedItem import io.github.reactivecircus.kstreamlined.kmp.model.feed.toDisplayable import kotlinx.datetime.Instant -context(SharedTransitionScope) @Composable -public fun TalkingKotlinCard( +public fun SharedTransitionScope.TalkingKotlinCard( item: DisplayableFeedItem, onItemClick: (FeedItem.TalkingKotlin) -> Unit, onSaveButtonClick: (FeedItem.TalkingKotlin) -> Unit, diff --git a/android/foundation/designsystem/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/designsystem/component/TopNavBar.kt b/android/foundation/designsystem/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/designsystem/component/TopNavBar.kt index eab58e23..9311ed59 100644 --- a/android/foundation/designsystem/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/designsystem/component/TopNavBar.kt +++ b/android/foundation/designsystem/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/foundation/designsystem/component/TopNavBar.kt @@ -34,9 +34,8 @@ import androidx.compose.ui.unit.sp import io.github.reactivecircus.kstreamlined.android.foundation.designsystem.foundation.KSTheme import io.github.reactivecircus.kstreamlined.android.foundation.designsystem.foundation.icon.KSIcons -context(SharedTransitionScope) @Composable -public fun TopNavBar( +public fun SharedTransitionScope.TopNavBar( title: String, modifier: Modifier = Modifier, animatedVisibilityScope: AnimatedVisibilityScope? = null, @@ -108,9 +107,8 @@ public fun TopNavBar( } } -context(SharedTransitionScope) @Composable -private fun GradientTitle( +private fun SharedTransitionScope.GradientTitle( animatedVisibilityScope: AnimatedVisibilityScope?, titleElementKey: String?, text: String, diff --git a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/languageSettings.kt b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/languageSettings.kt index e1166916..6684c670 100644 --- a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/languageSettings.kt +++ b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/languageSettings.kt @@ -6,7 +6,7 @@ internal fun LanguageSettingsBuilder.applyLanguageSettings(): LanguageSettingsBu return apply { progressiveMode = true optIn("kotlin.experimental.ExperimentalObjCName") - enableLanguageFeature("ContextReceivers") + enableLanguageFeature("ContextParameters") enableLanguageFeature("ExplicitBackingFields") } }