mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Force text color on UIDatePicker labels
This commit is contained in:
parent
166d4add27
commit
9d3f6d34c0
@ -13,6 +13,7 @@ swift_library(
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
"//submodules/TelegramStringFormatting:TelegramStringFormatting",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -68,6 +68,7 @@ swift_library(
|
||||
"//submodules/StatisticsUI:StatisticsUI",
|
||||
"//submodules/ChatListFilterSettingsHeaderItem:ChatListFilterSettingsHeaderItem",
|
||||
"//submodules/InviteLinksUI:InviteLinksUI",
|
||||
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -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
|
||||
|
@ -87,6 +87,7 @@ swift_library(
|
||||
"//submodules/AccountUtils:AccountUtils",
|
||||
"//submodules/AuthTransferUI:AuthTransferUI",
|
||||
"//submodules/WidgetSetupScreen:WidgetSetupScreen",
|
||||
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -6,3 +6,8 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface UILabel (DateLabel)
|
||||
|
||||
+ (void)setDateLabelColor:(UIColor *)color;
|
||||
|
||||
@end
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user