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 | |
fileprivate extension String { | |
func containsConsecutiveCharacters(length: Int) -> Bool { | |
let characters = Array(self) | |
for i in 0..<(characters.count - length + 1) { | |
let substring = String(characters[i..<(i + length)]) | |
if substring.allSatisfy({ $0 == substring.first }) { | |
return true | |
} |
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 AuthenticationServices | |
class AppleAuthViewModel: ObservableObject { | |
@Published var shouldShowAlert: Bool = false | |
@Published var alertTitle: String = "" | |
@Published var alertMessage: String = "" | |
//get notified when autherization state gets change | |
init() { |
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 CustomGlyphPicker: View { | |
@State private var name: String = "Default Name" | |
@State private var selectedImage: String = "defaultImage" | |
@State private var images: [String] = [ | |
"face.smiling.inverse", | |
"list.bullet", | |
"house.fill", | |
"star.fill", |
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 start = Date.now | |
var body: some View { | |
VStack { | |
TimelineView(.animation) { timeline in | |
let time = start.distance(to: timeline.date) | |
Rectangle() |
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
struct RemotePhotoDemoModel: Identifiable { | |
let id: UUID = .init() | |
let image: String | |
var imageData: Data? | |
static let allPhotos: [RemotePhotoDemoModel] = [ | |
//RemotePhotoDemoModel(image: "https://images.unsplash.com/photo-1531737212413-667205e1cda"), // error sample | |
RemotePhotoDemoModel(image: "https://images.unsplash.com/photo-1510001618818-4b4e3d86bf0f"), | |
RemotePhotoDemoModel(image: "https://images.unsplash.com/photo-1504284992506-f6d82d0f2f2a"), | |
RemotePhotoDemoModel(image: "https://images.unsplash.com/photo-1465447142348-e9952c393450"), |
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 MetalKit | |
struct Particle { | |
let color: SIMD4<Float> | |
let radius: Float | |
let lifespan: Float | |
let position: SIMD2<Float> | |
let velocity: SIMD2<Float> | |
} |
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 extension Date.FormatStyle { | |
func withTimeZone(_ timeZone: TimeZone?) -> Date.FormatStyle { | |
var copy = self | |
if let timeZone = timeZone { | |
copy.timeZone = timeZone | |
} | |
return copy | |
} |
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 SplashScreen: View { | |
var body: some View { | |
ZStack { | |
Rectangle().fill(Color.blue.gradient) | |
Image(systemName: "apple.logo") | |
.resizable() |
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
{ | |
"adult": false, | |
"backdrop_path": "/ifUfE79O1raUwbaQRIB7XnFz5ZC.jpg", | |
"belongs_to_collection": { | |
"id": 2602, | |
"name": "Scream Collection", | |
"poster_path": "/p3EjClFy20jjT0u06dzBs4lvvhi.jpg", | |
"backdrop_path": "/oUcscMECv8DOBsAPCh3KnDZqAC4.jpg" | |
}, | |
"budget": 24000000, |
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
// | |
// CoverFlowCarousel.swift | |
// ClockSample | |
// | |
// Created by Codelaby on 25/7/24. | |
// | |
import SwiftUI | |
//RandomAccessCollection & MutableCollection & RangeReplaceableCollection & Equatable & Hashable | |
struct CoverFlowCarousel<Content: View, Data: RandomAccessCollection>: View where Data.Element: Identifiable { |
NewerOlder