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
|
||||
|
||||
if self._color.isEqual(color) && self.enableBlur == effectiveEnableBlur {
|
||||
let effectiveEnableSaturation = enableSaturation ?? self.enableSaturation
|
||||
|
||||
if self._color.isEqual(color) && self.enableBlur == effectiveEnableBlur && self.enableSaturation == effectiveEnableSaturation {
|
||||
return
|
||||
}
|
||||
self._color = color
|
||||
self.enableBlur = effectiveEnableBlur
|
||||
self.enableSaturation = effectiveEnableSaturation
|
||||
|
||||
if sharedIsReduceTransparencyEnabled {
|
||||
transition.updateBackgroundColor(node: self.backgroundNode, color: self._color.withAlphaComponent(1.0))
|
||||
|
@ -119,7 +119,11 @@ final class ThemeAccentColorController: ViewController {
|
||||
} else {
|
||||
self.navigationItem.titleView = self.segmentedTitleView
|
||||
}
|
||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: UIView())
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
required init(coder aDecoder: NSCoder) {
|
||||
@ -129,6 +133,10 @@ final class ThemeAccentColorController: ViewController {
|
||||
deinit {
|
||||
self.applyDisposable.dispose()
|
||||
}
|
||||
|
||||
@objc private func cancelPressed() {
|
||||
self.dismiss()
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
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>
|
||||
if let patternWallpaper = state.patternWallpaper, case let .file(file) = patternWallpaper, !state.backgroundColors.isEmpty {
|
||||
let resource = file.file.resource
|
||||
|
@ -149,6 +149,7 @@ public final class ThemeColorsGridController: ViewController, AttachmentContaina
|
||||
fileprivate let mainButtonStatePromise = Promise<AttachmentMainButtonState?>(nil)
|
||||
|
||||
var pushController: (ViewController) -> Void = { _ in }
|
||||
var dismissControllers: (() -> Void)?
|
||||
|
||||
public init(context: AccountContext, mode: Mode = .default, canDelete: Bool = false) {
|
||||
self.context = context
|
||||
@ -240,23 +241,28 @@ public final class ThemeColorsGridController: ViewController, AttachmentContaina
|
||||
}
|
||||
|
||||
let controller = ThemeAccentColorController(context: strongSelf.context, mode: .background(themeReference: themeReference), resultMode: strongSelf.mode.colorPickerMode)
|
||||
controller.completion = { [weak self] in
|
||||
if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController {
|
||||
var controllers = navigationController.viewControllers
|
||||
controllers = controllers.filter { controller in
|
||||
if controller is ThemeColorsGridController {
|
||||
return false
|
||||
controller.completion = { [weak self, weak controller] in
|
||||
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
|
||||
controllers = controllers.filter { controller in
|
||||
if controller is ThemeColorsGridController {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
navigationController.setViewControllers(controllers, animated: false)
|
||||
controllers = controllers.filter { controller in
|
||||
if controller is ThemeAccentColorController {
|
||||
return false
|
||||
navigationController.setViewControllers(controllers, animated: false)
|
||||
controllers = controllers.filter { controller in
|
||||
if controller is ThemeAccentColorController {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
return true
|
||||
navigationController.setViewControllers(controllers, animated: true)
|
||||
}
|
||||
navigationController.setViewControllers(controllers, animated: true)
|
||||
}
|
||||
}
|
||||
strongSelf.pushController(controller)
|
||||
@ -388,6 +394,9 @@ public func standaloneColorPickerController(context: AccountContext, updatedPres
|
||||
colorPickerController.pushController = { controller in
|
||||
push(controller)
|
||||
}
|
||||
colorPickerController.dismissControllers = { [weak controller] in
|
||||
controller?.dismiss(animated: true)
|
||||
}
|
||||
present(colorPickerController, colorPickerController.mediaPickerContext)
|
||||
}
|
||||
return controller
|
||||
|
@ -132,25 +132,31 @@ final class ThemeColorsGridControllerNode: ASDisplayNode {
|
||||
self.addSubnode(self.gridNode)
|
||||
|
||||
let previousEntries = Atomic<[ThemeColorsGridControllerEntry]?>(value: nil)
|
||||
|
||||
let dismissControllers = { [weak self] in
|
||||
if let self, let navigationController = self.controller?.navigationController as? NavigationController {
|
||||
let controllers = navigationController.viewControllers.filter({ controller in
|
||||
if controller is ThemeColorsGridController || controller is WallpaperGalleryController {
|
||||
return false
|
||||
}
|
||||
return 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)
|
||||
|
||||
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
|
||||
if controller is ThemeColorsGridController || controller is WallpaperGalleryController {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
navigationController.setViewControllers(controllers, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
controller.navigationPresentation = .modal
|
||||
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 {
|
||||
|
@ -437,6 +437,12 @@ public class WallpaperGalleryController: ViewController {
|
||||
}
|
||||
|
||||
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
|
||||
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.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)?
|
||||
self.sliderNode = WallpaperSliderNode(minValue: 0.0, maxValue: 1.0, value: 0.5, valueChanged: { value, _ in
|
||||
@ -176,8 +176,10 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
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.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.enableSaturation = true
|
||||
|
||||
self.playButtonPlayImage = generateImage(CGSize(width: 48.0, height: 48.0), rotatedContext: { size, context in
|
||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
context.setFillColor(UIColor.white.cgColor)
|
||||
@ -400,6 +402,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
self.playButtonNode.setIcon(self.playButtonRotateImage)
|
||||
}
|
||||
|
||||
var isEditable = false
|
||||
var canShare = false
|
||||
switch entry {
|
||||
case let .wallpaper(wallpaper, message):
|
||||
@ -563,6 +566,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
}
|
||||
self.cropNode.removeFromSupernode()
|
||||
case let .asset(asset):
|
||||
isEditable = true
|
||||
let dimensions = CGSize(width: asset.pixelWidth, height: asset.pixelHeight)
|
||||
contentSize = dimensions
|
||||
displaySize = dimensions.dividedByScreenScale().integralFloor
|
||||
@ -573,6 +577,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
colorSignal = .single(UIColor(rgb: 0x000000, alpha: 0.3))
|
||||
self.wrapperNode.addSubnode(self.cropNode)
|
||||
case let .contextResult(result):
|
||||
isEditable = true
|
||||
var imageDimensions: CGSize?
|
||||
var imageResource: TelegramMediaResource?
|
||||
var thumbnailDimensions: CGSize?
|
||||
@ -629,6 +634,8 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
}
|
||||
self.contentSize = contentSize
|
||||
|
||||
self.cancelButtonNode.dark = !isEditable
|
||||
self.shareButtonNode.dark = !isEditable
|
||||
self.shareButtonNode.isHidden = !canShare
|
||||
|
||||
if self.cropNode.supernode == nil {
|
||||
@ -1238,15 +1245,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
}
|
||||
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))
|
||||
|
||||
if let messageNodes = self.messageNodes {
|
||||
@ -1258,6 +1257,14 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
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) {
|
||||
|
@ -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 doneButtonBackgroundNode: WallpaperLightButtonBackgroundNode
|
||||
private var doneButtonBackgroundNode: ASDisplayNode
|
||||
|
||||
private let doneButtonTitleNode: ImmediateTextNode
|
||||
|
||||
@ -48,6 +63,7 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode {
|
||||
self.strings = strings
|
||||
self.cancelButtonType = cancelButtonType
|
||||
self.doneButtonType = doneButtonType
|
||||
self.dark = false
|
||||
|
||||
self.doneButtonBackgroundNode = WallpaperLightButtonBackgroundNode()
|
||||
self.doneButtonBackgroundNode.cornerRadius = 14.0
|
||||
@ -73,7 +89,7 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode {
|
||||
super.init()
|
||||
|
||||
self.addSubnode(self.doneButtonBackgroundNode)
|
||||
self.doneButtonBackgroundNode.addSubnode(self.doneButtonTitleNode)
|
||||
self.addSubnode(self.doneButtonTitleNode)
|
||||
|
||||
self.addSubnode(self.doneButtonSolidBackgroundNode)
|
||||
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))
|
||||
self.doneButton.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
|
||||
|
||||
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)
|
||||
self.doneButtonSolidTitleNode.frame = self.doneButtonTitleNode.frame.offsetBy(dx: doneFrame.minX, dy: doneFrame.minY)
|
||||
self.doneButtonSolidTitleNode.frame = self.doneButtonTitleNode.frame
|
||||
}
|
||||
|
||||
@objc func cancelPressed() {
|
||||
|
@ -70,8 +70,8 @@ final class WallpaperLightButtonBackgroundNode: ASDisplayNode {
|
||||
final class WallpaperOptionBackgroundNode: ASDisplayNode {
|
||||
private let backgroundNode: NavigationBackgroundNode
|
||||
|
||||
override init() {
|
||||
self.backgroundNode = NavigationBackgroundNode(color: UIColor(rgb: 0x333333, alpha: 0.3), enableBlur: true, enableSaturation: false)
|
||||
init(enableSaturation: Bool = false) {
|
||||
self.backgroundNode = NavigationBackgroundNode(color: UIColor(rgb: 0x333333, alpha: 0.3), enableBlur: true, enableSaturation: enableSaturation)
|
||||
|
||||
super.init()
|
||||
|
||||
@ -95,12 +95,25 @@ final class WallpaperNavigationButtonNode: HighlightTrackingButtonNode {
|
||||
case text(String)
|
||||
}
|
||||
|
||||
var enableSaturation: Bool = false
|
||||
|
||||
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 textNode: ImmediateTextNode
|
||||
|
||||
func setIcon(_ image: UIImage?) {
|
||||
@ -109,6 +122,7 @@ final class WallpaperNavigationButtonNode: HighlightTrackingButtonNode {
|
||||
|
||||
init(content: Content, dark: Bool) {
|
||||
self.content = content
|
||||
self.dark = dark
|
||||
|
||||
if dark {
|
||||
self.backgroundNode = WallpaperOptionBackgroundNode()
|
||||
|
@ -3405,8 +3405,8 @@ func replayFinalState(
|
||||
for (space, _) in holesAtHistoryStart {
|
||||
transaction.removeHole(peerId: chatPeerId, threadId: nil, namespace: Namespaces.Message.Cloud, space: space, range: 1 ... id.id)
|
||||
}
|
||||
case let .setChatWallpaper(wallpaper):
|
||||
if chatPeerId == accountPeerId {
|
||||
case let .setChatWallpaper(wallpaper), let .setSameChatWallpaper(wallpaper):
|
||||
if message.authorId == accountPeerId {
|
||||
transaction.updatePeerCachedData(peerIds: [message.id.peerId], update: { peerId, current in
|
||||
var current = current
|
||||
if current == nil {
|
||||
|
@ -140,11 +140,11 @@ func _internal_setChatWallpaper(account: Account, peerId: PeerId, wallpaper: Tel
|
||||
var inputSettings: Api.WallPaperSettings?
|
||||
if let inputWallpaperAndInputSettings = wallpaper?.apiInputWallpaperAndSettings {
|
||||
flags |= 1 << 0
|
||||
|
||||
flags |= 1 << 2
|
||||
inputWallpaper = inputWallpaperAndInputSettings.0
|
||||
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
|
||||
return .complete()
|
||||
}
|
||||
@ -160,7 +160,7 @@ public enum SetExistingChatWallpaperError {
|
||||
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
|
||||
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 {
|
||||
@ -185,11 +185,11 @@ func _internal_setExistingChatWallpaper(account: Account, messageId: MessageId,
|
||||
var flags: Int32 = 1 << 1
|
||||
|
||||
var inputSettings: Api.WallPaperSettings?
|
||||
if let inputWallpaperAndInputSettings = wallpaper?.apiInputWallpaperAndSettings {
|
||||
if let settings = settings {
|
||||
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
|
||||
return .fail(.generic)
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ public extension TelegramEngine {
|
||||
return _internal_setChatWallpaper(account: self.account, peerId: peerId, wallpaper: wallpaper)
|
||||
}
|
||||
|
||||
public func setExistingChatWallpaper(messageId: MessageId, wallpaper: TelegramWallpaper?) -> Signal<Void, SetExistingChatWallpaperError> {
|
||||
return _internal_setExistingChatWallpaper(account: self.account, messageId: messageId, wallpaper: wallpaper)
|
||||
public func setExistingChatWallpaper(messageId: MessageId, settings: WallpaperSettings?) -> Signal<Void, SetExistingChatWallpaperError> {
|
||||
return _internal_setExistingChatWallpaper(account: self.account, messageId: messageId, settings: settings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -386,6 +386,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component {
|
||||
|
||||
let titleString: String
|
||||
var allChatsAdded = false
|
||||
var canAddChatCount = 0
|
||||
if case .linkList = component.subject {
|
||||
//TODO:localize
|
||||
titleString = "Share Folder"
|
||||
@ -397,13 +398,14 @@ private final class ChatFolderLinkPreviewScreenComponent: Component {
|
||||
if linkContents.alreadyMemberPeerIds == Set(linkContents.peers.map(\.id)) {
|
||||
allChatsAdded = true
|
||||
}
|
||||
canAddChatCount = linkContents.peers.map(\.id).count - linkContents.alreadyMemberPeerIds.count
|
||||
|
||||
if allChatsAdded {
|
||||
titleString = "Add Folder"
|
||||
} else if linkContents.peers.count == 1 {
|
||||
titleString = "Add \(linkContents.peers.count) chat"
|
||||
} else if canAddChatCount == 1 {
|
||||
titleString = "Add \(canAddChatCount) chat"
|
||||
} else {
|
||||
titleString = "Add \(linkContents.peers.count) chats"
|
||||
titleString = "Add \(canAddChatCount) chats"
|
||||
}
|
||||
} else {
|
||||
titleString = "Add Folder"
|
||||
@ -433,8 +435,8 @@ private final class ChatFolderLinkPreviewScreenComponent: Component {
|
||||
var topBadge: String?
|
||||
if case .linkList = component.subject {
|
||||
} else if case .remove = component.subject {
|
||||
} else if !allChatsAdded, let linkContents = component.linkContents, linkContents.localFilterId != nil {
|
||||
topBadge = "+\(linkContents.peers.count)"
|
||||
} else if !allChatsAdded, let linkContents = component.linkContents, linkContents.localFilterId != nil, canAddChatCount != 0 {
|
||||
topBadge = "+\(canAddChatCount)"
|
||||
}
|
||||
|
||||
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?"
|
||||
} else {
|
||||
let chatCountString: String
|
||||
if linkContents.peers.count == 1 {
|
||||
if canAddChatCount == 1 {
|
||||
chatCountString = "1 chat"
|
||||
} else {
|
||||
chatCountString = "\(linkContents.peers.count) chats"
|
||||
chatCountString = "\(canAddChatCount) chats"
|
||||
}
|
||||
if let title = linkContents.title {
|
||||
text = "Do you want to add **\(chatCountString)** to the\nfolder **\(title)**?"
|
||||
@ -934,7 +936,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component {
|
||||
actionButtonBadge = 0
|
||||
actionButtonTitle = "OK"
|
||||
} 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 self.selectedItems.isEmpty {
|
||||
actionButtonTitle = "Do Not Join Any Chats"
|
||||
|
@ -846,7 +846,7 @@ 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, wallpaper: nil)
|
||||
let _ = (strongSelf.context.engine.themes.setExistingChatWallpaper(messageId: message.id, settings: nil)
|
||||
|> deliverOnMainQueue).start(completed: { [weak wallpaperPreviewController] in
|
||||
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)
|
||||
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
|
||||
|
@ -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 placeholderFrame = updatedImageFrame.insetBy(dx: innerImageInset, dy: innerImageInset)
|
||||
|
Loading…
x
Reference in New Issue
Block a user