diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 00648a40d0..72eb35c170 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -9754,3 +9754,5 @@ Sorry for the inconvenience."; "StoryList.TooltipStoriesSavedToProfile_any" = "%d stories archived."; "Premium.New" = "NEW"; + +"MediaEditor.AddGif" = "Add GIF"; diff --git a/submodules/DrawingUI/Sources/DrawingScreen.swift b/submodules/DrawingUI/Sources/DrawingScreen.swift index e71f9c2ef9..9a8a55bf1a 100644 --- a/submodules/DrawingUI/Sources/DrawingScreen.swift +++ b/submodules/DrawingUI/Sources/DrawingScreen.swift @@ -516,6 +516,7 @@ private final class DrawingScreenComponent: CombinedComponent { let updateEntityView: ActionSlot<(UUID, Bool)> let endEditingTextEntityView: ActionSlot<(UUID, Bool)> let entityViewForEntity: (DrawingEntity) -> DrawingEntityView? + let presentGallery: (() -> Void)? let apply: ActionSlot let dismiss: ActionSlot @@ -551,6 +552,7 @@ private final class DrawingScreenComponent: CombinedComponent { updateEntityView: ActionSlot<(UUID, Bool)>, endEditingTextEntityView: ActionSlot<(UUID, Bool)>, entityViewForEntity: @escaping (DrawingEntity) -> DrawingEntityView?, + presentGallery: (() -> Void)?, apply: ActionSlot, dismiss: ActionSlot, presentColorPicker: @escaping (DrawingColor) -> Void, @@ -584,6 +586,7 @@ private final class DrawingScreenComponent: CombinedComponent { self.updateEntityView = updateEntityView self.endEditingTextEntityView = endEditingTextEntityView self.entityViewForEntity = entityViewForEntity + self.presentGallery = presentGallery self.apply = apply self.dismiss = dismiss self.presentColorPicker = presentColorPicker @@ -665,6 +668,7 @@ private final class DrawingScreenComponent: CombinedComponent { private let toggleWithPreviousTool: ActionSlot private let insertSticker: ActionSlot private let insertText: ActionSlot + fileprivate var presentGallery: (() -> Void)? private let updateEntityView: ActionSlot<(UUID, Bool)> private let endEditingTextEntityView: ActionSlot<(UUID, Bool)> private let entityViewForEntity: (DrawingEntity) -> DrawingEntityView? @@ -692,6 +696,7 @@ private final class DrawingScreenComponent: CombinedComponent { toggleWithPreviousTool: ActionSlot, insertSticker: ActionSlot, insertText: ActionSlot, + presentGallery: (() -> Void)?, updateEntityView: ActionSlot<(UUID, Bool)>, endEditingTextEntityView: ActionSlot<(UUID, Bool)>, entityViewForEntity: @escaping (DrawingEntity) -> DrawingEntityView?, @@ -707,6 +712,7 @@ private final class DrawingScreenComponent: CombinedComponent { self.toggleWithPreviousTool = toggleWithPreviousTool self.insertSticker = insertSticker self.insertText = insertText + self.presentGallery = presentGallery self.updateEntityView = updateEntityView self.endEditingTextEntityView = endEditingTextEntityView self.entityViewForEntity = entityViewForEntity @@ -1004,6 +1010,9 @@ private final class DrawingScreenComponent: CombinedComponent { self.updateEntitiesPlayback.invoke(false) let controller = StickerPickerScreen(context: self.context, inputData: self.stickerPickerInputData.get()) + if let presentGallery = self.presentGallery { + controller.presentGallery = presentGallery + } controller.completion = { [weak self] content in self?.updateEntitiesPlayback.invoke(true) @@ -1032,6 +1041,7 @@ private final class DrawingScreenComponent: CombinedComponent { toggleWithPreviousTool: self.toggleWithPreviousTool, insertSticker: self.insertSticker, insertText: self.insertText, + presentGallery: self.presentGallery, updateEntityView: self.updateEntityView, endEditingTextEntityView: self.endEditingTextEntityView, entityViewForEntity: self.entityViewForEntity, @@ -1113,6 +1123,8 @@ private final class DrawingScreenComponent: CombinedComponent { let updateEntityView = component.updateEntityView let endEditingTextEntityView = component.endEditingTextEntityView + state.presentGallery = component.presentGallery + component.updateState.connect { [weak state] updatedState in state?.updateDrawingState(updatedState) } @@ -2670,6 +2682,7 @@ public class DrawingScreen: ViewController, TGPhotoDrawingInterfaceController, U return nil } }, + presentGallery: self.controller?.presentGallery, apply: self.apply, dismiss: self.dismiss, presentColorPicker: { [weak self] initialColor in @@ -2737,6 +2750,8 @@ public class DrawingScreen: ViewController, TGPhotoDrawingInterfaceController, U public var getCurrentImage: () -> UIImage? = { return nil } public var updateVideoPlayback: (Bool) -> Void = { _ in } + public var presentGallery: (() -> Void)? + public init(context: AccountContext, sourceHint: SourceHint? = nil, size: CGSize, originalSize: CGSize, isVideo: Bool, isAvatar: Bool, drawingView: DrawingView?, entitiesView: (UIView & TGPhotoDrawingEntitiesView)?, selectionContainerView: DrawingSelectionContainerView?, existingStickerPickerInputData: Promise? = nil) { self.context = context self.sourceHint = sourceHint @@ -2965,7 +2980,7 @@ public final class DrawingToolsInteraction { private let onInteractionUpdated: (Bool) -> Void private let onTextEditingEnded: (Bool) -> Void private let editEntity: (DrawingEntity) -> Void - + public let getCurrentImage: () -> UIImage? private let getControllerNode: () -> ASDisplayNode? private let present: (ViewController, PresentationContextType, Any?) -> Void diff --git a/submodules/DrawingUI/Sources/StickerPickerScreen.swift b/submodules/DrawingUI/Sources/StickerPickerScreen.swift index 6410f5d443..8720b77c81 100644 --- a/submodules/DrawingUI/Sources/StickerPickerScreen.swift +++ b/submodules/DrawingUI/Sources/StickerPickerScreen.swift @@ -708,7 +708,7 @@ public class StickerPickerScreen: ViewController { if !canSaveGif { isGifSaved = false } - let presentationData = context.sharedContext.currentPresentationData.with { $0 } + let presentationData = context.sharedContext.currentPresentationData.with { $0 }.withUpdated(theme: defaultDarkPresentationTheme) let message = Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: PeerId(0), namespace: Namespaces.Message.Local, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [file.media], peers: SimpleDictionary(), associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]) @@ -717,8 +717,8 @@ public class StickerPickerScreen: ViewController { gallery.setHintWillBePresentedInPreviewingContext(true) var items: [ContextMenuItem] = [] - items.append(.action(ContextMenuActionItem(text: presentationData.strings.MediaPicker_Send, icon: { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.actionSheet.primaryTextColor) + items.append(.action(ContextMenuActionItem(text: presentationData.strings.MediaEditor_AddGif, icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Add"), color: theme.actionSheet.primaryTextColor) }, action: { [weak self] _, f in f(.default) if let self { diff --git a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift index 461bb52e9d..635916808d 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift @@ -1673,8 +1673,8 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { self.updateSelectionState(count: Int32(selectionContext.count())) self.longTapWithTabBar = { [weak self] in - if let strongSelf = self { - strongSelf.presentSearch(activateOnDisplay: false) + if let self, self.groupsController == nil { + self.presentSearch(activateOnDisplay: false) } } } @@ -1924,6 +1924,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { self.controllerNode.updateNavigation(delayDisappear: true, transition: .immediate) } + private weak var groupsController: MediaGroupsScreen? private func presentSearch(activateOnDisplay: Bool) { guard self.moreButtonNode.iconNode.iconState == .search, case let .assets(_, mode) = self.subject else { return @@ -1976,6 +1977,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { } else { self.presentWebSearch(groupsController, activateOnDisplay) } + self.groupsController = groupsController } @objc private func searchOrMorePressed(node: ContextReferenceContentNode, gesture: ContextGesture?) { diff --git a/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift b/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift index 4e7c1bb32a..02f870ac95 100644 --- a/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift @@ -256,6 +256,8 @@ public class PremiumLimitsListScreen: ViewController { }) let alphaTransition: ContainedViewLayoutTransition = .animated(duration: 0.25, curve: .easeInOut) alphaTransition.updateAlpha(node: self.dim, alpha: 0.0) + + self.controller?.updateModalStyleOverlayTransitionFactor(0.0, transition: positionTransition) } private var dismissOffset: CGFloat? diff --git a/submodules/PremiumUI/Sources/StoriesPageComponent.swift b/submodules/PremiumUI/Sources/StoriesPageComponent.swift index a1369162ed..0114304454 100644 --- a/submodules/PremiumUI/Sources/StoriesPageComponent.swift +++ b/submodules/PremiumUI/Sources/StoriesPageComponent.swift @@ -359,7 +359,7 @@ private final class StoriesListComponent: CombinedComponent { component: AnyComponent(ParagraphComponent( title: "Stealth Mode", titleColor: titleColor, - text: "Hide the fact that you viewd other people's stories.", + text: "Hide the fact that you viewed other people's stories.", textColor: textColor, iconName: "Premium/Stories/Stealth", iconColor: colors[1] @@ -373,7 +373,7 @@ private final class StoriesListComponent: CombinedComponent { component: AnyComponent(ParagraphComponent( title: "Permanent Views History", titleColor: titleColor, - text: "Check who opens your stories - even after they expire.", + text: "Check who opens your stories — even after they expire.", textColor: textColor, iconName: "Premium/Stories/Views", iconColor: colors[2] diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboard.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboard.swift index 8d63911b0c..7bc60ace4e 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboard.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboard.swift @@ -404,76 +404,19 @@ public final class EntityKeyboardComponent: Component { if let gifContent = component.gifContent { contents.append(AnyComponentWithIdentity(id: "gifs", component: AnyComponent(gifContent))) - /*var topGifItems: [EntityKeyboardTopPanelComponent.Item] = [] - if component.hasRecentGifs { - topGifItems.append(EntityKeyboardTopPanelComponent.Item( - id: "recent", - isReorderable: false, - content: AnyComponent(EntityKeyboardIconTopPanelComponent( - icon: .recent, - theme: component.theme, - useAccentColor: false, - title: component.strings.Stickers_Recent, - pressed: { [weak self] in - self?.component?.switchToGifSubject(.recent) - } - )) - )) - } - topGifItems.append(EntityKeyboardTopPanelComponent.Item( - id: "trending", - isReorderable: false, - content: AnyComponent(EntityKeyboardIconTopPanelComponent( - icon: .trending, - theme: component.theme, - useAccentColor: false, - title: component.strings.Stickers_Trending, - pressed: { [weak self] in - self?.component?.switchToGifSubject(.trending) - } - )) - )) - if let emojiContent = component.emojiContent { - for emoji in component.availableGifSearchEmojies { - topGifItems.append(EntityKeyboardTopPanelComponent.Item( - id: emoji.emoji, - isReorderable: false, - content: AnyComponent(EntityKeyboardAnimationTopPanelComponent( - context: emojiContent.context, - item: EntityKeyboardAnimationData(file: emoji.file), - isFeatured: false, - isPremiumLocked: false, - animationCache: emojiContent.animationCache, - animationRenderer: emojiContent.animationRenderer, - theme: component.theme, - title: emoji.title, - pressed: { [weak self] in - self?.component?.switchToGifSubject(.emojiSearch(emoji.emoji)) - } - )) - )) - } - } - let defaultActiveGifItemId: AnyHashable - switch gifContent.subject { - case .recent: - defaultActiveGifItemId = "recent" - case .trending: - defaultActiveGifItemId = "trending" - case let .emojiSearch(value): - defaultActiveGifItemId = AnyHashable(value) - } - contentTopPanels.append(AnyComponentWithIdentity(id: "gifs", component: AnyComponent(EntityKeyboardTopPanelComponent( - id: "gifs", - theme: component.theme, - items: topGifItems, - containerSideInset: component.containerInsets.left + component.topPanelInsets.left, - forceActiveItemId: defaultActiveGifItemId, - activeContentItemIdUpdated: gifsContentItemIdUpdated, - reorderItems: { _ in - } - ))))*/ contentIcons.append(PagerComponentContentIcon(id: "gifs", imageName: "Chat/Input/Media/EntityInputGifsIcon", title: component.strings.EmojiInput_TabGifs)) + if let addImage = component.stickerContent?.inputInteractionHolder.inputInteraction?.addImage { + contentAccessoryLeftButtons.append(AnyComponentWithIdentity(id: "gifs", component: AnyComponent(Button( + content: AnyComponent(BundleIconComponent( + name: "Media Editor/AddImage", + tintColor: component.theme.chat.inputMediaPanel.panelIconColor, + maxSize: nil + )), + action: { + addImage() + } + ).minSize(CGSize(width: 38.0, height: 38.0))))) + } } if let stickerContent = component.stickerContent { diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index 8e516e43ca..1d44f65d87 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -2691,10 +2691,11 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate } } - func presentGallery() { + func presentGallery(parentController: ViewController? = nil) { guard let controller = self.controller else { return } + let parentController = parentController ?? controller let galleryController = self.context.sharedContext.makeMediaPickerScreen(context: self.context, hasSearch: true, completion: { [weak self] result in guard let self else { return @@ -2743,7 +2744,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate self.updateModalTransitionFactor(transitionFactor, transition: transition) } } - controller.push(galleryController) + parentController.push(galleryController) } private let staticEmojiPack = Promise() @@ -3063,6 +3064,11 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate selectionContainerView: self.selectionContainerView, existingStickerPickerInputData: self.stickerPickerInputData ) + controller.presentGallery = { [weak self] in + if let self { + self.presentGallery() + } + } controller.getCurrentImage = { [weak self] in return self?.interaction?.getCurrentImage() } @@ -3123,7 +3129,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate self.interaction?.activate() self.entitiesView.selectEntity(nil) } - self.controller?.present(controller, in: .window(.root)) + self.controller?.present(controller, in: .current) self.animateOutToTool() } } @@ -3234,9 +3240,9 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate self.interaction?.containerLayoutUpdated(layout: layout, transition: transition) - var layout = layout - layout.intrinsicInsets.top = topInset - layout.intrinsicInsets.bottom = bottomInset + 60.0 +// var layout = layout +// layout.intrinsicInsets.top = topInset +// layout.intrinsicInsets.bottom = bottomInset + 60.0 controller.presentationContext.containerLayoutUpdated(layout, transition: transition.containedViewLayoutTransition) if isFirstTime { diff --git a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift index bfaece657b..b782f0dad6 100644 --- a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift +++ b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift @@ -2090,9 +2090,10 @@ final class ShareWithPeersScreenComponent: Component { transition.setFrame(view: actionButtonView, frame: actionButtonFrame) } - transition.setFrame(view: self.bottomBackgroundView, frame: CGRect(origin: CGPoint(x: containerSideInset, y: availableSize.height - bottomPanelHeight - 8.0), size: CGSize(width: containerWidth, height: bottomPanelHeight + 8.0))) + let bottomPanelInset: CGFloat = 8.0 + transition.setFrame(view: self.bottomBackgroundView, frame: CGRect(origin: CGPoint(x: containerSideInset, y: availableSize.height - bottomPanelHeight - 8.0), size: CGSize(width: containerWidth, height: bottomPanelHeight + bottomPanelInset))) self.bottomBackgroundView.update(size: self.bottomBackgroundView.bounds.size, transition: transition.containedViewLayoutTransition) - transition.setFrame(layer: self.bottomSeparatorLayer, frame: CGRect(origin: CGPoint(x: containerSideInset + sideInset, y: availableSize.height - bottomPanelHeight - 8.0 - UIScreenPixel), size: CGSize(width: containerWidth, height: UIScreenPixel))) + transition.setFrame(layer: self.bottomSeparatorLayer, frame: CGRect(origin: CGPoint(x: containerSideInset + sideInset, y: availableSize.height - bottomPanelHeight - bottomPanelInset - UIScreenPixel), size: CGSize(width: containerWidth, height: UIScreenPixel))) let itemContainerSize = CGSize(width: itemsContainerWidth, height: availableSize.height) let itemLayout = ItemLayout(style: itemLayoutStyle, containerSize: itemContainerSize, containerInset: containerInset, bottomInset: footersTotalHeight, topInset: topInset, sideInset: sideInset, navigationHeight: navigationHeight, sections: sections) @@ -2124,9 +2125,13 @@ final class ShareWithPeersScreenComponent: Component { if contentSize != self.scrollView.contentSize { self.scrollView.contentSize = contentSize } - let indicatorInsets = UIEdgeInsets(top: max(itemLayout.containerInset, environment.safeInsets.top + navigationHeight), left: 0.0, bottom: environment.safeInsets.bottom, right: 0.0) - if indicatorInsets != self.scrollView.scrollIndicatorInsets { - self.scrollView.scrollIndicatorInsets = indicatorInsets + let contentInset: UIEdgeInsets = UIEdgeInsets(top: 0.0, left: 0.0, bottom: bottomPanelHeight + bottomPanelInset, right: 0.0) + let indicatorInset = UIEdgeInsets(top: max(itemLayout.containerInset, environment.safeInsets.top + navigationHeight), left: 0.0, bottom: contentInset.bottom, right: 0.0) + if indicatorInset != self.scrollView.scrollIndicatorInsets { + self.scrollView.scrollIndicatorInsets = indicatorInset + } + if contentInset != self.scrollView.contentInset { + self.scrollView.contentInset = contentInset } if resetScrolling { self.scrollView.bounds = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: containerWidth, height: availableSize.height)) diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 82d0015f39..cbb0ac0db8 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -3839,7 +3839,7 @@ public final class StoryItemSetContainerComponent: Component { guard let file else { let context = component.context var replaceImpl: ((ViewController) -> Void)? - let controller = PremiumDemoScreen(context: context, subject: .uniqueReactions, action: { + let controller = PremiumDemoScreen(context: context, subject: .uniqueReactions, forceDark: true, action: { let controller = PremiumIntroScreen(context: context, source: .reactions) replaceImpl?(controller) }) @@ -3861,7 +3861,7 @@ public final class StoryItemSetContainerComponent: Component { let context = component.context var replaceImpl: ((ViewController) -> Void)? - let controller = PremiumDemoScreen(context: context, subject: .uniqueReactions, action: { + let controller = PremiumDemoScreen(context: context, subject: .uniqueReactions, forceDark: true, action: { let controller = PremiumIntroScreen(context: context, source: .reactions) replaceImpl?(controller) }) diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift index dd72cef086..bd90cee06b 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift @@ -3143,6 +3143,14 @@ final class StoryItemSetContainerSendMessage { let node = controller.displayNode let menuController = ContextMenuController(actions: actions, blurred: true) menuController.centerHorizontally = true + menuController.dismissed = { [weak self, weak view] in + if let self, let view { + Queue.mainQueue().after(0.1) { + self.menuController = nil + view.updateIsProgressPaused() + } + } + } controller.present( menuController, in: .window(.root),