-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
…10 and moved to KMP structure.
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,7 @@ | ||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat | ||
|
||
plugins { | ||
kotlin("multiplatform") | ||
id("org.jetbrains.compose") | ||
} | ||
|
||
group = "com.AabToApk" | ||
version = "1.0-SNAPSHOT" | ||
|
||
repositories { | ||
google() | ||
mavenCentral() | ||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") | ||
} | ||
|
||
kotlin { | ||
jvm { | ||
jvmToolchain(11) | ||
withJava() | ||
} | ||
sourceSets { | ||
val jvmMain by getting { | ||
dependencies { | ||
implementation(compose.desktop.currentOs) | ||
api("com.esotericsoftware:kryo:4.0.1") | ||
} | ||
} | ||
val jvmTest by getting { | ||
dependencies { | ||
implementation(compose.desktop.uiTestJUnit4) | ||
implementation(compose.desktop.currentOs) | ||
} | ||
} | ||
val resourcesDir = "src/common/resources" | ||
} | ||
} | ||
|
||
compose.desktop { | ||
application { | ||
mainClass = "MainKt" | ||
nativeDistributions { | ||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) | ||
packageName = "AabToApk" | ||
packageVersion = "1.0.4" | ||
val iconsRoot = project.file("desktop-icons") | ||
macOS{ | ||
iconFile.set(iconsRoot.resolve("launcher.icns")) | ||
} | ||
windows{ | ||
iconFile.set(iconsRoot.resolve("launcher.ico")) | ||
} | ||
linux{ | ||
iconFile.set(iconsRoot.resolve("launcher.png")) | ||
} | ||
} | ||
} | ||
} | ||
// this is necessary to avoid the plugins to be loaded multiple times | ||
// in each subproject's classloader | ||
alias(libs.plugins.jetbrainsCompose) apply false | ||
alias(libs.plugins.compose.compiler) apply false | ||
alias(libs.plugins.kotlinMultiplatform) apply false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat | ||
|
||
plugins { | ||
alias(libs.plugins.kotlinMultiplatform) | ||
alias(libs.plugins.jetbrainsCompose) | ||
alias(libs.plugins.compose.compiler) | ||
alias(libs.plugins.nativecoroutines) | ||
} | ||
|
||
group = "com.AabToApk" | ||
version = "1.0-SNAPSHOT" | ||
|
||
repositories { | ||
google() | ||
mavenCentral() | ||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") | ||
} | ||
|
||
kotlin { | ||
jvm("desktop") | ||
sourceSets { | ||
all { | ||
languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi") | ||
} | ||
val desktopMain by getting | ||
commonMain.dependencies { | ||
implementation(compose.runtime) | ||
implementation(compose.foundation) | ||
implementation(compose.material) | ||
implementation(compose.ui) | ||
implementation(compose.components.resources) | ||
implementation(compose.components.uiToolingPreview) | ||
} | ||
desktopMain.dependencies { | ||
implementation(compose.desktop.currentOs) | ||
api(libs.kryo) | ||
implementation(libs.voyager.navigator) | ||
implementation(libs.koin.core) | ||
implementation(libs.kmmViewModel) | ||
implementation(libs.koin.compose) | ||
implementation(compose.desktop.uiTestJUnit4) | ||
} | ||
} | ||
} | ||
|
||
compose.desktop { | ||
application { | ||
mainClass = "MainKt" | ||
nativeDistributions { | ||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) | ||
packageName = "AabToApk" | ||
packageVersion = "1.0.4" | ||
val iconsRoot = project.file("desktop-icons") | ||
macOS { | ||
iconFile.set(iconsRoot.resolve("launcher.icns")) | ||
} | ||
windows { | ||
iconFile.set(iconsRoot.resolve("launcher.ico")) | ||
} | ||
linux { | ||
iconFile.set(iconsRoot.resolve("launcher.png")) | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.window.Window | ||
import androidx.compose.ui.window.WindowPosition | ||
import androidx.compose.ui.window.application | ||
import androidx.compose.ui.window.rememberWindowState | ||
import cafe.adriel.voyager.navigator.Navigator | ||
import di.viewModelModules | ||
import local.FileStorageHelper | ||
import org.koin.compose.KoinApplication | ||
import ui.screens.HomeScreen | ||
import utils.DBConstants | ||
import utils.Log | ||
import utils.Strings | ||
|
||
fun main() = application { | ||
val fileStorageHelper = FileStorageHelper() | ||
// Check if path for bundletool exists in local storage | ||
val path = fileStorageHelper.read(DBConstants.BUNDLETOOL_PATH) as String? | ||
val adbPath = fileStorageHelper.read(DBConstants.ADB_PATH) as String? | ||
val icon = painterResource("launcher.png") | ||
Log.showLogs = true | ||
Window( | ||
icon = icon, | ||
onCloseRequest = ::exitApplication, | ||
state = rememberWindowState( | ||
width = 1200.dp, height = 1000.dp, | ||
position = WindowPosition(Alignment.Center) | ||
), | ||
title = Strings.APP_NAME | ||
) { | ||
KoinApplication( | ||
application = { | ||
modules(viewModelModules()) | ||
} | ||
) { | ||
Navigator(screen = HomeScreen(fileStorageHelper, path, adbPath)) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package di | ||
|
||
import org.koin.dsl.module | ||
import ui.screens.HomeViewModel | ||
|
||
fun viewModelModules() = module { | ||
single { HomeViewModel() } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ui.components | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.window.AwtWindow | ||
import utils.Strings | ||
import java.awt.FileDialog | ||
import java.awt.Frame | ||
|
||
@Composable | ||
fun FileDialog( | ||
parent: Frame? = null, | ||
onCloseRequest: (fileName: String?, directory: String?) -> Unit | ||
) = AwtWindow( | ||
create = { | ||
object : FileDialog(parent, Strings.CHOOSE_FILE, LOAD) { | ||
override fun setVisible(value: Boolean) { | ||
super.setVisible(value) | ||
if (value) { | ||
onCloseRequest(file, directory) | ||
} | ||
} | ||
} | ||
}, | ||
dispose = FileDialog::dispose | ||
) |