Browse Source

Resolve more errors

voice-calls
Niels Andriesse 10 months ago
parent
commit
90027c4a04
  1. 1
      SessionMessagingKit/Utilities/AppReadiness.h
  2. 7
      SessionMessagingKit/Utilities/AppReadiness.m
  3. 45
      SignalUtilitiesKit/Utilities/UIView+OWS.swift

1
SessionMessagingKit/Utilities/AppReadiness.h

@ -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

7
SessionMessagingKit/Utilities/AppReadiness.m

@ -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(^{

45
SignalUtilitiesKit/Utilities/UIView+OWS.swift

@ -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)
}
}

Loading…
Cancel
Save