Various fixes

This commit is contained in:
Ilya Laktyushin 2023-02-18 17:35:13 +04:00
parent fa1b3d5b97
commit 102864c9a0
6 changed files with 38 additions and 23 deletions

View File

@ -12,6 +12,7 @@ import UndoUI
import BundleIconComponent
import TelegramUIPreferences
import OpenInExternalAppUI
import MultilineTextComponent
private let settingsTag = GenericComponentViewTag()
@ -89,11 +90,7 @@ private final class BrowserScreenComponent: CombinedComponent {
navigationContent = AnyComponentWithIdentity(
id: "title",
component: AnyComponent(
Text(
text: context.component.contentState?.title ?? "",
font: Font.bold(17.0),
color: environment.theme.rootController.navigationBar.primaryTextColor
)
MultilineTextComponent(text: .plain(NSAttributedString(string: context.component.contentState?.title ?? "", font: Font.bold(17.0), textColor: environment.theme.rootController.navigationBar.primaryTextColor, paragraphAlignment: .center)), horizontalAlignment: .center, maximumNumberOfLines: 1)
)
)
navigationLeftItems = [

View File

@ -7,13 +7,16 @@ import ComponentDisplayAdapters
public final class BlurredBackgroundComponent: Component {
public let color: UIColor
public let tintContainerView: UIView?
public let cornerRadius: CGFloat
public init(
color: UIColor,
tintContainerView: UIView? = nil
tintContainerView: UIView? = nil,
cornerRadius: CGFloat = 0.0
) {
self.color = color
self.tintContainerView = tintContainerView
self.cornerRadius = cornerRadius
}
public static func ==(lhs: BlurredBackgroundComponent, rhs: BlurredBackgroundComponent) -> Bool {
@ -23,6 +26,9 @@ public final class BlurredBackgroundComponent: Component {
if lhs.tintContainerView !== rhs.tintContainerView {
return false
}
if lhs.cornerRadius != rhs.cornerRadius {
return false
}
return true
}
@ -106,7 +112,7 @@ public final class BlurredBackgroundComponent: Component {
view.frame = CGRect(origin: CGPoint(), size: availableSize)
}*/
self.update(size: availableSize, transition: transition.containedViewLayoutTransition)
self.update(size: availableSize, cornerRadius: component.cornerRadius, transition: transition.containedViewLayoutTransition)
if let tintContainerView = self.tintContainerView {
transition.setFrame(view: tintContainerView, frame: CGRect(origin: CGPoint(), size: availableSize))

View File

@ -1789,7 +1789,8 @@ private final class DrawingScreenComponent: CombinedComponent {
id: "background",
component: AnyComponent(
BlurredBackgroundComponent(
color: UIColor(rgb: 0x888888, alpha: 0.3)
color: UIColor(rgb: 0x888888, alpha: 0.3),
cornerRadius: 12.0
)
)
),

View File

@ -1241,12 +1241,17 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
var translateToLanguage: String?
if let translationState, isPremium && translationState.isEnabled {
translateToLanguage = translationState.toLang ?? presentationData.strings.baseLanguageCode
if translateToLanguage == "nb" {
translateToLanguage = "no"
} else if translateToLanguage == "pt-br" {
translateToLanguage = "pt"
var languageCode = translationState.toLang ?? presentationData.strings.baseLanguageCode
let rawSuffix = "-raw"
if languageCode.hasSuffix(rawSuffix) {
languageCode = String(languageCode.dropLast(rawSuffix.count))
}
if languageCode == "nb" {
languageCode = "no"
} else if languageCode == "pt-br" {
languageCode = "pt"
}
translateToLanguage = languageCode
}
let associatedData = extractAssociatedData(chatLocation: chatLocation, view: view, automaticDownloadNetworkType: networkType, animatedEmojiStickers: animatedEmojiStickers, additionalAnimatedEmojiStickers: additionalAnimatedEmojiStickers, subject: subject, currentlyPlayingMessageId: currentlyPlayingMessageIdAndType?.0, isCopyProtectionEnabled: isCopyProtectionEnabled, availableReactions: availableReactions, defaultReaction: defaultReaction, isPremium: isPremium, alwaysDisplayTranscribeButton: alwaysDisplayTranscribeButton, accountPeer: accountPeer, topicAuthorId: topicAuthorId, hasBots: chatHasBots, translateToLanguage: translateToLanguage)

View File

@ -1062,15 +1062,21 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
}
}
if !messageText.isEmpty || resourceAvailable || diceEmoji != nil {
let isCopyProtected = chatPresentationInterfaceState.copyProtectionEnabled || message.isCopyProtected()
let message = messages[0]
var isExpired = false
for media in message.media {
if let _ = media as? TelegramMediaExpiredContent {
isExpired = true
}
let message = messages[0]
var isExpired = false
var isImage = false
for media in message.media {
if let _ = media as? TelegramMediaExpiredContent {
isExpired = true
}
if media is TelegramMediaImage {
isImage = true
}
}
if !messageText.isEmpty || (resourceAvailable && isImage) || diceEmoji != nil {
let isCopyProtected = chatPresentationInterfaceState.copyProtectionEnabled || message.isCopyProtected()
if !isExpired {
if !isPoll {
if !isCopyProtected {

View File

@ -959,8 +959,8 @@ public func resolveUrlImpl(context: AccountContext, peerId: PeerId?, url: String
for scheme in schemes {
let basePrefix = scheme + basePath + "/"
var url = url
if (url.lowercased().hasPrefix(scheme) && url.lowercased().hasSuffix(".\(basePath)")) {
url = basePrefix + String(url[scheme.endIndex...]).replacingOccurrences(of: ".\(basePath)", with: "")
if (url.lowercased().hasPrefix(scheme) && (url.lowercased().hasSuffix(".\(basePath)") || url.lowercased().contains(".\(basePath)/"))) {
url = basePrefix + String(url[scheme.endIndex...]).replacingOccurrences(of: ".\(basePath)/", with: "").replacingOccurrences(of: ".\(basePath)", with: "")
}
if url.lowercased().hasPrefix(basePrefix) {
if let internalUrl = parseInternalUrl(query: String(url[basePrefix.endIndex...])) {