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
// See also: Pro SwiftUI, Chapter 4 Custom Layouts | |
import SwiftUI | |
struct RelativeHStack: Layout { | |
enum Alignment { | |
case top, center, bottom | |
} | |
var alignment: Alignment = .center |
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
// Responsive Chips Selection | |
// See Also: https://youtu.be/T82izB2XBMA?si=Cnf6rGdyisG8ZWoX | |
import SwiftUI | |
struct Tag: Hashable { | |
var name: String | |
var color: Color | |
} |
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 Combine | |
struct CountdownView: View { | |
let countdownSeconds: Int = 10 | |
let numberOfDivision: Int = 36 | |
let handSize: CGSize = .init(width: 8, height: 24) | |
let radius: CGFloat = 100 | |
@State var count: Int = 10 |
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
// Gradient Border Animation | |
// See Also: https://x.com/sucodeee/status/1894700908824395843 | |
import SwiftUI | |
struct ContentView: View { | |
@State var rotation: CGFloat = 0 | |
var body: some View { | |
VStack(spacing: 40) { |
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
protocol SegmentTypeProtocol: CaseIterable, Identifiable, Equatable { | |
var title: String { get } | |
var tintColor: Color? { get } | |
} | |
extension SegmentTypeProtocol { | |
var tintColor: Color? { nil } | |
} | |
struct SegmentedControl<SegmentType: SegmentTypeProtocol>: View where SegmentType.AllCases == [SegmentType] { |