Skip to content

Commit fb1265d

Browse files
authored
Merge pull request #211 from joreilly/kotlin-inject
remove unncessary expect/actual
2 parents 49e1156 + 5c686f4 commit fb1265d

File tree

9 files changed

+13
-19
lines changed

9 files changed

+13
-19
lines changed

common/src/androidMain/kotlin/dev/johnoreilly/common/actual.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package dev.johnoreilly.common
22

3-
import io.ktor.client.engine.android.*
43
import java.util.Locale
54

6-
actual val httpClientEngine = Android.create()
7-
85
actual fun getCountryName(countryCode: String): String {
96
val locale = Locale("", countryCode)
107
return locale.displayCountry

common/src/androidMain/kotlin/dev/johnoreilly/common/di/AndroidApplicationComponent.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dev.johnoreilly.common.di
33
import dev.johnoreilly.common.ui.CountryListScreen
44
import dev.johnoreilly.common.ui.NetworkListScreen
55
import dev.johnoreilly.common.ui.StationsScreen
6+
import io.ktor.client.engine.android.Android
67
import me.tatarka.inject.annotations.Component
78

89

@@ -16,5 +17,7 @@ abstract class AndroidApplicationComponent: SharedApplicationComponent {
1617
abstract val networkListScreen: NetworkListScreen
1718
abstract val stationsScreen: StationsScreen
1819

20+
override fun getHttpClientEngine() = Android.create()
21+
1922
companion object
2023
}

common/src/commonMain/kotlin/dev/johnoreilly/common/di/SharedApplicationComponent.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package dev.johnoreilly.common.di
22

3-
import dev.johnoreilly.common.httpClientEngine
43
import dev.johnoreilly.common.remote.CityBikesApi
54
import dev.johnoreilly.common.repository.CityBikesRepository
65
import dev.johnoreilly.common.repository.NetworkDb
@@ -49,7 +48,10 @@ interface SharedApplicationComponent {
4948
}
5049

5150
@Provides
52-
fun httpClient(): HttpClient = createHttpClient(httpClientEngine, json)
51+
fun getHttpClientEngine(): HttpClientEngine
52+
53+
@Provides
54+
fun httpClient(): HttpClient = createHttpClient(getHttpClientEngine(), json)
5355
}
5456

5557
fun createHttpClient(httpClientEngine: HttpClientEngine, json: Json) = HttpClient(httpClientEngine) {
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
package dev.johnoreilly.common
22

3-
import io.ktor.client.engine.HttpClientEngine
4-
5-
6-
expect val httpClientEngine: HttpClientEngine
7-
83
expect fun getCountryName(countryCode: String): String
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package dev.johnoreilly.common
22

3-
import io.ktor.client.engine.darwin.Darwin
43
import platform.Foundation.NSLocale
54
import platform.Foundation.NSLocaleCountryCode
65
import platform.Foundation.currentLocale
76

87

9-
actual val httpClientEngine = Darwin.create()
10-
118
actual fun getCountryName(countryCode: String): String {
129
return NSLocale.currentLocale.displayNameForKey(NSLocaleCountryCode, countryCode) ?: countryCode
1310
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package dev.johnoreilly.common.di
22

3+
import io.ktor.client.engine.darwin.Darwin
34
import me.tatarka.inject.annotations.Component
45

56

67
@Component
78
@Singleton
89
abstract class IosApplicationComponent: SharedApplicationComponent {
910

11+
override fun getHttpClientEngine() = Darwin.create()
12+
1013
companion object
1114
}

common/src/jvmMain/kotlin/dev/johnoreilly/common/actual.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package dev.johnoreilly.common
22

3-
import io.ktor.client.engine.java.*
43
import java.util.Locale
54

6-
actual val httpClientEngine = Java.create()
7-
85
actual fun getCountryName(countryCode: String): String {
96
val locale = Locale("", countryCode)
107
return locale.displayCountry
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package dev.johnoreilly.common.di
22

3+
import io.ktor.client.engine.java.Java
34
import me.tatarka.inject.annotations.Component
45

56
@Component
67
@Singleton
78
abstract class DesktopApplicationComponent: SharedApplicationComponent {
89

10+
override fun getHttpClientEngine() = Java.create()
11+
912
companion object
1013
}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package dev.johnoreilly.common
22

3-
import io.ktor.client.engine.darwin.Darwin
43
import platform.Foundation.NSLocale
54
import platform.Foundation.NSLocaleCountryCode
65
import platform.Foundation.currentLocale
76

87

9-
actual val httpClientEngine = Darwin.create()
10-
118
actual fun getCountryName(countryCode: String): String {
129
return NSLocale.currentLocale.displayNameForKey(NSLocaleCountryCode, countryCode) ?: countryCode
1310
}

0 commit comments

Comments
 (0)