mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Support private channel stories in chat
This commit is contained in:
parent
ae8e948b95
commit
1a08a9e2ba
@ -10046,3 +10046,6 @@ Sorry for the inconvenience.";
|
|||||||
"Story.Context.RemoveFromChannel" = "Remove from Posts";
|
"Story.Context.RemoveFromChannel" = "Remove from Posts";
|
||||||
|
|
||||||
"Story.StealthModePlaceholder" = "Stealth Mode active — {m}:{s}";
|
"Story.StealthModePlaceholder" = "Stealth Mode active — {m}:{s}";
|
||||||
|
|
||||||
|
"Chat.ReplyStoryPrivateChannel" = "Private story";
|
||||||
|
"Message.ForwardedUnavailableStoryShort" = "Private Story\nFrom: %@";
|
||||||
|
@ -58,11 +58,17 @@ private final class InfoButtonNode: HighlightableButtonNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ChatMessageForwardInfoNode: ASDisplayNode {
|
public class ChatMessageForwardInfoNode: ASDisplayNode {
|
||||||
public struct StoryData: Equatable {
|
public enum StoryType {
|
||||||
public var isExpired: Bool
|
case regular
|
||||||
|
case expired
|
||||||
|
case unavailable
|
||||||
|
}
|
||||||
|
|
||||||
public init(isExpired: Bool) {
|
public struct StoryData: Equatable {
|
||||||
self.isExpired = isExpired
|
public var storyType: StoryType
|
||||||
|
|
||||||
|
public init(storyType: StoryType) {
|
||||||
|
self.storyType = storyType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,10 +165,13 @@ public class ChatMessageForwardInfoNode: ASDisplayNode {
|
|||||||
titleColor = incoming ? presentationData.theme.theme.chat.message.incoming.accentTextColor : presentationData.theme.theme.chat.message.outgoing.accentTextColor
|
titleColor = incoming ? presentationData.theme.theme.chat.message.incoming.accentTextColor : presentationData.theme.theme.chat.message.outgoing.accentTextColor
|
||||||
|
|
||||||
if let storyData = storyData {
|
if let storyData = storyData {
|
||||||
if storyData.isExpired {
|
switch storyData.storyType {
|
||||||
completeSourceString = strings.Message_ForwardedExpiredStoryShort(peerString)
|
case .regular:
|
||||||
} else {
|
|
||||||
completeSourceString = strings.Message_ForwardedStoryShort(peerString)
|
completeSourceString = strings.Message_ForwardedStoryShort(peerString)
|
||||||
|
case .expired:
|
||||||
|
completeSourceString = strings.Message_ForwardedExpiredStoryShort(peerString)
|
||||||
|
case .unavailable:
|
||||||
|
completeSourceString = strings.Message_ForwardedUnavailableStoryShort(peerString)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
completeSourceString = strings.Message_ForwardedMessageShort(peerString)
|
completeSourceString = strings.Message_ForwardedMessageShort(peerString)
|
||||||
@ -251,9 +260,14 @@ public class ChatMessageForwardInfoNode: ASDisplayNode {
|
|||||||
infoWidth += leftOffset
|
infoWidth += leftOffset
|
||||||
|
|
||||||
var cutout: TextNodeCutout?
|
var cutout: TextNodeCutout?
|
||||||
if let storyData, storyData.isExpired {
|
if let storyData {
|
||||||
|
switch storyData.storyType {
|
||||||
|
case .regular, .unavailable:
|
||||||
|
break
|
||||||
|
case .expired:
|
||||||
cutout = TextNodeCutout(topLeft: CGSize(width: 16.0, height: 10.0))
|
cutout = TextNodeCutout(topLeft: CGSize(width: 16.0, height: 10.0))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (textLayout, textApply) = textNodeLayout(TextNodeLayoutArguments(attributedString: string, backgroundColor: nil, maximumNumberOfLines: 2, truncationType: .end, constrainedSize: CGSize(width: constrainedSize.width - credibilityIconWidth - infoWidth, height: constrainedSize.height), alignment: .natural, cutout: cutout, insets: UIEdgeInsets()))
|
let (textLayout, textApply) = textNodeLayout(TextNodeLayoutArguments(attributedString: string, backgroundColor: nil, maximumNumberOfLines: 2, truncationType: .end, constrainedSize: CGSize(width: constrainedSize.width - credibilityIconWidth - infoWidth, height: constrainedSize.height), alignment: .natural, cutout: cutout, insets: UIEdgeInsets()))
|
||||||
|
|
||||||
@ -273,7 +287,7 @@ public class ChatMessageForwardInfoNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
textNode.frame = CGRect(origin: CGPoint(x: leftOffset, y: 0.0), size: textLayout.size)
|
textNode.frame = CGRect(origin: CGPoint(x: leftOffset, y: 0.0), size: textLayout.size)
|
||||||
|
|
||||||
if let storyData, storyData.isExpired {
|
if let storyData, case .expired = storyData.storyType {
|
||||||
let expiredStoryIconView: UIImageView
|
let expiredStoryIconView: UIImageView
|
||||||
if let current = node.expiredStoryIconView {
|
if let current = node.expiredStoryIconView {
|
||||||
expiredStoryIconView = current
|
expiredStoryIconView = current
|
||||||
|
File diff suppressed because one or more lines are too long
@ -137,6 +137,17 @@ private func contentNodeMessagesAndClassesForItem(_ item: ChatMessageItem) -> ([
|
|||||||
result.append((message, ChatMessageStoryMentionContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .freeform, neighborSpacing: .default)))
|
result.append((message, ChatMessageStoryMentionContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .freeform, neighborSpacing: .default)))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
var hideStory = false
|
||||||
|
if let peer = message.peers[story.storyId.peerId] as? TelegramChannel, peer.username == nil, peer.usernames.isEmpty {
|
||||||
|
switch peer.participationStatus {
|
||||||
|
case .member:
|
||||||
|
break
|
||||||
|
case .kicked, .left:
|
||||||
|
hideStory = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !hideStory {
|
||||||
if let storyItem = message.associatedStories[story.storyId], storyItem.data.isEmpty {
|
if let storyItem = message.associatedStories[story.storyId], storyItem.data.isEmpty {
|
||||||
} else {
|
} else {
|
||||||
result.append((message, ChatMessageMediaBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .media, neighborSpacing: .default)))
|
result.append((message, ChatMessageMediaBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .media, neighborSpacing: .default)))
|
||||||
@ -148,6 +159,7 @@ private func contentNodeMessagesAndClassesForItem(_ item: ChatMessageItem) -> ([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if let file = media as? TelegramMediaFile {
|
} else if let file = media as? TelegramMediaFile {
|
||||||
let isVideo = file.isVideo || (file.isAnimated && file.dimensions != nil)
|
let isVideo = file.isVideo || (file.isAnimated && file.dimensions != nil)
|
||||||
if isVideo {
|
if isVideo {
|
||||||
@ -2049,15 +2061,23 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
|
|
||||||
forwardSource = firstMessage.peers[storyMedia.storyId.peerId]
|
forwardSource = firstMessage.peers[storyMedia.storyId.peerId]
|
||||||
|
|
||||||
var isExpired: Bool = false
|
var storyType: ChatMessageForwardInfoNode.StoryType = .regular
|
||||||
if let storyItem = firstMessage.associatedStories[storyMedia.storyId], storyItem.data.isEmpty {
|
if let storyItem = firstMessage.associatedStories[storyMedia.storyId], storyItem.data.isEmpty {
|
||||||
isExpired = true
|
storyType = .expired
|
||||||
|
}
|
||||||
|
if let peer = firstMessage.peers[storyMedia.storyId.peerId] as? TelegramChannel, peer.username == nil, peer.usernames.isEmpty {
|
||||||
|
switch peer.participationStatus {
|
||||||
|
case .member:
|
||||||
|
break
|
||||||
|
case .kicked, .left:
|
||||||
|
storyType = .unavailable
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sizeAndApply = forwardInfoLayout(item.presentationData, item.presentationData.strings, .bubble(incoming: incoming), forwardSource, nil, nil, ChatMessageForwardInfoNode.StoryData(isExpired: isExpired), CGSize(width: maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, height: CGFloat.greatestFiniteMagnitude))
|
let sizeAndApply = forwardInfoLayout(item.presentationData, item.presentationData.strings, .bubble(incoming: incoming), forwardSource, nil, nil, ChatMessageForwardInfoNode.StoryData(storyType: storyType), CGSize(width: maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, height: CGFloat.greatestFiniteMagnitude))
|
||||||
forwardInfoSizeApply = (sizeAndApply.0, { width in sizeAndApply.1(width) })
|
forwardInfoSizeApply = (sizeAndApply.0, { width in sizeAndApply.1(width) })
|
||||||
|
|
||||||
if isExpired {
|
if storyType != .regular {
|
||||||
headerSize.height += 6.0
|
headerSize.height += 6.0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2065,7 +2085,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
headerSize.width = max(headerSize.width, forwardInfoSizeApply.0.width + bubbleWidthInsets)
|
headerSize.width = max(headerSize.width, forwardInfoSizeApply.0.width + bubbleWidthInsets)
|
||||||
headerSize.height += forwardInfoSizeApply.0.height
|
headerSize.height += forwardInfoSizeApply.0.height
|
||||||
|
|
||||||
if isExpired {
|
if storyType != .regular {
|
||||||
headerSize.height += 16.0
|
headerSize.height += 16.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,10 +138,25 @@ public class ChatMessageReplyInfoNode: ASDisplayNode {
|
|||||||
titleString = arguments.strings.User_DeletedAccount
|
titleString = arguments.strings.User_DeletedAccount
|
||||||
}
|
}
|
||||||
isText = false
|
isText = false
|
||||||
|
|
||||||
|
var hideStory = false
|
||||||
|
if let peer = arguments.parentMessage.peers[story.peerId] as? TelegramChannel, peer.username == nil, peer.usernames.isEmpty {
|
||||||
|
switch peer.participationStatus {
|
||||||
|
case .member:
|
||||||
|
break
|
||||||
|
case .kicked, .left:
|
||||||
|
hideStory = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let storyItem = arguments.parentMessage.associatedStories[story], storyItem.data.isEmpty {
|
if let storyItem = arguments.parentMessage.associatedStories[story], storyItem.data.isEmpty {
|
||||||
isExpiredStory = true
|
isExpiredStory = true
|
||||||
textString = NSAttributedString(string: arguments.strings.Chat_ReplyExpiredStory)
|
textString = NSAttributedString(string: arguments.strings.Chat_ReplyExpiredStory)
|
||||||
isMedia = false
|
isMedia = false
|
||||||
|
} else if hideStory {
|
||||||
|
isExpiredStory = true
|
||||||
|
textString = NSAttributedString(string: arguments.strings.Chat_ReplyStoryPrivateChannel)
|
||||||
|
isMedia = false
|
||||||
} else {
|
} else {
|
||||||
isStory = true
|
isStory = true
|
||||||
textString = NSAttributedString(string: arguments.strings.Chat_ReplyStory)
|
textString = NSAttributedString(string: arguments.strings.Chat_ReplyStory)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user