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
| // Localizable.string - Spanish | |
| "Welcome **%@**, _please visit our [website](http://wwww.example.com)_" = | |
| "Bienvenido **%@**, _visita nuestro [sitioweb](http://wwww.example.com)_"; | |
| let welcomeAttributedString = | |
| AttributedString(localized: "Welcome **\(userName)**, _please visit our [website](http://wwww.example.com)_" | |
| // Source: https://medium.com/geekculture/automatic-grammar-agreement-b953cbf5d101 |
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
| Wednesday, Sep 12, 2018 --> EEEE, MMM d, yyyy | |
| 09/12/2018 --> MM/dd/yyyy | |
| 09-12-2018 14:11 --> MM-dd-yyyy HH:mm | |
| Sep 12, 2:11 PM --> MMM d, h:mm a | |
| Sep 12, 2022 14:11 --> MMM d, yyyy HH:mm | |
| September 2018 --> MMMM yyyy | |
| Sep 12, 2018 --> MMM d, yyyy | |
| Wed, 12 Sep 2018 14:11:54 +0000 --> E, d MMM yyyy HH:mm:ss Z | |
| 2018-09-12T14:11:54+0000 --> yyyy-MM-dd'T'HH:mm:ssZ | |
| 12.09.18 --> dd.MM.yy |
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 ScrollViewNoBounce: View { | |
| var body: some View { | |
| ScrollView { | |
| Text("Hello") | |
| } | |
| .onAppear { | |
| UIScrollView.appearance().bounces = false | |
| } |
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 SwiftUIView: View { | |
| @Namespace var topID | |
| @Namespace var bottomID | |
| var body: some View { | |
| ScrollViewReader { proxy in | |
| ScrollView { | |
| VStack(spacing: 15) { |
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 | |
| @propertyWrapper | |
| struct UserDefaultsBacked<Value> { | |
| private let key: String | |
| let storage: UserDefaults = .standard | |
| let defaultValue: Value | |
| var wrappedValue: Value { | |
| get { |
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
| @propertyWrapper | |
| struct Capitalized { | |
| var wrappedValue: String { | |
| didSet { wrappedValue = wrappedValue.capitalized } | |
| } | |
| init(wrappedValue: String) { | |
| // we need to explicitly capitalize any string that was passed into our initializer | |
| // since property observers are only triggered after a value or object was fully initialized. | |
| self.wrappedValue = wrappedValue.capitalized |
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 Fruit: Identifiable { | |
| let id = UUID() | |
| let name: String | |
| let emoji: String | |
| static var examples: [Fruit] { | |
| [ | |
| Fruit(name: "Kiwi", emoji: "🥝"), |
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 | |
| extension Optional { | |
| func unwrapOrThrow(_ errorExpression: @autoclosure () -> Error) throws -> Wrapped { | |
| guard let value = self else { | |
| throw errorExpression() | |
| } | |
| return value | |
| } |
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 PlatterContainer<Content: View>: View { | |
| @ViewBuilder let content: Content | |
| let shape = RoundedRectangle(cornerRadius: 20) | |
| var body: some View { | |
| content | |
| .frame(width: 100, height: 100) |
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 | |
| // Source: https://www.avanderlee.com/swiftui/conditional-view-modifier/ | |
| extension View { | |
| @ViewBuilder func `if`<Content: View>(_ condition: Bool, apply: (Self) -> Content) -> some View { | |
| if condition { | |
| apply(self) | |
| } else { | |
| self |