Skip to content

Commit

Permalink
Create :core:appInfo module
Browse files Browse the repository at this point in the history
  • Loading branch information
ksharma-xyz committed Dec 4, 2024
1 parent 647a757 commit af1a19e
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 11 deletions.
1 change: 1 addition & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ kotlin {
commonMain.dependencies {
implementation(projects.taj)
implementation(projects.sandook)
implementation(projects.core.appInfo)
implementation(projects.feature.tripPlanner.network)
implementation(projects.feature.tripPlanner.ui)
implementation(projects.feature.tripPlanner.state)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package xyz.ksharma.krail

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.di.koinConfig
import xyz.ksharma.krail.taj.theme.KrailTheme

@Composable
fun KrailApp() {
KoinApplication(application = koinConfig) {
KrailTheme {
KrailNavHost()
CompositionLocalProvider(LocalPlatformTypeProvider provides getPlatform().type) {
KrailTheme {
KrailNavHost()
}
}
}
}

This file was deleted.

45 changes: 45 additions & 0 deletions core/app-info/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
plugins {
alias(libs.plugins.krail.android.library)
alias(libs.plugins.krail.kotlin.multiplatform)
alias(libs.plugins.krail.compose.multiplatform)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.ksp)
alias(libs.plugins.compose.compiler)
}

android {
namespace = "xyz.ksharma.krail.core.appinfo"
}

kotlin {
applyDefaultHierarchyTemplate()

androidTarget()

iosArm64()
iosSimulatorArm64()

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(JavaVersion.VERSION_17.majorVersion))
}
}

sourceSets {
androidMain {
dependencies {
}
}

commonMain {
dependencies {
implementation(libs.kotlinx.serialization.json)

implementation(compose.runtime)
}
}

iosMain.dependencies {
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package xyz.ksharma.krail
package xyz.ksharma.krail.core.appinfo

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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package xyz.ksharma.krail.core.appinfo

import androidx.compose.runtime.compositionLocalOf

val LocalPlatformTypeProvider = compositionLocalOf { PlatformType.UNKNOWN }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package xyz.ksharma.krail.core.appinfo

interface Platform {
val name: String
val type: PlatformType
}

enum class PlatformType {
ANDROID,
IOS,
UNKNOWN,
}

expect fun getPlatform(): Platform
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package xyz.ksharma.krail
package xyz.ksharma.krail.core.appinfo

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()
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rootProject.name = "Krail"
//include(":android-app")
include(":composeApp")
include(":taj") // Design System
include(":core:app-info")
include(":core:date-time")
include(":feature:trip-planner:ui")
include(":feature:trip-planner:state")
Expand Down

0 comments on commit af1a19e

Please sign in to comment.