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
| // | |
| // ContentView.swift | |
| // Example of using matchedGeometryEffect in iOS 13 code | |
| // matchedGeometryEffect example code taken and adapted from : | |
| // https://sarunw.com/posts/a-first-look-at-matchedgeometryeffect/ | |
| // | |
| // Created by Emil Pedersen on 16/10/2020. | |
| // | |
| struct ContentView: View { |
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 Foundation | |
| import CoreTelephony | |
| struct PhoneHelper { | |
| static func getCountryCode() -> String { | |
| guard let carrier = CTTelephonyNetworkInfo().subscriberCellularProvider, let countryCode = carrier.isoCountryCode else { return "+" } | |
| let prefixCodes = ["AF": "93", "AE": "971", "AL": "355", "AN": "599", "AS":"1", "AD": "376", "AO": "244", "AI": "1", "AG":"1", "AR": "54","AM": "374", "AW": "297", "AU":"61", "AT": "43","AZ": "994", "BS": "1", "BH":"973", "BF": "226","BI": "257", "BD": "880", "BB": "1", "BY": "375", "BE":"32","BZ": "501", "BJ": "229", "BM": "1", "BT":"975", "BA": "387", "BW": "267", "BR": "55", "BG": "359", "BO": "591", "BL": "590", "BN": "673", "CC": "61", "CD":"243","CI": "225", "KH":"855", "CM": "237", "CA": "1", "CV": "238", "KY":"345", "CF":"236", "CH": "41", "CL": "56", "CN":"86","CX": "61", "CO": "57", "KM": "269", "CG":"242", "CK": "682", "CR": "506", "CU":"53", "CY":"537","CZ": "420", "DE": "49", "DK": "45", "DJ":"253", "DM": "1", "DO": "1", "DZ": "213", "EC": "593" |
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 LazyView<Content: View>: View { | |
| let build: () -> Content | |
| init(_ build: @autoclosure @escaping () -> Content) { | |
| self.build = build | |
| } | |
| var body: Content { | |
| build() | |
| } | |
| } |
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 | |
| struct ContentView : View { | |
| var body: some View { | |
| ZStack(alignment: Alignment.top) { | |
| MapView() | |
| SlideOverCard { | |
| VStack { | |
| CoverImage(imageName: "maitlandbay") | |
| Text("Maitland Bay") |
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 Foundation | |
| import Combine | |
| struct DataTaskSubscription: Subscription { | |
| let task: URLSessionTask | |
| let combineIdentifier: CombineIdentifier | |
| func request(_ demand: Subscribers.Demand) { | |
| } |
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
| // Swift enums cannot be declared with a rawValue if they have associated values | |
| // like good ol' Amargasaurus has. Using String(describing: dino) on a case with | |
| // associated also includes the values, but works fine on unassociated cases. | |
| // Mirror(reflecting: dino) can extract the name of an associated case, but is | |
| // nil for unassociated cases. Our hero ?? swoops in to save the day! | |
| enum Sauropoda { | |
| case Amargasaurus(things: Int64, hasOtherThing: Bool?) | |
| case Antetonitrus | |
| // ... |
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
| /* | |
| *** Academy Engraved LET *** | |
| AcademyEngravedLetPlain | |
| --------------------- | |
| *** Al Nile *** | |
| AlNile | |
| AlNile-Bold | |
| --------------------- | |
| *** American Typewriter *** | |
| AmericanTypewriter |
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 combineDateWithTime(date: NSDate, time: NSDate) -> NSDate? { | |
| let calendar = NSCalendar.currentCalendar() | |
| let dateComponents = calendar.components([.Year, .Month, .Day], fromDate: date) | |
| let timeComponents = calendar.components([.Hour, .Minute, .Second], fromDate: time) | |
| let mergedComponments = NSDateComponents() | |
| mergedComponments.year = dateComponents.year | |
| mergedComponments.month = dateComponents.month | |
| mergedComponments.day = dateComponents.day |
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
| // Playground - noun: a place where people can play | |
| import Foundation | |
| func toRoman(number: Int) -> String { | |
| let romanValues = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"] | |
| let arabicValues = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] | |
| var romanValue = "" |
NewerOlder