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
/// Sets a colored rounded rectangle behind the icon. | |
struct ColorIconLabelStyle: LabelStyle { | |
/// The color behind the icon. | |
var color: Color | |
/// The corner radius of the color behind the icon. | |
@ScaledMetric private var radius: CGFloat = 5 | |
func makeBody(configuration: Configuration) -> 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 | |
fileprivate struct ContentSizeCategoryModifier: ViewModifier { | |
// MARK:- Properties | |
/// The preferred size of the content. | |
@Environment(\.sizeCategory) private var sizeCategory | |
/// The maximum permitted content size category. |
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 Foundation | |
extension Array { | |
/// Safely provides the element at the requested index without encountering those dreaded index out of range errors 🥳. | |
/// | |
/// Take, for example, an array of characters. | |
/// ```` | |
/// let characters: [Character] = ["a", "b", "c", "d", "e"] | |
/// ```` |
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 Foundation | |
infix operator ??? | |
extension Optional where Wrapped: Collection { | |
/// Performs a nil-coalescing operation, returning the wrapped value of an `Optional` instance | |
/// only if the wrapped value is not empty, otherwise returns a default value. | |
/// | |
/// - Parameters: |
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 WidgetKit | |
enum WidgetPreviewProviderMode: CaseIterable { | |
/// Use for a system small widget preview. | |
case small | |
/// Use for a system medium widget preview. | |
case medium |
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 | |
enum PreviewProviderMode: CaseIterable { | |
/// Use for a light appearance preview. | |
case lightMode | |
/// Use for a dark appearance preview. | |
case darkMode | |
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 | |
@main | |
struct PropertyWrapperApp: App { | |
var body: some Scene { | |
WindowGroup { | |
VStack { | |
ContentView() | |
ContentView() | |
} |
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 | |
enum ColorAttribute: CodableAttributedStringKey, MarkdownDecodableAttributedStringKey { | |
enum Value: String, Codable, Hashable { | |
case red | |
case orange | |
case yellow | |
case green | |
case mint | |
case teal |
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 | |
enum ColorAttribute: CodableAttributedStringKey, MarkdownDecodableAttributedStringKey { | |
enum Value: String, Codable, Hashable { | |
case red | |
case orange | |
case yellow | |
case green | |
case mint | |
case teal |
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 | |
@Observable class ViewModel { | |
var isOn: Bool | |
var text: String | |
init(isOn: Bool = false, text: String = "default") { | |
self.isOn = isOn | |
self.text = text | |
} |
OlderNewer