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

Add support for SwiftUI #16

Merged
merged 21 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1
5.5
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "fxm90/LightweightObservable" ~> 1.0
github "fxm90/LightweightObservable" ~> 2.0
2 changes: 1 addition & 1 deletion Example/.swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ file_header:
required_pattern: |
\/\/
\/\/ SWIFTLINT_CURRENT_FILENAME
\/\/ (GradientProgressBar|GradientProgressBar_Example|GradientProgressBar_Tests|GradientProgressBar_SnapshotTests)
\/\/ (GradientProgressBar|Example|ExampleTests|ExampleSnapshotTests)
\/\/
\/\/ Created by .*? on \d{2}\.\d{2}\.\d{2}\.
\/\/ Copyright © \d{4} .*?\. All rights reserved\.
Expand Down
934 changes: 934 additions & 0 deletions Example/Example.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
11 changes: 11 additions & 0 deletions Example/Example/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
98 changes: 98 additions & 0 deletions Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Example/Example/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
31 changes: 31 additions & 0 deletions Example/Example/ExampleApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// ExampleApp.swift
// Example
//
// Created by Felix Mau on 02.02.22.
// Copyright © 2022 Felix Mau. All rights reserved.
//

import SwiftUI

@main
struct ExampleApp: App {
var body: some Scene {
WindowGroup {
EntryPointView()
.onAppear {
// Use iOS 13 navigation bar appearance.
//
// While the entry point scene looks better with an opaque navigation background, the child scenes look
// better with the default navigation background. As we can't update the appearance per scene we fallback
// to an appearance with the default background here.
//
// Based on: https://sarunw.com/posts/uinavigationbar-changes-in-ios13/
let appearance = UINavigationBarAppearance()
appearance.configureWithDefaultBackground()

UINavigationBar.appearance().scrollEdgeAppearance = appearance
}
}
}
}
28 changes: 28 additions & 0 deletions Example/Example/Helper/StoryboardView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// StoryboardView.swift
// Example
//
// Created by Felix Mau on 02.02.22.
// Copyright © 2022 Felix Mau. All rights reserved.
//

import SwiftUI

struct StoryboardView: UIViewControllerRepresentable {
// MARK: - Public properties

let name: String

// MARK: - Public properties

func makeUIViewController(context _: Context) -> UIViewController {
let storyboard = UIStoryboard(name: name, bundle: nil)
guard let viewController = storyboard.instantiateInitialViewController() else {
fatalError("⚠️ – Could not instantiate initial view controller for storyboard with name `\(name)`.")
}

return viewController
}

func updateUIViewController(_: UIViewController, context _: Context) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
106 changes: 106 additions & 0 deletions Example/Example/Scenes/AdvancedExample/AdvancedExample.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<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"/>
</dependencies>
<scenes>
<!--Advanced Example View Controller-->
<scene sceneID="s0d-6b-0kx">
<objects>
<viewController id="Y6W-OH-hqX" customClass="AdvancedExampleViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RyK-YD-yGW" customClass="GradientProgressBar" customModule="GradientProgressBar">
<rect key="frame" x="16" y="447" width="382" height="2"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="2" id="w6Q-xO-TYd"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="progress">
<real key="value" value="0.5"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="Odh-xK-4ag" userLabel="Button Stack View">
<rect key="frame" x="0.0" y="818" width="414" height="44"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Yk3-ws-1EO">
<rect key="frame" x="0.0" y="12.5" width="132.5" height="19"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="tintColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="titleEdgeInsets" minX="8" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Animate" image="timer" catalog="system">
<color key="titleColor" systemColor="systemBlueColor"/>
</state>
<connections>
<action selector="animateButtonTouchUpInside:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="Cs2-mD-ZV2"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="tailTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wUL-0K-ADk">
<rect key="frame" x="140.5" y="12" width="133" height="20.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<inset key="titleEdgeInsets" minX="9" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Set Progress" image="gearshape.2.fill" catalog="system">
<color key="titleColor" systemColor="systemBlueColor"/>
</state>
<connections>
<action selector="setProgressButtonTouchUpInside:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="8EG-z9-1QQ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VRQ-TU-3pM">
<rect key="frame" x="281.5" y="12" width="132.5" height="20.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="tintColor" red="1" green="0.14913141730000001" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="titleEdgeInsets" minX="8" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Reset" image="arrow.counterclockwise" catalog="system">
<color key="titleColor" systemColor="systemRedColor"/>
</state>
<connections>
<action selector="resetButtonTouchUpInside:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="acj-nM-duy"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="44" id="SO2-Gr-Jrb"/>
</constraints>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="RyK-YD-yGW" firstAttribute="centerY" secondItem="5EZ-qb-Rvc" secondAttribute="centerY" id="IIc-NP-7IE"/>
<constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="Odh-xK-4ag" secondAttribute="trailing" id="RRj-aW-RvG"/>
<constraint firstItem="vDu-zF-Fre" firstAttribute="bottom" secondItem="Odh-xK-4ag" secondAttribute="bottom" id="izk-Am-TsN"/>
<constraint firstItem="Odh-xK-4ag" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" id="jpn-JJ-quK"/>
<constraint firstAttribute="trailing" secondItem="RyK-YD-yGW" secondAttribute="trailing" constant="16" id="mSa-x7-Q79"/>
<constraint firstItem="RyK-YD-yGW" firstAttribute="leading" secondItem="5EZ-qb-Rvc" secondAttribute="leading" constant="16" id="mdW-v4-Qno"/>
</constraints>
</view>
<connections>
<outlet property="gradientProgressBar" destination="RyK-YD-yGW" id="wan-6l-slq"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="133" y="117"/>
</scene>
</scenes>
<resources>
<image name="arrow.counterclockwise" catalog="system" width="115" height="128"/>
<image name="gearshape.2.fill" catalog="system" width="128" height="100"/>
<image name="timer" catalog="system" width="128" height="121"/>
<systemColor name="systemBlueColor">
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemRedColor">
<color red="1" green="0.23137254901960785" blue="0.18823529411764706" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
Loading