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
final class PublicKeyPinner { | |
/// Stored public key hashes | |
private let hashes: [String] | |
public init(hashes: [String]) { | |
self.hashes = hashes | |
} | |
/// ASN1 header for our public key to re-create the subject public key info | |
private let rsa2048Asn1Header: [UInt8] = [ |
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
// | |
// UIDevice+Extension.swift | |
// Networking | |
// | |
// Created by alpiopio on 05/10/20. | |
// Copyright © 2020 alfian0. All rights reserved. | |
// | |
import UIKit |
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 UIView { | |
public func snapshotImage(bgColor: UIColor? = nil, rect: CGRect? = nil, state: Bool = false) -> UIImage? { | |
var definedRect = CGRect.zero | |
if let rect = rect { | |
definedRect = rect | |
} else { | |
definedRect = self.bounds | |
} | |
UIGraphicsBeginImageContextWithOptions(definedRect.size, false, UIScreen.main.scale) | |
guard let graphicContext = UIGraphicsGetCurrentContext() else { |
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
@IBDesignable | |
open class CheckBox: UIControl { | |
///Used to choose the style for the Checkbox | |
public enum Style { | |
/// ■ | |
case square | |
/// ● | |
case circle | |
/// x |
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 UIKit | |
@IBDesignable | |
class DoubleSlider: UIControl { | |
@IBInspectable | |
var minimumValue: CGFloat = 0 { | |
didSet { | |
updateLayerFrames() | |
} | |
} |
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
@IBDesignable class Badge: UILabel { | |
@IBInspectable var topInset: CGFloat = 5.0 | |
@IBInspectable var bottomInset: CGFloat = 5.0 | |
@IBInspectable var leftInset: CGFloat = 7.0 | |
@IBInspectable var rightInset: CGFloat = 7.0 | |
@IBInspectable var round: CGFloat = 7.0 { | |
didSet { | |
layer.cornerRadius = round | |
clipsToBounds = 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 UIKit | |
class GenericPickerView<T>: UIPickerView, UIPickerViewDataSource, UIPickerViewDelegate { | |
var items: [T] = [] { | |
didSet { | |
reloadAllComponents() | |
} | |
} | |
var titleForRow: ((T) -> String?)? | |
var selectionHandler: ((T) -> Void)? |
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
@IBDesignable | |
class RatingComponent: UIControl { | |
@IBInspectable | |
var count: Int = 5 { | |
didSet { | |
ratings = [] | |
for i in 0..<count { | |
let button = UIButton(type: .custom) | |
button.setImage(selectedImage, for: .selected) | |
button.setImage(unSelectedImage, for: .normal) |
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
@objc | |
private func panGesture(_ sender: UIPanGestureRecognizer) { | |
let percentThreshold: CGFloat = 0.3 | |
let translation = sender.translation(in: sender.view) | |
let verticalMovement = translation.y / sender.view!.bounds.height | |
let downwardMovement = fmaxf(Float(verticalMovement), 0.0) | |
let downwardMovementPercent = fminf(downwardMovement, 1.0) | |
let progress = CGFloat(downwardMovementPercent) | |
guard let interactor = interactor else { return } |
NewerOlder