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 | |
let prevImageIconName = "prevImageIcon" | |
let nextImageIconName = "nextImageIcon" | |
let favoriteIconName = "favoriteIcon" | |
let productDetailsViewImageSliderWidthKoef: CGFloat = 0.96 | |
protocol ProductDetailsViewDelegate: AnyObject { |
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 Product: Decodable { | |
var id: Int | |
var art: String? | |
var title: String? | |
var votesCount: Int | |
var averageRating: Double | |
enum CodingKeys: String, CodingKey { | |
case id |
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
#if DEBUG | |
import SwiftUI | |
struct <#ViewController#>Presentable: UIViewControllerRepresentable { | |
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { | |
} | |
@available(iOS 13.0, *) | |
func makeUIViewController(context: Context) -> UIViewController { |
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 UIImage { | |
enum AssetIdentifier: String { | |
case someImageName = "image-name-string" | |
} | |
convenience init!(assetIdentifier: AssetIdentifier) { | |
self.init(named: assetIdentifier.rawValue) | |
} | |
} |
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 dynamicColor = UIColor { (traitCollection: UITraitCollection) -> UIColor in | |
if traitCollection.userInterfaceStyle == .dark { | |
return .black | |
} else { | |
return .white | |
} | |
} |
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
dispatch_semaphore_t sema = dispatch_semaphore_create(0); | |
[object runSomeLongOperationAndDo:^{ | |
// hack hack hack... | |
dispatch_semaphore_signal(sema); | |
}]; | |
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); | |
dispatch_release(sema); |
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
// Subclass UICollectionViewFlowLayout and overrite this method. | |
- (UICollectionViewLayoutInvalidationContext *)invalidationContextForBoundsChange:(CGRect)newBounds { | |
UICollectionViewFlowLayoutInvalidationContext *context = (UICollectionViewFlowLayoutInvalidationContext *)[super invalidationContextForBoundsChange:newBounds]; | |
context.invalidateFlowLayoutDelegateMetrics = ( | |
CGRectGetWidth(newBounds) != CGRectGetWidth(self.collectionView.bounds) || | |
CGRectGetHeight(newBounds) != CGRectGetHeight(self.collectionView.bounds) | |
); | |
return context; | |
} |
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
1) Quit Xcode, Simulator, Instruments, etc. | |
2) Run in Terminal: sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService | |
3) Run in Terminal: sudo rm -rf ~/Library/*/CoreSimulator | |
# Was tested on Xcode 10.2 and iOS Simulator 12.2 |
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
[alias] | |
parent = "!git show-branch | grep '*' | grep -v \"$(git rev-parse --abbrev-ref HEAD)\" | head -n1 | sed 's/.*\\[\\(.*\\)\\].*/\\1/' | sed 's/[\\^~].*//' #" |
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
private func setupFormValidator() { | |
formValidator.rules.minValue = 1 | |
formValidator.rules.maxValue = 2000 | |
formValidator.addValidationTo( | |
view: receiverTextField, type: .require, fieldType: .none, errorMessage: "EmptyFormFieldError".localized, | |
errorMessageTitle: formTitleLabel.text) | |
if transferType == .receive || transferType == .refund { | |
formValidator.addValidationTo( |
NewerOlder