Add projects

This commit is contained in:
Ivan Vorobei
2019-06-07 09:04:22 +03:00
parent bbb48dbce9
commit fffd52a399
16 changed files with 1923 additions and 1 deletions

68
Examples/SFSymbols/.gitignore vendored Executable file
View File

@@ -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

7
Examples/SFSymbols/README.md Executable file
View File

@@ -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

View File

@@ -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..<symbols.count)
return NavigationView {
List(list) { index in
NavigationButton(destination: SymbolDetail(symbol: symbols[index])) {
SymbolRow(symbol: symbols[index])
}
}
}.navigationBarTitle(Text("SF Symbols"))
}
}
#if DEBUG
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
let contentView = ContentView()
PlaygroundPage.current.liveView = UIHostingController(rootView: contentView)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios'>
<timeline fileName='timeline.xctimeline'/>
</playground>

BIN
Examples/SFSymbols/demo.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

68
Examples/SplitView/.gitignore vendored Executable file
View File

@@ -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

21
Examples/SplitView/LICENSE Executable file
View File

@@ -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.

View File

@@ -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"]),
]
)

3
Examples/SplitView/README.md Executable file
View File

@@ -0,0 +1,3 @@
# SplitView
A SwiftUI view that manages a UISplitViewController.

View File

@@ -0,0 +1,22 @@
import SwiftUI
public struct SplitView<Master: View, Detail: View>: 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)
}
}

View File

@@ -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<SplitViewController>) -> UISplitViewController {
let splitViewController = UISplitViewController()
splitViewController.preferredDisplayMode = preferredDisplayMode
splitViewController.viewControllers = controllers
return splitViewController
}
public func updateUIViewController(_ uiViewController: UISplitViewController, context: UIViewControllerRepresentableContext<SplitViewController>) {
uiViewController.preferredDisplayMode = preferredDisplayMode
uiViewController.viewControllers = controllers
}
}

View File

@@ -0,0 +1,7 @@
import XCTest
import SplitViewTests
var tests = [XCTestCaseEntry]()
tests += SplitViewTests.allTests()
XCTMain(tests)

View File

@@ -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),
]
}

View File

@@ -0,0 +1,9 @@
import XCTest
#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(SplitViewTests.allTests),
]
}
#endif

View File

@@ -38,12 +38,13 @@ Also include:
- React Meets SwiftUI
- Webview
- UINote
- SplitView
## Projects
#### SFSymbols
<img src="Resources/SFSymbols.gif" width="600">
<img src="Resources/SFSymbols.gif" width="700">
#### Calculator