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
| // Backports the Swift 6 type Mutex<Value> to all Darwin platforms via OSAllocatedUnfairLock. | |
| // Lightweight version of https://github.com/swhitty/swift-mutex | |
| // Feel free to use any part of this gist. | |
| import struct os.OSAllocatedUnfairLock | |
| // Backports the Swift 6.0 Mutex API | |
| @available(iOS, introduced: 16.0, deprecated: 18.0, message: "use Mutex from Synchronization module") | |
| @available(macOS, introduced: 13.0, deprecated: 15.0, message: "use Mutex from Synchronization module") | |
| public struct Mutex<Value: ~Copyable>: @unchecked Sendable, ~Copyable { |
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
| extension String { | |
| /// Forces the string to apply the break by character mode. | |
| /// | |
| /// Text("This is a long text.".forceCharWrapping) | |
| var forceCharWrapping: Self { | |
| self.map({ String($0) }).joined(separator: "\u{200B}") | |
| } | |
| } |
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 | |
| struct ContentView: View { | |
| typealias Item = (Color, CGFloat) | |
| @State private var columnCount = 3 | |
| @State private var isWaterfall = true | |
| @State var items: [Item] = [ |