Skip to content

Commit

Permalink
Add web support
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedRejeb committed Mar 12, 2023
1 parent e769262 commit 95b440b
Show file tree
Hide file tree
Showing 24 changed files with 3,662 additions and 22 deletions.
16 changes: 9 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
plugins {
//trick: for the same plugin versions in all sub-modules
// kotlin("jvm") version "1.8.10" apply false
kotlin("android") version "1.8.10" apply false
kotlin("multiplatform") version "1.8.10" apply false
kotlin("plugin.serialization") version "1.8.10" apply false
kotlin("android") version "1.8.0" apply false
kotlin("multiplatform") version "1.8.0" apply false
kotlin("plugin.serialization") version "1.8.0" apply false
id("app.cash.sqldelight") version "2.0.0-alpha05" apply false
id("com.android.application") version "7.3.0" apply false
id("com.android.library") version "7.3.0" apply false
Expand All @@ -16,8 +15,11 @@ allprojects {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
afterEvaluate {
// Workaround for https://youtrack.jetbrains.com/issue/KT-52776
rootProject.extensions.findByType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>()?.apply {
versions.webpackCli.version = "4.10.0"
}
}
}
10 changes: 10 additions & 0 deletions buildSrc/src/main/java/com/mocoding/pokedex/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ object Deps {

const val kotlinxSerializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.serialization}"
}

object KotlinWrappers {
const val kotlinWrappersBom = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${Versions.kotlinWrappersBom}"
const val kotlinStyled = "org.jetbrains.kotlin-wrappers:kotlin-styled"
}
}
}

Expand All @@ -22,6 +27,7 @@ object Deps {
const val ktorClientAndroid = "io.ktor:ktor-client-android:${Versions.ktor}"
const val ktorClientDarwin = "io.ktor:ktor-client-darwin:${Versions.ktor}"
const val ktorClientJava = "io.ktor:ktor-client-java:${Versions.ktor}"
const val ktorClientJs = "io.ktor:ktor-client-js:${Versions.ktor}"
}
}

Expand Down Expand Up @@ -59,6 +65,10 @@ object Deps {
const val decompose = "com.arkivanov.decompose:decompose:${Versions.decompose}"
const val extensionsCompose = "com.arkivanov.decompose:extensions-compose-jetbrains:${Versions.decompose}"
}

object Essenty {
const val lifecycle = "com.arkivanov.essenty:lifecycle:${Versions.essenty}"
}
}

object Github {
Expand Down
6 changes: 4 additions & 2 deletions buildSrc/src/main/java/com/mocoding/pokedex/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ package com.mocoding.pokedex

object Versions {
const val gradlePlugin = "7.3.0"
const val kotlin = "1.8.10"
const val kotlin = "1.8.0"
const val compose = "1.3.1"
const val composeCompoiler = "1.4.2"
const val composeCompoiler = "1.4.1"
const val coroutines = "1.6.4"
const val serialization = "1.4.1"
const val mviKotlin = "3.1.0"
const val decompose = "1.0.0-compose-experimental"
const val essenty = "1.0.0"
const val ktor = "2.2.3"
const val sqlDelight = "2.0.0-alpha05"
const val koin = "3.2.0"
const val imageLoader = "1.2.10"
const val logbackClassic = "1.2.11"
const val kotlinWrappersBom = "1.0.0-pre.510"
}
2 changes: 0 additions & 2 deletions desktop/src/jvmMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import javax.swing.SwingUtilities
fun main() {
initKoin(enableNetworkLogs = false)

// overrideSchedulers(main = Dispatchers.Main::asScheduler)

val rootComponent = invokeOnAwtSync {
setMainThreadId(Thread.currentThread().id)

Expand Down
7 changes: 5 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ kotlin.mpp.androidSourceSetLayoutVersion=2
xcodeproj=./ios
org.jetbrains.compose.experimental.uikit.enabled=true

#Web
org.jetbrains.compose.experimental.jscanvas.enabled=true

#Versions
kotlin.version=1.8.10
agp.version=7.3.0
Expand All @@ -28,5 +31,5 @@ kotlin.native.binary.memoryModel=experimental
kotlin.native.cocoapods.generate.wrapper=true
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.enableGranularSourceSetsMetadata=true
#kotlin.native.enableDependencyPropagation=false
#kotlin.mpp.enableGranularSourceSetsMetadata=true
16 changes: 16 additions & 0 deletions ios/Pokedex/PokedexApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import shared

@main
struct PokedexApp: App {
@Environment(\.scenePhase) private var scenePhase

private let lifecycle = LifecycleRegistry()

var body: some Scene {
WindowGroup {
GeometryReader { geo in
Expand All @@ -23,6 +27,18 @@ struct PokedexApp: App {
// Hide keyboard on tap outside of TextField
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
.onChange(of: scenePhase) { phase in
switch phase {
case .active:
print(">> your code is here on scene become active")
case .inactive:
print(">> your code is here on scene become inactive")
case .background:
print(">> your code is here on scene go background")
default:
print(">> do something else in future")
}
}
}
}
}
Expand Down
Loading

0 comments on commit 95b440b

Please sign in to comment.