mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
[WIP] Premium setup
This commit is contained in:
@@ -27,6 +27,7 @@ public final class TextFieldComponent: Component {
|
||||
public final class ExternalState {
|
||||
public fileprivate(set) var isEditing: Bool = false
|
||||
public fileprivate(set) var hasText: Bool = false
|
||||
public fileprivate(set) var text: NSAttributedString = NSAttributedString()
|
||||
public fileprivate(set) var textLength: Int = 0
|
||||
public var initialText: NSAttributedString?
|
||||
|
||||
@@ -87,6 +88,7 @@ public final class TextFieldComponent: Component {
|
||||
}
|
||||
|
||||
public let context: AccountContext
|
||||
public let theme: PresentationTheme
|
||||
public let strings: PresentationStrings
|
||||
public let externalState: ExternalState
|
||||
public let fontSize: CGFloat
|
||||
@@ -105,6 +107,7 @@ public final class TextFieldComponent: Component {
|
||||
|
||||
public init(
|
||||
context: AccountContext,
|
||||
theme: PresentationTheme,
|
||||
strings: PresentationStrings,
|
||||
externalState: ExternalState,
|
||||
fontSize: CGFloat,
|
||||
@@ -122,6 +125,7 @@ public final class TextFieldComponent: Component {
|
||||
paste: @escaping (PasteData) -> Void
|
||||
) {
|
||||
self.context = context
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
self.externalState = externalState
|
||||
self.fontSize = fontSize
|
||||
@@ -140,6 +144,12 @@ public final class TextFieldComponent: Component {
|
||||
}
|
||||
|
||||
public static func ==(lhs: TextFieldComponent, rhs: TextFieldComponent) -> Bool {
|
||||
if lhs.context !== rhs.context {
|
||||
return false
|
||||
}
|
||||
if lhs.theme !== rhs.theme {
|
||||
return false
|
||||
}
|
||||
if lhs.strings !== rhs.strings {
|
||||
return false
|
||||
}
|
||||
@@ -219,7 +229,6 @@ public final class TextFieldComponent: Component {
|
||||
self.textView.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.textView.backgroundColor = nil
|
||||
self.textView.layer.isOpaque = false
|
||||
self.textView.keyboardAppearance = .dark
|
||||
self.textView.indicatorStyle = .white
|
||||
self.textView.scrollIndicatorInsets = UIEdgeInsets(top: 9.0, left: 0.0, bottom: 9.0, right: 0.0)
|
||||
|
||||
@@ -232,10 +241,6 @@ public final class TextFieldComponent: Component {
|
||||
self.textView.customDelegate = self
|
||||
self.addSubview(self.textView)
|
||||
|
||||
if #available(iOS 13.0, *) {
|
||||
self.textView.overrideUserInterfaceStyle = .dark
|
||||
}
|
||||
|
||||
self.textView.typingAttributes = [
|
||||
NSAttributedString.Key.font: Font.regular(17.0),
|
||||
NSAttributedString.Key.foregroundColor: UIColor.white
|
||||
@@ -724,7 +729,7 @@ public final class TextFieldComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }.withUpdated(theme: defaultDarkColorPresentationTheme)
|
||||
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }.withUpdated(theme: component.theme)
|
||||
let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>) = (presentationData, .single(presentationData))
|
||||
let controller = chatTextLinkEditController(sharedContext: component.context.sharedContext, updatedPresentationData: updatedPresentationData, account: component.context.account, text: text.string, link: link, apply: { [weak self] link in
|
||||
if let self {
|
||||
@@ -1048,9 +1053,17 @@ public final class TextFieldComponent: Component {
|
||||
self.isUpdating = false
|
||||
}
|
||||
|
||||
let previousComponent = self.component
|
||||
self.component = component
|
||||
self.state = state
|
||||
|
||||
if previousComponent?.theme !== component.theme {
|
||||
self.textView.keyboardAppearance = component.theme.overallDarkAppearance ? .dark : .light
|
||||
if #available(iOS 13.0, *) {
|
||||
self.textView.overrideUserInterfaceStyle = component.theme.overallDarkAppearance ? .dark : .light
|
||||
}
|
||||
}
|
||||
|
||||
if let initialText = component.externalState.initialText {
|
||||
component.externalState.initialText = nil
|
||||
self.updateInputState { _ in
|
||||
@@ -1128,6 +1141,7 @@ public final class TextFieldComponent: Component {
|
||||
component.externalState.hasText = self.textView.textStorage.length != 0
|
||||
component.externalState.isEditing = isEditing
|
||||
component.externalState.textLength = self.textView.textStorage.string.count
|
||||
component.externalState.text = NSAttributedString(attributedString: self.textView.textStorage)
|
||||
|
||||
if let inputView = component.customInputView {
|
||||
if self.textView.inputView == nil {
|
||||
|
||||
Reference in New Issue
Block a user