Skip to content

Commit

Permalink
Merge branch '0.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Naumov committed Sep 19, 2021
2 parents 5a42983 + b2b591e commit 0d54687
Show file tree
Hide file tree
Showing 141 changed files with 6,295 additions and 1,383 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.DS_Store

## Xcode workspace
*.xcworkspace
#*.xcworkspace

## Build generated
build/
Expand Down
29 changes: 29 additions & 0 deletions .watchOS/watchOS-App/App-1-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>WKWatchKitApp</key>
<true/>
</dict>
</plist>
18 changes: 18 additions & 0 deletions .watchOS/watchOS-App/Base.lproj/Interface.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="19158" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
<device id="watch38"/>
<dependencies>
<deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19141"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="19040"/>
</dependencies>
<scenes>
<!--Root Interface Controller-->
<scene sceneID="aou-V4-d1y">
<objects>
<controller id="AgC-eL-Hgc" customClass="RootInterfaceController" customModule="watchOS_Ext_2"/>
</objects>
<point key="canvasLocation" x="-17" y="-6"/>
</scene>
</scenes>
</document>
34 changes: 34 additions & 0 deletions .watchOS/watchOS-Ext/Ext-1-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>WKAppBundleIdentifier</key>
<string>com.viewinspector.watchOS1.watchkitapp</string>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.watchkit</string>
</dict>
<key>WKWatchOnly</key>
<true/>
</dict>
</plist>
16 changes: 16 additions & 0 deletions .watchOS/watchOS-Ext/Ext-2-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>WKAppBundleIdentifier</key>
<string>com.viewinspector.watchOS2.watchkitapp</string>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.watchkit</string>
</dict>
</dict>
</plist>
42 changes: 42 additions & 0 deletions .watchOS/watchOS-Ext/watchOSApp+Testable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import SwiftUI
import WatchKit
import Combine

#if !(os(watchOS) && DEBUG)

typealias RootView<T> = T
typealias TestViewSubject = Set<Int>

extension View {
@inline(__always)
func testable(_ injector: TestViewSubject) -> Self {
self
}
}

#else

typealias RootView<T> = ModifiedContent<T, TestViewHost>
typealias TestViewSubject = CurrentValueSubject<[(String, AnyView)], Never>

extension View {
func testable(_ injector: TestViewSubject) -> ModifiedContent<Self, TestViewHost> {
modifier(TestViewHost(injector: injector))
}
}

struct TestViewHost: ViewModifier {

@State private var hostedViews: [(String, AnyView)] = []
let injector: TestViewSubject

func body(content: Content) -> some View {
ZStack {
content
ForEach(hostedViews, id: \.0) { $0.1 }
}
.onReceive(injector) { hostedViews = $0 }
}
}

#endif
22 changes: 22 additions & 0 deletions .watchOS/watchOS-Ext/watchOSApp-1.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import SwiftUI

@main
struct watchOSApp: App {

// swiftlint:disable weak_delegate
@WKExtensionDelegateAdaptor(ExtensionDelegate.self) var extDelegate
// swiftlint:enable weak_delegate

var body: some Scene {
WindowGroup {
NavigationView {
Text("Hi")
}
.testable(extDelegate.testViewSubject)
}
}
}

final class ExtensionDelegate: NSObject, WKExtensionDelegate {
let testViewSubject = TestViewSubject([])
}
18 changes: 18 additions & 0 deletions .watchOS/watchOS-Ext/watchOSApp-2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import WatchKit
import SwiftUI

final class RootInterfaceController: WKHostingController<RootView<ContentView>> {

let testViewSubject = TestViewSubject([])

override var body: RootView<ContentView> {
return ContentView()
.testable(testViewSubject)
}
}

struct ContentView: View {
var body: some View {
Text("Hi")
}
}
Loading

0 comments on commit 0d54687

Please sign in to comment.