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 CustomLabelStyle: LabelStyle { | |
| @Environment(\.dynamicTypeSize) private var dynamicTypeSize | |
| private var leadingPadding: CGFloat { | |
| switch dynamicTypeSize { | |
| case .xSmall: -8 | |
| case .small: -9 | |
| case .medium: -9 | |
| case .large: -10 | |
| case .xLarge: -11 |
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 NSDecimalNumber { | |
| func round(decimalPlaces: Int, roundingMode: RoundingMode) -> NSDecimalNumber { | |
| let handler = NSDecimalNumberHandler( | |
| roundingMode: roundingMode, | |
| scale: Int16(decimalPlaces), | |
| raiseOnExactness: false, | |
| raiseOnOverflow: false, | |
| raiseOnUnderflow: false, | |
| raiseOnDivideByZero: false) | |
| return rounding(accordingToBehavior: handler) |
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 ToggleWidthPreferenceKey: PreferenceKey { | |
| static let defaultValue: CGFloat = 0 | |
| static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { | |
| value = max(value, nextValue()) | |
| } | |
| } | |
| extension View { | |
| func measureToggle() -> some View { | |
| self.background(GeometryReader { geometry 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
| struct ContentView: View { | |
| @State var flag = false | |
| var body: some View { | |
| VStack(spacing: 0) { | |
| Circle().fill(Color.orange) | |
| if flag { | |
| Circle() | |
| .fill(Color.red) | |
| .transition(.opacity) |
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 ContentView: View { | |
| @State var flag = false | |
| var body: some View { | |
| VStack(spacing: 0) { | |
| Circle().fill(Color.orange) | |
| if flag { | |
| Circle() | |
| .fill(Color.red) | |
| .transition(.opacity) |
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
| { | |
| "alfredtheme" : { | |
| "result" : { | |
| "textSpacing" : 4, | |
| "subtext" : { | |
| "size" : 12, | |
| "colorSelected" : "#FFFFFFFF", | |
| "font" : "CamingoCode", | |
| "color" : "#7F7F7FFF" | |
| }, |
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 Optional where Wrapped: Hashable { | |
| var hashValue: Int { | |
| switch self { | |
| case .some(let hashable): | |
| return hashable.hashValue | |
| default: | |
| return 0 | |
| } | |
| } | |
| } |
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
| /// Get the top most view controller in presentation chain | |
| func topPresentedController() -> UIViewController? { | |
| var topPresentedController = rootViewController | |
| while let nextTopPresentedController = topPresentedController?.presentedViewController { | |
| topPresentedController = nextTopPresentedController | |
| } | |
| return topPresentedController | |
| } |
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
| // | |
| // ViewController.swift | |
| // SendEmailWithAttachment | |
| // | |
| // Created by Kelly Egan on 3/17/15. | |
| // Copyright (c) 2015 Kelly Egan. All rights reserved. | |
| // | |
| import UIKit | |
| import MessageUI |
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 ObjectiveC | |
| import UIKit | |
| var associatedObjectHandle: UInt8 = 0 | |
| class TextDidChangeHandler: NSObject { | |
| unowned let textField: UITextField | |
| let handler: (textField: UITextField) -> Void | |
| init(textField: UITextField, handler: (textField: UITextField) -> Void) { | |
| self.handler = handler |
NewerOlder