mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Wallpaper improvements
This commit is contained in:
@@ -182,7 +182,21 @@ public class ChatMessageWallpaperBubbleContentNode: ChatMessageBubbleContentNode
|
||||
guard let item = self.item else {
|
||||
return
|
||||
}
|
||||
let _ = item.controllerInteraction.openMessage(item.message, OpenMessageParams(mode: .default))
|
||||
|
||||
var canRemove = false
|
||||
if item.message.effectivelyIncoming(item.context.account.peerId) {
|
||||
if let media = item.message.media.first(where: { $0 is TelegramMediaAction }) as? TelegramMediaAction, case let .setChatWallpaper(wallpaper, forBoth) = media.action {
|
||||
if forBoth, item.presentationData.theme.wallpaper.isBasicallyEqual(to: wallpaper) {
|
||||
canRemove = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if canRemove {
|
||||
let _ = item.context.engine.themes.revertChatWallpaper(peerId: item.message.id.peerId).startStandalone()
|
||||
} else {
|
||||
let _ = item.controllerInteraction.openMessage(item.message, OpenMessageParams(mode: .default))
|
||||
}
|
||||
}
|
||||
|
||||
private func updateProgress(_ progress: Float?) {
|
||||
@@ -225,12 +239,14 @@ public class ChatMessageWallpaperBubbleContentNode: ChatMessageBubbleContentNode
|
||||
let primaryTextColor = serviceMessageColorComponents(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper).primaryText
|
||||
|
||||
var wallpaper: TelegramWallpaper?
|
||||
if let media = item.message.media.first(where: { $0 is TelegramMediaAction }) as? TelegramMediaAction, case let .setChatWallpaper(wallpaperValue) = media.action {
|
||||
var forBoth = false
|
||||
if let media = item.message.media.first(where: { $0 is TelegramMediaAction }) as? TelegramMediaAction, case let .setChatWallpaper(wallpaperValue, forBothValue) = media.action {
|
||||
wallpaper = wallpaperValue
|
||||
forBoth = forBothValue
|
||||
}
|
||||
|
||||
var mediaUpdated = true
|
||||
if let wallpaper = wallpaper, let media = currentItem?.message.media.first(where: { $0 is TelegramMediaAction }) as? TelegramMediaAction, case let .setChatWallpaper(currentWallpaper) = media.action {
|
||||
if let wallpaper = wallpaper, let media = currentItem?.message.media.first(where: { $0 is TelegramMediaAction }) as? TelegramMediaAction, case let .setChatWallpaper(currentWallpaper, _) = media.action {
|
||||
mediaUpdated = wallpaper != currentWallpaper
|
||||
}
|
||||
|
||||
@@ -249,7 +265,11 @@ public class ChatMessageWallpaperBubbleContentNode: ChatMessageBubbleContentNode
|
||||
text = item.presentationData.strings.Notification_YouChangingWallpaper
|
||||
displayTrailingAnimatedDots = true
|
||||
} else {
|
||||
text = item.presentationData.strings.Notification_YouChangedWallpaper
|
||||
if forBoth {
|
||||
text = item.presentationData.strings.Notification_YouChangedWallpaperBoth(peerName).string
|
||||
} else {
|
||||
text = item.presentationData.strings.Notification_YouChangedWallpaper
|
||||
}
|
||||
}
|
||||
} else {
|
||||
text = item.presentationData.strings.Notification_ChangedWallpaper(peerName).string
|
||||
@@ -269,7 +289,14 @@ public class ChatMessageWallpaperBubbleContentNode: ChatMessageBubbleContentNode
|
||||
|
||||
let (subtitleLayout, subtitleApply) = makeSubtitleLayout(TextNodeLayoutArguments(attributedString: subtitle, backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: width - 32.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
let (buttonTitleLayout, buttonTitleApply) = makeButtonTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.presentationData.strings.Notification_Wallpaper_View, font: Font.semibold(15.0), textColor: primaryTextColor, paragraphAlignment: .center), backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: width - 32.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
|
||||
let buttonText: String
|
||||
if let wallpaper, forBoth && item.presentationData.theme.wallpaper.isBasicallyEqual(to: wallpaper) {
|
||||
buttonText = "Remove"
|
||||
} else {
|
||||
buttonText = item.presentationData.strings.Notification_Wallpaper_View
|
||||
}
|
||||
|
||||
let (buttonTitleLayout, buttonTitleApply) = makeButtonTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: buttonText, font: Font.semibold(15.0), textColor: primaryTextColor, paragraphAlignment: .center), backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: width - 32.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
var textHeight = subtitleLayout.size.height
|
||||
if displayTrailingAnimatedDots {
|
||||
@@ -463,6 +490,8 @@ public class ChatMessageWallpaperBubbleContentNode: ChatMessageBubbleContentNode
|
||||
override public func tapActionAtPoint(_ point: CGPoint, gesture: TapLongTapOrDoubleTapGesture, isEstimating: Bool) -> ChatMessageBubbleContentTapAction {
|
||||
if self.statusOverlayNode.alpha > 0.0 {
|
||||
return ChatMessageBubbleContentTapAction(content: .none)
|
||||
} else if self.buttonNode.frame.contains(point) {
|
||||
return ChatMessageBubbleContentTapAction(content: .ignore)
|
||||
} else if self.mediaBackgroundNode.frame.contains(point) {
|
||||
return ChatMessageBubbleContentTapAction(content: .openMessage)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user