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 UIKit | |
| import MessageUI | |
| public final class URLOpeningUtil: NSObject, Sendable { | |
| // MARK: - Validation | |
| public enum RegularExpressions: String { | |
| // swiftlint:disable line_length | |
| case phone = "^\\s*(?:\\+?(\\d{1,3}))?([-. (]*(\\d{3})[-. )]*)?((\\d{3})[-. ]*(\\d{2,4})(?:[-.x ]*(\\d+))?)\\s*$" | |
| case email = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}" | |
| // swiftlint:enable line_length |
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 UIKit | |
| public class InvalidFieldDetector { | |
| public static func isNumeric(string: String) -> Bool { | |
| let nums: Set<Character> = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] | |
| return Set(string).isSubset(of: nums) | |
| } | |
| public static func isValidEmail(email: String) -> Bool { |
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 UIKit | |
| extension UIViewController { | |
| /// Embeds a newly created view controller of the given type into a container view. | |
| /// - Parameters: | |
| /// - vcType: The type of the view controller to embed. | |
| /// - containerView: The container view that will hold the embedded view. | |
| /// - setup: Optional configuration closure executed after the view is added. | |
| public func fw_initEmbedVC(ofType vcType: UIViewController.Type, | |
| inside containerView: UIView, |
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 UIKit | |
| @IBDesignable extension UIView { | |
| @IBInspectable var borderColor: UIColor? { | |
| set { layer.borderColor = newValue?.cgColor } | |
| get { return layer.borderColor == nil ? nil : UIColor(cgColor: layer.borderColor!) } | |
| } | |
| } | |
| extension UIView { |
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 UIKit | |
| extension UITableViewCell { | |
| /// Search up the view hierarchy of the table view cell to find the containing table view | |
| public var fw_tableView: UITableView? { | |
| var table: UIView? = superview | |
| while !(table is UITableView) && table != nil { | |
| table = table?.superview | |
| } | |
| return table as? UITableView |
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 UIKit | |
| extension UITableView { | |
| // MARK: - Public API | |
| public func fw_setPlaceholder | |
| (text: String?, | |
| fontSize: CGFloat = 21, | |
| image: UIImage?, | |
| edgeInsets: UIEdgeInsets = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8)) { | |
| let stackView = fw_placeholderStackView() |
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 | |
| extension String { | |
| // Encoding for x-www-form-urlencoded | |
| // https://useyourloaf.com/blog/how-to-percent-encode-a-url-string/ | |
| public func addingPercentEncodingForFormData(plusForSpace: Bool = true) -> String? { | |
| let unreserved = "*-._," | |
| var allowed = CharacterSet.alphanumerics | |
| allowed.insert(charactersIn: unreserved) | |
| if plusForSpace { allowed.insert(charactersIn: " ") } |
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 UIKit | |
| @IBDesignable public class PaddingLabel: UILabel { | |
| // MARK: - Members | |
| @IBInspectable public var topInset: CGFloat = 0.0 | |
| @IBInspectable public var bottomInset: CGFloat = 0.0 | |
| @IBInspectable public var leftInset: CGFloat = 0.0 | |
| @IBInspectable public var rightInset: CGFloat = 0.0 | |
| // MARK: - Lifecycle |
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 UIKit.UIImage | |
| public enum ImageEncodingQuality: CGFloat { | |
| case png = 0 | |
| case jpegLow = 0.2 | |
| case jpegMid = 0.5 | |
| case jpegHigh = 0.75 | |
| } | |
| public extension KeyedEncodingContainer { |
NewerOlder