Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Passthrough representable #79

Merged
merged 13 commits into from Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -116,3 +116,15 @@ class TestInputViewController: UIWorkflowItem<String, Never>, StoryboardLoadable

required init?(coder: NSCoder) { nil }
}

// Literally just make sure it compiles....
class PassthroughViewController: UIViewController, StoryboardLoadable, PassthroughFlowRepresentable {
var _workflowPointer: AnyFlowRepresentable?

static var storyboardId: String {
String(describing: Self.self)
}
static var storyboard: UIStoryboard {
UIStoryboard(name: "TestStoryboard", bundle: Bundle(for: Self.self))
}
}
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -11,7 +11,7 @@
<!--Test No Input View Controller-->
<scene sceneID="D53-J0-gxQ">
<objects>
<viewController storyboardIdentifier="TestNoInputViewController" id="vfA-c5-hwQ" customClass="TestNoInputViewController" customModule="WorkflowUIKitTests" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="TestNoInputViewController" id="vfA-c5-hwQ" customClass="TestNoInputViewController" customModule="SwiftCurrent_UIKitTests" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="kXD-0r-n1P">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand All @@ -26,7 +26,7 @@
<!--Test Input View Controller-->
<scene sceneID="B5Y-K4-ia6">
<objects>
<viewController storyboardIdentifier="TestInputViewController" id="Ayy-IX-QKG" customClass="TestInputViewController" customModule="WorkflowUIKitTests" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="TestInputViewController" id="Ayy-IX-QKG" customClass="TestInputViewController" customModule="SwiftCurrent_UIKitTests" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="ida-Cw-sqr">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand All @@ -38,6 +38,21 @@
</objects>
<point key="canvasLocation" x="796" y="134"/>
</scene>
<!--Passthrough View Controller-->
<scene sceneID="h4u-WO-uVP">
<objects>
<viewController storyboardIdentifier="PassthroughViewController" id="vD2-ys-Nj9" customClass="PassthroughViewController" customModule="SwiftCurrent_UIKitTests" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="N0S-FD-OWF">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="SEq-zr-dev"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="AMB-YW-LZ3" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1451" y="134"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
Expand Down
12 changes: 12 additions & 0 deletions Sources/SwiftCurrent_UIKit/StoryboardLoadable.swift
Expand Up @@ -70,6 +70,18 @@ extension StoryboardLoadable {
}
}

@available(iOS 13.0, *)
extension PassthroughFlowRepresentable where Self: StoryboardLoadable {
/// :nodoc: **WARNING: This will throw a fatal error.** Just a default implementation of the required `FlowRepresentable` initializer meant to satisfy the protocol requirements.
public init(with args: WorkflowInput) { // swiftlint:disable:this unavailable_function
// swiftlint:disable:next line_length
fatalError("The StoryboardLoadable protocol provided a default implementation if this initializer so that consumers didn't have to worry about it in their UIViewController. If you encounter this error and need this initializer, simply add it to \(String(describing: Self.self))")
Tyler-Keith-Thompson marked this conversation as resolved.
Show resolved Hide resolved
}

// swiftlint:disable:next missing_docs
public init?(coder: NSCoder, with args: WorkflowInput) { self.init(coder: coder) }
}

@available(iOS 13.0, *)
extension StoryboardLoadable where WorkflowInput == Never {
// No public docs necessary, this cannot be called.
Expand Down