diff --git a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift index 304251b50f..97c3a39a9d 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift @@ -385,32 +385,40 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { override func didLoad() { super.didLoad() + guard let controller = self.controller else { + return + } + self.gridNode.scrollView.alwaysBounceVertical = true self.gridNode.scrollView.showsVerticalScrollIndicator = false - let selectionGesture = MediaPickerGridSelectionGesture() - selectionGesture.delegate = self - selectionGesture.began = { [weak self] in - self?.controller?.cancelPanGesture() - } - selectionGesture.updateIsScrollEnabled = { [weak self] isEnabled in - self?.gridNode.scrollView.isScrollEnabled = isEnabled - } - selectionGesture.itemAt = { [weak self] point in - if let strongSelf = self, let itemNode = strongSelf.gridNode.itemNodeAtPoint(point) as? MediaPickerGridItemNode, let selectableItem = itemNode.selectableItem { - return (selectableItem, strongSelf.controller?.interaction?.selectionState?.isIdentifierSelected(selectableItem.uniqueIdentifier) ?? false) - } else { - return nil + if case let .assets(_, mode) = controller.subject, case .wallpaper = mode { + + } else { + let selectionGesture = MediaPickerGridSelectionGesture() + selectionGesture.delegate = self + selectionGesture.began = { [weak self] in + self?.controller?.cancelPanGesture() } - } - selectionGesture.updateSelection = { [weak self] asset, selected in - if let strongSelf = self { - strongSelf.controller?.interaction?.selectionState?.setItem(asset, selected: selected, animated: true, sender: nil) + selectionGesture.updateIsScrollEnabled = { [weak self] isEnabled in + self?.gridNode.scrollView.isScrollEnabled = isEnabled } + selectionGesture.itemAt = { [weak self] point in + if let strongSelf = self, let itemNode = strongSelf.gridNode.itemNodeAtPoint(point) as? MediaPickerGridItemNode, let selectableItem = itemNode.selectableItem { + return (selectableItem, strongSelf.controller?.interaction?.selectionState?.isIdentifierSelected(selectableItem.uniqueIdentifier) ?? false) + } else { + return nil + } + } + selectionGesture.updateSelection = { [weak self] asset, selected in + if let strongSelf = self { + strongSelf.controller?.interaction?.selectionState?.setItem(asset, selected: selected, animated: true, sender: nil) + } + } + selectionGesture.sideInset = 44.0 + self.gridNode.view.addGestureRecognizer(selectionGesture) + self.selectionGesture = selectionGesture } - selectionGesture.sideInset = 44.0 - self.gridNode.view.addGestureRecognizer(selectionGesture) - self.selectionGesture = selectionGesture if let controller = self.controller, case let .assets(collection, _) = controller.subject, collection != nil { self.gridNode.view.interactiveTransitionGestureRecognizerTest = { point -> Bool in @@ -741,7 +749,11 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { } if let customSelection = controller.customSelection { + self.openingMedia = true customSelection(fetchResult[index]) + Queue.mainQueue().after(0.3) { + self.openingMedia = false + } return } @@ -2016,6 +2028,7 @@ public func wallpaperMediaPickerController( let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: nil, buttons: [.standalone], initialButton: .standalone, fromMenu: false, hasTextInput: false, makeEntityInputView: { return nil }) + //controller.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait) controller.requestController = { [weak controller] _, present in let presentationData = context.sharedContext.currentPresentationData.with { $0 } let mediaPickerController = MediaPickerScreen(context: context, peer: nil, threadTitle: nil, chatLocation: nil, bannedSendPhotos: nil, bannedSendVideos: nil, subject: .assets(nil, .wallpaper), mainButtonState: AttachmentMainButtonState(text: presentationData.strings.Conversation_Theme_SetColorWallpaper, font: .regular, background: .color(.clear), textColor: presentationData.theme.actionSheet.controlAccentColor, isVisible: true, progress: .none, isEnabled: true), mainButtonAction: { diff --git a/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift b/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift index 454225d3d7..71c6d650c2 100644 --- a/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift +++ b/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift @@ -293,7 +293,7 @@ public func uploadCustomPeerWallpaper(context: AccountContext, wallpaper: Wallpa var intensity: Int32? if let brightness { - intensity = Int32(brightness * 100.0) + intensity = max(1, Int32(brightness * 100.0)) } let settings = WallpaperSettings(blur: mode.contains(.blur), motion: mode.contains(.motion), colors: [], intensity: intensity) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift index 9ead4f5c37..12d8f61d15 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift @@ -152,6 +152,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate private let context: AccountContext private var theme: PresentationTheme private let mode: ThemeAccentColorControllerMode + private let resultMode: ThemeAccentColorController.ResultMode private var presentationData: PresentationData private let animationCache: AnimationCache @@ -227,6 +228,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate init(context: AccountContext, mode: ThemeAccentColorControllerMode, resultMode: ThemeAccentColorController.ResultMode, theme: PresentationTheme, wallpaper: TelegramWallpaper, dismiss: @escaping () -> Void, apply: @escaping (ThemeColorState, UIColor?) -> Void, ready: Promise) { self.context = context self.mode = mode + self.resultMode = resultMode self.state = ThemeColorState() self.presentationData = context.sharedContext.currentPresentationData.with { $0 } self.theme = theme @@ -766,6 +768,8 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate } else { if case .edit(_, _, _, _, _, true, _) = self.mode { doneButtonType = .proceed + } else if case .peer = self.resultMode { + doneButtonType = .setPeer } else { doneButtonType = .set } diff --git a/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift b/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift index 963e1244c2..36a5493534 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift @@ -394,6 +394,7 @@ public func standaloneColorPickerController( let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: nil, buttons: [.standalone], initialButton: .standalone, fromMenu: false, hasTextInput: false, makeEntityInputView: { return nil }) + //controller.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait) controller.requestController = { _, present in let colorPickerController = ThemeColorsGridController(context: context, mode: .peer(peer)) colorPickerController.pushController = { controller in diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift index 378b2b380a..f7eb64d7d6 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift @@ -1433,7 +1433,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { let _ = (signal |> deliverOnMainQueue).start(next: { [weak self] count, timestamp in - if let strongSelf = self, (count < 2 && currentTimestamp > timestamp + 24 * 60 * 60) || "".isEmpty { + if let strongSelf = self, (count < 2 && currentTimestamp > timestamp + 24 * 60 * 60) { strongSelf.displayedPreviewTooltip = true let controller = TooltipScreen(account: strongSelf.context.account, sharedContext: strongSelf.context.sharedContext, text: isDark ? strongSelf.presentationData.strings.WallpaperPreview_PreviewInDayMode : strongSelf.presentationData.strings.WallpaperPreview_PreviewInNightMode, style: .customBlur(UIColor(rgb: 0x333333, alpha: 0.33)), icon: nil, location: .point(frame.offsetBy(dx: 1.0, dy: 6.0), .bottom), displayDuration: .custom(3.0), inset: 3.0, shouldDismissOnTouch: { _ in diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 5b5e2c9c82..d7eb301bc4 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -10970,6 +10970,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return false } + if strongSelf.effectiveNavigationController?.topViewController !== strongSelf { + return false + } + if strongSelf.presentationInterfaceState.inputTextPanelState.mediaRecordingState != nil { return false } @@ -18617,6 +18621,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G openWallpaperPickerImpl = openWallpaperPicker openWallpaperPicker() }, + resetWallpaper: { [weak self] in + guard let strongSelf = self, let peerId else { + return + } + let _ = strongSelf.context.engine.themes.setChatWallpaper(peerId: peerId, wallpaper: nil).start() + }, completion: { [weak self] emoticon in guard let strongSelf = self, let peerId else { return @@ -18629,6 +18639,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }) } ) + controller.navigationPresentation = .flatModal controller.passthroughHitTestImpl = { [weak self] _ in if let strongSelf = self { return strongSelf.chatDisplayNode.historyNode.view @@ -18644,7 +18655,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.chatDisplayNode.historyNode.tapped = { [weak controller] in controller?.dimTapped() } - strongSelf.present(controller, in: .window(.root)) + strongSelf.push(controller) + //strongSelf.present(controller, in: .window(.root)) strongSelf.themeScreen = controller }) } diff --git a/submodules/TelegramUI/Sources/ChatThemeScreen.swift b/submodules/TelegramUI/Sources/ChatThemeScreen.swift index ae3a1955fb..0b2f0ac4fd 100644 --- a/submodules/TelegramUI/Sources/ChatThemeScreen.swift +++ b/submodules/TelegramUI/Sources/ChatThemeScreen.swift @@ -557,6 +557,7 @@ final class ChatThemeScreen: ViewController { let canResetWallpaper: Bool private let previewTheme: (String?, Bool?) -> Void fileprivate let changeWallpaper: () -> Void + fileprivate let resetWallpaper: () -> Void private let completion: (String?) -> Void private var presentationData: PresentationData @@ -581,6 +582,7 @@ final class ChatThemeScreen: ViewController { canResetWallpaper: Bool, previewTheme: @escaping (String?, Bool?) -> Void, changeWallpaper: @escaping () -> Void, + resetWallpaper: @escaping () -> Void, completion: @escaping (String?) -> Void ) { self.context = context @@ -591,12 +593,15 @@ final class ChatThemeScreen: ViewController { self.canResetWallpaper = canResetWallpaper self.previewTheme = previewTheme self.changeWallpaper = changeWallpaper + self.resetWallpaper = resetWallpaper self.completion = completion super.init(navigationBarPresentationData: nil) self.statusBar.statusBarStyle = .Ignore + self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait) + self.blocksBackgroundWhenInOverlay = true self.presentationDataDisposable = (updatedPresentationData.signal @@ -1107,7 +1112,8 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega self.setEmoticon(self.initiallySelectedEmoticon) } else { if self.controller?.canResetWallpaper == true { - + self.controller?.resetWallpaper() + self.cancelButtonPressed() } else { self.cancelButtonPressed() }