This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A fun little game written in SwiftUI | |
| // Copyright (c) John Sundell 2020, MIT license. | |
| // This is a hacky implementation written just for fun. | |
| // It's only verified to work on iPhones in portrait mode. | |
| import SwiftUI | |
| final class GameController: ObservableObject { | |
| @Published var plane = GameObject.plane() | |
| @Published private(set) var clouds = [GameObject]() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Original article here: https://www.fivestars.blog/code/section-title-index-swiftui.html | |
| import SwiftUI | |
| let database: [String: [String]] = [ | |
| "iPhone": [ | |
| "iPhone", "iPhone 3G", "iPhone 3GS", "iPhone 4", "iPhone 4S", "iPhone 5", "iPhone 5C", "iPhone 5S", "iPhone 6", "iPhone 6 Plus", "iPhone 6S", "iPhone 6S Plus", "iPhone SE", "iPhone 7", "iPhone 7 Plus", "iPhone 8", "iPhone 8 Plus", "iPhone X", "iPhone Xs", "iPhone Xs Max", "iPhone Xʀ", "iPhone 11", "iPhone 11 Pro", "iPhone 11 Pro Max", "iPhone SE 2" | |
| ], | |
| "iPad": [ | |
| "iPad", "iPad 2", "iPad 3", "iPad 4", "iPad 5", "iPad 6", "iPad 7", "iPad Air", "iPad Air 2", "iPad Air 3", "iPad Mini", "iPad Mini 2", "iPad Mini 3", "iPad Mini 4", "iPad Mini 5", "iPad Pro 9.7-inch", "iPad Pro 10.5-inch", "iPad Pro 11-inch", "iPad Pro 11-inch 2", "iPad Pro 12.9-inch", "iPad Pro 12.9-inch 2", "iPad Pro 12.9-inch 3", "iPad Pro 12.9-inch 4" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import WebKit | |
| import PlaygroundSupport | |
| struct ContentView: View { | |
| @State var webView = WebView() | |
| @State var url = "" | |
| var body: some View { | |
| VStack { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import MapKit | |
| import PlaygroundSupport | |
| struct Location { | |
| var title: String | |
| var latitude: Double | |
| var longitude: Double | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import PlaygroundSupport | |
| // NOTE: this example currently only works with US-based coordinates | |
| // constants | |
| // New York | |
| let latitude = 40.709335 | |
| let longitude = -73.956558 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import PlaygroundSupport | |
| // constants | |
| let deviceWidth: CGFloat = 320 | |
| let deviceHeight: CGFloat = 568 | |
| let hasFaceID = true // false for TouchID | |
| struct Device: View { | |
| var body: some View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import PlaygroundSupport | |
| // constants | |
| let cardWidth: CGFloat = 343 | |
| let cardHeight: CGFloat = 212 | |
| let spacing = 36 | |
| let animation = Animation.spring() | |
| let cardColors = [ | |
| Color(UIColor.systemRed), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import PlaygroundSupport | |
| struct Desktop: View { | |
| var body: some View { | |
| ZStack { | |
| // Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG")) | |
| Color(UIColor.systemBlue) | |
| macOS() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import PlaygroundSupport | |
| struct Content: View { | |
| @State var isExpanded = false | |
| @State var wifiEnabled = true | |
| @State var spacing: CGFloat = 12 | |
| var body: some View { | |
| VStack(spacing: self.spacing) { | |
| HStack(spacing: self.spacing) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class FourColumnsContainerViewController: UIViewController { | |
| let outerSplitViewController = UISplitViewController(style: .tripleColumn) | |
| let innerSplitViewController = UISplitViewController(style: .doubleColumn) | |
| let primary = makeContentViewController("App") | |
| let secondary = makeContentViewController("Files") | |
| let mainContent = makeContentViewController("File Content") | |
| let inspector = makeContentViewController("Inspector") |