Force text color on UIDatePicker labels

This commit is contained in:
Ilya Laktyushin 2021-02-20 19:24:35 +04:00
parent 166d4add27
commit 9d3f6d34c0
11 changed files with 51 additions and 3 deletions

View File

@ -13,6 +13,7 @@ swift_library(
"//submodules/AccountContext:AccountContext",
"//submodules/TelegramStringFormatting:TelegramStringFormatting",
"//submodules/TelegramPresentationData:TelegramPresentationData",
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
],
visibility = [
"//visibility:public",

View File

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

View File

@ -68,6 +68,7 @@ swift_library(
"//submodules/StatisticsUI:StatisticsUI",
"//submodules/ChatListFilterSettingsHeaderItem:ChatListFilterSettingsHeaderItem",
"//submodules/InviteLinksUI:InviteLinksUI",
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
],
visibility = [
"//visibility:public",

View File

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

View File

@ -87,6 +87,7 @@ swift_library(
"//submodules/AccountUtils:AccountUtils",
"//submodules/AuthTransferUI:AuthTransferUI",
"//submodules/WidgetSetupScreen:WidgetSetupScreen",
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
],
visibility = [
"//visibility:public",

View File

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

View File

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

View File

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

View File

@ -6,3 +6,8 @@
@end
@interface UILabel (DateLabel)
+ (void)setDateLabelColor:(UIColor *)color;
@end

View File

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