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
| struct StarFieldView: View { | |
| @State private var stars: [Star] = [] | |
| var body: some View { | |
| GeometryReader { geometry in | |
| ZStack { | |
| ForEach(stars) { star in | |
| Circle() | |
| .fill(star.color) | |
| .frame(width: star.size, height: star.size) |
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
| struct ProgressLine: Identifiable { | |
| var id: String = UUID().uuidString | |
| var length: CGFloat | |
| var gradient: LinearGradient | |
| } | |
| struct ContentView: View { | |
| var body: some View { | |
| VStack { | |
| CircularRectanglesView() |
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
| func binarySearchWithRecursion(arr: [Int], target: Int, s: Int, e: Int) -> Int { | |
| if s > e { | |
| return -1 | |
| } | |
| if arr[s] == target { | |
| return s | |
| } | |
| let med = e / arr.count |
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
| extension Calendar { | |
| public func getAllDates( | |
| dateInterval: DateInterval, | |
| dateComponent: DateComponents) -> [Date] { | |
| var dates: [Date] = [] | |
| dates.append(dateInterval.start) | |
| enumerateDates(startingAfter: dateInterval.start, matching: dateComponent, matchingPolicy: .nextTime) { date, _, stop in | |
| guard let date = date else { |
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
| class ViewModel : ObservableObject { | |
| @Published var weatherData : WeatherResponse? | |
| @Published var showErrorAlert = false | |
| @Published var alertDescription = "" | |
| let city = "https://api.openweathermap.org/data/2.5/weather?q=delhi&appid={YOUR-API-KEY}&units=metric" | |
| init(){ | |
| WeatherService.getData(city: city) { result in |
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
| enum NetworkError : Error { | |
| case cityNotFound | |
| case timeOut | |
| } | |
| class WeatherService { | |
| static func getData(city : String , completionHandler : @escaping (Result<WeatherResponse, NetworkError>) -> ()) { | |
| guard let url = URL(string: "\(city)") else { |
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
| class ViewModel : ObservableObject { | |
| @Published var temp : Double | |
| init(){ | |
| temp = 0 | |
| getData() | |
| } | |
| func getData() { | |
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
| struct WeatherResponse : Decodable { | |
| let name : String | |
| let weather : [WeatherAPI] | |
| let main : MainAPI | |
| } | |
| struct WeatherAPI : Decodable { | |
| let description : String | |
| } |
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
| class SomeClass: SomeSuperclass, MyProtocol, AnotherProtocol { | |
| // class definition goes here | |
| } |
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
| var myClosure = { (name : String) in | |
| print("Mycoluuure\(name)") | |
| } | |
| myClosure("yasir") |
NewerOlder