From f154a1f76f0c06e89eb1caafa4bbd38408398e88 Mon Sep 17 00:00:00 2001 From: Andrew Reed Date: Fri, 6 Dec 2024 14:16:59 +0000 Subject: [PATCH] Changed application context to be Application for ios (#151) --- examples/ComposeMultiplatform-Example/gradle.properties | 2 +- .../ComposeMultiplatform-Example/shared/build.gradle.kts | 2 +- .../ble/presentation/component/DeviceScanView.kt | 1 + .../bluefalconcomposemultiplatform/di/AppModule.ios.kt | 6 +++++- examples/KotlinMP-Example/gradle/libs.versions.toml | 2 +- examples/KotlinMP-Example/iosApp/iosApp/iOSApp.swift | 2 +- library/gradle.properties | 2 +- .../src/iosMain/kotlin/dev/bluefalcon/ApplicationContext.kt | 4 ++-- .../macosMain/kotlin/dev/bluefalcon/ApplicationContext.kt | 4 ++-- 9 files changed, 15 insertions(+), 10 deletions(-) diff --git a/examples/ComposeMultiplatform-Example/gradle.properties b/examples/ComposeMultiplatform-Example/gradle.properties index 201d367..e61a02c 100644 --- a/examples/ComposeMultiplatform-Example/gradle.properties +++ b/examples/ComposeMultiplatform-Example/gradle.properties @@ -14,6 +14,6 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.version=2.0.0 +kotlin.version=2.0.20 agp.version=8.3.0 compose.version=1.6.11 \ No newline at end of file diff --git a/examples/ComposeMultiplatform-Example/shared/build.gradle.kts b/examples/ComposeMultiplatform-Example/shared/build.gradle.kts index 6d88a03..31daa74 100644 --- a/examples/ComposeMultiplatform-Example/shared/build.gradle.kts +++ b/examples/ComposeMultiplatform-Example/shared/build.gradle.kts @@ -46,7 +46,7 @@ kotlin { implementation("dev.icerock.moko:mvvm-flow-compose:0.16.1") // BlueFalcon dependency here - implementation("dev.bluefalcon:blue-falcon:2.0.0") + implementation("dev.bluefalcon:blue-falcon:2.2.0") } } val commonTest by getting { diff --git a/examples/ComposeMultiplatform-Example/shared/src/commonMain/kotlin/com/example/bluefalconcomposemultiplatform/ble/presentation/component/DeviceScanView.kt b/examples/ComposeMultiplatform-Example/shared/src/commonMain/kotlin/com/example/bluefalconcomposemultiplatform/ble/presentation/component/DeviceScanView.kt index 5027069..741eb99 100644 --- a/examples/ComposeMultiplatform-Example/shared/src/commonMain/kotlin/com/example/bluefalconcomposemultiplatform/ble/presentation/component/DeviceScanView.kt +++ b/examples/ComposeMultiplatform-Example/shared/src/commonMain/kotlin/com/example/bluefalconcomposemultiplatform/ble/presentation/component/DeviceScanView.kt @@ -46,6 +46,7 @@ fun DeviceScanView( ) { LazyColumn { items(state.devices.values.toList().sortedByDescending { it.peripheral.name }) { device -> + @OptIn(kotlin.uuid.ExperimentalUuidApi::class) FoundDeviceCard( deviceName = if (!device.peripheral.name.isNullOrBlank()) device.peripheral.name else "No Name", macId = device.peripheral.uuid, diff --git a/examples/ComposeMultiplatform-Example/shared/src/iosMain/kotlin/com/example/bluefalconcomposemultiplatform/di/AppModule.ios.kt b/examples/ComposeMultiplatform-Example/shared/src/iosMain/kotlin/com/example/bluefalconcomposemultiplatform/di/AppModule.ios.kt index 19d744f..3695b23 100644 --- a/examples/ComposeMultiplatform-Example/shared/src/iosMain/kotlin/com/example/bluefalconcomposemultiplatform/di/AppModule.ios.kt +++ b/examples/ComposeMultiplatform-Example/shared/src/iosMain/kotlin/com/example/bluefalconcomposemultiplatform/di/AppModule.ios.kt @@ -2,8 +2,12 @@ package com.example.bluefalconcomposemultiplatform.di import dev.bluefalcon.ApplicationContext import dev.bluefalcon.BlueFalcon +import platform.UIKit.UIApplication actual class AppModule { actual val blueFalcon: BlueFalcon - get() = BlueFalcon(ApplicationContext()) + get() = BlueFalcon( + log = null, + context = UIApplication.sharedApplication + ) } \ No newline at end of file diff --git a/examples/KotlinMP-Example/gradle/libs.versions.toml b/examples/KotlinMP-Example/gradle/libs.versions.toml index bece723..baf9058 100644 --- a/examples/KotlinMP-Example/gradle/libs.versions.toml +++ b/examples/KotlinMP-Example/gradle/libs.versions.toml @@ -15,7 +15,7 @@ compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } -blue-falcon = { module = "dev.bluefalcon:blue-falcon", version = "2.0.0" } +blue-falcon = { module = "dev.bluefalcon:blue-falcon", version = "2.2.0" } kmm-viewmodel = { module = "com.rickclephas.kmp:kmp-observableviewmodel-core", version = "1.0.0-BETA-3" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } compose-permissions = { group = "com.github.dawidraszka.compose-permission-handler", name = "core", version = "1.5.0" } diff --git a/examples/KotlinMP-Example/iosApp/iosApp/iOSApp.swift b/examples/KotlinMP-Example/iosApp/iosApp/iOSApp.swift index 96ac49a..dd42ba5 100644 --- a/examples/KotlinMP-Example/iosApp/iosApp/iOSApp.swift +++ b/examples/KotlinMP-Example/iosApp/iosApp/iOSApp.swift @@ -3,7 +3,7 @@ import shared @main struct iOSApp: App { - let blueFalconApp = BlueFalconApplication(context: UIView()) + let blueFalconApp = BlueFalconApplication(context: UIApplication.shared) var body: some Scene { WindowGroup { DevicesView(viewModel: blueFalconApp.createDevicesViewModel()) diff --git a/library/gradle.properties b/library/gradle.properties index ea7d911..3d0a4d8 100644 --- a/library/gradle.properties +++ b/library/gradle.properties @@ -10,7 +10,7 @@ org.gradle.configureondemand = false android.useAndroidX=true android.enableJetifier=true -version=2.1.0 +version=2.2.0 group=dev.bluefalcon libraryName=blue-falcon kotlinx_coroutines_version=1.9.0 diff --git a/library/src/iosMain/kotlin/dev/bluefalcon/ApplicationContext.kt b/library/src/iosMain/kotlin/dev/bluefalcon/ApplicationContext.kt index f00b717..1b62bb7 100644 --- a/library/src/iosMain/kotlin/dev/bluefalcon/ApplicationContext.kt +++ b/library/src/iosMain/kotlin/dev/bluefalcon/ApplicationContext.kt @@ -1,5 +1,5 @@ package dev.bluefalcon -import platform.UIKit.UIView +import platform.UIKit.UIApplication -actual typealias ApplicationContext = UIView \ No newline at end of file +actual typealias ApplicationContext = UIApplication diff --git a/library/src/macosMain/kotlin/dev/bluefalcon/ApplicationContext.kt b/library/src/macosMain/kotlin/dev/bluefalcon/ApplicationContext.kt index cbd6d80..6c5f337 100644 --- a/library/src/macosMain/kotlin/dev/bluefalcon/ApplicationContext.kt +++ b/library/src/macosMain/kotlin/dev/bluefalcon/ApplicationContext.kt @@ -1,5 +1,5 @@ package dev.bluefalcon -import platform.AppKit.NSView +import platform.AppKit.NSApplication -actual typealias ApplicationContext = NSView \ No newline at end of file +actual typealias ApplicationContext = NSApplication