This file contains 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 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
struct SearchBar : View { | |
@Binding var searchText: String | |
var body: some View { | |
HStack { | |
Image(systemName: "magnifyingglass").foregroundColor(.secondary) | |
TextField( | |
$searchText, | |
placeholder: Text("Search")) { | |
UIApplication.shared.keyWindow?.endEditing(true) |
This file contains 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 app: View { | |
var appTitle: String | |
var appDesc: String | |
var appColor: Color | |
var body: some View { | |
HStack (alignment: .center, spacing: 14) { | |
VStack { |
This file contains 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
struct ExampleView: View { | |
var body: some View { | |
Text("Example") | |
.if(true) { $0.foregroundColor(.red) } | |
} | |
} |
This file contains 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
// | |
// Frost.swift | |
// | |
// Created by Clarko on 7/19/20. | |
// | |
// A SwiftUI representation of UIVisualEffectView | |
// and UIBlurEffect, that handles mostly like a | |
// SwiftUI Color view. Use it as a background. | |
// | |
// Comes with styles like Frost.thin and Frost.thick |
This file contains 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 | |
struct EnumPicker<T: Hashable & CaseIterable, V: View>: View { | |
@Binding var selected: T | |
var title: String? = nil | |
let mapping: (T) -> V | |
var body: some View { |
This file contains 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 ContentView: View { | |
@State var gradientAngle: Double = 0 | |
var colors = [ | |
Color(UIColor.systemRed), | |
Color(UIColor.systemOrange), | |
Color(UIColor.systemYellow), | |
Color(UIColor.systemGreen), |
This file contains 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 Sunset: View { | |
@State var backgroundColor = Color.blue | |
@State var sunSetted = false | |
let sunGradient = [Color.yellow, Color.orange] | |
let moonGradient = [Color.gray, Color.black] | |
@State var alignment = Alignment.top | |
This file contains 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
// Run any SwiftUI view as a Mac app. | |
import Cocoa | |
import SwiftUI | |
public func run<V: View>(view: V) { | |
let delegate = AppDelegate(view) | |
let app = NSApplication.shared | |
NSApp.setActivationPolicy(.regular) | |
app.mainMenu = app.customMenu |