Various fixes

This commit is contained in:
Ilya Laktyushin 2023-08-09 14:16:08 +02:00
parent 0ec02a6f86
commit a80709842e
5 changed files with 54 additions and 83 deletions

View File

@ -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<Void>
let dismiss: ActionSlot<Void>
@ -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<Void>,
dismiss: ActionSlot<Void>,
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<Void>
private let insertSticker: ActionSlot<Void>
private let insertText: ActionSlot<Void>
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<Void>,
insertSticker: ActionSlot<Void>,
insertText: ActionSlot<Void>,
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<StickerPickerInputData>? = 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

View File

@ -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?) {

View File

@ -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 {

View File

@ -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<LoadedStickerPack>()
@ -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 {

View File

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