mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Various improvements
This commit is contained in:
parent
e6ba681c03
commit
7c435bf03e
@ -368,8 +368,8 @@ public final class PrincipalThemeEssentialGraphics {
|
||||
self.mediaSelfExpiringIcon = generateTintedImage(image: selfExpiringImage, color: .white)!
|
||||
self.freeSelfExpiringIcon = generateTintedImage(image: selfExpiringImage, color: serviceColor.primaryText)!
|
||||
|
||||
self.radialIndicatorFileIconIncoming = emptyImage
|
||||
self.radialIndicatorFileIconOutgoing = emptyImage
|
||||
self.radialIndicatorFileIconIncoming = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/RadialProgressIconDocument"), color: .black)!
|
||||
self.radialIndicatorFileIconOutgoing = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/RadialProgressIconDocument"), color: .black)!
|
||||
} else {
|
||||
self.chatMessageBackgroundIncomingMaskImage = messageBubbleImage(maxCornerRadius: maxCornerRadius, minCornerRadius: minCornerRadius, incoming: true, fillColor: .black, strokeColor: .clear, neighbors: .none, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true)
|
||||
self.chatMessageBackgroundIncomingExtractedMaskImage = messageBubbleImage(maxCornerRadius: maxCornerRadius, minCornerRadius: minCornerRadius, incoming: true, fillColor: .black, strokeColor: .clear, neighbors: .extracted, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true)
|
||||
|
@ -86,7 +86,6 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
private let textNode: TextNodeWithEntities
|
||||
private var spoilerTextNode: TextNodeWithEntities?
|
||||
private var dustNode: InvisibleInkDustNode?
|
||||
private var moreNode: TextNode?
|
||||
|
||||
private let textAccessibilityOverlayNode: TextAccessibilityOverlayNode
|
||||
public var statusNode: ChatMessageDateAndStatusNode?
|
||||
@ -167,7 +166,6 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
let textLayout = TextNodeWithEntities.asyncLayout(self.textNode)
|
||||
let spoilerTextLayout = TextNodeWithEntities.asyncLayout(self.spoilerTextNode)
|
||||
let statusLayout = ChatMessageDateAndStatusNode.asyncLayout(self.statusNode)
|
||||
let moreLayout = TextNode.asyncLayout(self.moreNode)
|
||||
|
||||
let currentCachedChatMessageText = self.cachedChatMessageText
|
||||
|
||||
@ -505,28 +503,40 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
}
|
||||
attributedText = updatedString
|
||||
}
|
||||
|
||||
let hideAllAdditionalInfo = item.presentationData.isPreview
|
||||
|
||||
var moreLayoutAndApply: (TextNodeLayout, () -> TextNode)?
|
||||
var cutout: TextNodeCutout? = nil
|
||||
|
||||
var customTruncationToken: NSAttributedString?
|
||||
var maximumNumberOfLines: Int = 0
|
||||
if item.presentationData.isPreview {
|
||||
moreLayoutAndApply = moreLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.presentationData.strings.Conversation_ReadMore, font: textFont, textColor: messageTheme.accentTextColor), maximumNumberOfLines: 1, truncationType: .end, constrainedSize: textConstrainedSize))
|
||||
if let moreSize = moreLayoutAndApply?.0.size {
|
||||
cutout = TextNodeCutout(bottomRight: CGSize(width: moreSize.width + 8.0, height: moreSize.height))
|
||||
if item.message.groupingKey != nil {
|
||||
maximumNumberOfLines = 6
|
||||
} else if let image = item.message.media.first(where: { $0 is TelegramMediaImage }) as? TelegramMediaImage, let dimensions = image.representations.first?.dimensions {
|
||||
if dimensions.width > dimensions.height {
|
||||
maximumNumberOfLines = 9
|
||||
} else {
|
||||
maximumNumberOfLines = 6
|
||||
}
|
||||
} else if let file = item.message.media.first(where: { $0 is TelegramMediaFile }) as? TelegramMediaFile, file.isVideo || file.isAnimated, let dimensions = file.dimensions {
|
||||
if dimensions.width > dimensions.height {
|
||||
maximumNumberOfLines = 9
|
||||
} else {
|
||||
maximumNumberOfLines = 6
|
||||
}
|
||||
} else {
|
||||
maximumNumberOfLines = 12
|
||||
}
|
||||
|
||||
let truncationToken = NSMutableAttributedString()
|
||||
truncationToken.append(NSAttributedString(string: "\u{2026} ", font: textFont, textColor: messageTheme.primaryTextColor))
|
||||
truncationToken.append(NSAttributedString(string: item.presentationData.strings.Conversation_ReadMore, font: textFont, textColor: messageTheme.accentTextColor))
|
||||
customTruncationToken = truncationToken
|
||||
}
|
||||
|
||||
let textInsets = UIEdgeInsets(top: 2.0, left: 2.0, bottom: 5.0, right: 2.0)
|
||||
|
||||
let (textLayout, textApply) = textLayout(TextNodeLayoutArguments(attributedString: attributedText, backgroundColor: nil, maximumNumberOfLines: hideAllAdditionalInfo ? 12 : 0, truncationType: .end, constrainedSize: textConstrainedSize, alignment: .natural, cutout: cutout, insets: textInsets, lineColor: messageTheme.accentControlColor))
|
||||
if !textLayout.truncated {
|
||||
moreLayoutAndApply = nil
|
||||
}
|
||||
let (textLayout, textApply) = textLayout(TextNodeLayoutArguments(attributedString: attributedText, backgroundColor: nil, maximumNumberOfLines: maximumNumberOfLines, truncationType: .end, constrainedSize: textConstrainedSize, alignment: .natural, cutout: nil, insets: textInsets, lineColor: messageTheme.accentControlColor, customTruncationToken: customTruncationToken))
|
||||
|
||||
let spoilerTextLayoutAndApply: (TextNodeLayout, (TextNodeWithEntities.Arguments?) -> TextNodeWithEntities)?
|
||||
if !textLayout.spoilers.isEmpty {
|
||||
spoilerTextLayoutAndApply = spoilerTextLayout(TextNodeLayoutArguments(attributedString: attributedText, backgroundColor: nil, maximumNumberOfLines: hideAllAdditionalInfo ? 12 : 0, truncationType: .end, constrainedSize: textConstrainedSize, alignment: .natural, cutout: cutout, insets: textInsets, lineColor: messageTheme.accentControlColor, displaySpoilers: true, displayEmbeddedItemsUnderSpoilers: true))
|
||||
spoilerTextLayoutAndApply = spoilerTextLayout(TextNodeLayoutArguments(attributedString: attributedText, backgroundColor: nil, maximumNumberOfLines: maximumNumberOfLines, truncationType: .end, constrainedSize: textConstrainedSize, alignment: .natural, cutout: nil, insets: textInsets, lineColor: messageTheme.accentControlColor, displaySpoilers: true, displayEmbeddedItemsUnderSpoilers: true))
|
||||
} else {
|
||||
spoilerTextLayoutAndApply = nil
|
||||
}
|
||||
@ -546,12 +556,12 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
}
|
||||
|
||||
let dateLayoutInput: ChatMessageDateAndStatusNode.LayoutInput
|
||||
dateLayoutInput = .trailingContent(contentWidth: trailingWidthToMeasure, reactionSettings: hideAllAdditionalInfo ? nil : ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions), preferAdditionalInset: false))
|
||||
dateLayoutInput = .trailingContent(contentWidth: trailingWidthToMeasure, reactionSettings: item.presentationData.isPreview ? nil : ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions), preferAdditionalInset: false))
|
||||
|
||||
statusSuggestedWidthAndContinue = statusLayout(ChatMessageDateAndStatusNode.Arguments(
|
||||
context: item.context,
|
||||
presentationData: item.presentationData,
|
||||
edited: edited && !hideAllAdditionalInfo,
|
||||
edited: edited && !item.presentationData.isPreview,
|
||||
impressionCount: viewCount,
|
||||
dateText: dateText,
|
||||
type: statusType,
|
||||
@ -575,14 +585,6 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
|
||||
textFrame = textFrame.offsetBy(dx: layoutConstants.text.bubbleInsets.left, dy: topInset)
|
||||
textFrameWithoutInsets = textFrameWithoutInsets.offsetBy(dx: layoutConstants.text.bubbleInsets.left, dy: topInset)
|
||||
|
||||
var readMoreFrame: CGRect = .zero
|
||||
if let (readMoreLayout, _ ) = moreLayoutAndApply {
|
||||
let remainingLineWidth = textLayout.size.width - textLayout.trailingLineWidth
|
||||
if readMoreLayout.size.width < remainingLineWidth {
|
||||
readMoreFrame = CGRect(origin: CGPoint(x: textFrame.maxX - readMoreLayout.size.width - textInsets.right, y: textFrame.maxY - readMoreLayout.size.height - textInsets.bottom), size: readMoreLayout.size)
|
||||
}
|
||||
}
|
||||
|
||||
var suggestedBoundingWidth: CGFloat = textFrameWithoutInsets.width
|
||||
if let statusSuggestedWidthAndContinue = statusSuggestedWidthAndContinue {
|
||||
@ -674,19 +676,6 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
}
|
||||
}
|
||||
|
||||
if let (_, moreApply) = moreLayoutAndApply {
|
||||
let moreNode = moreApply()
|
||||
if strongSelf.moreNode == nil {
|
||||
moreNode.displaysAsynchronously = false
|
||||
strongSelf.moreNode = moreNode
|
||||
strongSelf.containerNode.insertSubnode(moreNode, aboveSubnode: strongSelf.textNode.textNode)
|
||||
}
|
||||
moreNode.frame = readMoreFrame
|
||||
} else if let moreNode = strongSelf.moreNode {
|
||||
strongSelf.moreNode = nil
|
||||
moreNode.removeFromSupernode()
|
||||
}
|
||||
|
||||
switch strongSelf.visibility {
|
||||
case .none:
|
||||
strongSelf.textNode.visibilityRect = nil
|
||||
|
@ -109,7 +109,7 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
|
||||
if case let .file(_, type) = self.content, case .reaction = type {
|
||||
self.scale = max(0.59, min(1.77, self.scale))
|
||||
} else if case .message = self.content {
|
||||
self.scale = max(1.0, min(4.0, self.scale))
|
||||
self.scale = max(2.5, self.scale)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2438,7 +2438,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
messageEntity.position = CGPoint(x: storyDimensions.width / 2.0, y: storyDimensions.height / 2.0)
|
||||
|
||||
let fraction = max(size.width, size.height) / 353.0
|
||||
messageEntity.scale = 3.3 * fraction
|
||||
messageEntity.scale = min(6.0, 3.3 * fraction)
|
||||
|
||||
self.entitiesView.add(messageEntity, announce: false)
|
||||
|
||||
@ -2698,8 +2698,14 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
}
|
||||
}
|
||||
|
||||
private var enhanceInitialTranslation: Float?
|
||||
private var canEnhance: Bool {
|
||||
if case .message = self.subject {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private var enhanceInitialTranslation: Float?
|
||||
@objc func handleDismissPan(_ gestureRecognizer: UIPanGestureRecognizer) {
|
||||
guard let controller = self.controller, let layout = self.validLayout, (layout.inputHeight ?? 0.0).isZero else {
|
||||
return
|
||||
@ -2724,7 +2730,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
self.isDismissBySwipeSuppressed = controller.isEligibleForDraft()
|
||||
controller.requestLayout(transition: .animated(duration: 0.25, curve: .easeInOut))
|
||||
}
|
||||
} else if abs(translation.x) > 10.0 && !self.isDismissing && !self.isEnhancing {
|
||||
} else if abs(translation.x) > 10.0 && !self.isDismissing && !self.isEnhancing && self.canEnhance {
|
||||
self.isEnhancing = true
|
||||
controller.requestLayout(transition: .animated(duration: 0.3, curve: .easeInOut))
|
||||
}
|
||||
@ -2770,7 +2776,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
self.isDismissing = false
|
||||
controller.requestLayout(transition: .animated(duration: 0.4, curve: .spring))
|
||||
}
|
||||
} else {
|
||||
} else if self.isEnhancing {
|
||||
self.isEnhancing = false
|
||||
Queue.mainQueue().after(0.5) {
|
||||
controller.requestLayout(transition: .animated(duration: 0.3, curve: .easeInOut))
|
||||
@ -4008,7 +4014,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
if self.entitiesView.hasSelection {
|
||||
self.entitiesView.selectEntity(nil)
|
||||
}
|
||||
let controller = MediaToolsScreen(context: self.context, mediaEditor: mediaEditor)
|
||||
let controller = MediaToolsScreen(context: self.context, mediaEditor: mediaEditor, hiddenTools: !self.canEnhance ? [.enhance] : [])
|
||||
controller.dismissed = { [weak self] in
|
||||
if let self {
|
||||
self.animateInFromTool()
|
||||
|
@ -127,17 +127,20 @@ private final class MediaToolsScreenComponent: Component {
|
||||
let context: AccountContext
|
||||
let mediaEditor: MediaEditor
|
||||
let section: MediaToolsSection
|
||||
let hiddenTools: [EditorToolKey]
|
||||
let sectionUpdated: (MediaToolsSection) -> Void
|
||||
|
||||
init(
|
||||
context: AccountContext,
|
||||
mediaEditor: MediaEditor,
|
||||
section: MediaToolsSection,
|
||||
hiddenTools: [EditorToolKey],
|
||||
sectionUpdated: @escaping (MediaToolsSection) -> Void
|
||||
) {
|
||||
self.context = context
|
||||
self.mediaEditor = mediaEditor
|
||||
self.section = section
|
||||
self.hiddenTools = hiddenTools
|
||||
self.sectionUpdated = sectionUpdated
|
||||
}
|
||||
|
||||
@ -148,6 +151,9 @@ private final class MediaToolsScreenComponent: Component {
|
||||
if lhs.section != rhs.section {
|
||||
return false
|
||||
}
|
||||
if lhs.hiddenTools != rhs.hiddenTools {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@ -362,7 +368,6 @@ private final class MediaToolsScreenComponent: Component {
|
||||
if availableSize.height < previewSize.height + 30.0 {
|
||||
topInset = 0.0
|
||||
controlsBottomInset = -75.0
|
||||
// self.buttonsBackgroundView.backgroundColor = .black
|
||||
} else {
|
||||
self.buttonsBackgroundView.backgroundColor = .clear
|
||||
}
|
||||
@ -658,6 +663,8 @@ private final class MediaToolsScreenComponent: Component {
|
||||
// )
|
||||
]
|
||||
|
||||
tools = tools.filter { !component.hiddenTools.contains($0.key) }
|
||||
|
||||
if !component.mediaEditor.sourceIsVideo {
|
||||
tools.insert(AdjustmentTool(
|
||||
key: .grain,
|
||||
@ -1044,6 +1051,7 @@ public final class MediaToolsScreen: ViewController {
|
||||
context: self.context,
|
||||
mediaEditor: controller.mediaEditor,
|
||||
section: self.currentSection,
|
||||
hiddenTools: controller.hiddenTools,
|
||||
sectionUpdated: { [weak self] section in
|
||||
if let self {
|
||||
self.currentSection = section
|
||||
@ -1087,15 +1095,17 @@ public final class MediaToolsScreen: ViewController {
|
||||
}
|
||||
|
||||
fileprivate let context: AccountContext
|
||||
fileprivate let hiddenTools: [EditorToolKey]
|
||||
fileprivate let mediaEditor: MediaEditor
|
||||
|
||||
public var dismissed: () -> Void = {}
|
||||
|
||||
private var initialValues: MediaEditorValues
|
||||
|
||||
public init(context: AccountContext, mediaEditor: MediaEditor) {
|
||||
public init(context: AccountContext, mediaEditor: MediaEditor, hiddenTools: [EditorToolKey]) {
|
||||
self.context = context
|
||||
self.mediaEditor = mediaEditor
|
||||
self.hiddenTools = hiddenTools
|
||||
self.initialValues = mediaEditor.values.makeCopy()
|
||||
|
||||
super.init(navigationBarPresentationData: nil)
|
||||
|
@ -2422,6 +2422,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
let shareController = ShareController(context: strongSelf.context, subject: .messages(messages), updatedPresentationData: strongSelf.updatedPresentationData, shareAsLink: true)
|
||||
|
||||
var canShareToStory = true
|
||||
if let message = messages.first, message.media.contains(where: { media in
|
||||
if media is TelegramMediaContact || media is TelegramMediaPoll {
|
||||
return true
|
||||
@ -2431,7 +2432,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return false
|
||||
}
|
||||
}) {
|
||||
} else {
|
||||
canShareToStory = false
|
||||
}
|
||||
if message.text.containsOnlyEmoji {
|
||||
canShareToStory = false
|
||||
}
|
||||
|
||||
if canShareToStory {
|
||||
shareController.shareStory = { [weak self] in
|
||||
guard let self else {
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user