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/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/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))