Use native threaded coroutines in watch app.
This commit is contained in:
parent
8140922437
commit
07a59c4a4f
14 changed files with 25 additions and 118 deletions
|
@ -1,6 +1,6 @@
|
|||
|
||||
object Versions {
|
||||
const val androidBuildToolsVersion = "4.0.0-alpha06"
|
||||
const val androidBuildToolsVersion = "4.0.0-alpha08"
|
||||
|
||||
const val kotlin = "1.3.61"
|
||||
const val kotlinCoroutines = "1.3.3"
|
||||
|
|
|
@ -117,7 +117,11 @@ kotlin {
|
|||
|
||||
watchMain.dependencies {
|
||||
// Coroutines
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${Versions.kotlinCoroutines}"
|
||||
implementation('org.jetbrains.kotlinx:kotlinx-coroutines-core-native') {
|
||||
version {
|
||||
strictly '1.3.3-native-mt'
|
||||
}
|
||||
}
|
||||
|
||||
// Ktor
|
||||
implementation "io.ktor:ktor-client-ios:${Versions.ktor}"
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package com.surrus.common
|
||||
|
||||
import kotlin.coroutines.*
|
||||
import kotlinx.coroutines.*
|
||||
import platform.darwin.*
|
||||
|
||||
|
||||
internal actual val ApplicationDispatcher: CoroutineDispatcher =
|
||||
NsQueueDispatcher(dispatch_get_main_queue())
|
||||
|
||||
internal class NsQueueDispatcher(
|
||||
private val dispatchQueue: dispatch_queue_t
|
||||
) : CoroutineDispatcher() {
|
||||
override fun dispatch(context: CoroutineContext, block: Runnable) {
|
||||
dispatch_async(dispatchQueue) {
|
||||
block.run()
|
||||
}
|
||||
}
|
||||
}
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-milestone-2-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-rc-1-all.zip
|
||||
|
|
Binary file not shown.
|
@ -20,16 +20,16 @@
|
|||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>WKWatchKitApp</key>
|
||||
<true/>
|
||||
</dict>
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
// ContentView.swift
|
||||
// PeopleInSpaceWatch WatchKit Extension
|
||||
//
|
||||
// Created by Neal Sanche on 2020-01-02.
|
||||
// Copyright © 2020 Neal Sanche. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import common
|
||||
|
@ -18,7 +15,6 @@ struct ContentView: View {
|
|||
List(peopleInSpaceViewModel.people, id: \.name) { person in
|
||||
PersonView(person: person)
|
||||
}
|
||||
//.navigationBarTitle(Text("PeopleInSpace"), displayMode: .large)
|
||||
.onAppear(perform: {
|
||||
self.peopleInSpaceViewModel.fetch()
|
||||
})
|
||||
|
@ -30,12 +26,7 @@ struct PersonView : View {
|
|||
var person: Assignment
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
VStack(alignment: .leading) {
|
||||
Text(person.name).font(.headline)
|
||||
Text(person.craft).font(.subheadline)
|
||||
}
|
||||
}
|
||||
NavigationLink(person.name, destination: Text(person.craft).font(.subheadline))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
// ExtensionDelegate.swift
|
||||
// PeopleInSpaceWatch WatchKit Extension
|
||||
//
|
||||
// Created by Neal Sanche on 2020-01-02.
|
||||
// Copyright © 2020 Neal Sanche. All rights reserved.
|
||||
//
|
||||
|
||||
import WatchKit
|
||||
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
// HostingController.swift
|
||||
// PeopleInSpaceWatch WatchKit Extension
|
||||
//
|
||||
// Created by Neal Sanche on 2020-01-02.
|
||||
// Copyright © 2020 Neal Sanche. All rights reserved.
|
||||
//
|
||||
|
||||
import WatchKit
|
||||
import Foundation
|
||||
|
|
|
@ -20,23 +20,23 @@
|
|||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
<dict>
|
||||
<key>WKAppBundleIdentifier</key>
|
||||
<string>dev.nosuch.apps.PeopleInSpaceWatch.watchkitapp</string>
|
||||
<string>com.surrus.PeopleInSpaceWatch.watchkitapp</string>
|
||||
</dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.watchkit</string>
|
||||
</dict>
|
||||
<key>WKExtensionDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).ExtensionDelegate</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>WKWatchOnly</key>
|
||||
<true/>
|
||||
</dict>
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
//
|
||||
// NotificationController.swift
|
||||
// PeopleInSpaceWatch WatchKit Extension
|
||||
//
|
||||
// Created by Neal Sanche on 2020-01-02.
|
||||
// Copyright © 2020 Neal Sanche. All rights reserved.
|
||||
//
|
||||
|
||||
import WatchKit
|
||||
import SwiftUI
|
||||
import UserNotifications
|
||||
|
||||
class NotificationController: WKUserNotificationHostingController<NotificationView> {
|
||||
|
||||
override var body: NotificationView {
|
||||
return NotificationView()
|
||||
}
|
||||
|
||||
override func willActivate() {
|
||||
// This method is called when watch view controller is about to be visible to user
|
||||
super.willActivate()
|
||||
}
|
||||
|
||||
override func didDeactivate() {
|
||||
// This method is called when watch view controller is no longer visible
|
||||
super.didDeactivate()
|
||||
}
|
||||
|
||||
override func didReceive(_ notification: UNNotification) {
|
||||
// This method is called when a notification needs to be presented.
|
||||
// Implement it if you use a dynamic notification interface.
|
||||
// Populate your dynamic notification interface as quickly as possible.
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
//
|
||||
// NotificationView.swift
|
||||
// PeopleInSpaceWatch WatchKit Extension
|
||||
//
|
||||
// Created by Neal Sanche on 2020-01-02.
|
||||
// Copyright © 2020 Neal Sanche. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct NotificationView: View {
|
||||
var body: some View {
|
||||
Text("Hello, World!")
|
||||
}
|
||||
}
|
||||
|
||||
struct NotificationView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NotificationView()
|
||||
}
|
||||
}
|
|
@ -15,8 +15,6 @@
|
|||
FD254FAE23BE528700C19A05 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD254FAD23BE528700C19A05 /* ContentView.swift */; };
|
||||
FD254FB023BE528700C19A05 /* HostingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD254FAF23BE528700C19A05 /* HostingController.swift */; };
|
||||
FD254FB223BE528700C19A05 /* ExtensionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD254FB123BE528700C19A05 /* ExtensionDelegate.swift */; };
|
||||
FD254FB423BE528700C19A05 /* NotificationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD254FB323BE528700C19A05 /* NotificationController.swift */; };
|
||||
FD254FB623BE528700C19A05 /* NotificationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD254FB523BE528700C19A05 /* NotificationView.swift */; };
|
||||
FD254FB823BE528800C19A05 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FD254FB723BE528800C19A05 /* Assets.xcassets */; };
|
||||
FD254FBB23BE528800C19A05 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FD254FBA23BE528800C19A05 /* Preview Assets.xcassets */; };
|
||||
FD254FCC23BE55DA00C19A05 /* ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD254FCB23BE55DA00C19A05 /* ViewModel.swift */; };
|
||||
|
@ -77,8 +75,6 @@
|
|||
FD254FAD23BE528700C19A05 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
FD254FAF23BE528700C19A05 /* HostingController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostingController.swift; sourceTree = "<group>"; };
|
||||
FD254FB123BE528700C19A05 /* ExtensionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionDelegate.swift; sourceTree = "<group>"; };
|
||||
FD254FB323BE528700C19A05 /* NotificationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationController.swift; sourceTree = "<group>"; };
|
||||
FD254FB523BE528700C19A05 /* NotificationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationView.swift; sourceTree = "<group>"; };
|
||||
FD254FB723BE528800C19A05 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
FD254FBA23BE528800C19A05 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||
FD254FBC23BE528800C19A05 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
|
@ -166,8 +162,6 @@
|
|||
FD254FAD23BE528700C19A05 /* ContentView.swift */,
|
||||
FD254FAF23BE528700C19A05 /* HostingController.swift */,
|
||||
FD254FB123BE528700C19A05 /* ExtensionDelegate.swift */,
|
||||
FD254FB323BE528700C19A05 /* NotificationController.swift */,
|
||||
FD254FB523BE528700C19A05 /* NotificationView.swift */,
|
||||
FD254FB723BE528800C19A05 /* Assets.xcassets */,
|
||||
FD254FBC23BE528800C19A05 /* Info.plist */,
|
||||
FD254FBD23BE528800C19A05 /* PushNotificationPayload.apns */,
|
||||
|
@ -343,10 +337,8 @@
|
|||
files = (
|
||||
FD254FB023BE528700C19A05 /* HostingController.swift in Sources */,
|
||||
FD254FAE23BE528700C19A05 /* ContentView.swift in Sources */,
|
||||
FD254FB423BE528700C19A05 /* NotificationController.swift in Sources */,
|
||||
FD254FB223BE528700C19A05 /* ExtensionDelegate.swift in Sources */,
|
||||
FD254FCC23BE55DA00C19A05 /* ViewModel.swift in Sources */,
|
||||
FD254FB623BE528700C19A05 /* NotificationView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -504,7 +496,7 @@
|
|||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.nosuch.apps.PeopleInSpaceWatch.watchkitapp.watchkitextension;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.surrus.PeopleInSpaceWatch.watchkitapp.watchkitextension;
|
||||
PRODUCT_NAME = "${TARGET_NAME}";
|
||||
SDKROOT = watchos;
|
||||
SKIP_INSTALL = YES;
|
||||
|
@ -529,7 +521,7 @@
|
|||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.nosuch.apps.PeopleInSpaceWatch.watchkitapp.watchkitextension;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.surrus.PeopleInSpaceWatch.watchkitapp.watchkitextension;
|
||||
PRODUCT_NAME = "${TARGET_NAME}";
|
||||
SDKROOT = watchos;
|
||||
SKIP_INSTALL = YES;
|
||||
|
@ -548,7 +540,7 @@
|
|||
DEVELOPMENT_TEAM = PBH8V487HB;
|
||||
IBSC_MODULE = PeopleInSpaceWatch_WatchKit_Extension;
|
||||
INFOPLIST_FILE = "PeopleInSpaceWatch WatchKit App/Info.plist";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.nosuch.apps.PeopleInSpaceWatch.watchkitapp;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.surrus.PeopleInSpaceWatch.watchkitapp;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = watchos;
|
||||
SKIP_INSTALL = YES;
|
||||
|
@ -567,7 +559,7 @@
|
|||
DEVELOPMENT_TEAM = PBH8V487HB;
|
||||
IBSC_MODULE = PeopleInSpaceWatch_WatchKit_Extension;
|
||||
INFOPLIST_FILE = "PeopleInSpaceWatch WatchKit App/Info.plist";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.nosuch.apps.PeopleInSpaceWatch.watchkitapp;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.surrus.PeopleInSpaceWatch.watchkitapp;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = watchos;
|
||||
SKIP_INSTALL = YES;
|
||||
|
@ -584,7 +576,7 @@
|
|||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = PBH8V487HB;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.nosuch.apps.PeopleInSpaceWatch;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.surrus.PeopleInSpaceWatch;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
|
@ -597,7 +589,7 @@
|
|||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = PBH8V487HB;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.nosuch.apps.PeopleInSpaceWatch;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.surrus.PeopleInSpaceWatch;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue