-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core: Add debug flag and rename Platform to AppPlatform (#422)
### TL;DR Added debug flag detection and improved platform-specific information handling across Android and iOS. ### What changed? - Renamed `Platform` interface to `AppPlatform` and `getPlatform()` to `getAppPlatform()` - Added `isDebug()` function to detect debug builds on both platforms - Enabled BuildConfig for Android to support debug detection - Updated `LocalPlatformTypeProvider` to use `staticCompositionLocalOf` with proper platform initialization - Implemented platform-specific debug detection (BuildConfig.DEBUG for Android, Platform.isDebugBinary for iOS) ### How to test? 1. Build and run the app in both debug and release configurations 2. Verify that `isDebug()` returns the correct boolean value for each build type 3. Confirm platform information is correctly displayed 4. Check that platform-specific features work as expected on both Android and iOS ### Why make this change? To provide a more robust way to detect debug builds across platforms and improve the platform-specific information architecture. This enables better debugging capabilities and platform-specific optimizations in the codebase.
- Loading branch information
1 parent
dd98943
commit 9f04ee0
Showing
6 changed files
with
21 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
core/app-info/src/commonMain/kotlin/xyz/ksharma/krail/core/appinfo/CompositionLocals.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() } |
8 changes: 6 additions & 2 deletions
8
core/app-info/src/iosMain/kotlin/xyz/ksharma/krail/core/appinfo/Platform.ios.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |