diff --git a/submodules/DateSelectionUI/BUILD b/submodules/DateSelectionUI/BUILD index a34f436ac4..2d9080285d 100644 --- a/submodules/DateSelectionUI/BUILD +++ b/submodules/DateSelectionUI/BUILD @@ -13,6 +13,7 @@ swift_library( "//submodules/AccountContext:AccountContext", "//submodules/TelegramStringFormatting:TelegramStringFormatting", "//submodules/TelegramPresentationData:TelegramPresentationData", + "//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils", ], visibility = [ "//visibility:public", diff --git a/submodules/DateSelectionUI/Sources/DateSelectionActionSheetController.swift b/submodules/DateSelectionUI/Sources/DateSelectionActionSheetController.swift index 35dcdd68ed..d8fe0af380 100644 --- a/submodules/DateSelectionUI/Sources/DateSelectionActionSheetController.swift +++ b/submodules/DateSelectionUI/Sources/DateSelectionActionSheetController.swift @@ -6,6 +6,7 @@ import TelegramPresentationData import TelegramStringFormatting import SwiftSignalKit import AccountContext +import UIKitRuntimeUtils public final class DateSelectionActionSheetController: ActionSheetController { private var presentationDisposable: Disposable? @@ -17,7 +18,6 @@ public final class DateSelectionActionSheetController: ActionSheetController { public init(context: AccountContext, title: String?, currentValue: Int32, minimumDate: Date? = nil, maximumDate: Date? = nil, emptyTitle: String? = nil, applyValue: @escaping (Int32?) -> Void) { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let theme = presentationData.theme let strings = presentationData.strings super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) @@ -103,6 +103,8 @@ private final class DateSelectionActionSheetItemNode: ActionSheetItemNode { self.strings = strings self.valueChanged = valueChanged + UILabel.setDateLabel(theme.primaryTextColor) + self.pickerView = UIDatePicker() self.pickerView.timeZone = TimeZone(secondsFromGMT: 0) self.pickerView.datePickerMode = .countDownTimer diff --git a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m index 9dd6b0c91d..44d2c8830f 100644 --- a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m +++ b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m @@ -23,7 +23,7 @@ origMethod = class_getInstanceMethod(targetClass, currentSelector); newMethod = class_getInstanceMethod(targetClass, newSelector); if ((origMethod != nil) && (newMethod != nil)) { - if(class_addMethod(targetClass, currentSelector, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { + if (class_addMethod(targetClass, currentSelector, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { class_replaceMethod(targetClass, newSelector, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); } else { method_exchangeImplementations(origMethod, newMethod); @@ -50,7 +50,7 @@ targetClass = object_getClass((id)targetClass); if ((origMethod != nil) && (newMethod != nil)) { - if(class_addMethod(targetClass, currentSelector, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { + if (class_addMethod(targetClass, currentSelector, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { class_replaceMethod(targetClass, newSelector, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); } else { method_exchangeImplementations(origMethod, newMethod); diff --git a/submodules/PeerInfoUI/BUILD b/submodules/PeerInfoUI/BUILD index c89dcb5bc4..2f8447fa6b 100644 --- a/submodules/PeerInfoUI/BUILD +++ b/submodules/PeerInfoUI/BUILD @@ -68,6 +68,7 @@ swift_library( "//submodules/StatisticsUI:StatisticsUI", "//submodules/ChatListFilterSettingsHeaderItem:ChatListFilterSettingsHeaderItem", "//submodules/InviteLinksUI:InviteLinksUI", + "//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils", ], visibility = [ "//visibility:public", diff --git a/submodules/PeerInfoUI/Sources/PeerBanTimeoutController.swift b/submodules/PeerInfoUI/Sources/PeerBanTimeoutController.swift index b509fcbb70..8649bcbb49 100644 --- a/submodules/PeerInfoUI/Sources/PeerBanTimeoutController.swift +++ b/submodules/PeerInfoUI/Sources/PeerBanTimeoutController.swift @@ -9,6 +9,7 @@ import SyncCore import TelegramPresentationData import TelegramStringFormatting import AccountContext +import UIKitRuntimeUtils final class PeerBanTimeoutController: ActionSheetController { private var presentationDisposable: Disposable? @@ -93,6 +94,8 @@ private final class PeerBanTimeoutActionSheetItemNode: ActionSheetItemNode { self.strings = strings self.valueChanged = valueChanged + UILabel.setDateLabel(theme.primaryTextColor) + self.pickerView = UIDatePicker() self.pickerView.datePickerMode = .countDownTimer self.pickerView.datePickerMode = .date diff --git a/submodules/SettingsUI/BUILD b/submodules/SettingsUI/BUILD index 417e3b44b0..97155853ad 100644 --- a/submodules/SettingsUI/BUILD +++ b/submodules/SettingsUI/BUILD @@ -87,6 +87,7 @@ swift_library( "//submodules/AccountUtils:AccountUtils", "//submodules/AuthTransferUI:AuthTransferUI", "//submodules/WidgetSetupScreen:WidgetSetupScreen", + "//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils", ], visibility = [ "//visibility:public", diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAutoNightTimeSelectionActionSheet.swift b/submodules/SettingsUI/Sources/Themes/ThemeAutoNightTimeSelectionActionSheet.swift index 1a72c592be..8f550268eb 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAutoNightTimeSelectionActionSheet.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAutoNightTimeSelectionActionSheet.swift @@ -8,6 +8,7 @@ import SyncCore import TelegramPresentationData import TelegramStringFormatting import AccountContext +import UIKitRuntimeUtils final class ThemeAutoNightTimeSelectionActionSheet: ActionSheetController { private var presentationDisposable: Disposable? @@ -98,6 +99,8 @@ private final class ThemeAutoNightTimeSelectionActionSheetItemNode: ActionSheetI self.strings = strings self.valueChanged = valueChanged + UILabel.setDateLabel(theme.primaryTextColor) + self.pickerView = UIDatePicker() self.pickerView.datePickerMode = .countDownTimer self.pickerView.datePickerMode = .time diff --git a/submodules/TelegramUI/Sources/ChatDateSelectionSheet.swift b/submodules/TelegramUI/Sources/ChatDateSelectionSheet.swift index e2688bf0ba..658c10305e 100644 --- a/submodules/TelegramUI/Sources/ChatDateSelectionSheet.swift +++ b/submodules/TelegramUI/Sources/ChatDateSelectionSheet.swift @@ -6,6 +6,7 @@ import UIKit import SwiftSignalKit import Photos import TelegramPresentationData +import UIKitRuntimeUtils final class ChatDateSelectionSheet: ActionSheetController { private let strings: PresentationStrings @@ -83,6 +84,8 @@ private final class ChatDateSelectorItemNode: ActionSheetItemNode { self.strings = strings self.valueChanged = valueChanged + UILabel.setDateLabel(theme.primaryTextColor) + self.pickerView = UIDatePicker() self.pickerView.datePickerMode = .countDownTimer self.pickerView.datePickerMode = .date @@ -96,6 +99,7 @@ private final class ChatDateSelectorItemNode: ActionSheetItemNode { } self.pickerView.setValue(theme.primaryTextColor, forKey: "textColor") + self.pickerView.setValue(theme.primaryTextColor, forKey: "highlightColor") super.init(theme: theme) diff --git a/submodules/TelegramUI/Sources/ChatScheduleTimeControllerNode.swift b/submodules/TelegramUI/Sources/ChatScheduleTimeControllerNode.swift index fcf97e0b49..7324f017ea 100644 --- a/submodules/TelegramUI/Sources/ChatScheduleTimeControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatScheduleTimeControllerNode.swift @@ -10,6 +10,7 @@ import TelegramStringFormatting import AccountContext import SolidRoundedButtonNode import PresentationDataUtils +import UIKitRuntimeUtils class ChatScheduleTimeControllerNode: ViewControllerTracingNode, UIScrollViewDelegate { private let context: AccountContext @@ -178,6 +179,8 @@ class ChatScheduleTimeControllerNode: ViewControllerTracingNode, UIScrollViewDel textColor = UIColor.white } + UILabel.setDateLabel(textColor) + let pickerView = UIDatePicker() pickerView.timeZone = TimeZone(secondsFromGMT: 0) pickerView.datePickerMode = .countDownTimer diff --git a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIMenuItem+Icons.h b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIMenuItem+Icons.h index 9db66d10b1..2acec4eee1 100644 --- a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIMenuItem+Icons.h +++ b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIMenuItem+Icons.h @@ -6,3 +6,8 @@ @end +@interface UILabel (DateLabel) + ++ (void)setDateLabelColor:(UIColor *)color; + +@end diff --git a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIMenuItem+Icons.m b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIMenuItem+Icons.m index 69f12f21c5..96d31fe858 100644 --- a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIMenuItem+Icons.m +++ b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIMenuItem+Icons.m @@ -85,6 +85,18 @@ static NSString *const imageItemIdetifier = @"\uFEFF\u200B"; @end +static UIColor *DateLabelColor = nil; + + +@implementation UILabel (DateLabel) + ++ (void)setDateLabelColor:(UIColor *)color +{ + DateLabelColor = color; +} + +@end + @implementation UILabel (Icons) + (void)load @@ -95,6 +107,7 @@ static NSString *const imageItemIdetifier = @"\uFEFF\u200B"; [RuntimeUtils swizzleInstanceMethodOfClass:[UILabel class] currentSelector:@selector(drawTextInRect:) newSelector:@selector(_78724db9_drawTextInRect:)]; [RuntimeUtils swizzleInstanceMethodOfClass:[UILabel class] currentSelector:@selector(layoutSubviews) newSelector:@selector(_78724db9_layoutSubviews)]; [RuntimeUtils swizzleInstanceMethodOfClass:[UILabel class] currentSelector:@selector(setFrame:) newSelector:@selector(_78724db9_setFrame:)]; + [RuntimeUtils swizzleInstanceMethodOfClass:[UILabel class] currentSelector:@selector(setTextColor:) newSelector:@selector(_78724db9_setTextColor:)]; }); } @@ -106,7 +119,19 @@ static NSString *const imageItemIdetifier = @"\uFEFF\u200B"; } } +- (void)_78724db9_setTextColor:(UIColor *)color { + if ([NSStringFromClass(self.superview.class) hasPrefix:@"UIDatePicker"] && DateLabelColor != nil) { + [self _78724db9_setTextColor:DateLabelColor]; + } else { + [self _78724db9_setTextColor:color]; + } +} + - (void)_78724db9_layoutSubviews { + if ([NSStringFromClass(self.superview.class) hasPrefix:@"UIDatePicker"] && DateLabelColor != nil) { + [self _78724db9_setTextColor:DateLabelColor]; + } + UIMenuItem *item = [[UIMenuController sharedMenuController] findImageItemByTitle:self.text]; UIImage *image = item._tg_image; if (image == nil) {