Skip to content

Commit

Permalink
feat: Apollo to support all apple devices
Browse files Browse the repository at this point in the history
- tvOS
- watchOS
- macOS
  • Loading branch information
hamada147 committed Sep 30, 2022
1 parent b48112b commit 355970f
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Apollo/src/macosX64Main/kotlin/io.iohk.prism.apollo/Platform.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.iohk.prism.apollo

import platform.Foundation.NSProcessInfo

actual object Platform {
actual val OS: String
get() {
val processInfo = NSProcessInfo.processInfo()
return "${processInfo.operatingSystemName()}-${processInfo.operatingSystemVersionString()}"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.iohk.prism.apollo

import kotlin.test.Test
import kotlin.test.assertTrue

class PlatformTest {

@Test
fun testPlatformName() {
println(Platform.OS)
assertTrue(Platform.OS.lowercase().contains("mac"), "Check macOS is mentioned")
}
}
7 changes: 7 additions & 0 deletions Apollo/src/tvosMain/kotlin/io.iohk.prism.apollo/Platform.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.iohk.prism.apollo

import platform.UIKit.UIDevice

actual object Platform {
actual val OS: String = "${UIDevice.currentDevice.systemName()}-${UIDevice.currentDevice.systemVersion}"
}
13 changes: 13 additions & 0 deletions Apollo/src/tvosTest/kotlin/io.iohk.prism.apollo/PlatformTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.iohk.prism.apollo

import kotlin.test.Test
import kotlin.test.assertTrue

class PlatformTest {

@Test
fun testPlatformName() {
println(Platform.OS)
assertTrue(Platform.OS.lowercase().contains("tvos"), "Check tvOS is mentioned")
}
}
11 changes: 11 additions & 0 deletions Apollo/src/watchosMain/kotlin/io.iohk.prism.apollo/Platform.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.iohk.prism.apollo

import platform.WatchKit.WKInterfaceDevice

actual object Platform {
actual val OS: String
get() {
val wkInterfaceDevice = WKInterfaceDevice.currentDevice()
return "${wkInterfaceDevice.systemName}-${wkInterfaceDevice.systemVersion}"
}
}
13 changes: 13 additions & 0 deletions Apollo/src/watchosTest/kotlin/io.iohk.prism.apollo/PlatformTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.iohk.prism.apollo

import kotlin.test.Test
import kotlin.test.assertTrue

class PlatformTest {

@Test
fun testPlatformName() {
println(Platform.OS)
assertTrue(Platform.OS.lowercase().contains("watchos"), "Check watchOS is mentioned")
}
}

0 comments on commit 355970f

Please sign in to comment.