mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Chat wallpaper improvements
This commit is contained in:
parent
8d53183b65
commit
35c8092a90
@ -425,7 +425,6 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
}
|
||||
|
||||
strongSelf.presentationData = presentationData
|
||||
strongSelf.nativeNode.updateBubbleTheme(bubbleTheme: presentationData.theme, bubbleCorners: presentationData.chatBubbleCorners)
|
||||
|
||||
if let (layout, _) = strongSelf.validLayout {
|
||||
strongSelf.updateMessagesLayout(layout: layout, offset: CGPoint(), transition: .animated(duration: 0.3, curve: .easeInOut))
|
||||
@ -533,7 +532,9 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
|
||||
switch entry {
|
||||
case let .wallpaper(wallpaper, _):
|
||||
self.nativeNode.update(wallpaper: wallpaper)
|
||||
Queue.mainQueue().justDispatch {
|
||||
self.nativeNode.update(wallpaper: wallpaper)
|
||||
}
|
||||
|
||||
if case let .file(file) = wallpaper, file.isPattern {
|
||||
self.nativeNode.isHidden = false
|
||||
@ -559,15 +560,14 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
self.nativeNode.update(wallpaper: wallpaper)
|
||||
self.patternButtonNode.isSelected = false
|
||||
} else {
|
||||
self.nativeNode._internalUpdateIsSettingUpWallpaper()
|
||||
self.nativeNode.isHidden = true
|
||||
self.patternButtonNode.isSelected = false
|
||||
self.playButtonNode.setIcon(self.playButtonRotateImage)
|
||||
}
|
||||
case .asset:
|
||||
self.nativeNode._internalUpdateIsSettingUpWallpaper()
|
||||
|
||||
//self.nativeNode.update(wallpaper: .color(0xff000000))
|
||||
self.nativeNode.isHidden = false
|
||||
self.nativeNode.isHidden = true
|
||||
self.patternButtonNode.isSelected = false
|
||||
self.playButtonNode.setIcon(self.playButtonRotateImage)
|
||||
default:
|
||||
@ -1322,6 +1322,8 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
}
|
||||
|
||||
private func updateMessagesLayout(layout: ContainerViewLayout, offset: CGPoint, transition: ContainedViewLayoutTransition) {
|
||||
self.nativeNode.updateBubbleTheme(bubbleTheme: self.presentationData.theme, bubbleCorners: self.presentationData.chatBubbleCorners)
|
||||
|
||||
var bottomInset: CGFloat = 132.0
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
@ -1468,7 +1470,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
|
||||
if let _ = serviceMessageText, let messageNodes = self.messageNodes, let node = messageNodes.last {
|
||||
if let backgroundNode = node.subnodes?.first?.subnodes?.first?.subnodes?.first?.subnodes?.first, let backdropNode = node.subnodes?.first?.subnodes?.first?.subnodes?.first?.subnodes?.last?.subnodes?.last?.subnodes?.first {
|
||||
backdropNode.isHidden = true
|
||||
backdropNode.isHidden = true
|
||||
let serviceBackgroundFrame = backgroundNode.view.convert(backgroundNode.bounds, to: self.view).offsetBy(dx: 0.0, dy: -1.0).insetBy(dx: 0.0, dy: -1.0)
|
||||
transition.updateFrame(node: self.serviceBackgroundNode, frame: serviceBackgroundFrame)
|
||||
self.serviceBackgroundNode.update(size: serviceBackgroundFrame.size, cornerRadius: serviceBackgroundFrame.height / 2.0, transition: transition)
|
||||
|
@ -423,7 +423,6 @@ final class WallpaperOptionButtonNode: HighlightTrackingButtonNode {
|
||||
|
||||
func setEnabled(_ enabled: Bool) {
|
||||
let alpha: CGFloat = enabled ? 1.0 : 0.4
|
||||
self.backgroundNode.alpha = alpha
|
||||
self.checkNode.alpha = alpha
|
||||
self.colorNode.alpha = alpha
|
||||
self.textNode.alpha = alpha
|
||||
|
@ -164,6 +164,10 @@ func _internal_setExistingChatWallpaper(account: Account, messageId: MessageId,
|
||||
return account.postbox.transaction { transaction -> Peer? in
|
||||
if let peer = transaction.getPeer(messageId.peerId), let message = transaction.getMessage(messageId) {
|
||||
if let action = message.media.first(where: { $0 is TelegramMediaAction }) as? TelegramMediaAction, case let .setChatWallpaper(wallpaper) = action.action {
|
||||
var wallpaper = wallpaper
|
||||
if let settings = settings {
|
||||
wallpaper = wallpaper.withUpdatedSettings(settings)
|
||||
}
|
||||
transaction.updatePeerCachedData(peerIds: Set([peer.id]), update: { _, current in
|
||||
if let current = current as? CachedUserData {
|
||||
return current.withUpdatedWallpaper(wallpaper)
|
||||
|
@ -858,11 +858,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
strongSelf.chatDisplayNode.dismissInput()
|
||||
let wallpaperPreviewController = WallpaperGalleryController(context: strongSelf.context, source: .wallpaper(wallpaper, nil, [], nil, nil, nil), mode: .peer(EnginePeer(peer), true))
|
||||
wallpaperPreviewController.apply = { wallpaper, options, _, _ in
|
||||
let _ = (strongSelf.context.engine.themes.setExistingChatWallpaper(messageId: message.id, settings: nil)
|
||||
|> deliverOnMainQueue).start(completed: { [weak wallpaperPreviewController] in
|
||||
wallpaperPreviewController?.dismiss()
|
||||
})
|
||||
wallpaperPreviewController.apply = { [weak wallpaperPreviewController] entry, options, _, _ in
|
||||
if case let .wallpaper(wallpaper, _) = entry, case let .file(file) = wallpaper, !file.isPattern && options.contains(.blur) {
|
||||
uploadCustomPeerWallpaper(context: strongSelf.context, wallpaper: entry, mode: options, cropRect: nil, brightness: nil, peerId: message.id.peerId, completion: {
|
||||
wallpaperPreviewController?.dismiss()
|
||||
})
|
||||
} else {
|
||||
let _ = (strongSelf.context.engine.themes.setExistingChatWallpaper(messageId: message.id, settings: nil)
|
||||
|> deliverOnMainQueue).start()
|
||||
Queue.mainQueue().after(0.1) {
|
||||
wallpaperPreviewController?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
strongSelf.push(wallpaperPreviewController)
|
||||
return true
|
||||
@ -5861,7 +5868,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
var themeEmoticon = themeEmoticon
|
||||
if let themeEmoticonPreview = themeEmoticonPreview {
|
||||
if !themeEmoticonPreview.isEmpty {
|
||||
if themeEmoticon != themeEmoticonPreview {
|
||||
if themeEmoticon?.strippedEmoji != themeEmoticonPreview.strippedEmoji {
|
||||
chatWallpaper = nil
|
||||
themeEmoticon = themeEmoticonPreview
|
||||
}
|
||||
|
@ -904,8 +904,19 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
||||
return
|
||||
}
|
||||
var dimAlpha: Float = 0.0
|
||||
if case let .file(file) = wallpaper, !file.isPattern {
|
||||
if let intensity = file.settings.intensity, intensity < 100, theme.overallDarkAppearance == true {
|
||||
if theme.overallDarkAppearance == true {
|
||||
var intensity: Int32?
|
||||
switch wallpaper {
|
||||
case let .image(_, settings):
|
||||
intensity = settings.intensity
|
||||
case let .file(file):
|
||||
if !file.isPattern {
|
||||
intensity = file.settings.intensity
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
if let intensity, intensity < 100 {
|
||||
dimAlpha = 1.0 - max(0.0, min(1.0, Float(intensity) / 100.0))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user