mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
8e6ed4c4d0
@ -229,14 +229,16 @@ public final class NavigationBackgroundNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateColor(color: UIColor, enableBlur: Bool? = nil, forceKeepBlur: Bool = false, transition: ContainedViewLayoutTransition) {
|
public func updateColor(color: UIColor, enableBlur: Bool? = nil, enableSaturation: Bool? = nil, forceKeepBlur: Bool = false, transition: ContainedViewLayoutTransition) {
|
||||||
let effectiveEnableBlur = enableBlur ?? self.enableBlur
|
let effectiveEnableBlur = enableBlur ?? self.enableBlur
|
||||||
|
let effectiveEnableSaturation = enableSaturation ?? self.enableSaturation
|
||||||
|
|
||||||
if self._color.isEqual(color) && self.enableBlur == effectiveEnableBlur {
|
if self._color.isEqual(color) && self.enableBlur == effectiveEnableBlur && self.enableSaturation == effectiveEnableSaturation {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self._color = color
|
self._color = color
|
||||||
self.enableBlur = effectiveEnableBlur
|
self.enableBlur = effectiveEnableBlur
|
||||||
|
self.enableSaturation = effectiveEnableSaturation
|
||||||
|
|
||||||
if sharedIsReduceTransparencyEnabled {
|
if sharedIsReduceTransparencyEnabled {
|
||||||
transition.updateBackgroundColor(node: self.backgroundNode, color: self._color.withAlphaComponent(1.0))
|
transition.updateBackgroundColor(node: self.backgroundNode, color: self._color.withAlphaComponent(1.0))
|
||||||
|
@ -119,8 +119,12 @@ 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))
|
||||||
|
} else {
|
||||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: UIView())
|
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: UIView())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
required init(coder aDecoder: NSCoder) {
|
required init(coder aDecoder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
@ -130,6 +134,10 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
self.applyDisposable.dispose()
|
self.applyDisposable.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc private func cancelPressed() {
|
||||||
|
self.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
super.viewDidAppear(animated)
|
super.viewDidAppear(animated)
|
||||||
|
|
||||||
@ -169,6 +177,12 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if case let .peer(peer) = strongSelf.resultMode {
|
||||||
|
let _ = strongSelf.context.engine.themes.setChatWallpaper(peerId: peer.id, wallpaper: coloredWallpaper).start()
|
||||||
|
strongSelf.completion?()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let prepareWallpaper: Signal<CreateThemeResult, CreateThemeError>
|
let prepareWallpaper: Signal<CreateThemeResult, CreateThemeError>
|
||||||
if let patternWallpaper = state.patternWallpaper, case let .file(file) = patternWallpaper, !state.backgroundColors.isEmpty {
|
if let patternWallpaper = state.patternWallpaper, case let .file(file) = patternWallpaper, !state.backgroundColors.isEmpty {
|
||||||
let resource = file.file.resource
|
let resource = file.file.resource
|
||||||
|
@ -149,6 +149,7 @@ public final class ThemeColorsGridController: ViewController, AttachmentContaina
|
|||||||
fileprivate let mainButtonStatePromise = Promise<AttachmentMainButtonState?>(nil)
|
fileprivate let mainButtonStatePromise = Promise<AttachmentMainButtonState?>(nil)
|
||||||
|
|
||||||
var pushController: (ViewController) -> Void = { _ in }
|
var pushController: (ViewController) -> Void = { _ in }
|
||||||
|
var dismissControllers: (() -> Void)?
|
||||||
|
|
||||||
public init(context: AccountContext, mode: Mode = .default, canDelete: Bool = false) {
|
public init(context: AccountContext, mode: Mode = .default, canDelete: Bool = false) {
|
||||||
self.context = context
|
self.context = context
|
||||||
@ -240,8 +241,12 @@ public final class ThemeColorsGridController: ViewController, AttachmentContaina
|
|||||||
}
|
}
|
||||||
|
|
||||||
let controller = ThemeAccentColorController(context: strongSelf.context, mode: .background(themeReference: themeReference), resultMode: strongSelf.mode.colorPickerMode)
|
let controller = ThemeAccentColorController(context: strongSelf.context, mode: .background(themeReference: themeReference), resultMode: strongSelf.mode.colorPickerMode)
|
||||||
controller.completion = { [weak self] in
|
controller.completion = { [weak self, weak controller] in
|
||||||
if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController {
|
if let strongSelf = self {
|
||||||
|
if let dismissControllers = strongSelf.dismissControllers {
|
||||||
|
dismissControllers()
|
||||||
|
controller?.dismiss(animated: true)
|
||||||
|
} else if let navigationController = strongSelf.navigationController as? NavigationController {
|
||||||
var controllers = navigationController.viewControllers
|
var controllers = navigationController.viewControllers
|
||||||
controllers = controllers.filter { controller in
|
controllers = controllers.filter { controller in
|
||||||
if controller is ThemeColorsGridController {
|
if controller is ThemeColorsGridController {
|
||||||
@ -259,6 +264,7 @@ public final class ThemeColorsGridController: ViewController, AttachmentContaina
|
|||||||
navigationController.setViewControllers(controllers, animated: true)
|
navigationController.setViewControllers(controllers, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
strongSelf.pushController(controller)
|
strongSelf.pushController(controller)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -388,6 +394,9 @@ public func standaloneColorPickerController(context: AccountContext, updatedPres
|
|||||||
colorPickerController.pushController = { controller in
|
colorPickerController.pushController = { controller in
|
||||||
push(controller)
|
push(controller)
|
||||||
}
|
}
|
||||||
|
colorPickerController.dismissControllers = { [weak controller] in
|
||||||
|
controller?.dismiss(animated: true)
|
||||||
|
}
|
||||||
present(colorPickerController, colorPickerController.mediaPickerContext)
|
present(colorPickerController, colorPickerController.mediaPickerContext)
|
||||||
}
|
}
|
||||||
return controller
|
return controller
|
||||||
|
@ -133,8 +133,19 @@ final class ThemeColorsGridControllerNode: ASDisplayNode {
|
|||||||
|
|
||||||
let previousEntries = Atomic<[ThemeColorsGridControllerEntry]?>(value: nil)
|
let previousEntries = Atomic<[ThemeColorsGridControllerEntry]?>(value: nil)
|
||||||
|
|
||||||
let dismissControllers = { [weak self] in
|
let interaction = ThemeColorsGridControllerInteraction(openWallpaper: { [weak self] wallpaper in
|
||||||
if let self, let navigationController = self.controller?.navigationController as? NavigationController {
|
if let strongSelf = self {
|
||||||
|
let entries = previousEntries.with { $0 }
|
||||||
|
if let entries = entries, !entries.isEmpty {
|
||||||
|
let wallpapers = entries.map { $0.wallpaper }
|
||||||
|
let controller = WallpaperGalleryController(context: context, source: .list(wallpapers: wallpapers, central: wallpaper, type: .colors), mode: strongSelf.controller?.mode.galleryMode ?? .default)
|
||||||
|
|
||||||
|
let dismissControllers = { [weak self, weak controller] in
|
||||||
|
if let self {
|
||||||
|
if let dismissControllers = self.controller?.dismissControllers {
|
||||||
|
dismissControllers()
|
||||||
|
controller?.dismiss(animated: true)
|
||||||
|
} else if let navigationController = self.controller?.navigationController as? NavigationController {
|
||||||
let controllers = navigationController.viewControllers.filter({ controller in
|
let controllers = navigationController.viewControllers.filter({ controller in
|
||||||
if controller is ThemeColorsGridController || controller is WallpaperGalleryController {
|
if controller is ThemeColorsGridController || controller is WallpaperGalleryController {
|
||||||
return false
|
return false
|
||||||
@ -144,13 +155,8 @@ final class ThemeColorsGridControllerNode: ASDisplayNode {
|
|||||||
navigationController.setViewControllers(controllers, animated: true)
|
navigationController.setViewControllers(controllers, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let interaction = ThemeColorsGridControllerInteraction(openWallpaper: { [weak self] wallpaper in
|
|
||||||
if let strongSelf = self {
|
|
||||||
let entries = previousEntries.with { $0 }
|
|
||||||
if let entries = entries, !entries.isEmpty {
|
|
||||||
let wallpapers = entries.map { $0.wallpaper }
|
|
||||||
let controller = WallpaperGalleryController(context: context, source: .list(wallpapers: wallpapers, central: wallpaper, type: .colors), mode: strongSelf.controller?.mode.galleryMode ?? .default)
|
|
||||||
controller.navigationPresentation = .modal
|
controller.navigationPresentation = .modal
|
||||||
controller.apply = { [weak self] wallpaper, _, _, _ in
|
controller.apply = { [weak self] wallpaper, _, _, _ in
|
||||||
if let strongSelf = self, let mode = strongSelf.controller?.mode, case let .peer(peer) = mode, case let .wallpaper(wallpaperValue, _) = wallpaper {
|
if let strongSelf = self, let mode = strongSelf.controller?.mode, case let .peer(peer) = mode, case let .wallpaper(wallpaperValue, _) = wallpaper {
|
||||||
|
@ -437,6 +437,12 @@ public class WallpaperGalleryController: ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let toolbarNode = WallpaperGalleryToolbarNode(theme: presentationData.theme, strings: presentationData.strings, doneButtonType: doneButtonType)
|
let toolbarNode = WallpaperGalleryToolbarNode(theme: presentationData.theme, strings: presentationData.strings, doneButtonType: doneButtonType)
|
||||||
|
switch self.source {
|
||||||
|
case .asset, .contextResult:
|
||||||
|
toolbarNode.dark = false
|
||||||
|
default:
|
||||||
|
toolbarNode.dark = true
|
||||||
|
}
|
||||||
self.toolbarNode = toolbarNode
|
self.toolbarNode = toolbarNode
|
||||||
overlayNode.addSubnode(toolbarNode)
|
overlayNode.addSubnode(toolbarNode)
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
self.patternButtonNode = WallpaperOptionButtonNode(title: self.presentationData.strings.WallpaperPreview_Pattern, value: .check(false))
|
self.patternButtonNode = WallpaperOptionButtonNode(title: self.presentationData.strings.WallpaperPreview_Pattern, value: .check(false))
|
||||||
self.patternButtonNode.setEnabled(false)
|
self.patternButtonNode.setEnabled(false)
|
||||||
|
|
||||||
self.serviceBackgroundNode = NavigationBackgroundNode(color: UIColor(rgb: 0x000000, alpha: 0.35))
|
self.serviceBackgroundNode = NavigationBackgroundNode(color: UIColor(rgb: 0x333333, alpha: 0.33))
|
||||||
|
|
||||||
var sliderValueChangedImpl: ((CGFloat) -> Void)?
|
var sliderValueChangedImpl: ((CGFloat) -> Void)?
|
||||||
self.sliderNode = WallpaperSliderNode(minValue: 0.0, maxValue: 1.0, value: 0.5, valueChanged: { value, _ in
|
self.sliderNode = WallpaperSliderNode(minValue: 0.0, maxValue: 1.0, value: 0.5, valueChanged: { value, _ in
|
||||||
@ -176,7 +176,9 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
self.colorsButtonNode = WallpaperOptionButtonNode(title: self.presentationData.strings.WallpaperPreview_WallpaperColors, value: .colors(false, [.clear]))
|
self.colorsButtonNode = WallpaperOptionButtonNode(title: self.presentationData.strings.WallpaperPreview_WallpaperColors, value: .colors(false, [.clear]))
|
||||||
|
|
||||||
self.cancelButtonNode = WallpaperNavigationButtonNode(content: .text(self.presentationData.strings.Common_Cancel), dark: false)
|
self.cancelButtonNode = WallpaperNavigationButtonNode(content: .text(self.presentationData.strings.Common_Cancel), dark: false)
|
||||||
|
self.cancelButtonNode.enableSaturation = true
|
||||||
self.shareButtonNode = WallpaperNavigationButtonNode(content: .icon(image: UIImage(bundleImageName: "Chat/Links/Share"), size: CGSize(width: 28.0, height: 28.0)), dark: false)
|
self.shareButtonNode = WallpaperNavigationButtonNode(content: .icon(image: UIImage(bundleImageName: "Chat/Links/Share"), size: CGSize(width: 28.0, height: 28.0)), dark: false)
|
||||||
|
self.shareButtonNode.enableSaturation = true
|
||||||
|
|
||||||
self.playButtonPlayImage = generateImage(CGSize(width: 48.0, height: 48.0), rotatedContext: { size, context in
|
self.playButtonPlayImage = generateImage(CGSize(width: 48.0, height: 48.0), rotatedContext: { size, context in
|
||||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||||
@ -400,6 +402,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
self.playButtonNode.setIcon(self.playButtonRotateImage)
|
self.playButtonNode.setIcon(self.playButtonRotateImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isEditable = false
|
||||||
var canShare = false
|
var canShare = false
|
||||||
switch entry {
|
switch entry {
|
||||||
case let .wallpaper(wallpaper, message):
|
case let .wallpaper(wallpaper, message):
|
||||||
@ -563,6 +566,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
}
|
}
|
||||||
self.cropNode.removeFromSupernode()
|
self.cropNode.removeFromSupernode()
|
||||||
case let .asset(asset):
|
case let .asset(asset):
|
||||||
|
isEditable = true
|
||||||
let dimensions = CGSize(width: asset.pixelWidth, height: asset.pixelHeight)
|
let dimensions = CGSize(width: asset.pixelWidth, height: asset.pixelHeight)
|
||||||
contentSize = dimensions
|
contentSize = dimensions
|
||||||
displaySize = dimensions.dividedByScreenScale().integralFloor
|
displaySize = dimensions.dividedByScreenScale().integralFloor
|
||||||
@ -573,6 +577,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
colorSignal = .single(UIColor(rgb: 0x000000, alpha: 0.3))
|
colorSignal = .single(UIColor(rgb: 0x000000, alpha: 0.3))
|
||||||
self.wrapperNode.addSubnode(self.cropNode)
|
self.wrapperNode.addSubnode(self.cropNode)
|
||||||
case let .contextResult(result):
|
case let .contextResult(result):
|
||||||
|
isEditable = true
|
||||||
var imageDimensions: CGSize?
|
var imageDimensions: CGSize?
|
||||||
var imageResource: TelegramMediaResource?
|
var imageResource: TelegramMediaResource?
|
||||||
var thumbnailDimensions: CGSize?
|
var thumbnailDimensions: CGSize?
|
||||||
@ -629,6 +634,8 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
}
|
}
|
||||||
self.contentSize = contentSize
|
self.contentSize = contentSize
|
||||||
|
|
||||||
|
self.cancelButtonNode.dark = !isEditable
|
||||||
|
self.shareButtonNode.dark = !isEditable
|
||||||
self.shareButtonNode.isHidden = !canShare
|
self.shareButtonNode.isHidden = !canShare
|
||||||
|
|
||||||
if self.cropNode.supernode == nil {
|
if self.cropNode.supernode == nil {
|
||||||
@ -1239,14 +1246,6 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
self.messageNodes = messageNodes
|
self.messageNodes = messageNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
if let _ = serviceMessageText, let messageNodes = self.messageNodes, let node = messageNodes.last {
|
|
||||||
if let backgroundNode = node.subnodes?.first?.subnodes?.first?.subnodes?.first?.subnodes?.first {
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let alpha = 1.0 - min(1.0, max(0.0, abs(offset.y) / 50.0))
|
let alpha = 1.0 - min(1.0, max(0.0, abs(offset.y) / 50.0))
|
||||||
|
|
||||||
if let messageNodes = self.messageNodes {
|
if let messageNodes = self.messageNodes {
|
||||||
@ -1258,6 +1257,14 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
transition.updateAlpha(node: itemNode, alpha: alpha)
|
transition.updateAlpha(node: itemNode, alpha: alpha)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let _ = serviceMessageText, let messageNodes = self.messageNodes, let node = messageNodes.last {
|
||||||
|
if let backgroundNode = node.subnodes?.first?.subnodes?.first?.subnodes?.first?.subnodes?.first {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
|
override func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
|
@ -32,8 +32,23 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dark: Bool {
|
||||||
|
didSet {
|
||||||
|
if self.dark != oldValue {
|
||||||
|
self.doneButtonBackgroundNode.removeFromSupernode()
|
||||||
|
if self.dark {
|
||||||
|
self.doneButtonBackgroundNode = WallpaperOptionBackgroundNode(enableSaturation: true)
|
||||||
|
} else {
|
||||||
|
self.doneButtonBackgroundNode = WallpaperLightButtonBackgroundNode()
|
||||||
|
}
|
||||||
|
self.doneButtonBackgroundNode.cornerRadius = 14.0
|
||||||
|
self.insertSubnode(self.doneButtonBackgroundNode, at: 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private let doneButton = HighlightTrackingButtonNode()
|
private let doneButton = HighlightTrackingButtonNode()
|
||||||
private let doneButtonBackgroundNode: WallpaperLightButtonBackgroundNode
|
private var doneButtonBackgroundNode: ASDisplayNode
|
||||||
|
|
||||||
private let doneButtonTitleNode: ImmediateTextNode
|
private let doneButtonTitleNode: ImmediateTextNode
|
||||||
|
|
||||||
@ -48,6 +63,7 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode {
|
|||||||
self.strings = strings
|
self.strings = strings
|
||||||
self.cancelButtonType = cancelButtonType
|
self.cancelButtonType = cancelButtonType
|
||||||
self.doneButtonType = doneButtonType
|
self.doneButtonType = doneButtonType
|
||||||
|
self.dark = false
|
||||||
|
|
||||||
self.doneButtonBackgroundNode = WallpaperLightButtonBackgroundNode()
|
self.doneButtonBackgroundNode = WallpaperLightButtonBackgroundNode()
|
||||||
self.doneButtonBackgroundNode.cornerRadius = 14.0
|
self.doneButtonBackgroundNode.cornerRadius = 14.0
|
||||||
@ -73,7 +89,7 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode {
|
|||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
self.addSubnode(self.doneButtonBackgroundNode)
|
self.addSubnode(self.doneButtonBackgroundNode)
|
||||||
self.doneButtonBackgroundNode.addSubnode(self.doneButtonTitleNode)
|
self.addSubnode(self.doneButtonTitleNode)
|
||||||
|
|
||||||
self.addSubnode(self.doneButtonSolidBackgroundNode)
|
self.addSubnode(self.doneButtonSolidBackgroundNode)
|
||||||
self.addSubnode(self.doneButtonSolidTitleNode)
|
self.addSubnode(self.doneButtonSolidTitleNode)
|
||||||
@ -163,14 +179,18 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode {
|
|||||||
let doneFrame = CGRect(origin: CGPoint(x: inset, y: 2.0), size: CGSize(width: size.width - inset * 2.0, height: buttonHeight))
|
let doneFrame = CGRect(origin: CGPoint(x: inset, y: 2.0), size: CGSize(width: size.width - inset * 2.0, height: buttonHeight))
|
||||||
self.doneButton.frame = doneFrame
|
self.doneButton.frame = doneFrame
|
||||||
self.doneButtonBackgroundNode.frame = doneFrame
|
self.doneButtonBackgroundNode.frame = doneFrame
|
||||||
self.doneButtonBackgroundNode.updateLayout(size: doneFrame.size)
|
if let backgroundNode = self.doneButtonBackgroundNode as? WallpaperOptionBackgroundNode {
|
||||||
|
backgroundNode.updateLayout(size: doneFrame.size)
|
||||||
|
} else if let backgroundNode = self.doneButtonBackgroundNode as? WallpaperLightButtonBackgroundNode {
|
||||||
|
backgroundNode.updateLayout(size: doneFrame.size)
|
||||||
|
}
|
||||||
self.doneButtonSolidBackgroundNode.frame = doneFrame
|
self.doneButtonSolidBackgroundNode.frame = doneFrame
|
||||||
|
|
||||||
let doneTitleSize = self.doneButtonTitleNode.updateLayout(doneFrame.size)
|
let doneTitleSize = self.doneButtonTitleNode.updateLayout(doneFrame.size)
|
||||||
self.doneButtonTitleNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((doneFrame.width - doneTitleSize.width) / 2.0), y: floorToScreenPixels((doneFrame.height - doneTitleSize.height) / 2.0)), size: doneTitleSize)
|
self.doneButtonTitleNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((doneFrame.width - doneTitleSize.width) / 2.0), y: floorToScreenPixels((doneFrame.height - doneTitleSize.height) / 2.0)), size: doneTitleSize).offsetBy(dx: doneFrame.minX, dy: doneFrame.minY)
|
||||||
|
|
||||||
let _ = self.doneButtonSolidTitleNode.updateLayout(doneFrame.size)
|
let _ = self.doneButtonSolidTitleNode.updateLayout(doneFrame.size)
|
||||||
self.doneButtonSolidTitleNode.frame = self.doneButtonTitleNode.frame.offsetBy(dx: doneFrame.minX, dy: doneFrame.minY)
|
self.doneButtonSolidTitleNode.frame = self.doneButtonTitleNode.frame
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func cancelPressed() {
|
@objc func cancelPressed() {
|
||||||
|
@ -70,8 +70,8 @@ final class WallpaperLightButtonBackgroundNode: ASDisplayNode {
|
|||||||
final class WallpaperOptionBackgroundNode: ASDisplayNode {
|
final class WallpaperOptionBackgroundNode: ASDisplayNode {
|
||||||
private let backgroundNode: NavigationBackgroundNode
|
private let backgroundNode: NavigationBackgroundNode
|
||||||
|
|
||||||
override init() {
|
init(enableSaturation: Bool = false) {
|
||||||
self.backgroundNode = NavigationBackgroundNode(color: UIColor(rgb: 0x333333, alpha: 0.3), enableBlur: true, enableSaturation: false)
|
self.backgroundNode = NavigationBackgroundNode(color: UIColor(rgb: 0x333333, alpha: 0.3), enableBlur: true, enableSaturation: enableSaturation)
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@ -95,12 +95,25 @@ final class WallpaperNavigationButtonNode: HighlightTrackingButtonNode {
|
|||||||
case text(String)
|
case text(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var enableSaturation: Bool = false
|
||||||
|
|
||||||
private let content: Content
|
private let content: Content
|
||||||
|
var dark: Bool {
|
||||||
|
didSet {
|
||||||
|
if self.dark != oldValue {
|
||||||
|
self.backgroundNode.removeFromSupernode()
|
||||||
|
if self.dark {
|
||||||
|
self.backgroundNode = WallpaperOptionBackgroundNode(enableSaturation: self.enableSaturation)
|
||||||
|
} else {
|
||||||
|
self.backgroundNode = WallpaperLightButtonBackgroundNode()
|
||||||
|
}
|
||||||
|
self.insertSubnode(self.backgroundNode, at: 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private let backgroundNode: ASDisplayNode
|
private var backgroundNode: ASDisplayNode
|
||||||
|
|
||||||
private let iconNode: ASImageNode
|
private let iconNode: ASImageNode
|
||||||
|
|
||||||
private let textNode: ImmediateTextNode
|
private let textNode: ImmediateTextNode
|
||||||
|
|
||||||
func setIcon(_ image: UIImage?) {
|
func setIcon(_ image: UIImage?) {
|
||||||
@ -109,6 +122,7 @@ final class WallpaperNavigationButtonNode: HighlightTrackingButtonNode {
|
|||||||
|
|
||||||
init(content: Content, dark: Bool) {
|
init(content: Content, dark: Bool) {
|
||||||
self.content = content
|
self.content = content
|
||||||
|
self.dark = dark
|
||||||
|
|
||||||
if dark {
|
if dark {
|
||||||
self.backgroundNode = WallpaperOptionBackgroundNode()
|
self.backgroundNode = WallpaperOptionBackgroundNode()
|
||||||
|
@ -3405,8 +3405,8 @@ func replayFinalState(
|
|||||||
for (space, _) in holesAtHistoryStart {
|
for (space, _) in holesAtHistoryStart {
|
||||||
transaction.removeHole(peerId: chatPeerId, threadId: nil, namespace: Namespaces.Message.Cloud, space: space, range: 1 ... id.id)
|
transaction.removeHole(peerId: chatPeerId, threadId: nil, namespace: Namespaces.Message.Cloud, space: space, range: 1 ... id.id)
|
||||||
}
|
}
|
||||||
case let .setChatWallpaper(wallpaper):
|
case let .setChatWallpaper(wallpaper), let .setSameChatWallpaper(wallpaper):
|
||||||
if chatPeerId == accountPeerId {
|
if message.authorId == accountPeerId {
|
||||||
transaction.updatePeerCachedData(peerIds: [message.id.peerId], update: { peerId, current in
|
transaction.updatePeerCachedData(peerIds: [message.id.peerId], update: { peerId, current in
|
||||||
var current = current
|
var current = current
|
||||||
if current == nil {
|
if current == nil {
|
||||||
|
@ -140,11 +140,11 @@ func _internal_setChatWallpaper(account: Account, peerId: PeerId, wallpaper: Tel
|
|||||||
var inputSettings: Api.WallPaperSettings?
|
var inputSettings: Api.WallPaperSettings?
|
||||||
if let inputWallpaperAndInputSettings = wallpaper?.apiInputWallpaperAndSettings {
|
if let inputWallpaperAndInputSettings = wallpaper?.apiInputWallpaperAndSettings {
|
||||||
flags |= 1 << 0
|
flags |= 1 << 0
|
||||||
|
flags |= 1 << 2
|
||||||
inputWallpaper = inputWallpaperAndInputSettings.0
|
inputWallpaper = inputWallpaperAndInputSettings.0
|
||||||
inputSettings = inputWallpaperAndInputSettings.1
|
inputSettings = inputWallpaperAndInputSettings.1
|
||||||
}
|
}
|
||||||
return account.network.request(Api.functions.messages.setChatWallPaper(flags: flags, peer: inputPeer, wallpaper: inputWallpaper, settings: inputSettings, id: nil))
|
return account.network.request(Api.functions.messages.setChatWallPaper(flags: flags, peer: inputPeer, wallpaper: inputWallpaper, settings: inputSettings, id: nil), automaticFloodWait: false)
|
||||||
|> `catch` { error in
|
|> `catch` { error in
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ public enum SetExistingChatWallpaperError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
func _internal_setExistingChatWallpaper(account: Account, messageId: MessageId, wallpaper: TelegramWallpaper?) -> Signal<Void, SetExistingChatWallpaperError> {
|
func _internal_setExistingChatWallpaper(account: Account, messageId: MessageId, settings: WallpaperSettings?) -> Signal<Void, SetExistingChatWallpaperError> {
|
||||||
return account.postbox.transaction { transaction -> Peer? in
|
return account.postbox.transaction { transaction -> Peer? in
|
||||||
if let peer = transaction.getPeer(messageId.peerId), let message = transaction.getMessage(messageId) {
|
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 {
|
if let action = message.media.first(where: { $0 is TelegramMediaAction }) as? TelegramMediaAction, case let .setChatWallpaper(wallpaper) = action.action {
|
||||||
@ -185,11 +185,11 @@ func _internal_setExistingChatWallpaper(account: Account, messageId: MessageId,
|
|||||||
var flags: Int32 = 1 << 1
|
var flags: Int32 = 1 << 1
|
||||||
|
|
||||||
var inputSettings: Api.WallPaperSettings?
|
var inputSettings: Api.WallPaperSettings?
|
||||||
if let inputWallpaperAndInputSettings = wallpaper?.apiInputWallpaperAndSettings {
|
if let settings = settings {
|
||||||
flags |= 1 << 2
|
flags |= 1 << 2
|
||||||
inputSettings = inputWallpaperAndInputSettings.1
|
inputSettings = apiWallpaperSettings(settings)
|
||||||
}
|
}
|
||||||
return account.network.request(Api.functions.messages.setChatWallPaper(flags: flags, peer: inputPeer, wallpaper: nil, settings: inputSettings, id: messageId.id))
|
return account.network.request(Api.functions.messages.setChatWallPaper(flags: flags, peer: inputPeer, wallpaper: nil, settings: inputSettings, id: messageId.id), automaticFloodWait: false)
|
||||||
|> `catch` { _ -> Signal<Api.Updates, SetExistingChatWallpaperError> in
|
|> `catch` { _ -> Signal<Api.Updates, SetExistingChatWallpaperError> in
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ public extension TelegramEngine {
|
|||||||
return _internal_setChatWallpaper(account: self.account, peerId: peerId, wallpaper: wallpaper)
|
return _internal_setChatWallpaper(account: self.account, peerId: peerId, wallpaper: wallpaper)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func setExistingChatWallpaper(messageId: MessageId, wallpaper: TelegramWallpaper?) -> Signal<Void, SetExistingChatWallpaperError> {
|
public func setExistingChatWallpaper(messageId: MessageId, settings: WallpaperSettings?) -> Signal<Void, SetExistingChatWallpaperError> {
|
||||||
return _internal_setExistingChatWallpaper(account: self.account, messageId: messageId, wallpaper: wallpaper)
|
return _internal_setExistingChatWallpaper(account: self.account, messageId: messageId, settings: settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,6 +386,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component {
|
|||||||
|
|
||||||
let titleString: String
|
let titleString: String
|
||||||
var allChatsAdded = false
|
var allChatsAdded = false
|
||||||
|
var canAddChatCount = 0
|
||||||
if case .linkList = component.subject {
|
if case .linkList = component.subject {
|
||||||
//TODO:localize
|
//TODO:localize
|
||||||
titleString = "Share Folder"
|
titleString = "Share Folder"
|
||||||
@ -397,13 +398,14 @@ private final class ChatFolderLinkPreviewScreenComponent: Component {
|
|||||||
if linkContents.alreadyMemberPeerIds == Set(linkContents.peers.map(\.id)) {
|
if linkContents.alreadyMemberPeerIds == Set(linkContents.peers.map(\.id)) {
|
||||||
allChatsAdded = true
|
allChatsAdded = true
|
||||||
}
|
}
|
||||||
|
canAddChatCount = linkContents.peers.map(\.id).count - linkContents.alreadyMemberPeerIds.count
|
||||||
|
|
||||||
if allChatsAdded {
|
if allChatsAdded {
|
||||||
titleString = "Add Folder"
|
titleString = "Add Folder"
|
||||||
} else if linkContents.peers.count == 1 {
|
} else if canAddChatCount == 1 {
|
||||||
titleString = "Add \(linkContents.peers.count) chat"
|
titleString = "Add \(canAddChatCount) chat"
|
||||||
} else {
|
} else {
|
||||||
titleString = "Add \(linkContents.peers.count) chats"
|
titleString = "Add \(canAddChatCount) chats"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
titleString = "Add Folder"
|
titleString = "Add Folder"
|
||||||
@ -433,8 +435,8 @@ private final class ChatFolderLinkPreviewScreenComponent: Component {
|
|||||||
var topBadge: String?
|
var topBadge: String?
|
||||||
if case .linkList = component.subject {
|
if case .linkList = component.subject {
|
||||||
} else if case .remove = component.subject {
|
} else if case .remove = component.subject {
|
||||||
} else if !allChatsAdded, let linkContents = component.linkContents, linkContents.localFilterId != nil {
|
} else if !allChatsAdded, let linkContents = component.linkContents, linkContents.localFilterId != nil, canAddChatCount != 0 {
|
||||||
topBadge = "+\(linkContents.peers.count)"
|
topBadge = "+\(canAddChatCount)"
|
||||||
}
|
}
|
||||||
|
|
||||||
let topIconSize = self.topIcon.update(
|
let topIconSize = self.topIcon.update(
|
||||||
@ -472,10 +474,10 @@ private final class ChatFolderLinkPreviewScreenComponent: Component {
|
|||||||
text = "Do you want to add a new chat folder\nand join its groups and channels?"
|
text = "Do you want to add a new chat folder\nand join its groups and channels?"
|
||||||
} else {
|
} else {
|
||||||
let chatCountString: String
|
let chatCountString: String
|
||||||
if linkContents.peers.count == 1 {
|
if canAddChatCount == 1 {
|
||||||
chatCountString = "1 chat"
|
chatCountString = "1 chat"
|
||||||
} else {
|
} else {
|
||||||
chatCountString = "\(linkContents.peers.count) chats"
|
chatCountString = "\(canAddChatCount) chats"
|
||||||
}
|
}
|
||||||
if let title = linkContents.title {
|
if let title = linkContents.title {
|
||||||
text = "Do you want to add **\(chatCountString)** to the\nfolder **\(title)**?"
|
text = "Do you want to add **\(chatCountString)** to the\nfolder **\(title)**?"
|
||||||
@ -934,7 +936,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component {
|
|||||||
actionButtonBadge = 0
|
actionButtonBadge = 0
|
||||||
actionButtonTitle = "OK"
|
actionButtonTitle = "OK"
|
||||||
} else if let linkContents = component.linkContents {
|
} else if let linkContents = component.linkContents {
|
||||||
actionButtonBadge = self.selectedItems.count
|
actionButtonBadge = max(0, self.selectedItems.count - (linkContents.peers.count - canAddChatCount))
|
||||||
if linkContents.localFilterId != nil {
|
if linkContents.localFilterId != nil {
|
||||||
if self.selectedItems.isEmpty {
|
if self.selectedItems.isEmpty {
|
||||||
actionButtonTitle = "Do Not Join Any Chats"
|
actionButtonTitle = "Do Not Join Any Chats"
|
||||||
|
@ -846,7 +846,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
strongSelf.chatDisplayNode.dismissInput()
|
strongSelf.chatDisplayNode.dismissInput()
|
||||||
let wallpaperPreviewController = WallpaperGalleryController(context: strongSelf.context, source: .wallpaper(wallpaper, nil, [], nil, nil, nil), mode: .peer(EnginePeer(peer), true))
|
let wallpaperPreviewController = WallpaperGalleryController(context: strongSelf.context, source: .wallpaper(wallpaper, nil, [], nil, nil, nil), mode: .peer(EnginePeer(peer), true))
|
||||||
wallpaperPreviewController.apply = { wallpaper, options, _, _ in
|
wallpaperPreviewController.apply = { wallpaper, options, _, _ in
|
||||||
let _ = (strongSelf.context.engine.themes.setExistingChatWallpaper(messageId: message.id, wallpaper: nil)
|
let _ = (strongSelf.context.engine.themes.setExistingChatWallpaper(messageId: message.id, settings: nil)
|
||||||
|> deliverOnMainQueue).start(completed: { [weak wallpaperPreviewController] in
|
|> deliverOnMainQueue).start(completed: { [weak wallpaperPreviewController] in
|
||||||
wallpaperPreviewController?.dismiss()
|
wallpaperPreviewController?.dismiss()
|
||||||
})
|
})
|
||||||
|
@ -1475,7 +1475,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let foregroundColor = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderColor, wallpaper: item.presentationData.theme.wallpaper)
|
let foregroundColor: UIColor = .clear// = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderColor, wallpaper: item.presentationData.theme.wallpaper)
|
||||||
let shimmeringColor = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderShimmerColor, wallpaper: item.presentationData.theme.wallpaper)
|
let shimmeringColor = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderShimmerColor, wallpaper: item.presentationData.theme.wallpaper)
|
||||||
strongSelf.placeholderNode.update(backgroundColor: nil, foregroundColor: foregroundColor, shimmeringColor: shimmeringColor, data: immediateThumbnailData, size: animationNodeFrame.size, enableEffect: item.context.sharedContext.energyUsageSettings.fullTranslucency, imageSize: file.dimensions?.cgSize ?? CGSize(width: 512.0, height: 512.0))
|
strongSelf.placeholderNode.update(backgroundColor: nil, foregroundColor: foregroundColor, shimmeringColor: shimmeringColor, data: immediateThumbnailData, size: animationNodeFrame.size, enableEffect: item.context.sharedContext.energyUsageSettings.fullTranslucency, imageSize: file.dimensions?.cgSize ?? CGSize(width: 512.0, height: 512.0))
|
||||||
strongSelf.placeholderNode.frame = animationNodeFrame
|
strongSelf.placeholderNode.frame = animationNodeFrame
|
||||||
|
@ -898,7 +898,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let foregroundColor = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderColor, wallpaper: item.presentationData.theme.wallpaper)
|
let foregroundColor: UIColor = .clear//bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderColor, wallpaper: item.presentationData.theme.wallpaper)
|
||||||
let shimmeringColor = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderShimmerColor, wallpaper: item.presentationData.theme.wallpaper)
|
let shimmeringColor = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderShimmerColor, wallpaper: item.presentationData.theme.wallpaper)
|
||||||
|
|
||||||
let placeholderFrame = updatedImageFrame.insetBy(dx: innerImageInset, dy: innerImageInset)
|
let placeholderFrame = updatedImageFrame.insetBy(dx: innerImageInset, dy: innerImageInset)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user