diff --git a/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/KrailApp.kt b/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/KrailApp.kt index cf9bac12..df7aed48 100644 --- a/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/KrailApp.kt +++ b/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/KrailApp.kt @@ -4,14 +4,14 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import org.koin.compose.KoinApplication import xyz.ksharma.krail.core.appinfo.LocalPlatformTypeProvider -import xyz.ksharma.krail.core.appinfo.getPlatform +import xyz.ksharma.krail.core.appinfo.getAppPlatform import xyz.ksharma.krail.di.koinConfig import xyz.ksharma.krail.taj.theme.KrailTheme @Composable fun KrailApp() { KoinApplication(application = koinConfig) { - CompositionLocalProvider(LocalPlatformTypeProvider provides getPlatform().type) { + CompositionLocalProvider(LocalPlatformTypeProvider provides getAppPlatform()) { KrailTheme { KrailNavHost() } diff --git a/core/app-info/build.gradle.kts b/core/app-info/build.gradle.kts index e35d26e4..4a4c9fa5 100644 --- a/core/app-info/build.gradle.kts +++ b/core/app-info/build.gradle.kts @@ -9,6 +9,10 @@ plugins { android { namespace = "xyz.ksharma.krail.core.appinfo" + + buildFeatures { + buildConfig = true + } } kotlin { diff --git a/core/app-info/src/androidMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.android.kt b/core/app-info/src/androidMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.android.kt index 795c90df..21c13116 100644 --- a/core/app-info/src/androidMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.android.kt +++ b/core/app-info/src/androidMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.android.kt @@ -2,9 +2,10 @@ package xyz.ksharma.krail.core.appinfo import android.os.Build -class AndroidPlatform : Platform { +class AndroidAppPlatform : AppPlatform { override val name: String = "Android ${Build.VERSION.SDK_INT}" override val type: PlatformType = PlatformType.ANDROID + override fun isDebug(): Boolean = BuildConfig.DEBUG } -actual fun getPlatform(): Platform = AndroidPlatform() +actual fun getAppPlatform(): AppPlatform = AndroidAppPlatform() diff --git a/core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.kt b/core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/AppPlatform.kt similarity index 62% rename from core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.kt rename to core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/AppPlatform.kt index e191b8d2..428126d2 100644 --- a/core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.kt +++ b/core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/AppPlatform.kt @@ -1,8 +1,10 @@ package xyz.ksharma.krail.core.appinfo -interface Platform { +interface AppPlatform { val name: String val type: PlatformType + + fun isDebug(): Boolean } enum class PlatformType { @@ -11,4 +13,4 @@ enum class PlatformType { UNKNOWN, } -expect fun getPlatform(): Platform +expect fun getAppPlatform(): AppPlatform diff --git a/core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/CompositionLocals.kt b/core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/CompositionLocals.kt index e791bc8a..eb1efd64 100644 --- a/core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/CompositionLocals.kt +++ b/core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/CompositionLocals.kt @@ -1,5 +1,5 @@ package xyz.ksharma.krail.core.appinfo -import androidx.compose.runtime.compositionLocalOf +import androidx.compose.runtime.staticCompositionLocalOf -val LocalPlatformTypeProvider = compositionLocalOf { PlatformType.UNKNOWN } +val LocalPlatformTypeProvider = staticCompositionLocalOf { getAppPlatform() } diff --git a/core/app-info/src/iosMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.ios.kt b/core/app-info/src/iosMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.ios.kt index c0a605eb..86c2a05b 100644 --- a/core/app-info/src/iosMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.ios.kt +++ b/core/app-info/src/iosMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.ios.kt @@ -1,12 +1,16 @@ package xyz.ksharma.krail.core.appinfo import platform.UIKit.UIDevice +import kotlin.experimental.ExperimentalNativeApi -class IOSPlatform : Platform { +class IOSAppPlatform : AppPlatform { override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion override val type: PlatformType = PlatformType.IOS + + @OptIn(ExperimentalNativeApi::class) + override fun isDebug(): Boolean = Platform.isDebugBinary } -actual fun getPlatform(): Platform = IOSPlatform() +actual fun getAppPlatform(): AppPlatform = IOSAppPlatform()