mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-04-27 02:58:43 +02:00
Add projects
This commit is contained in:
68
Examples/SFSymbols/.gitignore
vendored
Executable file
68
Examples/SFSymbols/.gitignore
vendored
Executable 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
7
Examples/SFSymbols/README.md
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
# SFSymbols-Playground
|
||||||
|
A playground listing all the SFSymbols in SwiftUI
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
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
|
||||||
60
Examples/SFSymbols/SFSymbols.playground/Contents.swift
Executable file
60
Examples/SFSymbols/SFSymbols.playground/Contents.swift
Executable 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)
|
||||||
1588
Examples/SFSymbols/SFSymbols.playground/Sources/Symbols.swift
Executable file
1588
Examples/SFSymbols/SFSymbols.playground/Sources/Symbols.swift
Executable file
File diff suppressed because it is too large
Load Diff
4
Examples/SFSymbols/SFSymbols.playground/contents.xcplayground
Executable file
4
Examples/SFSymbols/SFSymbols.playground/contents.xcplayground
Executable 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
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
68
Examples/SplitView/.gitignore
vendored
Executable 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
21
Examples/SplitView/LICENSE
Executable 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.
|
||||||
32
Examples/SplitView/Package.swift
Executable file
32
Examples/SplitView/Package.swift
Executable 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
3
Examples/SplitView/README.md
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
# SplitView
|
||||||
|
|
||||||
|
A SwiftUI view that manages a UISplitViewController.
|
||||||
22
Examples/SplitView/Sources/SplitView/SplitView.swift
Executable file
22
Examples/SplitView/Sources/SplitView/SplitView.swift
Executable 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Examples/SplitView/Sources/SplitView/SplitViewController.swift
Executable file
18
Examples/SplitView/Sources/SplitView/SplitViewController.swift
Executable 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
|
||||||
|
}
|
||||||
|
}
|
||||||
7
Examples/SplitView/Tests/LinuxMain.swift
Executable file
7
Examples/SplitView/Tests/LinuxMain.swift
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
import XCTest
|
||||||
|
|
||||||
|
import SplitViewTests
|
||||||
|
|
||||||
|
var tests = [XCTestCaseEntry]()
|
||||||
|
tests += SplitViewTests.allTests()
|
||||||
|
XCTMain(tests)
|
||||||
14
Examples/SplitView/Tests/SplitViewTests/SplitViewTests.swift
Executable file
14
Examples/SplitView/Tests/SplitViewTests/SplitViewTests.swift
Executable 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),
|
||||||
|
]
|
||||||
|
}
|
||||||
9
Examples/SplitView/Tests/SplitViewTests/XCTestManifests.swift
Executable file
9
Examples/SplitView/Tests/SplitViewTests/XCTestManifests.swift
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
import XCTest
|
||||||
|
|
||||||
|
#if !canImport(ObjectiveC)
|
||||||
|
public func allTests() -> [XCTestCaseEntry] {
|
||||||
|
return [
|
||||||
|
testCase(SplitViewTests.allTests),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -38,12 +38,13 @@ Also include:
|
|||||||
- React Meets SwiftUI
|
- React Meets SwiftUI
|
||||||
- Webview
|
- Webview
|
||||||
- UINote
|
- UINote
|
||||||
|
- SplitView
|
||||||
|
|
||||||
## Projects
|
## Projects
|
||||||
|
|
||||||
#### SFSymbols
|
#### SFSymbols
|
||||||
|
|
||||||
<img src="Resources/SFSymbols.gif" width="600">
|
<img src="Resources/SFSymbols.gif" width="700">
|
||||||
|
|
||||||
#### Calculator
|
#### Calculator
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user