mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 01:10:09 +00:00
Chat wallpaper improvements
This commit is contained in:
parent
32de4a1bc7
commit
a9e4419021
@ -131,12 +131,12 @@ func uploadCustomWallpaper(context: AccountContext, wallpaper: WallpaperGalleryE
|
|||||||
|
|
||||||
if let data = croppedImage.jpegData(compressionQuality: 0.8), let thumbnailImage = thumbnailImage, let thumbnailData = thumbnailImage.jpegData(compressionQuality: 0.4) {
|
if let data = croppedImage.jpegData(compressionQuality: 0.8), let thumbnailImage = thumbnailImage, let thumbnailData = thumbnailImage.jpegData(compressionQuality: 0.4) {
|
||||||
let thumbnailResource = LocalFileMediaResource(fileId: Int64.random(in: Int64.min ... Int64.max))
|
let thumbnailResource = LocalFileMediaResource(fileId: Int64.random(in: Int64.min ... Int64.max))
|
||||||
context.sharedContext.accountManager.mediaBox.storeResourceData(thumbnailResource.id, data: thumbnailData)
|
context.sharedContext.accountManager.mediaBox.storeResourceData(thumbnailResource.id, data: thumbnailData, synchronous: true)
|
||||||
context.account.postbox.mediaBox.storeResourceData(thumbnailResource.id, data: thumbnailData)
|
context.account.postbox.mediaBox.storeResourceData(thumbnailResource.id, data: thumbnailData, synchronous: true)
|
||||||
|
|
||||||
let resource = LocalFileMediaResource(fileId: Int64.random(in: Int64.min ... Int64.max))
|
let resource = LocalFileMediaResource(fileId: Int64.random(in: Int64.min ... Int64.max))
|
||||||
context.sharedContext.accountManager.mediaBox.storeResourceData(resource.id, data: data)
|
context.sharedContext.accountManager.mediaBox.storeResourceData(resource.id, data: data, synchronous: true)
|
||||||
context.account.postbox.mediaBox.storeResourceData(resource.id, data: data)
|
context.account.postbox.mediaBox.storeResourceData(resource.id, data: data, synchronous: true)
|
||||||
|
|
||||||
let autoNightModeTriggered = context.sharedContext.currentPresentationData.with {$0 }.autoNightModeTriggered
|
let autoNightModeTriggered = context.sharedContext.currentPresentationData.with {$0 }.autoNightModeTriggered
|
||||||
let accountManager = context.sharedContext.accountManager
|
let accountManager = context.sharedContext.accountManager
|
||||||
@ -203,7 +203,7 @@ public func uploadCustomPeerWallpaper(context: AccountContext, wallpaper: Wallpa
|
|||||||
switch wallpaper {
|
switch wallpaper {
|
||||||
case let .file(file):
|
case let .file(file):
|
||||||
if let path = context.account.postbox.mediaBox.completedResourcePath(file.file.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
if let path = context.account.postbox.mediaBox.completedResourcePath(file.file.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||||
context.sharedContext.accountManager.mediaBox.storeResourceData(file.file.resource.id, data: data)
|
context.sharedContext.accountManager.mediaBox.storeResourceData(file.file.resource.id, data: data, synchronous: true)
|
||||||
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
||||||
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedBlurredWallpaperRepresentation(), complete: true, fetch: true).start()
|
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedBlurredWallpaperRepresentation(), complete: true, fetch: true).start()
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ public func uploadCustomPeerWallpaper(context: AccountContext, wallpaper: Wallpa
|
|||||||
for representation in representations {
|
for representation in representations {
|
||||||
let resource = representation.resource
|
let resource = representation.resource
|
||||||
if let path = context.account.postbox.mediaBox.completedResourcePath(resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
if let path = context.account.postbox.mediaBox.completedResourcePath(resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||||
context.sharedContext.accountManager.mediaBox.storeResourceData(resource.id, data: data)
|
context.sharedContext.accountManager.mediaBox.storeResourceData(resource.id, data: data, synchronous: true)
|
||||||
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -425,6 +425,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strongSelf.presentationData = presentationData
|
strongSelf.presentationData = presentationData
|
||||||
|
strongSelf.nativeNode.updateBubbleTheme(bubbleTheme: presentationData.theme, bubbleCorners: presentationData.chatBubbleCorners)
|
||||||
|
|
||||||
if let (layout, _) = strongSelf.validLayout {
|
if let (layout, _) = strongSelf.validLayout {
|
||||||
strongSelf.updateMessagesLayout(layout: layout, offset: CGPoint(), transition: .animated(duration: 0.3, curve: .easeInOut))
|
strongSelf.updateMessagesLayout(layout: layout, offset: CGPoint(), transition: .animated(duration: 0.3, curve: .easeInOut))
|
||||||
@ -527,6 +528,8 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
let progressAction = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: presentationData.theme.rootController.navigationBar.accentTextColor))
|
let progressAction = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: presentationData.theme.rootController.navigationBar.accentTextColor))
|
||||||
|
|
||||||
var isBlurrable = true
|
var isBlurrable = true
|
||||||
|
|
||||||
|
self.nativeNode.updateBubbleTheme(bubbleTheme: presentationData.theme, bubbleCorners: presentationData.chatBubbleCorners)
|
||||||
|
|
||||||
switch entry {
|
switch entry {
|
||||||
case let .wallpaper(wallpaper, _):
|
case let .wallpaper(wallpaper, _):
|
||||||
@ -562,8 +565,9 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
}
|
}
|
||||||
case .asset:
|
case .asset:
|
||||||
self.nativeNode._internalUpdateIsSettingUpWallpaper()
|
self.nativeNode._internalUpdateIsSettingUpWallpaper()
|
||||||
//self.nativeNode.update(wallpaper: self.presentationData.chatWallpaper)
|
|
||||||
self.nativeNode.isHidden = true
|
//self.nativeNode.update(wallpaper: .color(0xff000000))
|
||||||
|
self.nativeNode.isHidden = false
|
||||||
self.patternButtonNode.isSelected = false
|
self.patternButtonNode.isSelected = false
|
||||||
self.playButtonNode.setIcon(self.playButtonRotateImage)
|
self.playButtonNode.setIcon(self.playButtonRotateImage)
|
||||||
default:
|
default:
|
||||||
@ -571,9 +575,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
self.patternButtonNode.isSelected = false
|
self.patternButtonNode.isSelected = false
|
||||||
self.playButtonNode.setIcon(self.playButtonRotateImage)
|
self.playButtonNode.setIcon(self.playButtonRotateImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.nativeNode.updateBubbleTheme(bubbleTheme: presentationData.theme, bubbleCorners: presentationData.chatBubbleCorners)
|
|
||||||
|
|
||||||
var canShare = false
|
var canShare = false
|
||||||
switch entry {
|
switch entry {
|
||||||
case let .wallpaper(wallpaper, message):
|
case let .wallpaper(wallpaper, message):
|
||||||
@ -814,6 +816,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
self.wrapperNode.addSubnode(self.imageNode)
|
self.wrapperNode.addSubnode(self.imageNode)
|
||||||
self.wrapperNode.addSubnode(self.nativeNode)
|
self.wrapperNode.addSubnode(self.nativeNode)
|
||||||
} else {
|
} else {
|
||||||
|
self.wrapperNode.insertSubnode(self.nativeNode, at: 0)
|
||||||
self.imageNode.contentMode = .scaleToFill
|
self.imageNode.contentMode = .scaleToFill
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -833,6 +836,14 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
}
|
}
|
||||||
strongSelf.blurredNode.image = image
|
strongSelf.blurredNode.image = image
|
||||||
imagePromise.set(.single(image))
|
imagePromise.set(.single(image))
|
||||||
|
|
||||||
|
if case .asset = entry, let image, let data = image.jpegData(compressionQuality: 0.5) {
|
||||||
|
let resource = LocalFileMediaResource(fileId: Int64.random(in: Int64.min ... Int64.max))
|
||||||
|
strongSelf.context.sharedContext.accountManager.mediaBox.storeResourceData(resource.id, data: data, synchronous: true)
|
||||||
|
|
||||||
|
let wallpaper: TelegramWallpaper = .image([TelegramMediaImageRepresentation(dimensions: PixelDimensions(image.size), resource: resource, progressiveSizes: [], immediateThumbnailData: nil, hasVideo: false, isPersonal: false)], WallpaperSettings())
|
||||||
|
strongSelf.nativeNode.update(wallpaper: wallpaper)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.fetchDisposable.set(fetchSignal.start())
|
self.fetchDisposable.set(fetchSignal.start())
|
||||||
@ -1456,7 +1467,8 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let _ = serviceMessageText, let messageNodes = self.messageNodes, let node = messageNodes.last {
|
if let _ = serviceMessageText, let messageNodes = self.messageNodes, let node = messageNodes.last {
|
||||||
if let backgroundNode = node.subnodes?.first?.subnodes?.first?.subnodes?.first?.subnodes?.first {
|
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
|
||||||
let serviceBackgroundFrame = backgroundNode.view.convert(backgroundNode.bounds, to: self.view).offsetBy(dx: 0.0, dy: -1.0).insetBy(dx: 0.0, dy: -1.0)
|
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)
|
transition.updateFrame(node: self.serviceBackgroundNode, frame: serviceBackgroundFrame)
|
||||||
self.serviceBackgroundNode.update(size: serviceBackgroundFrame.size, cornerRadius: serviceBackgroundFrame.height / 2.0, transition: transition)
|
self.serviceBackgroundNode.update(size: serviceBackgroundFrame.size, cornerRadius: serviceBackgroundFrame.height / 2.0, transition: transition)
|
||||||
|
|||||||
@ -18594,12 +18594,15 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var openWallpaperPickerImpl: (() -> Void)?
|
var openWallpaperPickerImpl: (() -> Void)?
|
||||||
let openWallpaperPicker = {
|
let openWallpaperPicker = { [weak self] in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
let controller = wallpaperMediaPickerController(
|
let controller = wallpaperMediaPickerController(
|
||||||
context: strongSelf.context,
|
context: strongSelf.context,
|
||||||
updatedPresentationData: strongSelf.updatedPresentationData,
|
updatedPresentationData: strongSelf.updatedPresentationData,
|
||||||
peer: EnginePeer(peer),
|
peer: EnginePeer(peer),
|
||||||
completion: { asset in
|
completion: { [weak self] asset in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user