mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
4456d4eed8
commit
d058e0a8c5
@ -1097,7 +1097,7 @@ public struct StoriesConfiguration {
|
||||
// return StoriesConfiguration(posting: .premium)
|
||||
//#else
|
||||
if let data = appConfiguration.data, let postingString = data["stories_posting"] as? String {
|
||||
let posting: PostingAvailability
|
||||
var posting: PostingAvailability
|
||||
switch postingString {
|
||||
case "enabled":
|
||||
posting = .enabled
|
||||
@ -1106,6 +1106,7 @@ public struct StoriesConfiguration {
|
||||
default:
|
||||
posting = .disabled
|
||||
}
|
||||
posting = .enabled
|
||||
return StoriesConfiguration(posting: posting)
|
||||
} else {
|
||||
return .defaultValue
|
||||
|
@ -1017,7 +1017,10 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
||||
}
|
||||
if groupId == AnyHashable("recent") {
|
||||
interaction.dismissTextInput()
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
var presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
if let forceTheme = interaction.forceTheme {
|
||||
presentationData = presentationData.withUpdated(theme: forceTheme)
|
||||
}
|
||||
let actionSheet = ActionSheetController(theme: ActionSheetControllerTheme(presentationTheme: presentationData.theme, fontSize: presentationData.listsFontSize))
|
||||
var items: [ActionSheetItem] = []
|
||||
items.append(ActionSheetButtonItem(title: presentationData.strings.Emoji_ClearRecent, color: .destructive, action: { [weak actionSheet] in
|
||||
@ -1448,7 +1451,10 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
||||
}
|
||||
if groupId == AnyHashable("recent") {
|
||||
interaction.dismissTextInput()
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
var presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
if let forceTheme = interaction.forceTheme {
|
||||
presentationData = presentationData.withUpdated(theme: forceTheme)
|
||||
}
|
||||
let actionSheet = ActionSheetController(theme: ActionSheetControllerTheme(presentationTheme: presentationData.theme, fontSize: presentationData.listsFontSize))
|
||||
var items: [ActionSheetItem] = []
|
||||
items.append(ActionSheetButtonItem(title: presentationData.strings.Stickers_ClearRecent, color: .destructive, action: { [weak actionSheet] in
|
||||
|
@ -293,25 +293,18 @@ final class MediaEditorScreenComponent: Component {
|
||||
self.didInitializeInputMediaNodeDataPromise = true
|
||||
|
||||
let context = component.context
|
||||
|
||||
self.inputMediaNodeDataPromise.set(
|
||||
EmojiPagerContentComponent.emojiInputData(
|
||||
ChatEntityKeyboardInputNode.inputData(
|
||||
context: context,
|
||||
animationCache: context.animationCache,
|
||||
animationRenderer: context.animationRenderer,
|
||||
isStandalone: true,
|
||||
isStatusSelection: false,
|
||||
isReactionSelection: false,
|
||||
isEmojiSelection: false,
|
||||
hasTrending: false,
|
||||
topReactionItems: [],
|
||||
areUnicodeEmojiEnabled: true,
|
||||
areCustomEmojiEnabled: true,
|
||||
chatPeerId: nil,
|
||||
forceHasPremium: false,
|
||||
hideBackground: true
|
||||
) |> map { emoji -> ChatEntityKeyboardInputNode.InputData in
|
||||
areCustomEmojiEnabled: true,
|
||||
hasSearch: false,
|
||||
hideBackground: true,
|
||||
sendGif: nil
|
||||
) |> map { inputData -> ChatEntityKeyboardInputNode.InputData in
|
||||
return ChatEntityKeyboardInputNode.InputData(
|
||||
emoji: emoji,
|
||||
emoji: inputData.emoji,
|
||||
stickers: nil,
|
||||
gifs: nil,
|
||||
availableGifSearchEmojies: []
|
||||
@ -365,10 +358,13 @@ final class MediaEditorScreenComponent: Component {
|
||||
}
|
||||
},
|
||||
getNavigationController: { return nil },
|
||||
requestLayout: { _ in
|
||||
|
||||
requestLayout: { [weak self] transition in
|
||||
if let self {
|
||||
self.environment?.controller()?.requestLayout(transition: transition)
|
||||
}
|
||||
}
|
||||
)
|
||||
self.inputMediaInteraction?.forceTheme = defaultDarkColorPresentationTheme
|
||||
}
|
||||
}
|
||||
|
||||
@ -916,6 +912,8 @@ final class MediaEditorScreenComponent: Component {
|
||||
default:
|
||||
nextInputMode = .emoji
|
||||
}
|
||||
|
||||
let keyboardWasHidden = self.inputPanelExternalState.isKeyboardHidden
|
||||
self.inputPanel.parentState = state
|
||||
let inputPanelSize = self.inputPanel.update(
|
||||
transition: transition,
|
||||
@ -930,10 +928,10 @@ final class MediaEditorScreenComponent: Component {
|
||||
nextInputMode: { _ in return nextInputMode },
|
||||
areVoiceMessagesAvailable: false,
|
||||
presentController: { [weak self] c in
|
||||
guard let self, let _ = self.component else {
|
||||
guard let self, let _ = self.component, let environment = self.environment, let controller = environment.controller() as? MediaEditorScreen else {
|
||||
return
|
||||
}
|
||||
//component.presentController(c)
|
||||
controller.present(c, in: .window(.root))
|
||||
},
|
||||
sendMessageAction: { [weak self] in
|
||||
guard let self else {
|
||||
@ -1019,7 +1017,7 @@ final class MediaEditorScreenComponent: Component {
|
||||
|
||||
var inputHeight = environment.inputHeight
|
||||
if self.inputPanelExternalState.isEditing {
|
||||
if self.currentInputMode == .emoji || inputHeight.isZero {
|
||||
if self.currentInputMode == .emoji || (inputHeight.isZero && keyboardWasHidden) {
|
||||
inputHeight = environment.deviceMetrics.standardInputHeight(inLandscape: false)
|
||||
}
|
||||
}
|
||||
|
@ -1206,7 +1206,6 @@ public final class MessageInputPanelComponent: Component {
|
||||
panelView.animateIn(transition: .spring(duration: 0.4))
|
||||
}
|
||||
}
|
||||
|
||||
} else if let contextQueryResultPanel = self.contextQueryResultPanel?.view as? ContextResultPanelComponent.View {
|
||||
self.contextQueryResultPanel = nil
|
||||
contextQueryResultPanel.animateOut(transition: .spring(duration: 0.4), completion: { [weak contextQueryResultPanel] in
|
||||
|
@ -13,6 +13,7 @@ swift_library(
|
||||
"//submodules/Display",
|
||||
"//submodules/ComponentFlow",
|
||||
"//submodules/TextFormat",
|
||||
"//submodules/SSignalKit/SwiftSignalKit",
|
||||
"//submodules/TelegramPresentationData",
|
||||
"//submodules/AccountContext",
|
||||
"//submodules/InvisibleInkDustNode",
|
||||
|
@ -2,6 +2,7 @@ import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import ComponentFlow
|
||||
import SwiftSignalKit
|
||||
import TextFormat
|
||||
import TelegramPresentationData
|
||||
import InvisibleInkDustNode
|
||||
@ -206,6 +207,11 @@ public final class TextFieldComponent: Component {
|
||||
refreshChatTextInputAttributes(textView: self.textView, primaryTextColor: component.textColor, accentTextColor: component.textColor, baseFontSize: component.fontSize, spoilersRevealed: self.spoilersRevealed, availableEmojis: Set(component.context.animatedEmojiStickers.keys), emojiViewProvider: self.emojiViewProvider)
|
||||
refreshChatTextInputTypingAttributes(self.textView, textColor: component.textColor, baseFontSize: component.fontSize)
|
||||
|
||||
if self.spoilerIsDisappearing {
|
||||
self.spoilerIsDisappearing = false
|
||||
self.updateInternalSpoilersRevealed(false, animated: false)
|
||||
}
|
||||
|
||||
self.updateEntities()
|
||||
|
||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(kind: .textChanged)))
|
||||
@ -215,6 +221,8 @@ public final class TextFieldComponent: Component {
|
||||
guard let _ = self.component else {
|
||||
return
|
||||
}
|
||||
|
||||
self.updateSpoilersRevealed()
|
||||
}
|
||||
|
||||
public func textViewDidBeginEditing(_ textView: UITextView) {
|
||||
@ -277,7 +285,17 @@ public final class TextFieldComponent: Component {
|
||||
]
|
||||
actions.append(UIAction(title: strings.TextFormat_Spoiler, image: nil) { [weak self] action in
|
||||
if let self {
|
||||
var animated = false
|
||||
let attributedText = self.inputState.inputText
|
||||
attributedText.enumerateAttributes(in: NSMakeRange(0, attributedText.length), options: [], using: { attributes, _, _ in
|
||||
if let _ = attributes[ChatTextInputAttributes.spoiler] {
|
||||
animated = true
|
||||
}
|
||||
})
|
||||
|
||||
self.toggleAttribute(key: ChatTextInputAttributes.spoiler)
|
||||
|
||||
self.updateSpoilersRevealed(animated: animated)
|
||||
}
|
||||
})
|
||||
|
||||
@ -307,12 +325,15 @@ public final class TextFieldComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
let controller = chatTextLinkEditController(sharedContext: component.context.sharedContext, account: component.context.account, text: text.string, link: link, apply: { [weak self] link in
|
||||
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }.withUpdated(theme: defaultDarkColorPresentationTheme)
|
||||
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 {
|
||||
if let link = link {
|
||||
self.updateInputState { state in
|
||||
return state.addLinkAttribute(selectionRange: selectionRange, url: link)
|
||||
}
|
||||
self.textView.becomeFirstResponder()
|
||||
}
|
||||
// strongSelf.updateChatPresentationInterfaceState(animated: false, interactive: true, {
|
||||
// return $0.updatedInputMode({ _ in return inputMode }).updatedInterfaceState({
|
||||
@ -348,7 +369,82 @@ public final class TextFieldComponent: Component {
|
||||
self.textView.becomeFirstResponder()
|
||||
}
|
||||
|
||||
var spoilersRevealed = false
|
||||
private var spoilersRevealed = false
|
||||
private var spoilerIsDisappearing = false
|
||||
private func updateSpoilersRevealed(animated: Bool = true) {
|
||||
let selectionRange = self.textView.selectedRange
|
||||
|
||||
var revealed = false
|
||||
if let attributedText = self.textView.attributedText {
|
||||
attributedText.enumerateAttributes(in: NSMakeRange(0, attributedText.length), options: [], using: { attributes, range, _ in
|
||||
if let _ = attributes[ChatTextInputAttributes.spoiler] {
|
||||
if let _ = selectionRange.intersection(range) {
|
||||
revealed = true
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
guard self.spoilersRevealed != revealed else {
|
||||
return
|
||||
}
|
||||
self.spoilersRevealed = revealed
|
||||
|
||||
if revealed {
|
||||
self.updateInternalSpoilersRevealed(true, animated: animated)
|
||||
} else {
|
||||
self.spoilerIsDisappearing = true
|
||||
Queue.mainQueue().after(1.5, {
|
||||
self.updateInternalSpoilersRevealed(false, animated: true)
|
||||
self.spoilerIsDisappearing = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private func updateInternalSpoilersRevealed(_ revealed: Bool, animated: Bool) {
|
||||
guard let component = self.component, self.spoilersRevealed == revealed else {
|
||||
return
|
||||
}
|
||||
|
||||
self.textView.isScrollEnabled = false
|
||||
|
||||
refreshChatTextInputAttributes(textView: self.textView, primaryTextColor: component.textColor, accentTextColor: component.textColor, baseFontSize: component.fontSize, spoilersRevealed: self.spoilersRevealed, availableEmojis: Set(component.context.animatedEmojiStickers.keys), emojiViewProvider: self.emojiViewProvider)
|
||||
refreshChatTextInputTypingAttributes(self.textView, textColor: component.textColor, baseFontSize: component.fontSize)
|
||||
|
||||
if self.textView.subviews.count > 1, animated {
|
||||
let containerView = self.textView.subviews[1]
|
||||
if let canvasView = containerView.subviews.first {
|
||||
if let snapshotView = canvasView.snapshotView(afterScreenUpdates: false) {
|
||||
snapshotView.frame = canvasView.frame.offsetBy(dx: 0.0, dy: -self.textView.contentOffset.y)
|
||||
self.insertSubview(snapshotView, at: 0)
|
||||
canvasView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak snapshotView] _ in
|
||||
self.textView.isScrollEnabled = false
|
||||
snapshotView?.removeFromSuperview()
|
||||
Queue.mainQueue().after(0.1) {
|
||||
self.textView.isScrollEnabled = true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Queue.mainQueue().after(0.1) {
|
||||
self.textView.isScrollEnabled = true
|
||||
}
|
||||
|
||||
if let spoilerView = self.spoilerView {
|
||||
if animated {
|
||||
let transition = Transition.easeInOut(duration: 0.3)
|
||||
if revealed {
|
||||
transition.setAlpha(view: spoilerView, alpha: 0.0)
|
||||
} else {
|
||||
transition.setAlpha(view: spoilerView, alpha: 1.0)
|
||||
}
|
||||
} else {
|
||||
spoilerView.alpha = revealed ? 0.0 : 1.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateEntities() {
|
||||
guard let component = self.component else {
|
||||
|
@ -539,6 +539,7 @@ public func refreshChatTextInputAttributes(textView: UITextView, primaryTextColo
|
||||
|
||||
textView.textStorage.removeAttribute(NSAttributedString.Key.font, range: fullRange)
|
||||
textView.textStorage.removeAttribute(NSAttributedString.Key.foregroundColor, range: fullRange)
|
||||
textView.textStorage.removeAttribute(NSAttributedString.Key.backgroundColor, range: fullRange)
|
||||
textView.textStorage.removeAttribute(NSAttributedString.Key.underlineStyle, range: fullRange)
|
||||
textView.textStorage.removeAttribute(NSAttributedString.Key.strikethroughStyle, range: fullRange)
|
||||
textView.textStorage.removeAttribute(ChatTextInputAttributes.textMention, range: fullRange)
|
||||
@ -646,6 +647,7 @@ public func refreshGenericTextInputAttributes(_ textNode: ASEditableTextNode, th
|
||||
if !resultAttributedText.isEqual(to: initialAttributedText) {
|
||||
textNode.textView.textStorage.removeAttribute(NSAttributedString.Key.font, range: fullRange)
|
||||
textNode.textView.textStorage.removeAttribute(NSAttributedString.Key.foregroundColor, range: fullRange)
|
||||
textNode.textView.textStorage.removeAttribute(NSAttributedString.Key.backgroundColor, range: fullRange)
|
||||
textNode.textView.textStorage.removeAttribute(NSAttributedString.Key.underlineStyle, range: fullRange)
|
||||
textNode.textView.textStorage.removeAttribute(NSAttributedString.Key.strikethroughStyle, range: fullRange)
|
||||
textNode.textView.textStorage.removeAttribute(ChatTextInputAttributes.textMention, range: fullRange)
|
||||
|
Loading…
x
Reference in New Issue
Block a user