Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,19 @@ android {
}

dependencies {
// The Metro graph and every module behind it come from :shared-compose. This module is just the
// Android entry point — an Activity, a theme, and a manifest.
implementation(project(":shared-compose"))

implementation(libs.circuit.foundation)

// Aligns every androidx.compose.* artifact on 1.12.0. Without it `foundation` and `animation`,
// which nothing declares, drift to whatever material3 and Compose Multiplatform ask for.
implementation(platform(libs.androidx.compose.bom))

// The Metro graph and every module behind it come from :shared-compose. This module is just the
// Android entry point — an Activity, a theme, and a manifest.
implementation(project(":shared-compose"))
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.material3)
implementation(libs.circuit.foundation)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.material)

Expand Down
14 changes: 8 additions & 6 deletions apple/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import io.github.solcott.countries.build.Versions
// here, not in the Xcode project, so Swift never constructs a Kotlin object graph by hand.
plugins {
id("formatting")
id("org.jetbrains.kotlin.multiplatform")
alias(libs.plugins.kotlin.multiplatform)
// Molecule recomposes `presenter.present()`, which is a @Composable call, so this module needs
// the Compose compiler even though it renders nothing.
alias(libs.plugins.kotlin.compose)
Expand All @@ -27,6 +27,8 @@ plugins {
// equality that lets `StateFlow` conflate a frame — see `EventSink` in AppleUiState.kt for that.
alias(libs.plugins.redacted)
id("compose.stability")
id("detekt")
alias(libs.plugins.dependency.sorter)
}

// Matches the `import CountriesKit` in the Swift sources. Changing it means changing both.
Expand Down Expand Up @@ -94,14 +96,14 @@ kotlin {
// makes commonMain the web source set in `:web`. A src/appleMain would hold everything and
// distinguish nothing.
commonMain.dependencies {
// `api` because Swift export emits everything reachable from this module's public API, and
// :model's data classes and :presenter's LoadStatus are reachable through the facade.
api(libs.dataresult)
api(project(":model"))
api(libs.uistate)
api(project(":presenter"))
api(libs.circuit.runtime)
api(libs.circuit.runtime.screen)
// `api` because Swift export emits everything reachable from this module's public API, and
// :model's data classes and :presenter's LoadStatus are reachable through the facade.
api(libs.dataresult)
api(libs.uistate)

// CoreGraph, and the repositories it vends. Not exported — Swift never sees the graph, only
// what CountriesKit hands back.
Expand All @@ -111,9 +113,9 @@ kotlin {
// references Compose `Modifier`; nothing in this module names it, so it stays out of the
// linked binary. `implementation`, so it never reaches the Swift export.
implementation(libs.circuitx.subcircuit)
implementation(libs.molecule.runtime)
implementation(libs.compose.runtime)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.molecule.runtime)
}

// Wired up by hand rather than by `kmp-library`, which this module deliberately does not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import app.cash.molecule.RecompositionMode
import app.cash.molecule.launchMolecule
import com.slack.circuit.runtime.Navigator
import io.github.solcott.countries.model.Continent
import io.github.solcott.countries.presenter.CountryDetailPresenter
import io.github.solcott.countries.presenter.CountryDetailScreen
import io.github.solcott.countries.presenter.CountryListPresenter
import io.github.solcott.countries.presenter.CountryListScreen
import io.github.solcott.countries.presenter.SearchAndFilterPresenter
import io.github.solcott.countries.presenter.SearchAndFilterScreen
import io.github.solcott.countries.presenter.countryDetailPresenter
import io.github.solcott.countries.presenter.countryListPresenter
import io.github.solcott.countries.repository.ContinentRepository
import io.github.solcott.countries.repository.CountryRepository
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -97,7 +97,7 @@ internal constructor(
* before anything is awaited — no optional, and no empty first render.
*/
val state: StateFlow<CountryListUiState> = moleculeState {
val listState = CountryListPresenter(navigator, countryRepository)
val listState = countryListPresenter(navigator, countryRepository)
val headerPresenter = remember { SearchAndFilterPresenter(continentRepository) }
val headerState = headerPresenter.present { outerEvent ->
when (outerEvent) {
Expand Down Expand Up @@ -143,7 +143,7 @@ internal constructor(
) : PresenterHolder(scope) {

val state: StateFlow<CountryDetailUiState> = moleculeState {
CountryDetailPresenter(screen, navigator, countryRepository).toUiState()
countryDetailPresenter(screen, navigator, countryRepository).toUiState()
}

fun back() {
Expand Down
6 changes: 5 additions & 1 deletion build-logic/src/main/kotlin/app.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import io.github.solcott.countries.build.Versions
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins { id("com.android.application") }
plugins {
id("com.android.application")
id("detekt")
id("com.squareup.sort-dependencies")
}

android {
compileSdk = Versions.compileSdk
Expand Down
38 changes: 38 additions & 0 deletions build-logic/src/main/kotlin/detekt.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import dev.detekt.gradle.Detekt
import dev.detekt.gradle.extensions.DetektExtension
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension

plugins { id("dev.detekt") }

configure<DetektExtension> {
config.setFrom(files("$rootDir/config/detekt/detekt.yml"))
buildUponDefaultConfig = true
allRules = false
}

tasks.withType<Detekt> {
reports { html.required = true }

exclude {
// excludes build directories
val buildDirectory = project.layout.buildDirectory.get().asFile
it.file.absolutePath.startsWith(buildDirectory.absolutePath) ||
it.file.path.contains("/build/") ||
it.file.name == "SharedBuildConfig.kt"
}
}

dependencies {
val composeRulesDep = versionCatalog.findLibrary("detekt.compose.rules").get()
add("detektPlugins", composeRulesDep)
}

tasks.register("detektAll") {
group = "verification"
val detektTasks = tasks.withType<Detekt>().matching { it.name != "detektDevJvm" }
dependsOn(detektTasks)
}

val Project.versionCatalog
get() = extensions.getByType(VersionCatalogsExtension::class.java).named("libs")
2 changes: 2 additions & 0 deletions build-logic/src/main/kotlin/kmp-library.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ plugins {
id("formatting")
id("org.jetbrains.kotlin.multiplatform")
id("com.android.kotlin.multiplatform.library")
id("com.squareup.sort-dependencies")
id("detekt")
}

// Captured here rather than inline: inside `kotlin { android { } }`, `name` resolves to the
Expand Down
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.metro) apply false
alias(libs.plugins.apollo) apply false
alias(libs.plugins.ktfmt) apply false
alias(libs.plugins.kmp.parcelize) apply false
alias(libs.plugins.compose.hot.reload) apply false
alias(libs.plugins.compose.multiplatform) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.detekt) apply false
alias(libs.plugins.dependency.sorter) apply false
}

// Pins the Gradle daemon's JVM. `./gradlew updateDaemonJvm` writes the criteria to
Expand Down
Loading
Loading