diff --git a/app-launcher/android/build.gradle.kts b/app-launcher/android/build.gradle.kts index 6578a44ee..fc7f0443d 100644 --- a/app-launcher/android/build.gradle.kts +++ b/app-launcher/android/build.gradle.kts @@ -52,7 +52,10 @@ kotlin { } val androidInstrumentedTest by getting { - dependsOn(androidMain.get()) + dependencies { + implementation(libs.androidx.core.splashscreen) + implementation(libs.google.android.material) + } } } } diff --git a/conferences-app/build.gradle.kts b/conferences-app/build.gradle.kts index 1a198f6fc..269946946 100644 --- a/conferences-app/build.gradle.kts +++ b/conferences-app/build.gradle.kts @@ -141,7 +141,10 @@ kotlin { } val androidInstrumentedTest by getting { - dependsOn(androidMain.get()) + dependencies { + implementation(libs.androidx.core.splashscreen) + implementation(libs.google.android.material) + } } jvmMain.dependencies { diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/config/CircuitConfig.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/config/CircuitConfig.kt index cfc2cbe82..dbff53fcb 100644 --- a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/config/CircuitConfig.kt +++ b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/config/CircuitConfig.kt @@ -7,19 +7,26 @@ import com.slack.circuit.foundation.Circuit import com.slack.circuit.runtime.presenter.presenterOf import io.ashdavies.content.PlatformContext import io.ashdavies.content.reportFullyDrawn +import io.ashdavies.http.DefaultHttpConfiguration import io.ashdavies.identity.IdentityManager import io.ashdavies.party.coroutines.rememberRetainedCoroutineScope import io.ashdavies.party.events.EventsPresenter import io.ashdavies.party.events.EventsScreen import io.ashdavies.party.events.paging.rememberEventPager +import io.ashdavies.party.gallery.File import io.ashdavies.party.gallery.GalleryPresenter import io.ashdavies.party.gallery.GalleryScreen +import io.ashdavies.party.gallery.ImageManager import io.ashdavies.party.gallery.PathProvider import io.ashdavies.party.gallery.StorageManager +import io.ashdavies.party.gallery.SyncManager +import io.ashdavies.party.gallery.inMemoryHttpClientEngine +import io.ashdavies.party.gallery.readChannel import io.ashdavies.party.home.HomePresenter import io.ashdavies.party.home.HomeScreen import io.ashdavies.playground.PlaygroundDatabase import io.ashdavies.sql.LocalTransacter +import io.ktor.client.HttpClient import kotlinx.coroutines.CoroutineScope import io.ashdavies.party.events.Event as DatabaseEvent @@ -31,6 +38,9 @@ public fun rememberCircuit( coroutineScope: CoroutineScope = rememberRetainedCoroutineScope(), ): Circuit = remember(platformContext) { val identityManager = IdentityManager(platformContext, playgroundDatabase.credentialQueries) + val imageManager = ImageManager(platformContext, playgroundDatabase.imageQueries) + val inMemoryHttpClient = HttpClient(inMemoryHttpClientEngine(), DefaultHttpConfiguration) + val syncManager = SyncManager(inMemoryHttpClient, File::readChannel) val storageManager = StorageManager(PathProvider(platformContext)) Circuit.Builder() @@ -41,7 +51,7 @@ public fun rememberCircuit( presenterOf { EventsPresenter(eventPager, coroutineScope) } } .addPresenter { _, _, _ -> - presenterOf { GalleryPresenter(platformContext) } + presenterOf { GalleryPresenter(imageManager, syncManager) } } .addUi { state, modifier -> HomeScreen(state, modifier, platformContext::reportFullyDrawn) diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/events/paging/EventPager.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/events/paging/EventPager.kt index dee63b9bf..798a9746d 100644 --- a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/events/paging/EventPager.kt +++ b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/events/paging/EventPager.kt @@ -6,6 +6,7 @@ import androidx.paging.ExperimentalPagingApi import androidx.paging.InvalidatingPagingSourceFactory import androidx.paging.Pager import androidx.paging.PagingConfig +import app.cash.sqldelight.Transacter import io.ashdavies.aggregator.AsgConference import io.ashdavies.aggregator.UpcomingConferencesCallable import io.ashdavies.config.RemoteConfig @@ -15,7 +16,8 @@ import io.ashdavies.http.common.models.EventCfp import io.ashdavies.party.events.EventsQueries import io.ashdavies.party.events.callable.PagedUpcomingEventsCallable import io.ashdavies.party.network.todayAsString -import io.ashdavies.party.sql.rememberLocalQueries +import io.ashdavies.playground.PlaygroundDatabase +import io.ashdavies.sql.LocalTransacter import io.ktor.client.HttpClient import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json @@ -70,6 +72,12 @@ private fun rememberUpcomingEventsCallable( } } +@Composable +internal fun rememberLocalQueries( + database: PlaygroundDatabase = LocalTransacter.current as PlaygroundDatabase, + transform: (PlaygroundDatabase) -> T, +): T = remember { transform(database) } + private fun AsgConference.toEvent(): ApiEvent = ApiEvent( id = hash(), name = name, website = website, location = location, dateStart = dateStart, dateEnd = dateEnd, imageUrl = imageUrl, status = status, online = online, diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/gallery/GalleryPresenter.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/gallery/GalleryPresenter.kt index 5828630b4..8182bb025 100644 --- a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/gallery/GalleryPresenter.kt +++ b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/gallery/GalleryPresenter.kt @@ -3,29 +3,16 @@ package io.ashdavies.party.gallery import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import com.slack.circuit.retained.produceRetainedState import com.slack.circuit.retained.rememberRetained -import io.ashdavies.content.PlatformContext -import io.ashdavies.party.sql.rememberLocalQueries import kotlinx.coroutines.launch -@Composable -internal fun GalleryPresenter( - platformContext: PlatformContext, - imageQueries: ImageQueries = rememberLocalQueries { it.imageQueries }, -): GalleryScreen.State = GalleryPresenter( - imageManager = remember(imageQueries) { - ImageManager(platformContext, imageQueries) - }, -) - @Composable internal fun GalleryPresenter( imageManager: ImageManager, - syncManager: SyncManager = remember { SyncManager() }, + syncManager: SyncManager, ): GalleryScreen.State { val itemList by produceRetainedState(emptyList()) { imageManager.list.collect { value = it } diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/gallery/SyncManager.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/gallery/SyncManager.kt index 0100d9dd6..c7fe28926 100644 --- a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/gallery/SyncManager.kt +++ b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/gallery/SyncManager.kt @@ -1,6 +1,5 @@ package io.ashdavies.party.gallery -import io.ashdavies.http.DefaultHttpConfiguration import io.ktor.client.HttpClient import io.ktor.client.call.body import io.ktor.client.request.get @@ -28,8 +27,8 @@ internal enum class SyncState { } internal fun SyncManager( - client: HttpClient = HttpClient(inMemoryHttpClientEngine(), DefaultHttpConfiguration), - reader: File.() -> ByteReadChannel = File::readChannel, + client: HttpClient, + reader: File.() -> ByteReadChannel, ): SyncManager = object : SyncManager { private val _state = MutableStateFlow>(emptyMap()) diff --git a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/sql/LocalQueries.kt b/conferences-app/src/commonMain/kotlin/io/ashdavies/party/sql/LocalQueries.kt deleted file mode 100644 index b67941c4b..000000000 --- a/conferences-app/src/commonMain/kotlin/io/ashdavies/party/sql/LocalQueries.kt +++ /dev/null @@ -1,13 +0,0 @@ -package io.ashdavies.party.sql - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import app.cash.sqldelight.Transacter -import io.ashdavies.playground.PlaygroundDatabase -import io.ashdavies.sql.LocalTransacter - -@Composable -internal fun rememberLocalQueries( - database: PlaygroundDatabase = LocalTransacter.current as PlaygroundDatabase, - transform: (PlaygroundDatabase) -> T, -): T = remember { transform(database) }