mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Chat wallpaper fixes
This commit is contained in:
parent
293e7b7578
commit
888ec6b5cc
@ -183,6 +183,7 @@ public class AttachmentController: ViewController {
|
|||||||
private let fromMenu: Bool
|
private let fromMenu: Bool
|
||||||
private let hasTextInput: Bool
|
private let hasTextInput: Bool
|
||||||
private let makeEntityInputView: () -> AttachmentTextInputPanelInputView?
|
private let makeEntityInputView: () -> AttachmentTextInputPanelInputView?
|
||||||
|
public var animateAppearance: Bool = false
|
||||||
|
|
||||||
public var willDismiss: () -> Void = {}
|
public var willDismiss: () -> Void = {}
|
||||||
public var didDismiss: () -> Void = {}
|
public var didDismiss: () -> Void = {}
|
||||||
@ -619,14 +620,26 @@ public class AttachmentController: ViewController {
|
|||||||
|
|
||||||
private var animating = false
|
private var animating = false
|
||||||
func animateIn() {
|
func animateIn() {
|
||||||
guard let layout = self.validLayout else {
|
guard let layout = self.validLayout, let controller = self.controller else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
self.animating = true
|
self.animating = true
|
||||||
if case .regular = layout.metrics.widthClass {
|
if case .regular = layout.metrics.widthClass {
|
||||||
self.animating = false
|
if controller.animateAppearance {
|
||||||
|
let targetPosition = self.position
|
||||||
|
let startPosition = targetPosition.offsetBy(dx: 0.0, dy: layout.size.height)
|
||||||
|
|
||||||
|
self.position = startPosition
|
||||||
|
let transition = ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring)
|
||||||
|
transition.animateView(allowUserInteraction: true, {
|
||||||
|
self.position = targetPosition
|
||||||
|
}, completion: { _ in
|
||||||
|
self.animating = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
self.animating = false
|
||||||
|
}
|
||||||
ContainedViewLayoutTransition.animated(duration: 0.3, curve: .linear).updateAlpha(node: self.dim, alpha: 0.1)
|
ContainedViewLayoutTransition.animated(duration: 0.3, curve: .linear).updateAlpha(node: self.dim, alpha: 0.1)
|
||||||
} else {
|
} else {
|
||||||
ContainedViewLayoutTransition.animated(duration: 0.3, curve: .linear).updateAlpha(node: self.dim, alpha: 1.0)
|
ContainedViewLayoutTransition.animated(duration: 0.3, curve: .linear).updateAlpha(node: self.dim, alpha: 1.0)
|
||||||
|
@ -1469,7 +1469,7 @@ final class AttachmentPanel: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let bounds = CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: buttonSize.height + insets.bottom))
|
let bounds = CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: buttonSize.height + insets.bottom))
|
||||||
let containerTransition: ContainedViewLayoutTransition
|
var containerTransition: ContainedViewLayoutTransition
|
||||||
let containerFrame: CGRect
|
let containerFrame: CGRect
|
||||||
if isButtonVisible {
|
if isButtonVisible {
|
||||||
var height: CGFloat
|
var height: CGFloat
|
||||||
@ -1520,6 +1520,10 @@ final class AttachmentPanel: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.containerNode.frame.size.width.isZero {
|
||||||
|
containerTransition = .immediate
|
||||||
|
}
|
||||||
|
|
||||||
containerTransition.updateFrame(node: self.containerNode, frame: containerFrame)
|
containerTransition.updateFrame(node: self.containerNode, frame: containerFrame)
|
||||||
containerTransition.updateFrame(node: self.backgroundNode, frame: containerBounds)
|
containerTransition.updateFrame(node: self.backgroundNode, frame: containerBounds)
|
||||||
self.backgroundNode.update(size: containerBounds.size, transition: transition)
|
self.backgroundNode.update(size: containerBounds.size, transition: transition)
|
||||||
|
@ -585,7 +585,7 @@ public final class GalleryPagerNode: ASDisplayNode, UIScrollViewDelegate, UIGest
|
|||||||
let node = self.itemNodes[i]
|
let node = self.itemNodes[i]
|
||||||
transition.updateFrame(node: node, frame: CGRect(origin: CGPoint(x: CGFloat(i) * self.scrollView.bounds.size.width + self.pageGap, y: 0.0), size: CGSize(width: self.scrollView.bounds.size.width - self.pageGap * 2.0, height: self.scrollView.bounds.size.height)))
|
transition.updateFrame(node: node, frame: CGRect(origin: CGPoint(x: CGFloat(i) * self.scrollView.bounds.size.width + self.pageGap, y: 0.0), size: CGSize(width: self.scrollView.bounds.size.width - self.pageGap * 2.0, height: self.scrollView.bounds.size.height)))
|
||||||
|
|
||||||
let screenFrame = node.convert(node.bounds, to: self.supernode)
|
let screenFrame = node.view.convert(node.view.bounds, to: self.view.superview)
|
||||||
node.screenFrameUpdated(screenFrame)
|
node.screenFrameUpdated(screenFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2022,12 +2022,14 @@ public func wallpaperMediaPickerController(
|
|||||||
context: AccountContext,
|
context: AccountContext,
|
||||||
updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil,
|
updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil,
|
||||||
peer: EnginePeer,
|
peer: EnginePeer,
|
||||||
|
animateAppearance: Bool,
|
||||||
completion: @escaping (PHAsset) -> Void = { _ in },
|
completion: @escaping (PHAsset) -> Void = { _ in },
|
||||||
openColors: @escaping () -> Void
|
openColors: @escaping () -> Void
|
||||||
) -> ViewController {
|
) -> ViewController {
|
||||||
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: nil, buttons: [.standalone], initialButton: .standalone, fromMenu: false, hasTextInput: false, makeEntityInputView: {
|
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: nil, buttons: [.standalone], initialButton: .standalone, fromMenu: false, hasTextInput: false, makeEntityInputView: {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
controller.animateAppearance = animateAppearance
|
||||||
//controller.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
|
//controller.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
|
||||||
controller.requestController = { [weak controller] _, present in
|
controller.requestController = { [weak controller] _, present in
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
@ -119,11 +119,8 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
} else {
|
} else {
|
||||||
self.navigationItem.titleView = self.segmentedTitleView
|
self.navigationItem.titleView = self.segmentedTitleView
|
||||||
}
|
}
|
||||||
if case .peer = resultMode {
|
|
||||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
|
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
|
||||||
} else {
|
|
||||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: UIView())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required init(coder aDecoder: NSCoder) {
|
required init(coder aDecoder: NSCoder) {
|
||||||
|
@ -313,6 +313,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
doneButtonType = .set
|
doneButtonType = .set
|
||||||
}
|
}
|
||||||
self.toolbarNode = WallpaperGalleryToolbarNode(theme: self.theme, strings: self.presentationData.strings, doneButtonType: doneButtonType)
|
self.toolbarNode = WallpaperGalleryToolbarNode(theme: self.theme, strings: self.presentationData.strings, doneButtonType: doneButtonType)
|
||||||
|
self.toolbarNode.dark = true
|
||||||
self.toolbarNode.setDoneIsSolid(true, transition: .immediate)
|
self.toolbarNode.setDoneIsSolid(true, transition: .immediate)
|
||||||
|
|
||||||
self.maskNode = ASImageNode()
|
self.maskNode = ASImageNode()
|
||||||
@ -1177,12 +1178,16 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
let colorPanelHeight = max(standardInputHeight, layout.inputHeight ?? 0.0) - bottomInset + inputFieldPanelHeight
|
let colorPanelHeight = max(standardInputHeight, layout.inputHeight ?? 0.0) - bottomInset + inputFieldPanelHeight
|
||||||
|
|
||||||
var colorPanelOffset: CGFloat = 0.0
|
var colorPanelOffset: CGFloat = 0.0
|
||||||
|
var colorPanelY = layout.size.height - bottomInset - colorPanelHeight
|
||||||
if self.state.colorPanelCollapsed {
|
if self.state.colorPanelCollapsed {
|
||||||
colorPanelOffset = colorPanelHeight
|
colorPanelOffset = colorPanelHeight
|
||||||
|
colorPanelY = layout.size.height
|
||||||
}
|
}
|
||||||
let colorPanelFrame = CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - bottomInset - colorPanelHeight + colorPanelOffset), size: CGSize(width: layout.size.width, height: colorPanelHeight))
|
let colorPanelFrame = CGRect(origin: CGPoint(x: 0.0, y: colorPanelY), size: CGSize(width: layout.size.width, height: colorPanelHeight))
|
||||||
bottomInset += (colorPanelHeight - colorPanelOffset)
|
bottomInset += (colorPanelHeight - colorPanelOffset)
|
||||||
|
|
||||||
|
self.toolbarNode.setDoneIsSolid(!self.state.colorPanelCollapsed, transition: transition)
|
||||||
|
|
||||||
if bottomInset + navigationBarHeight > bounds.height {
|
if bottomInset + navigationBarHeight > bounds.height {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ public final class ThemeColorsGridController: ViewController, AttachmentContaina
|
|||||||
|
|
||||||
private var previousContentOffset: GridNodeVisibleContentOffset?
|
private var previousContentOffset: GridNodeVisibleContentOffset?
|
||||||
|
|
||||||
fileprivate let mainButtonStatePromise = Promise<AttachmentMainButtonState?>(nil)
|
fileprivate var mainButtonState: AttachmentMainButtonState?
|
||||||
|
|
||||||
var pushController: (ViewController) -> Void = { _ in }
|
var pushController: (ViewController) -> Void = { _ in }
|
||||||
var dismissControllers: (() -> Void)?
|
var dismissControllers: (() -> Void)?
|
||||||
@ -193,7 +193,7 @@ public final class ThemeColorsGridController: ViewController, AttachmentContaina
|
|||||||
self?.push(controller)
|
self?.push(controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.mainButtonStatePromise.set(.single(AttachmentMainButtonState(text: self.presentationData.strings.Conversation_Theme_SetPhotoWallpaper, font: .regular, background: .color(.clear), textColor: self.presentationData.theme.actionSheet.controlAccentColor, isVisible: true, progress: .none, isEnabled: true)))
|
self.mainButtonState = AttachmentMainButtonState(text: self.presentationData.strings.Conversation_Theme_SetPhotoWallpaper, font: .regular, background: .color(.clear), textColor: self.presentationData.theme.actionSheet.controlAccentColor, isVisible: true, progress: .none, isEnabled: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(coder aDecoder: NSCoder) {
|
required public init(coder aDecoder: NSCoder) {
|
||||||
@ -362,7 +362,7 @@ private final class ThemeColorsGridContext: AttachmentMediaPickerContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public var mainButtonState: Signal<AttachmentMainButtonState?, NoError> {
|
public var mainButtonState: Signal<AttachmentMainButtonState?, NoError> {
|
||||||
return self.controller?.mainButtonStatePromise.get() ?? .single(nil)
|
return .single(self.controller?.mainButtonState)
|
||||||
}
|
}
|
||||||
|
|
||||||
init(controller: ThemeColorsGridController) {
|
init(controller: ThemeColorsGridController) {
|
||||||
|
@ -960,8 +960,8 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
var image = isBlurrable ? image : nil
|
var image = isBlurrable ? image : nil
|
||||||
if let imageToScale = image {
|
if let imageToScale = image {
|
||||||
let actualSize = CGSize(width: imageToScale.size.width * imageToScale.scale, height: imageToScale.size.height * imageToScale.scale)
|
let actualSize = CGSize(width: imageToScale.size.width * imageToScale.scale, height: imageToScale.size.height * imageToScale.scale)
|
||||||
if actualSize.width > 1280.0 || actualSize.height > 1280.0 {
|
if actualSize.width > 960.0 || actualSize.height > 960.0 {
|
||||||
image = TGScaleImageToPixelSize(image, actualSize.fitted(CGSize(width: 1280.0, height: 1280.0)))
|
image = TGScaleImageToPixelSize(image, actualSize.fitted(CGSize(width: 960.0, height: 960.0)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strongSelf.blurredNode.image = image
|
strongSelf.blurredNode.image = image
|
||||||
@ -1092,11 +1092,15 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleBlur() {
|
@objc func toggleBlur() {
|
||||||
|
guard !self.animatingBlur else {
|
||||||
|
return
|
||||||
|
}
|
||||||
let value = !self.blurButtonNode.isSelected
|
let value = !self.blurButtonNode.isSelected
|
||||||
self.blurButtonNode.setSelected(value, animated: true)
|
self.blurButtonNode.setSelected(value, animated: true)
|
||||||
self.setBlurEnabled(value, animated: true)
|
self.setBlurEnabled(value, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var animatingBlur = false
|
||||||
func setBlurEnabled(_ enabled: Bool, animated: Bool) {
|
func setBlurEnabled(_ enabled: Bool, animated: Bool) {
|
||||||
let blurRadius: CGFloat = 30.0
|
let blurRadius: CGFloat = 30.0
|
||||||
|
|
||||||
@ -1114,19 +1118,24 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if animated {
|
if animated {
|
||||||
|
self.animatingBlur = true
|
||||||
self.blurredNode.blurView.blurRadius = 0.0
|
self.blurredNode.blurView.blurRadius = 0.0
|
||||||
UIView.animate(withDuration: 0.3, delay: 0.0, options: UIView.AnimationOptions(rawValue: 7 << 16), animations: {
|
UIView.animate(withDuration: 0.3, delay: 0.0, options: UIView.AnimationOptions(rawValue: 7 << 16), animations: {
|
||||||
self.blurredNode.blurView.blurRadius = blurRadius
|
self.blurredNode.blurView.blurRadius = blurRadius
|
||||||
}, completion: nil)
|
}, completion: { _ in
|
||||||
|
self.animatingBlur = false
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
self.blurredNode.blurView.blurRadius = blurRadius
|
self.blurredNode.blurView.blurRadius = blurRadius
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if self.blurredNode.supernode != nil {
|
if self.blurredNode.supernode != nil {
|
||||||
if animated {
|
if animated {
|
||||||
|
self.animatingBlur = true
|
||||||
UIView.animate(withDuration: 0.3, delay: 0.0, options: UIView.AnimationOptions(rawValue: 7 << 16), animations: {
|
UIView.animate(withDuration: 0.3, delay: 0.0, options: UIView.AnimationOptions(rawValue: 7 << 16), animations: {
|
||||||
self.blurredNode.blurView.blurRadius = 0.0
|
self.blurredNode.blurView.blurRadius = 0.0
|
||||||
}, completion: { finished in
|
}, completion: { finished in
|
||||||
|
self.animatingBlur = false
|
||||||
if finished {
|
if finished {
|
||||||
self.blurredNode.removeFromSupernode()
|
self.blurredNode.removeFromSupernode()
|
||||||
}
|
}
|
||||||
|
@ -18543,6 +18543,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func presentThemeSelection() {
|
public func presentThemeSelection() {
|
||||||
|
guard self.themeScreen == nil else {
|
||||||
|
return
|
||||||
|
}
|
||||||
let context = self.context
|
let context = self.context
|
||||||
let peerId = self.chatLocation.peerId
|
let peerId = self.chatLocation.peerId
|
||||||
|
|
||||||
@ -18618,8 +18621,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
navigationController.setViewControllers(controllers, animated: true)
|
navigationController.setViewControllers(controllers, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var openWallpaperPickerImpl: (() -> Void)?
|
var openWallpaperPickerImpl: ((Bool) -> Void)?
|
||||||
let openWallpaperPicker = { [weak self] in
|
let openWallpaperPicker = { [weak self] animateAppearance in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -18627,6 +18630,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
context: strongSelf.context,
|
context: strongSelf.context,
|
||||||
updatedPresentationData: strongSelf.updatedPresentationData,
|
updatedPresentationData: strongSelf.updatedPresentationData,
|
||||||
peer: EnginePeer(peer),
|
peer: EnginePeer(peer),
|
||||||
|
animateAppearance: animateAppearance,
|
||||||
completion: { [weak self] asset in
|
completion: { [weak self] asset in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
@ -18636,8 +18640,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
controller.apply = { [weak self] wallpaper, options, editedImage, cropRect, brightness in
|
controller.apply = { [weak self] wallpaper, options, editedImage, cropRect, brightness in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
uploadCustomPeerWallpaper(context: strongSelf.context, wallpaper: wallpaper, mode: options, editedImage: editedImage, cropRect: cropRect, brightness: brightness, peerId: peerId, completion: {
|
uploadCustomPeerWallpaper(context: strongSelf.context, wallpaper: wallpaper, mode: options, editedImage: editedImage, cropRect: cropRect, brightness: brightness, peerId: peerId, completion: {
|
||||||
|
Queue.mainQueue().after(0.3, {
|
||||||
dismissControllers()
|
dismissControllers()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strongSelf.push(controller)
|
strongSelf.push(controller)
|
||||||
@ -18651,7 +18657,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
strongSelf.push(controller)
|
strongSelf.push(controller)
|
||||||
}
|
}
|
||||||
}, openGallery: {
|
}, openGallery: {
|
||||||
openWallpaperPickerImpl?()
|
openWallpaperPickerImpl?(false)
|
||||||
})
|
})
|
||||||
controller.navigationPresentation = .flatModal
|
controller.navigationPresentation = .flatModal
|
||||||
strongSelf.push(controller)
|
strongSelf.push(controller)
|
||||||
@ -18661,7 +18667,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
strongSelf.push(controller)
|
strongSelf.push(controller)
|
||||||
}
|
}
|
||||||
openWallpaperPickerImpl = openWallpaperPicker
|
openWallpaperPickerImpl = openWallpaperPicker
|
||||||
openWallpaperPicker()
|
openWallpaperPicker(true)
|
||||||
},
|
},
|
||||||
resetWallpaper: { [weak self] in
|
resetWallpaper: { [weak self] in
|
||||||
guard let strongSelf = self, let peerId else {
|
guard let strongSelf = self, let peerId else {
|
||||||
|
@ -286,14 +286,37 @@ class ChatMessageWallpaperBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
let boundingSize = imageSize
|
let boundingSize = imageSize
|
||||||
var imageSize = boundingSize
|
var imageSize = boundingSize
|
||||||
let updateImageSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>
|
let updateImageSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>
|
||||||
|
var patternArguments: PatternWallpaperArguments?
|
||||||
switch media.content {
|
switch media.content {
|
||||||
case let .file(file, _, _, _, _, _):
|
case let .file(file, patternColors, rotation, intensity, _, _):
|
||||||
var representations: [ImageRepresentationWithReference] = file.previewRepresentations.map({ ImageRepresentationWithReference(representation: $0, reference: AnyMediaReference.message(message: MessageReference(item.message), media: file).resourceReference($0.resource)) })
|
var representations: [ImageRepresentationWithReference] = file.previewRepresentations.map({ ImageRepresentationWithReference(representation: $0, reference: AnyMediaReference.message(message: MessageReference(item.message), media: file).resourceReference($0.resource)) })
|
||||||
if file.mimeType == "image/svg+xml" || file.mimeType == "application/x-tgwallpattern" {
|
if file.mimeType == "image/svg+xml" || file.mimeType == "application/x-tgwallpattern" {
|
||||||
representations.append(ImageRepresentationWithReference(representation: .init(dimensions: PixelDimensions(width: 1440, height: 2960), resource: file.resource, progressiveSizes: [], immediateThumbnailData: nil, hasVideo: false, isPersonal: false), reference: AnyMediaReference.message(message: MessageReference(item.message), media: file).resourceReference(file.resource)))
|
representations.append(ImageRepresentationWithReference(representation: .init(dimensions: PixelDimensions(width: 1440, height: 2960), resource: file.resource, progressiveSizes: [], immediateThumbnailData: nil, hasVideo: false, isPersonal: false), reference: AnyMediaReference.message(message: MessageReference(item.message), media: file).resourceReference(file.resource)))
|
||||||
|
|
||||||
|
var colors: [UIColor] = []
|
||||||
|
var customPatternColor: UIColor? = nil
|
||||||
|
var bakePatternAlpha: CGFloat = 1.0
|
||||||
|
if let intensity = intensity, intensity < 0 {
|
||||||
|
if patternColors.isEmpty {
|
||||||
|
colors.append(UIColor(rgb: 0xd6e2ee, alpha: 0.5))
|
||||||
|
} else {
|
||||||
|
colors.append(contentsOf: patternColors.map(UIColor.init(rgb:)))
|
||||||
|
}
|
||||||
|
customPatternColor = UIColor(white: 0.0, alpha: 1.0 - CGFloat(abs(intensity)))
|
||||||
|
} else {
|
||||||
|
if patternColors.isEmpty {
|
||||||
|
colors.append(UIColor(rgb: 0xd6e2ee, alpha: 0.5))
|
||||||
|
} else {
|
||||||
|
colors.append(contentsOf: patternColors.map(UIColor.init(rgb:)))
|
||||||
|
}
|
||||||
|
let isLight = UIColor.average(of: patternColors.map(UIColor.init(rgb:))).hsb.b > 0.3
|
||||||
|
customPatternColor = isLight ? .black : .white
|
||||||
|
bakePatternAlpha = CGFloat(intensity ?? 50) / 100.0
|
||||||
|
}
|
||||||
|
patternArguments = PatternWallpaperArguments(colors: colors, rotation: rotation, customPatternColor: customPatternColor, bakePatternAlpha: bakePatternAlpha)
|
||||||
}
|
}
|
||||||
if ["image/png", "image/svg+xml", "application/x-tgwallpattern"].contains(file.mimeType) {
|
if ["image/png", "image/svg+xml", "application/x-tgwallpattern"].contains(file.mimeType) {
|
||||||
updateImageSignal = patternWallpaperImage(account: item.context.account, accountManager: item.context.sharedContext.accountManager, representations: representations, mode: .screen)
|
updateImageSignal = patternWallpaperImage(account: item.context.account, accountManager: item.context.sharedContext.accountManager, representations: representations, mode: .thumbnail)
|
||||||
|> mapToSignal { value -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> in
|
|> mapToSignal { value -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> in
|
||||||
if let value {
|
if let value {
|
||||||
return .single(value)
|
return .single(value)
|
||||||
@ -322,7 +345,7 @@ class ChatMessageWallpaperBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
|
|
||||||
strongSelf.imageNode.setSignal(updateImageSignal, attemptSynchronously: synchronousLoads)
|
strongSelf.imageNode.setSignal(updateImageSignal, attemptSynchronously: synchronousLoads)
|
||||||
|
|
||||||
let arguments = TransformImageArguments(corners: ImageCorners(radius: boundingSize.width / 2.0), imageSize: imageSize, boundingSize: boundingSize, intrinsicInsets: UIEdgeInsets())
|
let arguments = TransformImageArguments(corners: ImageCorners(radius: boundingSize.width / 2.0), imageSize: imageSize, boundingSize: boundingSize, intrinsicInsets: UIEdgeInsets(), custom: patternArguments)
|
||||||
let apply = makeImageLayout(arguments)
|
let apply = makeImageLayout(arguments)
|
||||||
apply()
|
apply()
|
||||||
|
|
||||||
|
@ -4763,8 +4763,8 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let user = peer as? TelegramUser {
|
if let user = peer as? TelegramUser {
|
||||||
if user.botInfo == nil && strongSelf.data?.encryptionKeyFingerprint == nil {
|
if user.botInfo == nil && strongSelf.data?.encryptionKeyFingerprint == nil && !user.isDeleted {
|
||||||
items.append(.action(ContextMenuActionItem(text: "Change Background", icon: { theme in
|
items.append(.action(ContextMenuActionItem(text: presentationData.strings.UserInfo_ChangeWallpaper, icon: { theme in
|
||||||
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ApplyTheme"), color: theme.contextMenu.primaryColor)
|
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ApplyTheme"), color: theme.contextMenu.primaryColor)
|
||||||
}, action: { _, f in
|
}, action: { _, f in
|
||||||
f(.dismissWithoutContent)
|
f(.dismissWithoutContent)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user