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
# <type>: (If applied, this commit will...) <subject> (Max 50 char) | |
# |<---- Using a Maximum Of 50 Characters ---->| | |
# Explain why this change is being made | |
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->| | |
# Provide links or keys to any relevant tickets, articles or other resources | |
# Example: Github issue #23 |
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 Alamofire | |
import ObjectMapper | |
typealias NetworkSuccessClosure = (BaseModel?) -> Void | |
typealias NetworkFailureClosure = (Error?) -> Void | |
class NetworkManager: NSObject { | |
class func startRequest<T: BaseModel>(withRequestConfiguration request: RequestConfiguraton, andMappingObject objectClass: T?, successClouser success: NetworkSuccessClosure?, andFailure failure: NetworkFailureClosure?) { |
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 XLPagerTabStrip | |
class ProfileTabsVC: ButtonBarPagerTabStripViewController { | |
//MARK: - Life Cycle | |
override func viewDidLoad() { | |
setupPager() | |
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
import Foundation | |
import PhoneNumberKit | |
enum Format { | |
case e164 | |
case national | |
case international | |
} | |
class PhoneNumberManager { |
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 ContactsUI | |
enum ContactsFilter { | |
case none | |
case mail | |
case message | |
} | |
struct PhoneContact { |
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
class func timeAgoSince(_ date: Date, from currentDate: Date = Date(), numericDates: Bool = false) -> String { | |
let calendar = Calendar.current | |
let now = currentDate | |
let earliest = (now as NSDate).earlierDate(date) | |
let latest = (earliest == now) ? date : now | |
let components:DateComponents = (calendar as NSCalendar).components([NSCalendar.Unit.minute , NSCalendar.Unit.hour , NSCalendar.Unit.day , NSCalendar.Unit.weekOfYear , NSCalendar.Unit.month , NSCalendar.Unit.year , NSCalendar.Unit.second], from: earliest, to: latest, options: NSCalendar.Options()) | |
if (components.year! >= 2) { | |
return "\(components.year!) years ago" | |
} else if (components.year! >= 1){ |
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 | |
protocol Sociable: MFMailComposeViewControllerDelegate, UINavigationControllerDelegate { | |
func openInstagramAccount(withID id: String) | |
func openTwitterAccount(withID id: String) | |
func openFacebookAccount(withID id: String) | |
func openSnapchatAccount(withID id: String) | |
func sendEmail(to email: String, withDefaultMessage message: String) | |
func call(_ mobileNumber: String) |
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
UIFont.familyNames.sorted().forEach{ familyName in | |
print("*** \(familyName) ***") | |
UIFont.fontNames(forFamilyName: familyName).forEach { fontName in | |
print("\(fontName)") | |
} | |
print("---------------------") | |
} | |
/* | |
*** Academy Engraved LET *** |
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
//Don't forget to import AVFoundation | |
func getVideoThumbnail(from path: URL?) -> UIImage? { | |
guard let path = path else { return nil } | |
do { | |
let asset = AVURLAsset(url: path , options: nil) | |
let imgGenerator = AVAssetImageGenerator(asset: asset) | |
imgGenerator.appliesPreferredTrackTransform = true | |
let cgImage = try imgGenerator.copyCGImage(at: CMTimeMake(0, 1), actualTime: nil) | |
let thumbnail = UIImage(cgImage: cgImage) |
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
//Don't forget to import AVFoundation | |
func getVideoDuration(from path: URL) -> String { | |
let asset = AVURLAsset(url: path) | |
let duration: CMTime = asset.duration | |
let totalSeconds = CMTimeGetSeconds(duration) | |
let hours = Int(totalSeconds / 3600) | |
let minutes = Int((totalSeconds.truncatingRemainder(dividingBy: 3600)) / 60) | |
let seconds = Int(totalSeconds.truncatingRemainder(dividingBy: 60)) |