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 AWSSQS | |
class SQS { | |
func send(_ model: Encodable, to queueURL: String) -> () { | |
guard let messageString = model.jsonString() else { return } | |
let sqs = AWSSQS.default() | |
let sendMsgRequest = AWSSQSSendMessageRequest() | |
sendMsgRequest?.queueUrl = queueURL | |
sendMsgRequest?.messageBody = messageString |
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 Date { | |
func differenceFromNow() -> DateComponents { | |
return Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: self, to: Date()) | |
} | |
} | |
extension DateComponents { | |
func agoString() -> String { | |
if let year = year, year > 0 { | |
return "\(year) \(year > 1 ? "years" : "year") ago" |
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 UISegmentedControl { | |
private var underlineWidth: CGFloat { 20 } | |
private var underlineHeight: CGFloat { 2 } | |
private var segmentWidth: CGFloat { | |
bounds.width / CGFloat(numberOfSegments) | |
} | |
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 | |
class SearchViewController: UIViewController { | |
private var searchWorkItem: DispatchWorkItem? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
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 textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { | |
var nextTextfieldTag = 0 | |
if string.isEmpty { | |
return true | |
} else if string.count == 1 { // Auto fill OTP to multiple textfield | |
textField.text = string | |
nextTextfieldTag = textField.tag + 1 | |
} else if string.count == maximumDigits { // Paste OTP to multiple textfield | |
var pastedOTP = string | |
for tag in 1...maximumDigits { |
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 AWSCognitoIdentityProvider | |
extension Error { | |
var customizedDescription: String { | |
let nsError = self as NSError | |
if nsError.domain == AWSCognitoIdentityProviderErrorDomain, let code = AWSCognitoIdentityProviderErrorType(rawValue: nsError.code) { | |
switch code { | |
case .expiredCode: return "Verification code has expired. Please try again" | |
case .codeMismatch: return "Incorrect verification code. Please enter the correct code to continue." | |
case .notAuthorized: return "Authentication failed. Please enter the correct credentials to continue." |
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 UILabel { | |
private var attributes: [NSAttributedString.Key: Any] { | |
return [.font: self.font ?? UIFont.systemFont(ofSize: 15)] | |
} | |
private var highlightAttributes: [NSAttributedString.Key: Any] { | |
return [.backgroundColor: UIColor.lightGray.withAlphaComponent(0.2), .foregroundColor: UIColor.red] | |
} | |
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 | |
enum TrailingContent { | |
case readmore | |
case readless | |
var text: String { | |
switch self { | |
case .readmore: return "...Read More" | |
case .readless: return " Read Less" |
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 AWSS3 | |
class AWSS3Uploader { | |
/// Creates a upload request for uploading the specified file to a presigned remote URL | |
/// | |
/// - Parameters: | |
/// - fileURL: The URL of the file to upload. | |
/// - remoteURL: The presigned URL | |
/// - completion: The completion handler to call when the upload request is complete. |