Resolve more errors

This commit is contained in:
Niels Andriesse 2021-08-05 14:15:34 +10:00
parent ef41ea22fa
commit 90027c4a04
3 changed files with 53 additions and 0 deletions

View File

@ -31,6 +31,7 @@ typedef void (^AppReadyBlock)(void);
// on app launch, especially work that uses other components.
// * We should usually use "did become ready" blocks since they are safer.
+ (void)runNowOrWhenAppWillBecomeReady:(AppReadyBlock)block NS_SWIFT_NAME(runNowOrWhenAppWillBecomeReady(_:));
+ (void)runNowOrWhenAppDidBecomeReadySync:(AppReadyBlock)block NS_SWIFT_NAME(runNowOrWhenAppDidBecomeReadySync(_:));
+ (void)runNowOrWhenAppDidBecomeReady:(AppReadyBlock)block NS_SWIFT_NAME(runNowOrWhenAppDidBecomeReady(_:));
@end

View File

@ -73,6 +73,13 @@ NS_ASSUME_NONNULL_BEGIN
[self.appWillBecomeReadyBlocks addObject:block];
}
+ (void)runNowOrWhenAppDidBecomeReadySync:(AppReadyBlock)block
{
DispatchSyncMainThreadSafe(^{
[self.sharedManager runNowOrWhenAppDidBecomeReady:block];
});
}
+ (void)runNowOrWhenAppDidBecomeReady:(AppReadyBlock)block
{
DispatchMainThreadSafe(^{

View File

@ -393,3 +393,48 @@ public extension UIBarButtonItem {
self.accessibilityIdentifier = accessibilityIdentifier
}
}
// MARK: -
@objc
public extension UIButton {
func setTemplateImage(_ templateImage: UIImage?, tintColor: UIColor) {
guard let templateImage = templateImage else {
owsFailDebug("Missing image")
return
}
setImage(templateImage.withRenderingMode(.alwaysTemplate), for: .normal)
self.tintColor = tintColor
}
func setTemplateImageName(_ imageName: String, tintColor: UIColor) {
guard let image = UIImage(named: imageName) else {
owsFailDebug("Couldn't load image: \(imageName)")
return
}
setTemplateImage(image, tintColor: tintColor)
}
}
// MARK: -
@objc
public extension UIImageView {
func setTemplateImage(_ templateImage: UIImage?, tintColor: UIColor) {
guard let templateImage = templateImage else {
owsFailDebug("Missing image")
return
}
self.image = templateImage.withRenderingMode(.alwaysTemplate)
self.tintColor = tintColor
}
func setTemplateImageName(_ imageName: String, tintColor: UIColor) {
guard let image = UIImage(named: imageName) else {
owsFailDebug("Couldn't load image: \(imageName)")
return
}
setTemplateImage(image, tintColor: tintColor)
}
}