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 Foundation | |
| public class Disposable { | |
| private var isDisposed = false | |
| private let _dispose: () -> Void | |
| public func dispose() { | |
| if !isDisposed { | |
| _dispose() | |
| isDisposed = true | |
| } |
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
| // | |
| // VirtualKeyboard.swift | |
| // MacBook Air M1 Zhuyin Keyboard | |
| // Written with SwiftUI ~=300 LOC, < 4hrs | |
| // Created by Ethan Huang on 2021/1/13. | |
| // Twitter: @ethanhuang13 | |
| import SwiftUI | |
| struct VirtualKeyboard: 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
| Copyright (c) 2023 Douglas Parker | |
| 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 |
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
| @_functionBuilder | |
| public enum CollectionBuilder<Element>: SimpleBuilder { | |
| public typealias Component = Element | |
| } | |
| public extension RangeReplaceableCollection { | |
| mutating func collect (@CollectionBuilder<Element> _ builder: () -> Element) { | |
| append(builder()) | |
| } |
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 AppleTV: View { | |
| var body: some View { | |
| ZStack { | |
| // Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG")) | |
| // .resizable() | |
| // .aspectRatio(contentMode: .fill) | |
| Color.gray |
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 | |
| // Note: There are some issues with using these modifiers inside of ButtonStyles on macOS. Please see https://twitter.com/noahsark769/status/1288256379640139776?s=20 for more info. | |
| struct ConditionalContent<TrueContent: View, FalseContent: View>: View { | |
| let value: Bool | |
| let trueContent: () -> TrueContent | |
| let falseContent: () -> FalseContent | |
| @ViewBuilder 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 | |
| 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 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
| // | |
| // ContentView.swift | |
| // Widgets | |
| // | |
| // Created by Kyle Halevi on 7/3/20. | |
| // | |
| import SwiftUI | |
| struct Widget: 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 | |
| struct ContentView: View { | |
| var body: some View { | |
| VStack(spacing: 24) { | |
| Text("Apple TV") | |
| .font(.headline) | |
| Rectangle() |