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 | |
// Xcode: 16.0 | |
// Swift: 6.0 | |
struct EnumPicker<Enum>: View where Enum: CaseIterable & Hashable, Enum == Enum.AllCases.Element, Enum.AllCases: RandomAccessCollection { | |
@Binding var selection: Enum | |
var body: some View { | |
Picker(String(describing: Enum.self), selection: $selection) { | |
ForEach(Enum.allCases, id: \.self) { value in |
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 ContentView: View { | |
@State var ratio: Double = 0 | |
var body: some View { | |
ZStack { | |
Color(hue: 1, saturation: 0.3, brightness: 1) | |
.hueRotation(.degrees(360 * ratio)) | |
.ignoresSafeArea() |
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 ContentView: View { | |
@ViewBuilder | |
private func leftHandSide() -> some View { | |
HelloWorld() | |
.clipShape(Rectangle()) | |
HelloWorld() | |
.clipShape(RoundedRectangle(cornerRadius: 20)) | |
HelloWorld() |
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 ContentView: View { | |
var body: some View { | |
Group { | |
HelloWorld() | |
.clipShape(UnevenRoundedRectangle( | |
topLeadingRadius: 80, | |
bottomTrailingRadius: 80 | |
)) |
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 | |
extension Color { | |
static var random: Self { | |
Color( | |
hue: .random(in: 0..<1), | |
saturation: .random(in: (0.9)..<1), | |
brightness: .random(in: (0.9)..<1) | |
) | |
} |
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 ContentView: View { | |
@Environment(\.colorScheme) var scheme | |
private let date = Date() | |
private let colors = [Color.green, .pink, .blue, .orange, .purple] | |
private let titles = ["NEON", "GLOW", "LIGHT", "SHINE", "BRIGHT"] | |
var body: some View { | |
TimelineView(.animation) { context in |
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 ContentView: View { | |
@State var progress = 0.0 | |
var body: some View { | |
ZStack { | |
Ring(value: progress, speed: 4) | |
.foregroundStyle(gradation(.yellow, .orange)) | |
.frame(width: 120) |
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 ContentView: View { | |
@State var progress = 0.0 | |
var body: some View { | |
ProgressRing(value: progress) | |
.frame(maxWidth: .infinity, maxHeight: .infinity) | |
.contentShape(.rect) | |
.ignoresSafeArea() |
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 ContentView: View { | |
@State private var show = false | |
@State private var items: [Item] = .samples() | |
var body: some View { | |
ScrollView { | |
LazyVStack { | |
ForEach(items.indices, id: \.self) { index in |
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 ContentView: View { | |
@State private var item: [Item] = .samples() | |
@State private var show = false | |
var body: some View { | |
ScrollView { | |
LazyVStack { | |
ForEach(item.indices, id: \.self) { index in |
NewerOlder