refactor: split composeApp to client and ui
also renamed client.datasource to client.data, which made me realise
.gitignore was ignoring `data` and therefore some gtfsr source files
😭
2
.gitignore
vendored
|
|
@ -19,4 +19,4 @@ captures
|
|||
|
||||
secrets.properties
|
||||
shared/src/commonMain/kotlin/moe/lava/banksia/Constants.kt
|
||||
data/
|
||||
/data/
|
||||
|
|
|
|||
55
client/build.gradle.kts
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
alias(libs.plugins.kotlinSerialization)
|
||||
alias(libs.plugins.androidLibrary)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
androidTarget {
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
compilerOptions {
|
||||
jvmTarget.set(JvmTarget.JVM_11)
|
||||
}
|
||||
}
|
||||
|
||||
compilerOptions {
|
||||
freeCompilerArgs.add("-opt-in=kotlin.time.ExperimentalTime")
|
||||
}
|
||||
|
||||
iosX64()
|
||||
iosArm64()
|
||||
iosSimulatorArm64()
|
||||
|
||||
sourceSets {
|
||||
androidMain.dependencies {
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(libs.kotlinx.coroutines.android)
|
||||
implementation(libs.play.services.location)
|
||||
}
|
||||
commonMain.dependencies {
|
||||
implementation(libs.koin.core)
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
implementation(libs.kotlinx.datetime)
|
||||
implementation(libs.ktor.client.core)
|
||||
implementation(libs.ktor.client.contentnegotiation)
|
||||
implementation(libs.ktor.serialization.kotlinx.json)
|
||||
implementation(projects.shared)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "moe.lava.banksia.client"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package moe.lava.banksia.client.datasource.local
|
||||
package moe.lava.banksia.client.data.route
|
||||
|
||||
import moe.lava.banksia.model.Route
|
||||
import moe.lava.banksia.room.dao.RouteDao
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package moe.lava.banksia.client.datasource.remote
|
||||
package moe.lava.banksia.client.data.route
|
||||
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.body
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package moe.lava.banksia.client.datasource.local
|
||||
package moe.lava.banksia.client.data.stop
|
||||
|
||||
import moe.lava.banksia.model.Stop
|
||||
import moe.lava.banksia.room.dao.RouteDao
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package moe.lava.banksia.client.datasource.remote
|
||||
package moe.lava.banksia.client.data.stop
|
||||
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.body
|
||||
|
|
@ -8,17 +8,15 @@ import io.ktor.client.plugins.plugin
|
|||
import io.ktor.serialization.kotlinx.json.json
|
||||
import kotlinx.serialization.json.Json
|
||||
import moe.lava.banksia.Constants
|
||||
import moe.lava.banksia.client.datasource.local.RouteLocalDataSource
|
||||
import moe.lava.banksia.client.datasource.local.StopLocalDataSource
|
||||
import moe.lava.banksia.client.datasource.remote.RouteRemoteDataSource
|
||||
import moe.lava.banksia.client.datasource.remote.StopRemoteDataSource
|
||||
import moe.lava.banksia.client.data.route.RouteLocalDataSource
|
||||
import moe.lava.banksia.client.data.route.RouteRemoteDataSource
|
||||
import moe.lava.banksia.client.data.stop.StopLocalDataSource
|
||||
import moe.lava.banksia.client.data.stop.StopRemoteDataSource
|
||||
import moe.lava.banksia.client.repository.RouteRepository
|
||||
import moe.lava.banksia.client.repository.StopRepository
|
||||
import moe.lava.banksia.data.ptv.PtvService
|
||||
import moe.lava.banksia.ui.screens.map.MapScreenViewModel
|
||||
import moe.lava.banksia.util.log
|
||||
import org.koin.core.module.dsl.singleOf
|
||||
import org.koin.core.module.dsl.viewModelOf
|
||||
import org.koin.dsl.module
|
||||
|
||||
val ClientModule = module {
|
||||
|
|
@ -52,7 +50,4 @@ val ClientModule = module {
|
|||
// Repositories
|
||||
singleOf(::RouteRepository)
|
||||
singleOf(::StopRepository)
|
||||
|
||||
// ViewModel
|
||||
viewModelOf(::MapScreenViewModel)
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@ package moe.lava.banksia.client.repository
|
|||
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import moe.lava.banksia.client.datasource.local.RouteLocalDataSource
|
||||
import moe.lava.banksia.client.datasource.remote.RouteRemoteDataSource
|
||||
import moe.lava.banksia.client.data.route.RouteLocalDataSource
|
||||
import moe.lava.banksia.client.data.route.RouteRemoteDataSource
|
||||
|
||||
class RouteRepository(
|
||||
private val local: RouteLocalDataSource,
|
||||
|
|
@ -2,8 +2,8 @@ package moe.lava.banksia.client.repository
|
|||
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import moe.lava.banksia.client.datasource.local.StopLocalDataSource
|
||||
import moe.lava.banksia.client.datasource.remote.StopRemoteDataSource
|
||||
import moe.lava.banksia.client.data.stop.StopLocalDataSource
|
||||
import moe.lava.banksia.client.data.stop.StopRemoteDataSource
|
||||
|
||||
class StopRepository(
|
||||
private val local: StopLocalDataSource,
|
||||
|
|
@ -28,6 +28,7 @@ dependencyResolutionManagement {
|
|||
}
|
||||
}
|
||||
|
||||
include(":composeApp")
|
||||
include(":client")
|
||||
include(":server")
|
||||
include(":shared")
|
||||
include(":ui")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package moe.lava.banksia.data.gtfsr
|
||||
|
||||
import com.google.transit.realtime.FeedMessage
|
||||
|
||||
abstract class GtfsRealtime(protected val data: FeedMessage) {
|
||||
companion object {
|
||||
inline fun <T: GtfsRealtime> parse(ctor: (FeedMessage) -> T, data: ByteArray): T {
|
||||
val message = FeedMessage.ADAPTER.decode(data)
|
||||
return ctor(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package moe.lava.banksia.data.gtfsr
|
||||
|
||||
import com.google.transit.realtime.FeedMessage
|
||||
import moe.lava.banksia.util.Point
|
||||
|
||||
class RealtimeVehiclePositions(data: FeedMessage) : GtfsRealtime(data) {
|
||||
private val positions = mutableMapOf<String, Point>()
|
||||
|
||||
init {
|
||||
data.entity
|
||||
.mapNotNull { ent ->
|
||||
if (ent.vehicle?.position == null) return@mapNotNull null
|
||||
ent.id to ent.vehicle.position.run {
|
||||
Point(latitude.toDouble(), longitude.toDouble())
|
||||
}
|
||||
}
|
||||
.let { positions.putAll(it) }
|
||||
}
|
||||
|
||||
fun getAll() = positions.toMap()
|
||||
fun forTrip(tripId: String) = positions[tripId]
|
||||
}
|
||||
|
|
@ -34,7 +34,6 @@ kotlin {
|
|||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
androidMain.dependencies {
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
|
|
@ -63,8 +62,10 @@ kotlin {
|
|||
implementation(libs.maplibre.compose)
|
||||
implementation(libs.moko.geo)
|
||||
implementation(libs.moko.geo.compose)
|
||||
implementation(projects.shared)
|
||||
implementation(libs.ui.backhandler)
|
||||
|
||||
implementation(projects.client)
|
||||
implementation(projects.shared)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
|
@ -3,8 +3,8 @@ package moe.lava.banksia.ui
|
|||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import moe.lava.banksia.client.di.ClientModule
|
||||
import moe.lava.banksia.di.CommonModules
|
||||
import moe.lava.banksia.ui.di.AppModule
|
||||
import moe.lava.banksia.ui.screens.map.MapScreen
|
||||
import org.koin.compose.KoinMultiplatformApplication
|
||||
import org.koin.core.annotation.KoinExperimentalAPI
|
||||
|
|
@ -14,7 +14,7 @@ import org.koin.dsl.koinConfiguration
|
|||
@Composable
|
||||
fun App() {
|
||||
KoinMultiplatformApplication(config = koinConfiguration {
|
||||
modules(CommonModules, ClientModule)
|
||||
modules(CommonModules, AppModule)
|
||||
}) {
|
||||
MapScreen()
|
||||
}
|
||||
12
ui/src/commonMain/kotlin/moe/lava/banksia/ui/di/AppModule.kt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package moe.lava.banksia.ui.di
|
||||
|
||||
import moe.lava.banksia.client.di.ClientModule
|
||||
import moe.lava.banksia.ui.screens.map.MapScreenViewModel
|
||||
import org.koin.core.module.dsl.viewModelOf
|
||||
import org.koin.dsl.module
|
||||
|
||||
val AppModule = module {
|
||||
includes(ClientModule)
|
||||
// ViewModel
|
||||
viewModelOf(::MapScreenViewModel)
|
||||
}
|
||||