Use folder references for all groups and sort files/folders
This commit is contained in:
parent
38b44cedf8
commit
d698f2e3c3
12 changed files with 154 additions and 154 deletions
25
passKit/Extensions/String+Localization.swift
Normal file
25
passKit/Extensions/String+Localization.swift
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
String+Localization.swift
|
||||
passKit
|
||||
|
||||
Created by Danny Moesch on 12.01.19.
|
||||
Copyright © 2019 Bob Sun. All rights reserved.
|
||||
*/
|
||||
|
||||
extension String {
|
||||
public func localize() -> String {
|
||||
return NSLocalizedString(self, value: "#\(self)#", comment: "")
|
||||
}
|
||||
|
||||
public func localize(_ firstValue: CVarArg) -> String {
|
||||
return String(format: localize(), firstValue)
|
||||
}
|
||||
|
||||
public func localize(_ firstValue: CVarArg, _ secondValue: CVarArg) -> String {
|
||||
return String(format: localize(), firstValue, secondValue)
|
||||
}
|
||||
|
||||
public func localize(_ error: Error) -> String {
|
||||
return localize(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
26
passKit/Extensions/String+Utilities.swift
Normal file
26
passKit/Extensions/String+Utilities.swift
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// String+Utilities.swift
|
||||
// passKit
|
||||
//
|
||||
// Created by Yishi Lin on 2018/9/23.
|
||||
// Copyright © 2018 Bob Sun. All rights reserved.
|
||||
//
|
||||
|
||||
extension String {
|
||||
public var trimmed: String {
|
||||
return trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
|
||||
public func stringByAddingPercentEncodingForRFC3986() -> String? {
|
||||
let unreserved = "-._~/?"
|
||||
var allowed = CharacterSet.alphanumerics
|
||||
allowed.insert(charactersIn: unreserved)
|
||||
return addingPercentEncoding(withAllowedCharacters: allowed)
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
public static func | (left: String, right: String) -> String {
|
||||
return right.isEmpty ? left : left + "\n" + right
|
||||
}
|
||||
}
|
||||
23
passKit/Extensions/UITextFieldExtension.swift
Normal file
23
passKit/Extensions/UITextFieldExtension.swift
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// UITextFieldExtension.swift
|
||||
// pass
|
||||
//
|
||||
// Created by Yishi Lin on 5/4/17.
|
||||
// Copyright © 2017 Yishi Lin. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
private var kAssociationKeyNextField: UInt8 = 0
|
||||
|
||||
extension UITextField {
|
||||
@IBOutlet var nextField: UITextField? {
|
||||
get {
|
||||
return objc_getAssociatedObject(self, &kAssociationKeyNextField) as? UITextField
|
||||
}
|
||||
set(newField) {
|
||||
objc_setAssociatedObject(self, &kAssociationKeyNextField, newField, .OBJC_ASSOCIATION_RETAIN)
|
||||
}
|
||||
}
|
||||
}
|
||||
18
passKit/Extensions/UIViewControllerExtension.swift
Normal file
18
passKit/Extensions/UIViewControllerExtension.swift
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// UIViewControllerExtension.swift
|
||||
// pass
|
||||
//
|
||||
// Created by Yishi Lin on 5/4/17.
|
||||
// Copyright © 2017 Yishi Lin. All rights reserved.
|
||||
//
|
||||
|
||||
extension UIViewController {
|
||||
@objc public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
if textField.nextField != nil {
|
||||
textField.nextField?.becomeFirstResponder()
|
||||
} else {
|
||||
textField.resignFirstResponder()
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
45
passKit/Extensions/UIViewExtension.swift
Normal file
45
passKit/Extensions/UIViewExtension.swift
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// UIViewExtension.swift
|
||||
// passKit
|
||||
//
|
||||
// Created by Yishi Lin on 2018/4/11.
|
||||
// Copyright © 2018 Yishi Lin. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension UIView {
|
||||
|
||||
// Save anchors: https://stackoverflow.com/questions/46317061/use-safe-area-layout-programmatically
|
||||
var safeTopAnchor: NSLayoutYAxisAnchor {
|
||||
if #available(iOS 11.0, *) {
|
||||
return self.safeAreaLayoutGuide.topAnchor
|
||||
} else {
|
||||
return self.topAnchor
|
||||
}
|
||||
}
|
||||
|
||||
var safeLeftAnchor: NSLayoutXAxisAnchor {
|
||||
if #available(iOS 11.0, *){
|
||||
return self.safeAreaLayoutGuide.leftAnchor
|
||||
} else {
|
||||
return self.leftAnchor
|
||||
}
|
||||
}
|
||||
|
||||
var safeRightAnchor: NSLayoutXAxisAnchor {
|
||||
if #available(iOS 11.0, *){
|
||||
return self.safeAreaLayoutGuide.rightAnchor
|
||||
} else {
|
||||
return self.rightAnchor
|
||||
}
|
||||
}
|
||||
|
||||
var safeBottomAnchor: NSLayoutYAxisAnchor {
|
||||
if #available(iOS 11.0, *) {
|
||||
return self.safeAreaLayoutGuide.bottomAnchor
|
||||
} else {
|
||||
return self.bottomAnchor
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue