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
extension String { | |
/** Get email addresses in a string, discard any other content. */ | |
func emailAddresses() -> [String] { | |
var addresses = [String]() | |
if let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) { | |
let matches = detector.matches(in: self, options: [], range: NSMakeRange(0, self.count)) | |
for match in matches { | |
if let matchURL = match.url, | |
let matchURLComponents = URLComponents(url: matchURL, resolvingAgainstBaseURL: false), | |
matchURLComponents.scheme == "mailto" |
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
// MARK: - Usage | |
struct ContentView: View { | |
@State private var isFlipped = false | |
var body: some View { | |
FlipView(duration: 0.75, | |
perspective: 0.5, | |
isFlipped: $isFlipped) { | |
Color.red |
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 | |
// MARK: - ReadSize | |
struct SizePreferenceKey: PreferenceKey { | |
static var defaultValue: CGSize = .zero | |
static func reduce(value: inout CGSize, nextValue: () -> CGSize) {} | |
} | |
extension 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 | |
// MARK: - Usage | |
struct ContentView: View { | |
@State var isRevealed: Bool = false | |
@State var scratchProgress: Double = 0 | |
var body: some View { | |
VStack(spacing: 16) { |