Various fixes

This commit is contained in:
Ilya Laktyushin 2022-10-23 16:57:00 +03:00
parent 7f0e194aca
commit 09b6cb6103
4 changed files with 77 additions and 51 deletions

View File

@ -8165,3 +8165,13 @@ Sorry for the inconvenience.";
"Message.AudioTranscription.SubscribeToPremium" = "Subscribe to **Telegram Premium** to convert voice to text.";
"Message.AudioTranscription.SubscribeToPremiumAction" = "More";
"PeerInfo.PrivateShareLinkInfo" = "This link will work only for group members.";
"CreateTopic.CreateTitle" = "New Topic";
"CreateTopic.EditTitle" = "Edit Topic";
"CreateTopic.Create" = "Create";
"CreateTopic.EnterTopicTitle" = "ENTER TOPIC TITLE";
"CreateTopic.EnterTopicTitlePlaceholder" = "What do you want to discuss?";
"CreateTopic.SelectTopicIcon" = "SELECT TOPIC ICON";

View File

@ -27,6 +27,7 @@ private final class TitleFieldComponent: Component {
let fileId: Int64
let iconColor: Int32
let text: String
let placeholderText: String
let textUpdated: (String) -> Void
let iconPressed: () -> Void
@ -38,6 +39,7 @@ private final class TitleFieldComponent: Component {
fileId: Int64,
iconColor: Int32,
text: String,
placeholderText: String,
textUpdated: @escaping (String) -> Void,
iconPressed: @escaping () -> Void
) {
@ -48,6 +50,7 @@ private final class TitleFieldComponent: Component {
self.fileId = fileId
self.iconColor = iconColor
self.text = text
self.placeholderText = placeholderText
self.textUpdated = textUpdated
self.iconPressed = iconPressed
}
@ -74,6 +77,9 @@ private final class TitleFieldComponent: Component {
if lhs.text != rhs.text {
return false
}
if lhs.placeholderText != rhs.placeholderText {
return false
}
return true
}
@ -146,7 +152,7 @@ private final class TitleFieldComponent: Component {
transition: .easeInOut(duration: 0.2),
component: AnyComponent(
Text(
text: "What do you want to discuss?",
text: component.placeholderText,
font: Font.regular(17.0),
color: component.placeholderColor
)
@ -599,7 +605,7 @@ private final class ForumCreateTopicScreenComponent: CombinedComponent {
let titleHeader = titleHeader.update(
component: MultilineTextComponent(
text: .plain(NSAttributedString(
string: "ENTER TOPIC TITLE",
string: environment.strings.CreateTopic_EnterTopicTitle,
font: Font.regular(13.0),
textColor: environment.theme.list.freeTextColor,
paragraphAlignment: .natural)
@ -636,6 +642,7 @@ private final class ForumCreateTopicScreenComponent: CombinedComponent {
fileId: state.fileId,
iconColor: state.iconColor,
text: state.title,
placeholderText: environment.strings.CreateTopic_EnterTopicTitlePlaceholder,
textUpdated: { [weak state] text in
state?.updateTitle(text)
},
@ -655,7 +662,7 @@ private final class ForumCreateTopicScreenComponent: CombinedComponent {
let iconHeader = iconHeader.update(
component: MultilineTextComponent(
text: .plain(NSAttributedString(
string: "SELECT TOPIC ICON",
string: environment.strings.CreateTopic_SelectTopicIcon,
font: Font.regular(13.0),
textColor: environment.theme.list.freeTextColor,
paragraphAlignment: .natural)
@ -823,23 +830,22 @@ public class ForumCreateTopicScreen: ViewControllerComponentContainer {
openPremiumImpl?()
}), navigationBarAppearance: .transparent)
//TODO:localize
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
let title: String
let doneTitle: String
switch mode {
case .create:
title = "New Topic"
doneTitle = "Create"
title = presentationData.strings.CreateTopic_CreateTitle
doneTitle = presentationData.strings.CreateTopic_Create
case let .edit(topic):
title = "Edit Topic"
doneTitle = "Done"
title = presentationData.strings.CreateTopic_EditTitle
doneTitle = presentationData.strings.Common_Done
self.state = (topic.title, topic.icon)
}
self.title = title
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
self.doneBarItem = UIBarButtonItem(title: doneTitle, style: .done, target: self, action: #selector(self.createPressed))

View File

@ -235,11 +235,13 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
var updatedInstantVideoBackgroundImage: UIImage?
let instantVideoBackgroundImage: UIImage?
var ignoreHeaders = false
switch statusDisplayType {
case .free:
instantVideoBackgroundImage = nil
case .bubble:
instantVideoBackgroundImage = nil
ignoreHeaders = true
}
if item.presentationData.theme != currentItem?.presentationData.theme {
@ -306,47 +308,49 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
let availableWidth = max(60.0, width - 210.0 - bubbleEdgeInset * 2.0 - bubbleContentInsetsLeft - 20.0)
let availableContentWidth = width - bubbleEdgeInset * 2.0 - bubbleContentInsetsLeft - 20.0
for attribute in item.message.attributes {
if let attribute = attribute as? InlineBotMessageAttribute {
var inlineBotNameString: String?
if let peerId = attribute.peerId, let bot = item.message.peers[peerId] as? TelegramUser {
inlineBotNameString = bot.addressName
} else {
inlineBotNameString = attribute.title
if !ignoreHeaders {
for attribute in item.message.attributes {
if let attribute = attribute as? InlineBotMessageAttribute {
var inlineBotNameString: String?
if let peerId = attribute.peerId, let bot = item.message.peers[peerId] as? TelegramUser {
inlineBotNameString = bot.addressName
} else {
inlineBotNameString = attribute.title
}
if let inlineBotNameString = inlineBotNameString {
let inlineBotNameColor = serviceMessageColorComponents(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper).primaryText
let bodyAttributes = MarkdownAttributeSet(font: nameFont, textColor: inlineBotNameColor)
let boldAttributes = MarkdownAttributeSet(font: inlineBotPrefixFont, textColor: inlineBotNameColor)
let botString = addAttributesToStringWithRanges(item.presentationData.strings.Conversation_MessageViaUser("@\(inlineBotNameString)")._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
viaBotApply = viaBotLayout(TextNodeLayoutArguments(attributedString: botString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0, availableWidth), height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
ignoreForward = true
}
}
if let inlineBotNameString = inlineBotNameString {
let inlineBotNameColor = serviceMessageColorComponents(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper).primaryText
let bodyAttributes = MarkdownAttributeSet(font: nameFont, textColor: inlineBotNameColor)
let boldAttributes = MarkdownAttributeSet(font: inlineBotPrefixFont, textColor: inlineBotNameColor)
let botString = addAttributesToStringWithRanges(item.presentationData.strings.Conversation_MessageViaUser("@\(inlineBotNameString)")._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
viaBotApply = viaBotLayout(TextNodeLayoutArguments(attributedString: botString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0, availableWidth), height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
ignoreForward = true
}
}
if let replyAttribute = attribute as? ReplyMessageAttribute, let replyMessage = item.message.associatedMessages[replyAttribute.messageId] {
if case let .replyThread(replyThreadMessage) = item.chatLocation, replyThreadMessage.messageId == replyAttribute.messageId {
} else {
replyInfoApply = makeReplyInfoLayout(ChatMessageReplyInfoNode.Arguments(
presentationData: item.presentationData,
strings: item.presentationData.strings,
context: item.context,
type: .standalone,
message: replyMessage,
parentMessage: item.message,
constrainedSize: CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude),
animationCache: item.controllerInteraction.presentationContext.animationCache,
animationRenderer: item.controllerInteraction.presentationContext.animationRenderer
))
if let replyAttribute = attribute as? ReplyMessageAttribute, let replyMessage = item.message.associatedMessages[replyAttribute.messageId] {
if case let .replyThread(replyThreadMessage) = item.chatLocation, replyThreadMessage.messageId == replyAttribute.messageId {
} else {
replyInfoApply = makeReplyInfoLayout(ChatMessageReplyInfoNode.Arguments(
presentationData: item.presentationData,
strings: item.presentationData.strings,
context: item.context,
type: .standalone,
message: replyMessage,
parentMessage: item.message,
constrainedSize: CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude),
animationCache: item.controllerInteraction.presentationContext.animationCache,
animationRenderer: item.controllerInteraction.presentationContext.animationRenderer
))
}
}
}
}
if !ignoreSource, !item.message.id.peerId.isRepliesOrSavedMessages(accountPeerId: item.context.account.peerId) {
if !ignoreSource && !ignoreHeaders, !item.message.id.peerId.isRepliesOrSavedMessages(accountPeerId: item.context.account.peerId) {
for attribute in item.message.attributes {
if let attribute = attribute as? SourceReferenceMessageAttribute {
if let sourcePeer = item.message.peers[attribute.messageId.peerId] {
@ -365,7 +369,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
var forwardInfoSizeApply: (CGSize, (CGFloat) -> ChatMessageForwardInfoNode)?
if !ignoreForward, let forwardInfo = item.message.forwardInfo {
if !ignoreForward && !ignoreHeaders, let forwardInfo = item.message.forwardInfo {
let forwardPsaType = forwardInfo.psaType
if let source = forwardInfo.source {

View File

@ -1082,12 +1082,13 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
}
} else if let channel = data.peer as? TelegramChannel {
let ItemUsername = 1
let ItemAbout = 2
let ItemLocationHeader = 3
let ItemLocation = 4
let ItemAdmins = 5
let ItemMembers = 6
let ItemMemberRequests = 7
let ItemUsernameInfo = 2
let ItemAbout = 3
let ItemLocationHeader = 4
let ItemLocation = 5
let ItemAdmins = 6
let ItemMembers = 7
let ItemMemberRequests = 8
if let _ = data.threadData {
let mainUsername: String
@ -1128,6 +1129,11 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
}
)
)
if let _ = channel.addressName {
} else {
items[.peerInfo]!.append(PeerInfoScreenCommentItem(id: ItemUsernameInfo, text: presentationData.strings.PeerInfo_PrivateShareLinkInfo))
}
} else {
if let location = (data.cachedData as? CachedChannelData)?.peerGeoLocation {
items[.groupLocation]!.append(PeerInfoScreenHeaderItem(id: ItemLocationHeader, text: presentationData.strings.GroupInfo_Location.uppercased()))