Skip to content

Commit

Permalink
Multi PlatForm SetUp
Browse files Browse the repository at this point in the history
  • Loading branch information
arya458 committed May 26, 2024
1 parent 85d21f9 commit f4d9fe4
Show file tree
Hide file tree
Showing 40 changed files with 1,242 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/artifacts/common_desktop_1_0_SNAPSHOT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/artifacts/desktop_jvm_1_0_SNAPSHOT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
plugins {
id("org.jetbrains.compose")
id("com.android.application")
kotlin("android")
}

group = "com.aria.danesh"
version = "1.0-SNAPSHOT"

repositories {
jcenter()
}

dependencies {
implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.5.0")
}

android {
compileSdkVersion(33)
defaultConfig {
applicationId = "com.aria.danesh.android"
minSdkVersion(24)
targetSdkVersion(33)
versionCode = 1
versionName = "1.0-SNAPSHOT"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
}
14 changes: 14 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.aria.danesh.android">
<application
android:allowBackup="false"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
18 changes: 18 additions & 0 deletions android/src/main/java/com/aria/danesh/android/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.aria.danesh.android

import com.aria.danesh.common.App
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.MaterialTheme

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
App()
}
}
}
}
61 changes: 61 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import org.jetbrains.compose.compose

plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
id("com.android.library")
}

group = "com.aria.danesh"
version = "1.0-SNAPSHOT"

kotlin {
android()
jvm("desktop") {
jvmToolchain(11)
}
sourceSets {
val commonMain by getting {
dependencies {
api(compose.runtime)
api(compose.foundation)
api(compose.material)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting {
dependencies {
api("androidx.appcompat:appcompat:1.5.1")
api("androidx.core:core-ktx:1.9.0")
}
}
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
}
val desktopMain by getting {
dependencies {
api(compose.preview)
}
}
val desktopTest by getting
}
}

android {
compileSdkVersion(33)
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdkVersion(24)
targetSdkVersion(33)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
2 changes: 2 additions & 0 deletions common/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.aria.danesh.common"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.aria.danesh.common

actual fun getPlatformName(): String {
return "Android"
}
21 changes: 21 additions & 0 deletions common/src/commonMain/kotlin/com/aria/danesh/common/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.aria.danesh.common

import androidx.compose.material.Text
import androidx.compose.material.Button
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue

@Composable
fun App() {
var text by remember { mutableStateOf("Hello, World!") }
val platformName = getPlatformName()

Button(onClick = {
text = "Hello, ${platformName}"
}) {
Text(text)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.aria.danesh.common

expect fun getPlatformName(): String
10 changes: 10 additions & 0 deletions common/src/desktopMain/kotlin/com/aria/danesh/common/DesktopApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.aria.danesh.common

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.runtime.Composable

@Preview
@Composable
fun AppPreview() {
App()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.aria.danesh.common

actual fun getPlatformName(): String {
return "Desktop"
}
47 changes: 47 additions & 0 deletions desktop/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
}

group = "com.aria.danesh"
version = "1.0-SNAPSHOT"


kotlin {
jvm {
jvmToolchain(11)
withJava()
}
sourceSets {
val jvmMain by getting {
dependencies {
implementation(project(":common"))
implementation(compose.desktop.currentOs)
implementation("de.sfuhrm:radiobrowser4j:3.0.0")
implementation("com.darkrockstudios:mpfilepicker:3.1.0")

implementation("io.insert-koin:koin-core:$koin_version")
api("io.github.qdsfdhvh:image-loader:1.7.8")
api("io.github.qdsfdhvh:image-loader-extension-moko-resources:1.7.8")
// implementation("io.insert-koin:koin-core-coroutines:$koin_version")
// implementation("io.insert-koin:koin-compose:$koin_version")
implementation("io.insert-koin:koin-logger-slf4j:$koin_version")
implementation("org.jetbrains.androidx.navigation:navigation-compose:2.7.0-alpha03")
}
}
val jvmTest by getting
}
}

compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Exe)
packageName = "RadioBrowser"
packageVersion = "1.0.0"
}
}
}
10 changes: 10 additions & 0 deletions desktop/src/jvmMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import com.aria.danesh.common.App


fun main() = application {
Window(onCloseRequest = ::exitApplication) {
App()
}
}
43 changes: 43 additions & 0 deletions desktop/src/jvmMain/kotlin/main/di/SharedModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main.di

import org.koin.core.module.dsl.bind
import org.koin.core.module.dsl.createdAtStart
import org.koin.core.module.dsl.singleOf
import org.koin.core.module.dsl.withOptions
import player.data.repository.PlayerImpl
import org.koin.core.qualifier.named
import org.koin.dsl.module
import player.domain.repository.PlayerRepository
import player.presentation.viewmodel.PlayerViewModel


val SharedModule = module(createdAtStart=true) {

// single<PlayerRepository>(named("playerRepository")) {
// PlayerImpl()
// }

singleOf(::PlayerImpl) withOptions {
// definition options
named("playerRepository")
bind<PlayerRepository>()
createdAtStart()
}


single<PlayerViewModel>{
PlayerViewModel()
} withOptions {
// definition options
named("playerViewModel")
createdAtStart()
}




// single<PlayerRepository> { PlayerImpl() as PlayerRepository } withOptions {
// named("playerRepository")
// createdAtStart()
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main.domain.repository


interface SharedRepository {




}
Loading

0 comments on commit f4d9fe4

Please sign in to comment.