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 { | |
| func ask(title: String?, question: String?, positiveButtonTitle: String = "Yes", negativeButtonTitle: String = "No", isDangerousAction: Bool = false, delegate: @escaping (_ agreed: Bool) -> Void) { | |
| let alert = UIAlertController(title: title, message: question, preferredStyle: .alert) | |
| alert.addAction(UIAlertAction(title: positiveButtonTitle, style: isDangerousAction ? .destructive : .default) { (_) in | |
| delegate(true) | |
| }) | |
| alert.addAction(UIAlertAction(title: negativeButtonTitle, style: .cancel) { (_) in | |
| delegate(false) |
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 Alamofire | |
| class API { | |
| func loadEmojiString(url: URL, delegate: @escaping (_ str: String?) -> Void) { | |
| AF.request(url).responseData { (response) in | |
| switch response.result { | |
| case .success(let data): | |
| let str = String(bytes: data, encoding: .utf8) | |
| delegate(str) |
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 { | |
| if let text = textField.text, | |
| let textRange = Range(range, in: text) { | |
| let updatedText = text.replacingCharacters(in: textRange, with: string) | |
| if updatedText.containsEmoji { | |
| return false | |
| } | |
| } | |
| return true | |
| } |
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
| let 🌸 = 1 | |
| let 🌸🌸 = 2 | |
| func +(_ 🐶: Int, _ 🐮: Int) -> Int { | |
| 🐶 + 🐮 | |
| } | |
| let 🌸🌸🌸 = +(🌸🌸, 🌸) | |
| print(🌸🌸🌸) |
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 { | |
| func askDate(title: String, delegate: @escaping (_ date: Date?) -> Void) { | |
| _ = DatePickerPopup.createAndShow(in: self, title: title, delegate: delegate) | |
| } | |
| } |
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 SnapKit | |
| class DatePickerPopup: UIView { | |
| private var frameView: UIView! | |
| private var titleLabel: UILabel! | |
| private var datePicker: UIDatePicker! | |
| private var okButton: UIButton! | |
| private var cancelButton: UIButton! |
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 { | |
| func ask(title: String?, question: String?, placeholder: String?, keyboardType: UIKeyboardType = .default, delegate: @escaping (_ answer: String?) -> Void) { | |
| let alert = UIAlertController(title: title, message: question, preferredStyle: .alert) | |
| alert.addTextField { (textField) in | |
| textField.placeholder = placeholder | |
| textField.keyboardType = keyboardType | |
| } | |
| alert.addAction(UIAlertAction(title: "OK", style: .default) { (_) in |
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 { | |
| func ask(title: String?, question: String?, placeholder: String?, keyboardType: UIKeyboardType = .default, delegate: @escaping (_ answer: String?) -> Void) { | |
| let alert = UIAlertController(title: title, message: question, preferredStyle: .alert) | |
| alert.addTextField { (textField) in | |
| textField.placeholder = placeholder | |
| textField.keyboardType = keyboardType | |
| } | |
| alert.addAction(UIAlertAction(title: "OK", style: .default) { (_) in |
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 { | |
| func show(error: String) { | |
| let alert = UIAlertController(title: NSLocalizedString("error", comment: ""), message: error, preferredStyle: .alert) | |
| alert.addAction(UIAlertAction(title: NSLocalizedString("ok", comment: ""), style: .cancel, handler: nil)) | |
| present(alert, animated: true, completion: nil) | |
| } | |
| func show(warning: 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
| import UIKit | |
| extension UIViewController { | |
| func show(error: String) { | |
| let alert = UIAlertController(title: "Error", message: error, preferredStyle: .alert) | |
| alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil)) | |
| present(alert, animated: true, completion: nil) | |
| } | |
| func show(warning: String) { |