π―
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 UIViewController { | |
| func add(_ child: UIViewController) { | |
| addChildViewController(child) | |
| view.addSubview(child.view) | |
| child.view.frame = view.bounds | |
| child.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
| child.didMove(toParentViewController: self) | |
| } | |
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 tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { | |
| let color = cell.backgroundColor?.cgColor | |
| let cornerRadius: CGFloat = 5 | |
| cell.backgroundColor = .clear | |
| let layer = CAShapeLayer() | |
| let pathRef = CGMutablePath() | |
| let bounds = cell.bounds.insetBy(dx: 20, dy: 0) | |
| var addLine = 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
| extension NSMutableAttributedString { | |
| func attr(_ link: String?, linkColor: UIColor, text: String) { | |
| let pattern = "(\(text))" | |
| let regex = try! NSRegularExpression.init(pattern: pattern, | |
| options: NSRegularExpression.Options(rawValue: 0)) | |
| let matches = regex.matches(in: self.string, | |
| options: NSRegularExpression.MatchingOptions(rawValue: 0), | |
| range: NSRange.init(location: 0, length: self.string.count)) | |
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
| // Adapted from Stack Overflow answer by David Crow http://stackoverflow.com/a/43235 | |
| // Question: Algorithm to randomly generate an aesthetically-pleasing color palette by Brian Gianforcaro | |
| // Method randomly generates a pastel color, and optionally mixes it with another color | |
| func generateRandomPastelColor(withMixedColor mixColor: UIColor?) -> UIColor { | |
| // Randomly generate number in closure | |
| let randomColorGenerator = { ()-> CGFloat in | |
| CGFloat(arc4random() % 256 ) / 256 | |
| } | |
| var red: CGFloat = randomColorGenerator() |
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 RxSwift // Version 3.2.0 | |
| import RxCocoa // Version 3.2.0 | |
| func keyboardHeight() -> Observable<CGFloat> { | |
| return Observable | |
| .from([ | |
| NotificationCenter.default.rx.notification(NSNotification.Name.UIKeyboardWillShow) | |
| .map { notification -> CGFloat in | |
| (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.height ?? 0 | |
| }, |
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
| package official.alfian.useless; | |
| import com.android.billingclient.api.BillingClient; | |
| import com.android.billingclient.api.BillingClientStateListener; | |
| import com.android.billingclient.api.BillingFlowParams; | |
| import com.android.billingclient.api.ConsumeResponseListener; | |
| import com.android.billingclient.api.Purchase; | |
| import com.android.billingclient.api.PurchasesUpdatedListener; | |
| import com.android.billingclient.api.SkuDetails; | |
| import com.android.billingclient.api.SkuDetailsParams; |
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
| // | |
| // KeychainService.swift | |
| // PKBPartyKit | |
| // | |
| // Created by alfian0 on 2/6/18. | |
| // Copyright Β© 2018 Extra Integer. All rights reserved. | |
| // | |
| import Foundation | |
| import Security |
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
| // | |
| // NetworkService.swift | |
| // PKBPartyKit | |
| // | |
| // Created by alfian0 on 2/6/18. | |
| // Copyright Β© 2018 Extra Integer. All rights reserved. | |
| // | |
| import ObjectMapper | |
| import Moya |
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
| // | |
| // Localized.swift | |
| // PKBPartyKit | |
| // | |
| // Created by alfian0 on 1/19/18. | |
| // Copyright Β© 2018 alfian0. All rights reserved. | |
| // | |
| // Taken from | |
| // 1. https://github.com/marmelroy/Localize-Swift |