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 MapKit | |
import CoreLocation | |
import Foundation | |
extension MKMapItem { | |
var fullName: String { | |
guard let name = name, !placemark.fullLocationAddress.contains(name) else { | |
return placemark.fullLocationAddress | |
} |
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
func drawPolyline() { | |
let path = GMSMutablePath() | |
path.add(CLLocationCoordinate2D(latitude: 50.014787, longitude: 36.232725)) | |
path.add(CLLocationCoordinate2D(latitude: 50.014997, longitude: 36.233533)) | |
path.add(CLLocationCoordinate2D(latitude: 50.016942, longitude: 36.232385)) | |
path.add(CLLocationCoordinate2D(latitude: 50.016019, longitude: 36.226335)) | |
path.add(CLLocationCoordinate2D(latitude: 50.010419, longitude: 36.227913)) | |
let rectangle = GMSPolyline(path: path) |
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
// SnapKit(Masonry) 1 | |
// https://github.com/SnapKit/Masonry | |
[self. addSubview: scrollView]; | |
[scrollView mas_makeConstraints:^(MASConstraintMaker *make) { | |
make.edges.equalTo(safeAreaLayoutGuide); | |
}]; | |
[scrollView addSubview: contentView]; | |
[contentView mas_makeConstraints:^(MASConstraintMaker *make) { |
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
typealias Localizable = R.string.localizable | |
typealias TypeClosure<T> = (T) -> Void | |
typealias VoidClosure = () -> Void | |
typealias VoidResult = Swift.Result<Void, Error> | |
typealias VoidResultClosure = (Swift.Result<Void, Error>) -> Void | |
typealias ImagePickerConfiguration = (source: UIImagePickerController.SourceType, | |
isLimited: Bool, |
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
fileprivate func showImageLoadingProgress() { | |
let imageSize = CGSize(width: UIScreen.width / 2, height: UIScreen.width / 2) | |
let imageLoadingProgressView = UIImageView(frame: CGRect(origin: CGPoint.zero, size: imageSize)) | |
PKHUD.sharedHUD.contentView = imageLoadingProgressView | |
let fileName = R.image.imageLoaderGif.name.replacingOccurrences(of: ".gif", with: "") | |
imageLoadingProgressView.loadGif(name: fileName) | |
PKHUD.sharedHUD.show() | |
} | |
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 Foundation | |
import Moya | |
import Alamofire | |
// NOTE: Custom timeout configuration | |
class DefaultAlamofireManager: Alamofire.SessionManager { | |
static let sharedManager: DefaultAlamofireManager = { | |
let configuration = URLSessionConfiguration.default | |
configuration.httpAdditionalHeaders = Alamofire.SessionManager.defaultHTTPHeaders | |
configuration.timeoutIntervalForRequest = 10 |
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
// Add border | |
let gradient = CAGradientLayer() | |
let size = CGSize(width: avatarSize, height: avatarSize) | |
let rect = CGRect(origin: .zero, size: size) | |
gradient.frame = CGRect(origin: CGPoint.zero, size: size) | |
gradient.colors = [UIColor.blue.cgColor, UIColor.green.cgColor] | |
let shape = CAShapeLayer() | |
shape.lineWidth = 5 | |
shape.path = UIBezierPath(rect: rect).cgPath |
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
private func validateQuestionLanguage(_ question: String) -> Bool { | |
if question.isEmpty { return true } | |
do { | |
let regex = try NSRegularExpression(pattern: "^[a-zA-Z0-9\"$@$!%*?&#^-_. +()_\\-=\\[\\]{};:\\|,<>\\/?]+$", options: .caseInsensitive) | |
return regex.matches(in: question, options: [], range: NSRange(location: 0, length: question.count)).count > 0 | |
} catch { | |
assert(false, "Invalid regex syntax") | |
} | |
} |
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
func isModal() -> Bool { | |
let presentingIsModal = presentingViewController != nil | |
let presentingIsNavigation = navigationController?.presentingViewController?.presentedViewController == navigationController | |
let presentingIsTabBar = tabBarController?.presentingViewController is UITabBarController | |
return presentingIsModal || presentingIsNavigation || presentingIsTabBar | |
} |
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 | |
extension UIImageView { | |
func addCircleGradiendBorder(_ width: CGFloat) { | |
let gradient = CAGradientLayer() | |
gradient.frame = CGRect(origin: CGPoint.zero, size: bounds.size) | |
let colors: [CGColor] = [UIColor.supSoftGreenThree.cgColor, UIColor.supSoftGreenTwo.cgColor, | |
UIColor.supSoftGreen.cgColor, UIColor.supTea.cgColor, | |
UIColor.supAquaMarineTwo.cgColor, UIColor.supAquaMarineThree.cgColor, |
OlderNewer