diff --git a/conferences-app/src/androidMain/kotlin/io/ashdavies/party/MainActivity.kt b/conferences-app/src/androidMain/kotlin/io/ashdavies/party/MainActivity.kt index 997f1b913..bfd67f1ad 100644 --- a/conferences-app/src/androidMain/kotlin/io/ashdavies/party/MainActivity.kt +++ b/conferences-app/src/androidMain/kotlin/io/ashdavies/party/MainActivity.kt @@ -24,7 +24,7 @@ import io.ashdavies.http.ProvideHttpClient import io.ashdavies.http.publicStorage import io.ashdavies.io.resolveCacheDir import io.ashdavies.material.dynamicColorScheme -import io.ashdavies.party.config.rememberCircuit +import io.ashdavies.party.circuit.rememberCircuit import io.ashdavies.party.home.HomeScreen import io.ashdavies.party.material.ProvideLocalWindowSizeClass import io.ashdavies.playground.BuildConfig diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/config/CircuitConfig.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/circuit/CircuitConfig.kt similarity index 93% rename from conferences-app/src/commonMain/kotlin/io/ashdavies/party/config/CircuitConfig.kt rename to conferences-app/src/commonMain/kotlin/io/ashdavies/party/circuit/CircuitConfig.kt index a69785c98..b552ba2c9 100644 --- a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/config/CircuitConfig.kt +++ b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/circuit/CircuitConfig.kt @@ -1,4 +1,4 @@ -package io.ashdavies.party.config +package io.ashdavies.party.circuit import androidx.compose.runtime.Composable import androidx.compose.runtime.remember @@ -17,7 +17,6 @@ import io.ashdavies.content.reportFullyDrawn import io.ashdavies.http.DefaultHttpConfiguration import io.ashdavies.http.LocalHttpClient import io.ashdavies.identity.IdentityManager -import io.ashdavies.party.coroutines.rememberRetainedCoroutineScope import io.ashdavies.party.events.paging.rememberEventPager import io.ashdavies.party.gallery.File import io.ashdavies.party.gallery.GalleryPresenter @@ -37,7 +36,6 @@ import io.ashdavies.party.upcoming.UpcomingEventsScreen import io.ashdavies.playground.PlaygroundDatabase import io.ashdavies.sql.LocalTransacter import io.ktor.client.HttpClient -import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import io.ashdavies.party.events.Event as DatabaseEvent @@ -46,7 +44,6 @@ public fun rememberCircuit( platformContext: PlatformContext, eventPager: Pager = rememberEventPager(), playgroundDatabase: PlaygroundDatabase = LocalTransacter.current as PlaygroundDatabase, - coroutineScope: CoroutineScope = rememberRetainedCoroutineScope(), ): Circuit = remember(platformContext) { val identityManager = IdentityManager(platformContext, playgroundDatabase.credentialQueries) val imageManager = ImageManager(platformContext, playgroundDatabase.imageQueries) @@ -57,7 +54,7 @@ public fun rememberCircuit( Circuit.Builder() .addCircuit( presenterFactory = { _, navigator, _ -> - presenterOf { HomePresenter(identityManager, coroutineScope, navigator) } + presenterOf { HomePresenter(identityManager, navigator) } }, uiFactory = { state, modifier -> HomeScreen(state, modifier, platformContext::reportFullyDrawn) @@ -65,7 +62,7 @@ public fun rememberCircuit( ) .addCircuit( presenterFactory = { _, _, _ -> - presenterOf { UpcomingEventsPresenter(eventPager, coroutineScope) } + presenterOf { UpcomingEventsPresenter(eventPager) } }, uiFactory = { state, modifier -> UpcomingEventsScreen(state, modifier) diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/events/EventsDetailPane.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/events/EventsDetailPane.kt index 7a7673228..ace3a181b 100644 --- a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/events/EventsDetailPane.kt +++ b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/events/EventsDetailPane.kt @@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Warning import androidx.compose.material.icons.outlined.MyLocation import androidx.compose.material3.Card @@ -27,6 +26,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.unit.dp import coil3.compose.AsyncImage +import io.ashdavies.party.material.BackButton import io.ashdavies.party.material.LocalWindowSizeClass import io.ashdavies.party.material.padding import io.ashdavies.party.material.spacing @@ -56,12 +56,7 @@ internal fun EventsDetailPane( }, navigationIcon = { if (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Compact) { - IconButton(onClick = onBackClick) { - Icon( - imageVector = Icons.AutoMirrored.Filled.ArrowBack, - contentDescription = null, - ) - } + BackButton(onBackClick) } }, ) diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/home/HomePresenter.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/home/HomePresenter.kt index 74bf0913f..ca45c3e0f 100644 --- a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/home/HomePresenter.kt +++ b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/home/HomePresenter.kt @@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import com.slack.circuit.foundation.onNavEvent import com.slack.circuit.retained.rememberRetained @@ -12,17 +13,16 @@ import com.slack.circuit.runtime.screen.Screen import io.ashdavies.identity.IdentityManager import io.ashdavies.identity.IdentityState import io.ashdavies.party.upcoming.UpcomingEventsScreen -import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch @Composable internal fun HomePresenter( identityManager: IdentityManager, - coroutineScope: CoroutineScope, navigator: Navigator, ): HomeScreen.State { val identityState by identityManager.state.collectAsState(IdentityState.Unauthenticated) var screen by rememberRetained { mutableStateOf(UpcomingEventsScreen) } + val coroutineScope = rememberCoroutineScope() return HomeScreen.State( identityState = identityState, diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/material/BackButton.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/material/BackButton.kt new file mode 100644 index 000000000..f65899d56 --- /dev/null +++ b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/material/BackButton.kt @@ -0,0 +1,25 @@ +package io.ashdavies.party.material + +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier + +@Composable +internal fun BackButton( + onClick: () -> Unit, + modifier: Modifier = Modifier, + contentDescription: String? = null, +) { + IconButton( + onClick = onClick, + modifier = modifier, + ) { + Icon( + imageVector = Icons.AutoMirrored.Filled.ArrowBack, + contentDescription = contentDescription, + ) + } +} diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/upcoming/UpcomingEventsPane.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/upcoming/UpcomingEventsPane.kt index 3d7b5ef65..4b04cd3ae 100644 --- a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/upcoming/UpcomingEventsPane.kt +++ b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/upcoming/UpcomingEventsPane.kt @@ -48,6 +48,7 @@ import io.ashdavies.party.events.EventsTopBar import io.ashdavies.party.events.daysUntilCfpEnd import io.ashdavies.party.material.padding import io.ashdavies.party.material.spacing +import io.ashdavies.party.material.values import io.ashdavies.placeholder.PlaceholderHighlight import io.ashdavies.placeholder.fade import io.ashdavies.placeholder.placeholder @@ -80,12 +81,15 @@ internal fun UpcomingEventsPane( EventFailure(state.errorMessage) } - LazyColumn(Modifier.fillMaxSize()) { + LazyColumn( + modifier = Modifier.fillMaxSize(), + contentPadding = MaterialTheme.spacing.large.values, + verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.large.vertical), + ) { itemsIndexed(state.itemList) { index, item -> val itemModifier = Modifier .animateItem() // TODO Slow animation on addition .fillMaxWidth() - .padding(MaterialTheme.spacing.large) .clip(MaterialTheme.shapes.medium) when (item) { diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/upcoming/UpcomingEventsPresenter.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/upcoming/UpcomingEventsPresenter.kt index b3bc6dcf7..1881cca8f 100644 --- a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/upcoming/UpcomingEventsPresenter.kt +++ b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/upcoming/UpcomingEventsPresenter.kt @@ -1,6 +1,7 @@ package io.ashdavies.party.upcoming import androidx.compose.runtime.Composable +import androidx.compose.runtime.rememberCoroutineScope import androidx.paging.Pager import androidx.paging.cachedIn import androidx.paging.compose.collectAsLazyPagingItems @@ -9,13 +10,12 @@ import io.ashdavies.party.events.Event import io.ashdavies.party.events.paging.errorMessage import io.ashdavies.party.events.paging.isRefreshing import kotlinx.collections.immutable.toImmutableList -import kotlinx.coroutines.CoroutineScope @Composable internal fun UpcomingEventsPresenter( eventPager: Pager, - coroutineScope: CoroutineScope, ): UpcomingEventsScreen.State { + val coroutineScope = rememberCoroutineScope() val pagingItems = rememberRetained(coroutineScope) { eventPager.flow.cachedIn(coroutineScope) }.collectAsLazyPagingItems() @@ -28,8 +28,8 @@ internal fun UpcomingEventsPresenter( isRefreshing = pagingItems.loadState.isRefreshing, errorMessage = pagingItems.loadState.errorMessage, ) { event -> - if (event is UpcomingEventsScreen.Event.Refresh) { - pagingItems.refresh() + when (event) { + is UpcomingEventsScreen.Event.Refresh -> pagingItems.refresh() } } } diff --git a/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/Main.kt b/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/Main.kt index c9bbd1b3e..838241773 100644 --- a/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/Main.kt +++ b/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/Main.kt @@ -23,7 +23,7 @@ import io.ashdavies.http.ProvideHttpClient import io.ashdavies.http.publicStorage import io.ashdavies.io.resolveCacheDir import io.ashdavies.material.dynamicColorScheme -import io.ashdavies.party.config.rememberCircuit +import io.ashdavies.party.circuit.rememberCircuit import io.ashdavies.party.home.HomeScreen import io.ashdavies.party.material.ProvideLocalWindowSizeClass import io.ashdavies.playground.BuildConfig diff --git a/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfig.kt b/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfig.kt index e8eaba1b2..115b0d059 100644 --- a/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfig.kt +++ b/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfig.kt @@ -8,7 +8,3 @@ public interface RemoteConfig { public suspend fun RemoteConfig.getBoolean(key: String): Boolean { return getValue(key) { it.asBoolean() } } - -public suspend fun RemoteConfig.getString(key: String): String { - return getValue(key) { it.asString() } -}