Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
Clean up dependency graph to remove cycle
  • Loading branch information
dellisd committed Feb 3, 2024
1 parent 9dc093d commit 703bd3f
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 298 deletions.
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
coroutines = "1.6.4"
kotlin = "1.8.10"
kotlin = "1.9.21"
kotlinx-serialization = "1.5.0"
sqldelight = "2.0.0"
sqldelight = "2.0.1"
ktlint = "0.48.2"
ktor = "2.3.4"
inject = "0.5.1"
inject = "0.6.3"

copyWebpackPlugin = "9.1.0"
mapboxGl = "2.10.0"
Expand Down Expand Up @@ -47,7 +47,7 @@ inject-runtime = { module = "me.tatarka.inject:kotlin-inject-runtime", version.r
molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version = "0.7.1" }

assertk = { module = "com.willowtreeapps.assertk:assertk", version = "0.27.0" }
compose-mapbox = { module = "ca.derekellis.mapbox:compose-web-mapbox", version = "0.1.0-SNAPSHOT" }
compose-mapbox = { module = "ca.derekellis.mapbox:compose-web-mapbox", version = "0.2.0-SNAPSHOT" }
spatialk-geojson = "io.github.dellisd.spatialk:geojson:0.3.0-SNAPSHOT"
kgtfs-gtfs = "ca.derekellis.kgtfs:gtfs:0.2.0-SNAPSHOT"
logback = "ch.qos.logback:logback-classic:1.2.11"
Expand All @@ -60,9 +60,9 @@ junit = "junit:junit:4.13.2"
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
compose = { id = "org.jetbrains.compose", version = "1.3.1-rc02" }
compose = { id = "org.jetbrains.compose", version = "1.5.11" }
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
ksp = { id = "com.google.devtools.ksp", version = "1.8.10-1.0.9" }
ksp = { id = "com.google.devtools.ksp", version = "1.9.21-1.0.15" }
buildkonfig = { id = "com.codingfeline.buildkonfig", version = "0.12.0" }
shadow = { id = "com.github.johnrengelman.shadow", version = "7.1.2" }
spotless = { id = "com.diffplug.spotless", version = "6.16.0" }
640 changes: 370 additions & 270 deletions kotlin-js-store/yarn.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ kotlin {
implementation(libs.sqldelight.coroutines)
implementation(libs.sqldelight.primitiveAdapters)

// implementation(libs.spatialk.geojson)
implementation(libs.spatialk.geojson)
implementation(libs.inject.runtime)
implementation(libs.kotlinx.datetime)
implementation(libs.kotlinx.serialization.json)
Expand Down
6 changes: 4 additions & 2 deletions web/src/jsMain/kotlin/ca/derekellis/reroute/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.runtime.remember
import ca.derekellis.reroute.di.AppComponent
import ca.derekellis.reroute.di.create
import ca.derekellis.reroute.map.Map
import ca.derekellis.reroute.ui.AppNavigator
import ca.derekellis.reroute.ui.AppStylesheet
import ca.derekellis.reroute.ui.Presenter
import ca.derekellis.reroute.ui.ScreenWrapper
Expand All @@ -23,21 +24,22 @@ fun main() {
renderComposable(rootElementId = "root") {
Style(AppStylesheet)

MapSection(component.viewFactory, component.presenterFactory)
MapSection(component.appNavigator, component.viewFactory, component.presenterFactory)
component.application()
component.appNavigator.handleNavigation()
}
}

@Composable
fun MapSection(
appNavigator: AppNavigator,
viewFactory: ViewFactory,
presenterFactory: PresenterFactory,
) {
val wrapper = remember {
@Suppress("UNCHECKED_CAST")
ScreenWrapper(
presenterFactory.createPresenter(Map) as Presenter<Any, Any>,
presenterFactory.createPresenter(appNavigator, Map) as Presenter<Any, Any>,
viewFactory.createView(Map) as View<Any, Any>,
)
}
Expand Down
19 changes: 10 additions & 9 deletions web/src/jsMain/kotlin/ca/derekellis/reroute/PresenterFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ import ca.derekellis.reroute.search.Search
import ca.derekellis.reroute.search.SearchPresenter
import ca.derekellis.reroute.stops.Stop
import ca.derekellis.reroute.stops.StopPresenter
import ca.derekellis.reroute.ui.Navigator
import ca.derekellis.reroute.ui.Presenter
import ca.derekellis.reroute.ui.Screen
import me.tatarka.inject.annotations.Inject

@Inject
class PresenterFactory(
private val stopPresenterFactory: (Stop) -> StopPresenter,
private val homePresenterFactory: (Home) -> HomePresenter,
private val mapPresenterFactory: (Map) -> MapPresenter,
private val searchPresenterFactory: (Search) -> SearchPresenter,
private val stopPresenterFactory: StopPresenter.Factory,
private val homePresenterFactory: HomePresenter.Factory,
private val mapPresenterFactory: MapPresenter.Factory,
private val searchPresenterFactory: SearchPresenter.Factory,
) {
fun createPresenter(screen: Screen): Presenter<*, *> = when (screen) {
is Home -> homePresenterFactory(screen)
is Stop -> stopPresenterFactory(screen)
is Map -> mapPresenterFactory(screen)
is Search -> searchPresenterFactory(screen)
fun createPresenter(navigator: Navigator, screen: Screen): Presenter<*, *> = when (screen) {
is Home -> homePresenterFactory.create(screen)
is Stop -> stopPresenterFactory.create(navigator, screen)
is Map -> mapPresenterFactory.create(navigator, screen)
is Search -> searchPresenterFactory.create(navigator, screen)
else -> throw IllegalArgumentException("Unsupported screen $screen")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract class AppComponent {
@AppScope
protected fun searchScreenWrapper(viewFactory: ViewFactory, presenterFactory: PresenterFactory): SearchScreenWrapper =
ScreenWrapper(
presenterFactory.createPresenter(Search) as Presenter<Any, Any>,
presenterFactory.createPresenter(appNavigator, Search) as Presenter<Any, Any>,
viewFactory.createView(Search) as View<Any, Any>,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ package ca.derekellis.reroute.home
import androidx.compose.runtime.Composable
import ca.derekellis.reroute.ui.Presenter
import kotlinx.coroutines.flow.Flow
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject

@Inject
class HomePresenter(private val args: Home) : Presenter<Unit, Unit> {
class HomePresenter(@Assisted private val args: Home) : Presenter<Unit, Unit> {
@Composable
override fun produceModel(events: Flow<Unit>) = Unit

// TODO: Replace with fun interface
@Inject
class Factory(val create: (Home) -> HomePresenter)
}
11 changes: 8 additions & 3 deletions web/src/jsMain/kotlin/ca/derekellis/reroute/map/MapPresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ import ca.derekellis.reroute.ui.Presenter
import io.github.dellisd.spatialk.geojson.Feature
import io.github.dellisd.spatialk.geojson.dsl.feature
import kotlinx.coroutines.flow.Flow
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject
import ca.derekellis.reroute.stops.Stop as StopScreen

@Inject
class MapPresenter(
private val dataSource: DataSource,
private val interactionsManager: MapInteractionsManager,
private val navigator: Navigator,
private val withDatabase: DatabaseHelper,
private val args: Map,
@Assisted private val navigator: Navigator,
@Assisted private val args: Map,
) : Presenter<MapViewModel, MapViewEvent> {
@Composable
override fun produceModel(events: Flow<MapViewEvent>): MapViewModel {
Expand All @@ -45,7 +46,7 @@ class MapPresenter(
} else {
database.routeVariantQueries.getByIds(displayedRoutes).asFlow().mapToList(coroutineContext)
.collect { routes ->
routeFeatures = routes.mapIndexedTo(mutableSetOf()) { index, route ->
routeFeatures = routes.mapIndexedTo(mutableSetOf()) { _, route ->
feature(route.shape) {
put("id", route.id)
put("gtfsId", route.gtfsId)
Expand Down Expand Up @@ -80,4 +81,8 @@ class MapPresenter(
private const val COLOR_CONFEDERATION = "#d62e3b"
private const val COLOR_TRILLIUM = "#76bf43"
}

// TODO: Replace with fun interface
@Inject
class Factory(val create: (Navigator, Map) -> MapPresenter)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import ca.derekellis.reroute.ui.Presenter
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject
import ca.derekellis.reroute.stops.Stop as StopScreen

@Inject
class SearchPresenter(
private val dataSource: DataSource,
private val navigator: Navigator,
private val args: Search,
@Assisted private val navigator: Navigator,
@Assisted private val args: Search,
) : Presenter<SearchViewModel, SearchViewEvent> {
@Composable
override fun produceModel(events: Flow<SearchViewEvent>): SearchViewModel {
Expand All @@ -41,4 +42,8 @@ class SearchPresenter(

return SearchViewModel("", results)
}

// TODO: Replace with fun interface
@Inject
class Factory(val create: (Navigator, Search) -> SearchPresenter)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ import ca.derekellis.reroute.ui.Presenter
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject

@Inject
class StopPresenter(
private val client: RerouteClient,
private val dataSource: DataSource,
private val navigator: Navigator,
private val mapInteractionsManager: MapInteractionsManager,
private val args: Stop,
@Assisted private val navigator: Navigator,
@Assisted private val args: Stop,
) : Presenter<StopViewModel, StopViewEvent> {
@Composable
override fun produceModel(events: Flow<StopViewEvent>): StopViewModel {
Expand Down Expand Up @@ -90,4 +91,8 @@ class StopPresenter(
section.copy(nextTrips = nextTrips?.trips)
}
}

// TODO: Replace with fun interface
@Inject
class Factory(val create: (Navigator, Stop) -> StopPresenter)
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AppNavigator(
screen?.let {
val wrapper = remember(it) {
ScreenWrapper(
presenterFactory.createPresenter(it) as Presenter<Any, Any>,
presenterFactory.createPresenter(this, it) as Presenter<Any, Any>,
viewFactory.createView(it) as View<Any, Any>,
)
}
Expand Down

0 comments on commit 703bd3f

Please sign in to comment.