Various fixes

This commit is contained in:
Ilya Laktyushin 2023-07-10 20:04:23 +02:00
parent 5fbd1b7c61
commit 0d69b86b92
9 changed files with 38 additions and 13 deletions

View File

@ -758,9 +758,11 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
selectionView.handlePan(gestureRecognizer)
}
}
} else if gestureRecognizer.numberOfTouches == 1, let viewToSelect = self.entity(at: location) {
self.selectEntity(viewToSelect.entity)
} else if gestureRecognizer.numberOfTouches == 2, let mediaEntityView = self.subviews.first(where: { $0 is DrawingEntityMediaView }) as? DrawingEntityMediaView {
}
// else if gestureRecognizer.numberOfTouches == 1, let viewToSelect = self.entity(at: location) {
// self.selectEntity(viewToSelect.entity)
// }
else if gestureRecognizer.numberOfTouches == 2, let mediaEntityView = self.subviews.first(where: { $0 is DrawingEntityMediaView }) as? DrawingEntityMediaView {
mediaEntityView.handlePan(gestureRecognizer)
}
}

View File

@ -1295,6 +1295,7 @@ private final class DrawingScreenComponent: CombinedComponent {
completion()
}
}))
.opacity(controlsAreVisible ? 1.0 : 0.0)
)
}
@ -1828,13 +1829,6 @@ private final class DrawingScreenComponent: CombinedComponent {
.opacity(isEditingText || !controlsAreVisible ? 0.0 : 1.0)
)
let textButtonTopInset: CGFloat
if let sourceHint = component.sourceHint, case .storyEditor = sourceHint {
textButtonTopInset = environment.statusBarHeight
} else {
textButtonTopInset = topInset
}
let textCancelButton = textCancelButton.update(
component: Button(
content: AnyComponent(
@ -1870,7 +1864,7 @@ private final class DrawingScreenComponent: CombinedComponent {
transition: context.transition
)
context.add(textDoneButton
.position(CGPoint(x: context.availableSize.width - environment.safeInsets.right - textDoneButton.size.width / 2.0 - 13.0, y: textButtonTopInset))
.position(CGPoint(x: context.availableSize.width - environment.safeInsets.right - textDoneButton.size.width / 2.0 - 13.0, y: topInset))
.scale(isEditingText ? 1.0 : 0.01)
.opacity(isEditingText ? 1.0 : 0.0)
)

View File

@ -1111,6 +1111,7 @@ final class MediaEditorScreenComponent: Component {
}
self.deactivateInput()
},
sendMessageOptionsAction: { },
sendStickerAction: { _ in },
setMediaRecordingActive: nil,
lockMediaRecording: nil,
@ -2225,7 +2226,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
self.enhanceInitialTranslation = value
}
let delta = Float((translation.x / self.frame.width) * 1.5)
let delta = Float((translation.x / self.frame.width) * 1.8)
var updatedValue = max(-1.0, min(1.0, value + delta))
if let enhanceInitialTranslation = self.enhanceInitialTranslation {
if enhanceInitialTranslation > 0.0 {

View File

@ -258,6 +258,7 @@ final class StoryPreviewComponent: Component {
presentController: { _ in },
presentInGlobalOverlay: { _ in },
sendMessageAction: { },
sendMessageOptionsAction: { },
sendStickerAction: { _ in },
setMediaRecordingActive: { _, _, _ in },
lockMediaRecording: nil,

View File

@ -8,6 +8,7 @@ import AccountContext
import TelegramPresentationData
import ChatPresentationInterfaceState
import MoreHeaderButton
import ContextUI
private extension MessageInputActionButtonComponent.Mode {
var iconName: String? {
@ -45,6 +46,7 @@ public final class MessageInputActionButtonComponent: Component {
public let mode: Mode
public let action: (Mode, Action, Bool) -> Void
public let longPressAction: () -> Void
public let switchMediaInputMode: () -> Void
public let updateMediaCancelFraction: (CGFloat) -> Void
public let lockMediaRecording: () -> Void
@ -60,6 +62,7 @@ public final class MessageInputActionButtonComponent: Component {
public init(
mode: Mode,
action: @escaping (Mode, Action, Bool) -> Void,
longPressAction: @escaping () -> Void,
switchMediaInputMode: @escaping () -> Void,
updateMediaCancelFraction: @escaping (CGFloat) -> Void,
lockMediaRecording: @escaping () -> Void,
@ -74,6 +77,7 @@ public final class MessageInputActionButtonComponent: Component {
) {
self.mode = mode
self.action = action
self.longPressAction = longPressAction
self.switchMediaInputMode = switchMediaInputMode
self.updateMediaCancelFraction = updateMediaCancelFraction
self.lockMediaRecording = lockMediaRecording

View File

@ -72,6 +72,7 @@ public final class MessageInputPanelComponent: Component {
public let presentController: (ViewController) -> Void
public let presentInGlobalOverlay: (ViewController) -> Void
public let sendMessageAction: () -> Void
public let sendMessageOptionsAction: () -> Void
public let sendStickerAction: (TelegramMediaFile) -> Void
public let setMediaRecordingActive: ((Bool, Bool, Bool) -> Void)?
public let lockMediaRecording: (() -> Void)?
@ -113,6 +114,7 @@ public final class MessageInputPanelComponent: Component {
presentController: @escaping (ViewController) -> Void,
presentInGlobalOverlay: @escaping (ViewController) -> Void,
sendMessageAction: @escaping () -> Void,
sendMessageOptionsAction: @escaping () -> Void,
sendStickerAction: @escaping (TelegramMediaFile) -> Void,
setMediaRecordingActive: ((Bool, Bool, Bool) -> Void)?,
lockMediaRecording: (() -> Void)?,
@ -153,6 +155,7 @@ public final class MessageInputPanelComponent: Component {
self.presentController = presentController
self.presentInGlobalOverlay = presentInGlobalOverlay
self.sendMessageAction = sendMessageAction
self.sendMessageOptionsAction = sendMessageOptionsAction
self.sendStickerAction = sendStickerAction
self.setMediaRecordingActive = setMediaRecordingActive
self.lockMediaRecording = lockMediaRecording
@ -744,6 +747,7 @@ public final class MessageInputPanelComponent: Component {
break
}
},
longPressAction: {},
switchMediaInputMode: {
},
updateMediaCancelFraction: { _ in
@ -922,6 +926,12 @@ public final class MessageInputPanelComponent: Component {
break
}
},
longPressAction: { [weak self] in
guard let self, let component = self.component else {
return
}
component.sendMessageOptionsAction()
},
switchMediaInputMode: { [weak self] in
guard let self else {
return

View File

@ -1718,6 +1718,12 @@ public final class StoryItemSetContainerComponent: Component {
}
self.sendMessageContext.performSendMessageAction(view: self)
},
sendMessageOptionsAction: { [weak self] in
guard let self else {
return
}
self.sendMessageContext.presentSendMessageOptions(view: self)
},
sendStickerAction: { [weak self] sticker in
guard let self else {
return
@ -2215,6 +2221,7 @@ public final class StoryItemSetContainerComponent: Component {
mode: .more,
action: { _, _, _ in
},
longPressAction: {},
switchMediaInputMode: {
},
updateMediaCancelFraction: { _ in

View File

@ -360,6 +360,10 @@ final class StoryItemSetContainerSendMessage {
view.updateIsProgressPaused()
}
func presentSendMessageOptions(view: StoryItemSetContainerComponent.View) {
}
func performSendMessageAction(
view: StoryItemSetContainerComponent.View
) {

View File

@ -15,6 +15,8 @@ import AttachmentUI
import ForumCreateTopicScreen
import LegacyInstantVideoController
import StoryContainerScreen
import CameraScreen
import MediaEditorScreen
public func navigateToChatControllerImpl(_ params: NavigateToChatControllerParams) {
if case let .peer(peer) = params.chatLocation, case let .channel(channel) = peer, channel.flags.contains(.isForum) {
@ -264,7 +266,7 @@ private func findOpaqueLayer(rootLayer: CALayer, layer: CALayer) -> Bool {
}
public func isInlineControllerForChatNotificationOverlayPresentation(_ controller: ViewController) -> Bool {
if controller is InstantPageController {
if controller is InstantPageController || controller is MediaEditorScreen || controller is CameraScreen {
return true
}
return false