diff --git a/Examples/SFSymbols/.gitignore b/Examples/SFSymbols/.gitignore new file mode 100755 index 0000000..312d1f6 --- /dev/null +++ b/Examples/SFSymbols/.gitignore @@ -0,0 +1,68 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output diff --git a/Examples/SFSymbols/README.md b/Examples/SFSymbols/README.md new file mode 100755 index 0000000..a92033f --- /dev/null +++ b/Examples/SFSymbols/README.md @@ -0,0 +1,7 @@ +# SFSymbols-Playground +A playground listing all the SFSymbols in SwiftUI + +![Demo GIF](https://github.com/jstart/SFSymbols-Playground/blob/master/demo.gif) + +You can download the SF Symbols.app beta for Mac here: https://developer.apple.com/design/downloads/SF-Symbols.dmg +A Swift Package has already been developed to make SF Symbols an enum instead of strings: https://twitter.com/simjp/status/1135936933916336128 diff --git a/Examples/SFSymbols/SFSymbols.playground/Contents.swift b/Examples/SFSymbols/SFSymbols.playground/Contents.swift new file mode 100755 index 0000000..2f25612 --- /dev/null +++ b/Examples/SFSymbols/SFSymbols.playground/Contents.swift @@ -0,0 +1,60 @@ +import UIKit +import PlaygroundSupport +import SwiftUI + +var colors: [Color] = [.red, .blue, .black, .gray, .green, .yellow, .orange, .pink, .purple] + +struct SymbolRow: View { + var symbol: String + + var body: some View { + HStack { + Image(systemName: symbol).foregroundColor(colors.randomElement()) + Divider() + Text(symbol) + } + } +} + +struct SymbolDetail: View { + var symbol: String + + var body: some View { + VStack { + Image(systemName: symbol) + .foregroundColor(colors.randomElement()) + .imageScale(.large) + .scaleEffect(3.0) + .padding(.bottom, 100) + Divider() +// .animation(Animation.basic().delay(0.25)) + Text(symbol).font(.headline) + } + } +} + +struct ContentView: View { + + var body: some View { + let list = (0.. + + + \ No newline at end of file diff --git a/Examples/SFSymbols/demo.gif b/Examples/SFSymbols/demo.gif new file mode 100755 index 0000000..9606053 Binary files /dev/null and b/Examples/SFSymbols/demo.gif differ diff --git a/Examples/SplitView/.gitignore b/Examples/SplitView/.gitignore new file mode 100755 index 0000000..312d1f6 --- /dev/null +++ b/Examples/SplitView/.gitignore @@ -0,0 +1,68 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output diff --git a/Examples/SplitView/LICENSE b/Examples/SplitView/LICENSE new file mode 100755 index 0000000..713ace4 --- /dev/null +++ b/Examples/SplitView/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Alexsander Akers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Examples/SplitView/Package.swift b/Examples/SplitView/Package.swift new file mode 100755 index 0000000..132d1ec --- /dev/null +++ b/Examples/SplitView/Package.swift @@ -0,0 +1,32 @@ +// swift-tools-version:5.1 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "SplitView", + platforms: [ + .iOS(.v13), + .tvOS(.v13) + ], + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "SplitView", + targets: ["SplitView"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "SplitView", + dependencies: []), + .testTarget( + name: "SplitViewTests", + dependencies: ["SplitView"]), + ] +) diff --git a/Examples/SplitView/README.md b/Examples/SplitView/README.md new file mode 100755 index 0000000..9c557dc --- /dev/null +++ b/Examples/SplitView/README.md @@ -0,0 +1,3 @@ +# SplitView + +A SwiftUI view that manages a UISplitViewController. diff --git a/Examples/SplitView/Sources/SplitView/SplitView.swift b/Examples/SplitView/Sources/SplitView/SplitView.swift new file mode 100755 index 0000000..7e0f958 --- /dev/null +++ b/Examples/SplitView/Sources/SplitView/SplitView.swift @@ -0,0 +1,22 @@ +import SwiftUI + +public struct SplitView: View { + public var master: Master + public var detail: Detail + @State public var preferredDisplayMode: UISplitViewController.DisplayMode + + public var body: some View { + let controllers = [UIHostingController(rootView: master), UIHostingController(rootView: detail)] + return SplitViewController(controllers: controllers, preferredDisplayMode: $preferredDisplayMode) + } +} + +public extension SplitView { + init(master: Master, detail: Detail) { + self.init(master: master, detail: detail, preferredDisplayMode: .automatic) + } + + func preferredDisplayMode(_ preferredDisplayMode: UISplitViewController.DisplayMode) -> Self { + return SplitView(master: master, detail: detail, preferredDisplayMode: preferredDisplayMode) + } +} diff --git a/Examples/SplitView/Sources/SplitView/SplitViewController.swift b/Examples/SplitView/Sources/SplitView/SplitViewController.swift new file mode 100755 index 0000000..8910ab7 --- /dev/null +++ b/Examples/SplitView/Sources/SplitView/SplitViewController.swift @@ -0,0 +1,18 @@ +import SwiftUI + +public struct SplitViewController: UIViewControllerRepresentable { + public var controllers: [UIViewController] + @Binding public var preferredDisplayMode: UISplitViewController.DisplayMode + + public func makeUIViewController(context: UIViewControllerRepresentableContext) -> UISplitViewController { + let splitViewController = UISplitViewController() + splitViewController.preferredDisplayMode = preferredDisplayMode + splitViewController.viewControllers = controllers + return splitViewController + } + + public func updateUIViewController(_ uiViewController: UISplitViewController, context: UIViewControllerRepresentableContext) { + uiViewController.preferredDisplayMode = preferredDisplayMode + uiViewController.viewControllers = controllers + } +} diff --git a/Examples/SplitView/Tests/LinuxMain.swift b/Examples/SplitView/Tests/LinuxMain.swift new file mode 100755 index 0000000..ed76b32 --- /dev/null +++ b/Examples/SplitView/Tests/LinuxMain.swift @@ -0,0 +1,7 @@ +import XCTest + +import SplitViewTests + +var tests = [XCTestCaseEntry]() +tests += SplitViewTests.allTests() +XCTMain(tests) diff --git a/Examples/SplitView/Tests/SplitViewTests/SplitViewTests.swift b/Examples/SplitView/Tests/SplitViewTests/SplitViewTests.swift new file mode 100755 index 0000000..0491d33 --- /dev/null +++ b/Examples/SplitView/Tests/SplitViewTests/SplitViewTests.swift @@ -0,0 +1,14 @@ +import XCTest +@testable import SplitView + +final class SplitViewTests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + } + + static var allTests = [ + ("testExample", testExample), + ] +} diff --git a/Examples/SplitView/Tests/SplitViewTests/XCTestManifests.swift b/Examples/SplitView/Tests/SplitViewTests/XCTestManifests.swift new file mode 100755 index 0000000..7c6256c --- /dev/null +++ b/Examples/SplitView/Tests/SplitViewTests/XCTestManifests.swift @@ -0,0 +1,9 @@ +import XCTest + +#if !canImport(ObjectiveC) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(SplitViewTests.allTests), + ] +} +#endif diff --git a/README.md b/README.md index ecee30b..be51bf9 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,13 @@ Also include: - React Meets SwiftUI - Webview - UINote +- SplitView ## Projects #### SFSymbols - + #### Calculator