diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 3bff09516c..21413559e7 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -255,6 +255,8 @@ "PUSH_MESSAGE_SUGGEST_USERPIC" = "%1$@|suggested you new profile photo"; +"PUSH_MESSAGE_WALLPAPER" = "%1$@ set a new background for the chat with you"; +"PUSH_MESSAGE_SAME_WALLPAPER" = "%1$@ set the same background for the chat with you"; "PUSH_REMINDER_TITLE" = "🗓 Reminder"; "PUSH_SENDER_YOU" = "📅 You"; diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 841213c27f..d9d620a424 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -3349,7 +3349,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { if let currentMutedIconImage = currentMutedIconImage { strongSelf.mutedIconNode.image = currentMutedIconImage strongSelf.mutedIconNode.isHidden = false - transition.updateFrame(node: strongSelf.mutedIconNode, frame: CGRect(origin: CGPoint(x: nextTitleIconOrigin - 5.0, y: titleFrame.maxY - currentMutedIconImage.size.height + 0.0 + UIScreenPixel), size: currentMutedIconImage.size)) + transition.updateFrame(node: strongSelf.mutedIconNode, frame: CGRect(origin: CGPoint(x: nextTitleIconOrigin - 5.0, y: floorToScreenPixels(titleFrame.midY - currentMutedIconImage.size.height / 2.0)), size: currentMutedIconImage.size)) nextTitleIconOrigin += currentMutedIconImage.size.width + 1.0 } else { strongSelf.mutedIconNode.image = nil diff --git a/submodules/Components/ViewControllerComponent/Sources/ViewControllerComponent.swift b/submodules/Components/ViewControllerComponent/Sources/ViewControllerComponent.swift index 0266f7142a..33b44070db 100644 --- a/submodules/Components/ViewControllerComponent/Sources/ViewControllerComponent.swift +++ b/submodules/Components/ViewControllerComponent/Sources/ViewControllerComponent.swift @@ -225,7 +225,7 @@ open class ViewControllerComponentContainer: ViewController { |> deliverOnMainQueue).start(next: { [weak self] presentationData in if let strongSelf = self { var theme = presentationData.theme - if case .modal = presentationMode, theme.list.blocksBackgroundColor.rgb == theme.list.plainBackgroundColor.rgb { + if case .modal = presentationMode { theme = theme.withModalBlocksBackground() } diff --git a/submodules/ComposePollUI/Sources/CreatePollController.swift b/submodules/ComposePollUI/Sources/CreatePollController.swift index e157558914..c523e844ec 100644 --- a/submodules/ComposePollUI/Sources/CreatePollController.swift +++ b/submodules/ComposePollUI/Sources/CreatePollController.swift @@ -870,10 +870,9 @@ public func createPollController(context: AccountContext, updatedPresentationDat ) |> map { presentationData, state, limitsConfiguration -> (ItemListControllerState, (ItemListNodeState, Any)) in var presentationData = presentationData - if presentationData.theme.list.blocksBackgroundColor.rgb == presentationData.theme.list.plainBackgroundColor.rgb { - let updatedTheme = presentationData.theme.withModalBlocksBackground() - presentationData = presentationData.withUpdated(theme: updatedTheme) - } + + let updatedTheme = presentationData.theme.withModalBlocksBackground() + presentationData = presentationData.withUpdated(theme: updatedTheme) var enabled = true if processPollText(state.text).isEmpty { diff --git a/submodules/ContactListUI/Sources/ContactsControllerNode.swift b/submodules/ContactListUI/Sources/ContactsControllerNode.swift index 387fb5b87d..c8c9914257 100644 --- a/submodules/ContactListUI/Sources/ContactsControllerNode.swift +++ b/submodules/ContactListUI/Sources/ContactsControllerNode.swift @@ -114,7 +114,7 @@ final class ContactsControllerNode: ASDisplayNode { strongSelf.presentationData = presentationData - if previousStrings !== presentationData.strings { + if previousStrings.baseLanguageCode != presentationData.strings.baseLanguageCode { strongSelf.stringsPromise.set(.single(presentationData.strings)) } diff --git a/submodules/LegacyComponents/Sources/TGPaintUtils.m b/submodules/LegacyComponents/Sources/TGPaintUtils.m index c512277404..d8c3fabf31 100644 --- a/submodules/LegacyComponents/Sources/TGPaintUtils.m +++ b/submodules/LegacyComponents/Sources/TGPaintUtils.m @@ -80,7 +80,7 @@ UIImage *TGPaintCombineCroppedImages(UIImage *background, UIImage *foreground, b CGFloat pRatio = foreground.size.width / originalSize.width; CGSize rotatedContentSize = TGRotatedContentSize(foreground.size, cropRotation); - UIGraphicsBeginImageContextWithOptions(background.size, opaque, 0.0); + UIGraphicsBeginImageContextWithOptions(background.size, opaque, 1.0); CGContextRef context = UIGraphicsGetCurrentContext(); CGRect backgroundRect = CGRectMake(0, 0, background.size.width, background.size.height); diff --git a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift index 2141c5d944..eb9d6215d5 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift @@ -1317,7 +1317,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { self.navigationItem.titleView = self.titleView if case let .assets(_, isStandalone) = self.subject, isStandalone { - self.navigationItem.leftBarButtonItem = UIBarButtonItem(backButtonAppearanceWithTitle: self.presentationData.strings.Common_Back, target: self, action: #selector(self.backPressed)) + self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed)) } else { if case let .assets(collection, _) = self.subject, collection != nil { self.navigationItem.leftBarButtonItem = UIBarButtonItem(backButtonAppearanceWithTitle: self.presentationData.strings.Common_Back, target: self, action: #selector(self.backPressed)) diff --git a/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift b/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift index 2e3299e879..ff47699cce 100644 --- a/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift +++ b/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift @@ -1063,6 +1063,10 @@ public func deviceContactInfoController(context: AccountContext, updatedPresenta let previousEditingPhoneIds = Atomic?>(value: nil) let signal = combineLatest(presentationData, statePromise.get(), contactData, hiddenAvatarPromise.get()) |> map { presentationData, state, peerAndContactData, hiddenAvatar -> (ItemListControllerState, (ItemListNodeState, Any)) in + var presentationData = presentationData + let updatedTheme = presentationData.theme.withModalBlocksBackground() + presentationData = presentationData.withUpdated(theme: updatedTheme) + var leftNavigationButton: ItemListNavigationButton? switch subject { case .vcard: diff --git a/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift b/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift index 9a69f600dd..673a53fb0f 100644 --- a/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift +++ b/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift @@ -196,7 +196,7 @@ func uploadCustomWallpaper(context: AccountContext, wallpaper: WallpaperGalleryE }).start() } -func uploadCustomPeerWallpaper(context: AccountContext, wallpaper: WallpaperGalleryEntry, mode: WallpaperPresentationOptions, cropRect: CGRect?, peerId: PeerId, completion: @escaping () -> Void) { +public func uploadCustomPeerWallpaper(context: AccountContext, wallpaper: WallpaperGalleryEntry, mode: WallpaperPresentationOptions, cropRect: CGRect?, peerId: PeerId, completion: @escaping () -> Void) { let imageSignal: Signal switch wallpaper { case let .wallpaper(wallpaper, _): @@ -276,7 +276,7 @@ func uploadCustomPeerWallpaper(context: AccountContext, wallpaper: WallpaperGall croppedImage = TGPhotoEditorCrop(image, nil, .up, 0.0, finalCropRect, false, CGSize(width: 1440.0, height: 2960.0), image.size, true) if mode.contains(.blur) { - croppedImage = blurredImage(croppedImage, radius: 45.0)! + croppedImage = blurredImage(croppedImage, radius: 30.0)! } let thumbnailDimensions = finalCropRect.size.fitted(CGSize(width: 320.0, height: 320.0)) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift index e4763e3c45..9d9c93a936 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift @@ -37,6 +37,7 @@ enum ThemeAccentColorControllerMode { final class ThemeAccentColorController: ViewController { private let context: AccountContext private let mode: ThemeAccentColorControllerMode + private let forChat: Bool private let section: ThemeColorSection private let initialBackgroundColor: UIColor? private var presentationData: PresentationData @@ -57,9 +58,10 @@ final class ThemeAccentColorController: ViewController { var completion: (() -> Void)? - init(context: AccountContext, mode: ThemeAccentColorControllerMode) { + init(context: AccountContext, mode: ThemeAccentColorControllerMode, forChat: Bool = false) { self.context = context self.mode = mode + self.forChat = forChat self.presentationData = context.sharedContext.currentPresentationData.with { $0 } let section: ThemeColorSection = .background @@ -143,7 +145,7 @@ final class ThemeAccentColorController: ViewController { initialWallpaper = self.presentationData.chatWallpaper } - self.displayNode = ThemeAccentColorControllerNode(context: self.context, mode: self.mode, theme: theme, wallpaper: initialWallpaper, dismiss: { [weak self] in + self.displayNode = ThemeAccentColorControllerNode(context: self.context, mode: self.mode, forChat: self.forChat, theme: theme, wallpaper: initialWallpaper, dismiss: { [weak self] in if let strongSelf = self { strongSelf.dismiss() } diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift index cdb56f665a..a500239f95 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift @@ -224,7 +224,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate } } - init(context: AccountContext, mode: ThemeAccentColorControllerMode, theme: PresentationTheme, wallpaper: TelegramWallpaper, dismiss: @escaping () -> Void, apply: @escaping (ThemeColorState, UIColor?) -> Void, ready: Promise) { + init(context: AccountContext, mode: ThemeAccentColorControllerMode, forChat: Bool, theme: PresentationTheme, wallpaper: TelegramWallpaper, dismiss: @escaping () -> Void, apply: @escaping (ThemeColorState, UIColor?) -> Void, ready: Promise) { self.context = context self.mode = mode self.state = ThemeColorState() @@ -306,9 +306,10 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate if case .edit(_, _, _, _, _, true, _) = self.mode { doneButtonType = .proceed } else { - doneButtonType = .set + doneButtonType = forChat ? .setPeer : .set } self.toolbarNode = WallpaperGalleryToolbarNode(theme: self.theme, strings: self.presentationData.strings, doneButtonType: doneButtonType) + self.toolbarNode.setDoneIsSolid(true, transition: .immediate) self.maskNode = ASImageNode() self.maskNode.displaysAsynchronously = false diff --git a/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift b/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift index 82cb6fad06..3511eadd64 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift @@ -102,17 +102,18 @@ private func availableColors(theme: PresentationTheme) -> [UInt32] { } } -final class ThemeColorsGridController: ViewController { +public final class ThemeColorsGridController: ViewController { private var controllerNode: ThemeColorsGridControllerNode { return self.displayNode as! ThemeColorsGridControllerNode } private let _ready = Promise() - override var ready: Promise { + public override var ready: Promise { return self._ready } private let context: AccountContext + private let peerId: PeerId? private var presentationData: PresentationData private var presentationDataDisposable: Disposable? @@ -121,8 +122,9 @@ final class ThemeColorsGridController: ViewController { private var previousContentOffset: GridNodeVisibleContentOffset? - init(context: AccountContext) { + public init(context: AccountContext, peerId: PeerId? = nil) { self.context = context + self.peerId = peerId self.presentationData = context.sharedContext.currentPresentationData.with { $0 } super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData)) @@ -169,9 +171,9 @@ final class ThemeColorsGridController: ViewController { } } - override func loadDisplayNode() { - self.displayNode = ThemeColorsGridControllerNode(context: self.context, presentationData: self.presentationData, gradients: availableGradients(theme: self.presentationData.theme), colors: availableColors(theme: self.presentationData.theme), present: { [weak self] controller, arguments in - self?.present(controller, in: .window(.root), with: arguments, blockInteraction: true) + public override func loadDisplayNode() { + self.displayNode = ThemeColorsGridControllerNode(context: self.context, presentationData: self.presentationData, peerId: self.peerId, gradients: availableGradients(theme: self.presentationData.theme), colors: availableColors(theme: self.presentationData.theme), push: { [weak self] controller in + self?.push(controller) }, pop: { [weak self] in if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController { let _ = navigationController.popViewController(animated: true) @@ -194,7 +196,7 @@ final class ThemeColorsGridController: ViewController { themeReference = settings.theme } - let controller = ThemeAccentColorController(context: strongSelf.context, mode: .background(themeReference: themeReference)) + let controller = ThemeAccentColorController(context: strongSelf.context, mode: .background(themeReference: themeReference), forChat: strongSelf.peerId != nil) controller.completion = { [weak self] in if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController { var controllers = navigationController.viewControllers @@ -249,7 +251,7 @@ final class ThemeColorsGridController: ViewController { self.displayNodeDidLoad() } - override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { + public override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { super.containerLayoutUpdated(layout, transition: transition) self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, transition: transition) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeColorsGridControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeColorsGridControllerNode.swift index b093d4428b..d03b53c1fa 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeColorsGridControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeColorsGridControllerNode.swift @@ -66,8 +66,9 @@ private func preparedThemeColorsGridEntryTransition(context: AccountContext, fro final class ThemeColorsGridControllerNode: ASDisplayNode { private let context: AccountContext private var presentationData: PresentationData + private let peerId: PeerId? private var controllerInteraction: ThemeColorsGridControllerInteraction? - private let present: (ViewController, Any?) -> Void + private let push: (ViewController) -> Void private let presentColorPicker: () -> Void let ready = ValuePromise() @@ -87,10 +88,11 @@ final class ThemeColorsGridControllerNode: ASDisplayNode { private var disposable: Disposable? - init(context: AccountContext, presentationData: PresentationData, gradients: [[UInt32]], colors: [UInt32], present: @escaping (ViewController, Any?) -> Void, pop: @escaping () -> Void, presentColorPicker: @escaping () -> Void) { + init(context: AccountContext, presentationData: PresentationData, peerId: PeerId?, gradients: [[UInt32]], colors: [UInt32], push: @escaping (ViewController) -> Void, pop: @escaping () -> Void, presentColorPicker: @escaping () -> Void) { self.context = context + self.peerId = peerId self.presentationData = presentationData - self.present = present + self.push = push self.presentColorPicker = presentColorPicker self.gridNode = GridNode() @@ -131,11 +133,12 @@ final class ThemeColorsGridControllerNode: ASDisplayNode { 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)) - controller.apply = { _, _, _ in + let controller = WallpaperGalleryController(context: context, source: .list(wallpapers: wallpapers, central: wallpaper, type: .colors), mode: strongSelf.peerId.flatMap { .peer($0) } ?? .default) + controller.navigationPresentation = .modal + controller.apply = { _, _, _ in pop() } - strongSelf.present(controller, nil) + strongSelf.push(controller) } } }) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift b/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift index c297370792..f4c5dc3d57 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift @@ -115,7 +115,7 @@ public final class ThemeGridController: ViewController { self.navigationItem.backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Back, style: .plain, target: nil, action: nil) if let isEmpty = self.isEmpty, isEmpty { - } else { + } else if case .default = mode { if self.editingMode { self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Done, style: .done, target: self, action: #selector(self.donePressed)) } else { @@ -215,7 +215,7 @@ public final class ThemeGridController: ViewController { if empty { strongSelf.navigationItem.setRightBarButton(nil, animated: true) - } else { + } else if case .default = strongSelf.mode { if strongSelf.editingMode { strongSelf.navigationItem.rightBarButtonItem = UIBarButtonItem(title: strongSelf.presentationData.strings.Common_Done, style: .done, target: strongSelf, action: #selector(strongSelf.donePressed)) } else { diff --git a/submodules/SettingsUI/Sources/Themes/ThemeGridControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeGridControllerNode.swift index 46fe2a32ea..d2dc4f4494 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeGridControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeGridControllerNode.swift @@ -263,8 +263,10 @@ final class ThemeGridControllerNode: ASDisplayNode { self.gridNode.addSubnode(self.colorItemNode) self.gridNode.addSubnode(self.galleryItemNode) self.gridNode.addSubnode(self.descriptionItemNode) - self.gridNode.addSubnode(self.resetItemNode) - self.gridNode.addSubnode(self.resetDescriptionItemNode) + if case .default = self.mode { + self.gridNode.addSubnode(self.resetItemNode) + self.gridNode.addSubnode(self.resetDescriptionItemNode) + } self.addSubnode(self.gridNode) let previousEntries = Atomic<[ThemeGridControllerEntry]?>(value: nil) @@ -348,10 +350,11 @@ final class ThemeGridControllerNode: ASDisplayNode { let transition = combineLatest(self.wallpapersPromise.get(), deletedWallpaperIdsPromise.get(), context.sharedContext.presentationData) |> map { wallpapers, deletedWallpaperIds, presentationData -> (ThemeGridEntryTransition, Bool) in var entries: [ThemeGridControllerEntry] = [] - var index = 1 + var index: Int = 0 if selectFirst { entries.insert(ThemeGridControllerEntry(index: 0, wallpaper: presentationData.chatWallpaper, isEditable: false, isSelected: true), at: 0) + index += 1 } var defaultWallpaper: TelegramWallpaper? @@ -422,10 +425,6 @@ final class ThemeGridControllerNode: ASDisplayNode { } } - /*if !entries.isEmpty { - entries = [entries[0]] - }*/ - let previous = previousEntries.swap(entries) return (preparedThemeGridEntryTransition(context: context, from: previous ?? [], to: entries, interaction: interaction), previous == nil) } @@ -757,7 +756,9 @@ final class ThemeGridControllerNode: ASDisplayNode { let makeResetDescriptionLayout = self.resetDescriptionItemNode.asyncLayout() let (resetDescriptionLayout, _) = makeResetDescriptionLayout(self.resetDescriptionItem, params, ItemListNeighbors(top: .none, bottom: .none)) - insets.bottom += buttonHeight + 35.0 + resetDescriptionLayout.contentSize.height + 32.0 + if case .default = self.mode { + insets.bottom += buttonHeight + 35.0 + resetDescriptionLayout.contentSize.height + 32.0 + } self.gridNode.frame = CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: layout.size.height) self.gridNode.transaction(GridNodeTransaction(deleteItems: [], insertItems: [], updateItems: [], scrollToItem: nil, updateLayout: GridNodeUpdateLayout(layout: GridNodeLayout(size: layout.size, insets: insets, scrollIndicatorInsets: scrollIndicatorInsets, preloadSize: 300.0, type: .fixed(itemSize: imageSize, fillWidth: nil, lineSpacing: spacing, itemSpacing: nil)), transition: transition), itemTransition: .immediate, stationaryItems: .none, updateFirstIndexInSectionOffset: nil), completion: { _ in }) diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift index 7f19484096..89e4136341 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift @@ -457,7 +457,6 @@ public class WallpaperGalleryController: ViewController { return } - switch entry { case let .wallpaper(wallpaper, _): var resource: MediaResource? diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift index 9c61d7c61d..e8972b5cf6 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift @@ -111,7 +111,7 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe case let .messageActionSetChatWallPaper(wallpaper): return TelegramMediaAction(action: .setChatWallpaper(wallpaper: TelegramWallpaper(apiWallpaper: wallpaper))) case .messageActionSetSameChatWallPaper: - return nil + return TelegramMediaAction(action: .setSameChatWallpaper) } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift index 1375319350..4d7c7609cf 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift @@ -141,7 +141,8 @@ func _internal_setChatWallpaper(account: Account, peerId: PeerId, wallpaper: Tel inputSettings = inputWallpaperAndInputSettings.1 } - return account.network.request(Api.functions.messages.setChatWallPaper(flags: 0, peer: inputPeer, wallpaper: inputWallpaper ?? .inputWallPaperNoFile(id: 0), settings: inputSettings ?? apiWallpaperSettings(WallpaperSettings()), id: nil)) + let flags: Int32 = 1 << 0 + return account.network.request(Api.functions.messages.setChatWallPaper(flags: flags, peer: inputPeer, wallpaper: inputWallpaper ?? .inputWallPaperNoFile(id: 0), settings: inputSettings ?? apiWallpaperSettings(WallpaperSettings()), id: nil)) |> `catch` { error in return .complete() } @@ -159,7 +160,20 @@ public enum SetExistingChatWallpaperError { func _internal_setExistingChatWallpaper(account: Account, messageId: MessageId) -> Signal { return account.postbox.transaction { transaction -> Peer? in - return transaction.getPeer(messageId.peerId) + 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 { + transaction.updatePeerCachedData(peerIds: Set([peer.id]), update: { _, current in + if let current = current as? CachedUserData { + return current.withUpdatedWallpaper(wallpaper) + } else { + return current + } + }) + } + return peer + } else { + return nil + } } |> castError(SetExistingChatWallpaperError.self) |> mapToSignal { peer -> Signal in diff --git a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift index a50dcdb2a8..42c5da6266 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift @@ -1603,7 +1603,11 @@ public final class PresentationTheme: Equatable { } public func withModalBlocksBackground() -> PresentationTheme { - let list = self.list.withUpdated(blocksBackgroundColor: self.list.modalBlocksBackgroundColor, itemBlocksBackgroundColor: self.list.itemModalBlocksBackgroundColor) - return PresentationTheme(name: self.name, index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: list, chatList: self.chatList, chat: self.chat, actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification, chart: self.chart, preview: self.preview) + if self.list.blocksBackgroundColor.rgb == self.list.plainBackgroundColor.rgb { + let list = self.list.withUpdated(blocksBackgroundColor: self.list.modalBlocksBackgroundColor, itemBlocksBackgroundColor: self.list.itemModalBlocksBackgroundColor) + return PresentationTheme(name: self.name, index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: list, chatList: self.chatList, chat: self.chat, actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification, chart: self.chart, preview: self.preview) + } else { + return self + } } } diff --git a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift index 25b189dc89..0e4f25ab67 100644 --- a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift +++ b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift @@ -1029,25 +1029,52 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { } |> distinctUntilChanged - let resultSignal = signal - |> mapToSignal { keywords -> Signal<[EmojiPagerContentComponent.ItemGroup], NoError> in + let resultSignal = combineLatest( + signal, + hasPremium + ) + |> mapToSignal { keywords, hasPremium -> Signal<[EmojiPagerContentComponent.ItemGroup], NoError> in var allEmoticons: [String: String] = [:] for keyword in keywords { for emoticon in keyword.emoticons { allEmoticons[emoticon] = keyword.keyword } } - - return combineLatest( - hasPremium, - context.engine.stickers.searchEmoji(emojiString: Array(allEmoticons.keys)) - ) - |> mapToSignal { hasPremium, foundEmoji -> Signal<[EmojiPagerContentComponent.ItemGroup], NoError> in + let remoteSignal: Signal<(items: [TelegramMediaFile], isFinalResult: Bool), NoError> + if hasPremium { + remoteSignal = context.engine.stickers.searchEmoji(emojiString: Array(allEmoticons.keys)) + } else { + remoteSignal = .single(([], true)) + } + return remoteSignal + |> mapToSignal { foundEmoji -> Signal<[EmojiPagerContentComponent.ItemGroup], NoError> in if foundEmoji.items.isEmpty && !foundEmoji.isFinalResult { return .complete() } var items: [EmojiPagerContentComponent.Item] = [] + let appendUnicodeEmoji = { + for (_, list) in EmojiPagerContentComponent.staticEmojiMapping { + for emojiString in list { + if allEmoticons[emojiString] != nil { + let item = EmojiPagerContentComponent.Item( + animationData: nil, + content: .staticEmoji(emojiString), + itemFile: nil, + subgroupId: nil, + icon: .none, + tintMode: .none + ) + items.append(item) + } + } + } + } + + if !hasPremium { + appendUnicodeEmoji() + } + var existingIds = Set() for itemFile in foundEmoji.items { if existingIds.contains(itemFile.fileId) { @@ -1061,12 +1088,17 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { let item = EmojiPagerContentComponent.Item( animationData: animationData, content: .animation(animationData), - itemFile: itemFile, subgroupId: nil, + itemFile: itemFile, + subgroupId: nil, icon: .none, tintMode: animationData.isTemplate ? .primary : .none ) items.append(item) } + + if hasPremium { + appendUnicodeEmoji() + } return .single([EmojiPagerContentComponent.ItemGroup( supergroupId: "search", diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift index 6bb3cfc864..0a9b72b465 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift @@ -29,26 +29,6 @@ private let premiumBadgeIcon: UIImage? = generateTintedImage(image: UIImage(bund private let featuredBadgeIcon: UIImage? = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Media/PanelBadgeAdd"), color: .white) private let lockedBadgeIcon: UIImage? = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Media/PanelBadgeLock"), color: .white) -private let staticEmojiMapping: [(EmojiPagerContentComponent.StaticEmojiSegment, [String])] = { - guard let path = getAppBundle().path(forResource: "emoji1016", ofType: "txt") else { - return [] - } - guard let string = try? String(contentsOf: URL(fileURLWithPath: path)) else { - return [] - } - - var result: [(EmojiPagerContentComponent.StaticEmojiSegment, [String])] = [] - - let orderedSegments = EmojiPagerContentComponent.StaticEmojiSegment.allCases - - let segments = string.components(separatedBy: "\n\n") - for i in 0 ..< min(segments.count, orderedSegments.count) { - let list = segments[i].components(separatedBy: " ") - result.append((orderedSegments[i], list)) - } - - return result -}() private final class WarpView: UIView { private final class WarpPartView: UIView { @@ -2226,6 +2206,27 @@ public protocol EmojiContentPeekBehavior: AnyObject { } public final class EmojiPagerContentComponent: Component { + public static let staticEmojiMapping: [(EmojiPagerContentComponent.StaticEmojiSegment, [String])] = { + guard let path = getAppBundle().path(forResource: "emoji1016", ofType: "txt") else { + return [] + } + guard let string = try? String(contentsOf: URL(fileURLWithPath: path)) else { + return [] + } + + var result: [(EmojiPagerContentComponent.StaticEmojiSegment, [String])] = [] + + let orderedSegments = EmojiPagerContentComponent.StaticEmojiSegment.allCases + + let segments = string.components(separatedBy: "\n\n") + for i in 0 ..< min(segments.count, orderedSegments.count) { + let list = segments[i].components(separatedBy: " ") + result.append((orderedSegments[i], list)) + } + + return result + }() + public typealias EnvironmentType = (EntityKeyboardChildEnvironment, PagerComponentChildEnvironment) public final class ContentAnimation { diff --git a/submodules/TelegramUI/Sources/AttachmentFileController.swift b/submodules/TelegramUI/Sources/AttachmentFileController.swift index 30cc6cfffc..a1e0ef24b3 100644 --- a/submodules/TelegramUI/Sources/AttachmentFileController.swift +++ b/submodules/TelegramUI/Sources/AttachmentFileController.swift @@ -273,10 +273,9 @@ func attachmentFileController(context: AccountContext, updatedPresentationData: ) |> map { presentationData, recentDocuments, state -> (ItemListControllerState, (ItemListNodeState, Any)) in var presentationData = presentationData - if presentationData.theme.list.blocksBackgroundColor.rgb == presentationData.theme.list.plainBackgroundColor.rgb { - let updatedTheme = presentationData.theme.withModalBlocksBackground() - presentationData = presentationData.withUpdated(theme: updatedTheme) - } + + let updatedTheme = presentationData.theme.withModalBlocksBackground() + presentationData = presentationData.withUpdated(theme: updatedTheme) let previousRecentDocuments = previousRecentDocuments.swap(recentDocuments) let crossfade = previousRecentDocuments == nil && recentDocuments != nil diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 15c86331c0..2e1560dd8d 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -839,10 +839,26 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.presentThemeSelection() return true case let .setChatWallpaper(wallpaper): + guard message.effectivelyIncoming(strongSelf.context.account.peerId) else { + return true + } strongSelf.chatDisplayNode.dismissInput() - let wallpaperPreviewController = WallpaperGalleryController(context: strongSelf.context, source: .wallpaper(wallpaper, nil, [], nil, nil, nil)) + let wallpaperPreviewController = WallpaperGalleryController(context: strongSelf.context, source: .wallpaper(wallpaper, nil, [], nil, nil, nil), mode: .peer(message.id.peerId)) + wallpaperPreviewController.apply = { wallpaper, options, _ in + let _ = (strongSelf.context.engine.themes.setExistingChatWallpaper(messageId: message.id) + |> deliverOnMainQueue).start(completed: { [weak wallpaperPreviewController] in + wallpaperPreviewController?.dismiss() + }) + } strongSelf.push(wallpaperPreviewController) return true + case .setSameChatWallpaper: + for attribute in message.attributes { + if let attribute = attribute as? ReplyMessageAttribute { + strongSelf.controllerInteraction?.navigateToMessage(message.id, attribute.messageId) + return true + } + } case let .giftPremium(_, _, duration, _, _): strongSelf.chatDisplayNode.dismissInput() let fromPeerId: PeerId = message.author?.id == strongSelf.context.account.peerId ? strongSelf.context.account.peerId : message.id.peerId @@ -16928,7 +16944,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G Queue.mainQueue().async { unblockingPeer.set(false) if let strongSelf = self, restartBot { - let _ = enqueueMessages(account: strongSelf.context.account, peerId: peerId, messages: [.message(text: "/start", attributes: [], inlineStickers: [:], mediaReference: nil, replyToMessageId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: [])]).start() + strongSelf.startBot(strongSelf.presentationInterfaceState.botStartPayload) } } })).start()) @@ -18489,8 +18505,47 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let themeController = strongSelf.themeScreen { strongSelf.themeScreen = nil themeController.dimTapped() + } + let dismissControllers = { [weak self] in + if let self, let navigationController = self.navigationController as? NavigationController { + let controllers = navigationController.viewControllers.filter({ controller in + if controller is WallpaperGalleryController || controller is MediaPickerScreen { + return false + } + return true + }) + navigationController.setViewControllers(controllers, animated: true) + } } - let controller = ThemeGridController(context: strongSelf.context, mode: .peer(peerId, strongSelf.presentationData.chatWallpaper)) + + let controller = MediaPickerScreen(context: strongSelf.context, peer: nil, threadTitle: nil, chatLocation: nil, bannedSendPhotos: nil, bannedSendVideos: nil, subject: .assets(nil, true)) + controller.navigationPresentation = .modal + controller.customSelection = { [weak self] asset in + guard let strongSelf = self else { + return + } + let controller = WallpaperGalleryController(context: strongSelf.context, source: .asset(asset), mode: .peer(peerId)) + controller.navigationPresentation = .modal + controller.apply = { [weak self] wallpaper, options, cropRect in + if let strongSelf = self { + uploadCustomPeerWallpaper(context: strongSelf.context, wallpaper: wallpaper, mode: options, cropRect: cropRect, peerId: peerId, completion: { + dismissControllers() + }) + } + } + strongSelf.push(controller) + } + strongSelf.push(controller) + }, + changeColor: { + guard let strongSelf = self, let peerId else { + return + } + if let themeController = strongSelf.themeScreen { + strongSelf.themeScreen = nil + themeController.dimTapped() + } + let controller = ThemeColorsGridController(context: context, peerId: peerId) controller.navigationPresentation = .modal strongSelf.push(controller) }, diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index b928764dfe..a695150d1c 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -1394,8 +1394,10 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { if case .scheduledMessages = interfaceState.subject { } else { - if let chatHistoryState = interfaceState.chatHistoryState, case .loaded(true) = chatHistoryState { - if let user = interfaceState.renderedPeer?.peer as? TelegramUser, user.botInfo != nil { + if let user = interfaceState.renderedPeer?.peer as? TelegramUser, user.botInfo != nil { + if let chatHistoryState = interfaceState.chatHistoryState, case .loaded(true) = chatHistoryState { + displayBotStartButton = true + } else if interfaceState.peerIsBlocked { displayBotStartButton = true } } diff --git a/submodules/TelegramUI/Sources/ChatThemeScreen.swift b/submodules/TelegramUI/Sources/ChatThemeScreen.swift index a2686e1b0c..32c75da6dd 100644 --- a/submodules/TelegramUI/Sources/ChatThemeScreen.swift +++ b/submodules/TelegramUI/Sources/ChatThemeScreen.swift @@ -556,6 +556,7 @@ final class ChatThemeScreen: ViewController { private let peerName: String private let previewTheme: (String?, Bool?) -> Void fileprivate let changeWallpaper: () -> Void + fileprivate let changeColor: () -> Void private let completion: (String?) -> Void private var presentationData: PresentationData @@ -579,6 +580,7 @@ final class ChatThemeScreen: ViewController { peerName: String, previewTheme: @escaping (String?, Bool?) -> Void, changeWallpaper: @escaping () -> Void, + changeColor: @escaping () -> Void, completion: @escaping (String?) -> Void ) { self.context = context @@ -588,6 +590,7 @@ final class ChatThemeScreen: ViewController { self.peerName = peerName self.previewTheme = previewTheme self.changeWallpaper = changeWallpaper + self.changeColor = changeColor self.completion = completion super.init(navigationBarPresentationData: nil) @@ -724,7 +727,9 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega private let animationContainerNode: ASDisplayNode private var animationNode: AnimationNode private let doneButton: SolidRoundedButtonNode - private let wallpaperButton: HighlightableButtonNode + private let galleryButton: HighlightableButtonNode + private let colorButton: HighlightableButtonNode + private let optionsButton: HighlightableButtonNode private let listNode: ListView private var entries: [ThemeSettingsThemeEntry]? @@ -818,9 +823,17 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega self.doneButton = SolidRoundedButtonNode(theme: SolidRoundedButtonTheme(theme: self.presentationData.theme), height: 52.0, cornerRadius: 11.0, gloss: false) self.doneButton.title = initiallySelectedEmoticon == nil ? self.presentationData.strings.Conversation_Theme_DontSetTheme : self.presentationData.strings.Conversation_Theme_Apply + self.doneButton.isHidden = true - self.wallpaperButton = HighlightableButtonNode() - self.wallpaperButton.setTitle("Set Background from Gallery", with: Font.regular(17.0), with: self.presentationData.theme.actionSheet.controlAccentColor, for: .normal) + self.galleryButton = HighlightableButtonNode() + self.galleryButton.setTitle("Choose Background From Photos", with: Font.regular(17.0), with: self.presentationData.theme.actionSheet.controlAccentColor, for: .normal) + + self.colorButton = HighlightableButtonNode() + self.colorButton.setTitle("Choose Color as a Background", with: Font.regular(17.0), with: self.presentationData.theme.actionSheet.controlAccentColor, for: .normal) + + self.optionsButton = HighlightableButtonNode() + self.optionsButton.setTitle("Other Options...", with: Font.regular(17.0), with: self.presentationData.theme.actionSheet.controlAccentColor, for: .normal) + self.optionsButton.isHidden = true self.listNode = ListView() self.listNode.transform = CATransform3DMakeRotation(-CGFloat.pi / 2.0, 0.0, 0.0, 1.0) @@ -844,7 +857,9 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega self.contentContainerNode.addSubnode(self.titleNode) self.contentContainerNode.addSubnode(self.textNode) self.contentContainerNode.addSubnode(self.doneButton) - self.contentContainerNode.addSubnode(self.wallpaperButton) + self.contentContainerNode.addSubnode(self.galleryButton) + self.contentContainerNode.addSubnode(self.colorButton) + self.contentContainerNode.addSubnode(self.optionsButton) self.topContentContainerNode.addSubnode(self.animationContainerNode) self.animationContainerNode.addSubnode(self.animationNode) @@ -860,7 +875,9 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega strongSelf.completion?(strongSelf.selectedEmoticon) } } - self.wallpaperButton.addTarget(self, action: #selector(self.wallpaperButtonPressed), forControlEvents: .touchUpInside) + self.galleryButton.addTarget(self, action: #selector(self.galleryButtonPressed), forControlEvents: .touchUpInside) + self.colorButton.addTarget(self, action: #selector(self.colorButtonPressed), forControlEvents: .touchUpInside) + self.optionsButton.addTarget(self, action: #selector(self.optionsButtonPressed), forControlEvents: .touchUpInside) self.disposable.set(combineLatest(queue: Queue.mainQueue(), self.context.engine.themes.getChatThemes(accountManager: self.context.sharedContext.accountManager), self.selectedEmoticonPromise.get(), self.isDarkAppearancePromise.get()).start(next: { [weak self] themes, selectedEmoticon, isDarkAppearance in guard let strongSelf = self else { @@ -881,24 +898,7 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega let action: (String?) -> Void = { [weak self] emoticon in if let strongSelf = self, strongSelf.selectedEmoticon != emoticon { - strongSelf.animateCrossfade(animateIcon: true) - - strongSelf.previewTheme?(emoticon, strongSelf.isDarkAppearance) - strongSelf.selectedEmoticon = emoticon - let _ = ensureThemeVisible(listNode: strongSelf.listNode, emoticon: emoticon, animated: true) - - let doneButtonTitle: String - if emoticon == nil { - doneButtonTitle = strongSelf.initiallySelectedEmoticon == nil ? strongSelf.presentationData.strings.Conversation_Theme_DontSetTheme : strongSelf.presentationData.strings.Conversation_Theme_Reset - } else { - doneButtonTitle = strongSelf.presentationData.strings.Conversation_Theme_Apply - } - strongSelf.doneButton.title = doneButtonTitle - - strongSelf.themeSelectionsCount += 1 - if strongSelf.themeSelectionsCount == 2 { - strongSelf.maybePresentPreviewTooltip() - } + strongSelf.setEmoticon(emoticon) } } let previousEntries = strongSelf.entries ?? [] @@ -987,6 +987,35 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega }) } + private func setEmoticon(_ emoticon: String?) { + self.animateCrossfade(animateIcon: true) + + self.previewTheme?(emoticon, self.isDarkAppearance) + self.selectedEmoticon = emoticon + let _ = ensureThemeVisible(listNode: self.listNode, emoticon: emoticon, animated: true) + + let doneButtonTitle: String + if emoticon == nil { + self.doneButton.isHidden = true + self.galleryButton.isHidden = false + self.colorButton.isHidden = false + self.optionsButton.isHidden = true + doneButtonTitle = self.initiallySelectedEmoticon == nil ? self.presentationData.strings.Conversation_Theme_DontSetTheme : self.presentationData.strings.Conversation_Theme_Reset + } else { + self.doneButton.isHidden = false + self.galleryButton.isHidden = true + self.colorButton.isHidden = true + self.optionsButton.isHidden = false + doneButtonTitle = self.presentationData.strings.Conversation_Theme_Apply + } + self.doneButton.title = doneButtonTitle + + self.themeSelectionsCount += 1 + if self.themeSelectionsCount == 2 { + self.maybePresentPreviewTooltip() + } + } + func updatePresentationData(_ presentationData: PresentationData) { guard !self.animatedOut else { return @@ -1037,10 +1066,18 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega self.cancel?() } - @objc func wallpaperButtonPressed() { + @objc func galleryButtonPressed() { self.controller?.changeWallpaper() } + @objc func colorButtonPressed() { + self.controller?.changeColor() + } + + @objc func optionsButtonPressed() { + self.setEmoticon(nil) + } + func dimTapped() { if self.selectedEmoticon == self.initiallySelectedEmoticon { self.cancelButtonPressed() @@ -1098,14 +1135,14 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega self.contentBackgroundNode.layer.animate(from: previousColor.cgColor, to: (self.contentBackgroundNode.backgroundColor ?? .clear).cgColor, keyPath: "backgroundColor", timingFunction: CAMediaTimingFunctionName.linear.rawValue, duration: ChatThemeScreen.themeCrossfadeDuration) } - if let snapshotView = self.contentContainerNode.view.snapshotView(afterScreenUpdates: false) { - snapshotView.frame = self.contentContainerNode.frame - self.contentContainerNode.view.superview?.insertSubview(snapshotView, aboveSubview: self.contentContainerNode.view) - - snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: ChatThemeScreen.themeCrossfadeDuration, delay: ChatThemeScreen.themeCrossfadeDelay, timingFunction: CAMediaTimingFunctionName.linear.rawValue, removeOnCompletion: false, completion: { [weak snapshotView] _ in - snapshotView?.removeFromSuperview() - }) - } +// if let snapshotView = self.contentContainerNode.view.snapshotView(afterScreenUpdates: false) { +// snapshotView.frame = self.contentContainerNode.frame +// self.contentContainerNode.view.superview?.insertSubview(snapshotView, aboveSubview: self.contentContainerNode.view) +// +// snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: ChatThemeScreen.themeCrossfadeDuration, delay: ChatThemeScreen.themeCrossfadeDelay, timingFunction: CAMediaTimingFunctionName.linear.rawValue, removeOnCompletion: false, completion: { [weak snapshotView] _ in +// snapshotView?.removeFromSuperview() +// }) +// } self.listNode.forEachVisibleItemNode { node in if let node = node as? ThemeSettingsThemeItemIconNode { @@ -1258,8 +1295,14 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega let doneButtonHeight = self.doneButton.updateLayout(width: contentFrame.width - buttonInset * 2.0, transition: transition) transition.updateFrame(node: self.doneButton, frame: CGRect(x: buttonInset, y: contentHeight - doneButtonHeight - 50.0 - insets.bottom - 6.0, width: contentFrame.width, height: doneButtonHeight)) - let wallpaperButtonSize = self.wallpaperButton.measure(CGSize(width: contentFrame.width - buttonInset * 2.0, height: .greatestFiniteMagnitude)) - transition.updateFrame(node: self.wallpaperButton, frame: CGRect(origin: CGPoint(x: floor((contentFrame.width - wallpaperButtonSize.width) / 2.0), y: contentHeight - wallpaperButtonSize.height - insets.bottom - 6.0 - 9.0), size: wallpaperButtonSize)) + let wallpaperButtonSize = self.galleryButton.measure(CGSize(width: contentFrame.width - buttonInset * 2.0, height: .greatestFiniteMagnitude)) + transition.updateFrame(node: self.galleryButton, frame: CGRect(origin: CGPoint(x: floor((contentFrame.width - wallpaperButtonSize.width) / 2.0), y: contentHeight - doneButtonHeight / 2.0 - wallpaperButtonSize.height / 2.0 - 50.0 - insets.bottom - 6.0), size: wallpaperButtonSize)) + + let colorButtonSize = self.galleryButton.measure(CGSize(width: contentFrame.width - buttonInset * 2.0, height: .greatestFiniteMagnitude)) + transition.updateFrame(node: self.colorButton, frame: CGRect(origin: CGPoint(x: floor((contentFrame.width - colorButtonSize.width) / 2.0), y: contentHeight - colorButtonSize.height - insets.bottom - 6.0 - 9.0), size: colorButtonSize)) + + let optionsButtonSize = self.galleryButton.measure(CGSize(width: contentFrame.width - buttonInset * 2.0, height: .greatestFiniteMagnitude)) + transition.updateFrame(node: self.optionsButton, frame: CGRect(origin: CGPoint(x: floor((contentFrame.width - optionsButtonSize.width) / 2.0), y: contentHeight - optionsButtonSize.height - insets.bottom - 6.0 - 9.0), size: optionsButtonSize)) transition.updateFrame(node: self.contentContainerNode, frame: contentContainerFrame) transition.updateFrame(node: self.topContentContainerNode, frame: contentContainerFrame) diff --git a/submodules/TelegramUI/Sources/FetchCachedRepresentations.swift b/submodules/TelegramUI/Sources/FetchCachedRepresentations.swift index 0bd2cc6f99..2ee3fccb9a 100644 --- a/submodules/TelegramUI/Sources/FetchCachedRepresentations.swift +++ b/submodules/TelegramUI/Sources/FetchCachedRepresentations.swift @@ -398,7 +398,7 @@ private func fetchCachedBlurredWallpaperRepresentation(resource: MediaResource, let path = NSTemporaryDirectory() + "\(Int64.random(in: Int64.min ... Int64.max))" let url = URL(fileURLWithPath: path) - if let colorImage = blurredImage(image, radius: 45.0), let colorDestination = CGImageDestinationCreateWithURL(url as CFURL, kUTTypeJPEG, 1, nil) { + if let colorImage = blurredImage(image, radius: 30.0), let colorDestination = CGImageDestinationCreateWithURL(url as CFURL, kUTTypeJPEG, 1, nil) { CGImageDestinationSetProperties(colorDestination, [:] as CFDictionary) let colorQuality: Float = 0.5 @@ -447,7 +447,7 @@ private func fetchCachedBlurredWallpaperRepresentation(account: Account, resourc let path = NSTemporaryDirectory() + "\(Int64.random(in: Int64.min ... Int64.max))" let url = URL(fileURLWithPath: path) - if let colorImage = blurredImage(image, radius: 45.0), let colorDestination = CGImageDestinationCreateWithURL(url as CFURL, kUTTypeJPEG, 1, nil) { + if let colorImage = blurredImage(image, radius: 30.0), let colorDestination = CGImageDestinationCreateWithURL(url as CFURL, kUTTypeJPEG, 1, nil) { CGImageDestinationSetProperties(colorDestination, [:] as CFDictionary) let colorQuality: Float = 0.5 diff --git a/submodules/WallpaperResources/Sources/WallpaperResources.swift b/submodules/WallpaperResources/Sources/WallpaperResources.swift index 7e149abeb2..3b6c123ad8 100644 --- a/submodules/WallpaperResources/Sources/WallpaperResources.swift +++ b/submodules/WallpaperResources/Sources/WallpaperResources.swift @@ -300,6 +300,7 @@ public func wallpaperImage(account: Account, accountManager: AccountManager