Added PlatformType (even though it's not used somewhere)

This commit is contained in:
dankito 2024-08-26 01:28:54 +02:00
parent b0f7f23f98
commit 9116dd945f
6 changed files with 24 additions and 1 deletions

View File

@ -4,6 +4,8 @@ import android.os.Build
class AndroidPlatform : Platform {
override val name: String = "Android ${Build.VERSION.SDK_INT}"
override val type: PlatformType = PlatformType.Android
}
actual fun getPlatform(): Platform = AndroidPlatform()

View File

@ -1,7 +1,16 @@
package net.codinux.banking.ui
expect fun getPlatform(): Platform
interface Platform {
val name: String
val type: PlatformType
}
expect fun getPlatform(): Platform
enum class PlatformType {
JVM,
Android,
iOS,
Web
}

View File

@ -1,7 +1,12 @@
package net.codinux.banking.ui.service
import net.codinux.banking.ui.Platform
import net.codinux.banking.ui.getPlatform
object DI {
val platform: Platform = getPlatform()
val bankFinder = BankFinder()
val bankingService = BankingService(bankFinder)

View File

@ -2,6 +2,8 @@ package net.codinux.banking.ui
class JVMPlatform: Platform {
override val name: String = "Java ${System.getProperty("java.version")}"
override val type: PlatformType = PlatformType.JVM
}
actual fun getPlatform(): Platform = JVMPlatform()

View File

@ -4,6 +4,8 @@ import platform.UIKit.UIDevice
class IOSPlatform: Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
override val type: PlatformType = PlatformType.iOS
}
actual fun getPlatform(): Platform = IOSPlatform()

View File

@ -2,6 +2,9 @@ package net.codinux.banking.ui
class WasmPlatform: Platform {
override val name: String = "Web with Kotlin/Wasm"
override val type: PlatformType = PlatformType.Web
}
actual fun getPlatform(): Platform = WasmPlatform()