mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit '0d69b86b921950cfe87bdc8d94671a2a87a0aaed'
This commit is contained in:
commit
4e06ed8bdd
@ -2564,7 +2564,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
return nil
|
||||
}
|
||||
|
||||
fileprivate func openStoryCamera() {
|
||||
fileprivate func openStoryCamera(fromList: Bool) {
|
||||
switch self.storyPostingAvailability {
|
||||
case .premium:
|
||||
guard self.isPremium else {
|
||||
@ -2588,12 +2588,22 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
|
||||
var cameraTransitionIn: StoryCameraTransitionIn?
|
||||
if let componentView = self.chatListHeaderView() {
|
||||
if let (transitionView, _) = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
|
||||
cameraTransitionIn = StoryCameraTransitionIn(
|
||||
sourceView: transitionView,
|
||||
sourceRect: transitionView.bounds,
|
||||
sourceCornerRadius: transitionView.bounds.height * 0.5
|
||||
)
|
||||
if fromList {
|
||||
if let (transitionView, _) = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
|
||||
cameraTransitionIn = StoryCameraTransitionIn(
|
||||
sourceView: transitionView,
|
||||
sourceRect: transitionView.bounds,
|
||||
sourceCornerRadius: transitionView.bounds.height * 0.5
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if let rightButtonView = componentView.rightButtonViews["story"] {
|
||||
cameraTransitionIn = StoryCameraTransitionIn(
|
||||
sourceView: rightButtonView,
|
||||
sourceRect: rightButtonView.bounds,
|
||||
sourceCornerRadius: rightButtonView.bounds.height * 0.5
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2609,6 +2619,12 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
destinationRect: transitionView.bounds,
|
||||
destinationCornerRadius: transitionView.bounds.height * 0.5
|
||||
)
|
||||
} else if let rightButtonView = componentView.rightButtonViews["story"] {
|
||||
return StoryCameraTransitionOut(
|
||||
destinationView: rightButtonView,
|
||||
destinationRect: rightButtonView.bounds,
|
||||
destinationCornerRadius: rightButtonView.bounds.height * 0.5
|
||||
)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -2651,7 +2667,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
}
|
||||
|
||||
if openCamera {
|
||||
self.openStoryCamera()
|
||||
self.openStoryCamera(fromList: true)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -2686,7 +2702,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
return
|
||||
}
|
||||
|
||||
self.openStoryCamera()
|
||||
self.openStoryCamera(fromList: true)
|
||||
})
|
||||
})))
|
||||
|
||||
@ -3552,7 +3568,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
}
|
||||
|
||||
if peerId == self.context.account.peerId, storyContentState.slice == nil {
|
||||
self.openStoryCamera()
|
||||
self.openStoryCamera(fromList: true)
|
||||
return
|
||||
}
|
||||
|
||||
@ -5846,7 +5862,7 @@ private final class ChatListLocationContext {
|
||||
guard let self, let parentController = self.parentController else {
|
||||
return
|
||||
}
|
||||
parentController.openStoryCamera()
|
||||
parentController.openStoryCamera(fromList: false)
|
||||
}
|
||||
)))
|
||||
} else {
|
||||
|
@ -221,7 +221,7 @@ public extension UIView {
|
||||
}
|
||||
|
||||
private func layoutMetricsForScreenSize(_ size: CGSize) -> LayoutMetrics {
|
||||
if size.width > 690.0 && size.height > 690.0 {
|
||||
if size.width > 690.0 && size.height > 650.0 {
|
||||
return LayoutMetrics(widthClass: .regular, heightClass: .regular)
|
||||
} else {
|
||||
return LayoutMetrics(widthClass: .compact, heightClass: .compact)
|
||||
|
@ -259,9 +259,9 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
|
||||
}
|
||||
}
|
||||
|
||||
private func startPosition(relativeTo entity: DrawingEntity?) -> CGPoint {
|
||||
private func startPosition(relativeTo entity: DrawingEntity?, onlyVertical: Bool = false) -> CGPoint {
|
||||
let offsetLength = round(self.size.width * 0.1)
|
||||
let offset = CGPoint(x: offsetLength, y: offsetLength)
|
||||
let offset = CGPoint(x: onlyVertical ? 0.0 : offsetLength, y: offsetLength)
|
||||
if let entity = entity {
|
||||
return entity.center.offsetBy(dx: offset.x, dy: offset.y)
|
||||
} else {
|
||||
@ -297,7 +297,7 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
|
||||
}
|
||||
|
||||
public func prepareNewEntity(_ entity: DrawingEntity, setup: Bool = true, relativeTo: DrawingEntity? = nil) {
|
||||
let center = self.startPosition(relativeTo: relativeTo)
|
||||
let center = self.startPosition(relativeTo: relativeTo, onlyVertical: entity is DrawingTextEntity)
|
||||
let rotation = self.getEntityInitialRotation()
|
||||
let zoomScale = 1.0 / (self.drawingView?.zoomScale ?? 1.0)
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
)
|
||||
|
@ -1220,7 +1220,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
|
||||
var itemHeight = itemWidth
|
||||
if case let .assets(_, mode) = controller.subject, case .story = mode {
|
||||
itemHeight = 180.0
|
||||
itemHeight = floor(itemWidth * 1.227)
|
||||
}
|
||||
|
||||
self.gridNode.transaction(GridNodeTransaction(deleteItems: [], insertItems: [], updateItems: [], scrollToItem: nil, updateLayout: GridNodeUpdateLayout(layout: GridNodeLayout(size: bounds.size, insets: gridInsets, scrollIndicatorInsets: nil, preloadSize: itemHeight * 3.0, type: .fixed(itemSize: CGSize(width: itemWidth, height: itemHeight), fillWidth: true, lineSpacing: itemSpacing, itemSpacing: itemSpacing), cutout: cameraRect), transition: transition), itemTransition: .immediate, stationaryItems: .none, updateFirstIndexInSectionOffset: nil, updateOpaqueState: nil, synchronousLoads: false), completion: { [weak self] _ in
|
||||
|
@ -111,7 +111,7 @@ private final class ShutterButtonContentComponent: Component {
|
||||
self.blobView = ShutterBlobView(test: false)
|
||||
self.addSubview(self.blobView!)
|
||||
|
||||
Queue.mainQueue().after(0.1) {
|
||||
Queue.mainQueue().after(0.2) {
|
||||
self.innerLayer.removeFromSuperlayer()
|
||||
}
|
||||
}
|
||||
|
@ -760,6 +760,12 @@ public final class ChatListHeaderComponent: Component {
|
||||
return self.effectiveContentView?.rightButtonViews.first?.value.view
|
||||
}
|
||||
|
||||
public var rightButtonViews: [AnyHashable: UIView] {
|
||||
return self.effectiveContentView?.rightButtonViews.reduce(into: [:], { result, view in
|
||||
result[view.key] = view.value.view
|
||||
}) ?? [:]
|
||||
}
|
||||
|
||||
public var titleContentView: UIView? {
|
||||
return self.effectiveContentView?.titleContentView?.view
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ extension CIImage {
|
||||
}
|
||||
|
||||
private func render(context: CIContext, width: Int, height: Int, bytesPerRow: Int, data: Data, type: AnimationRendererFrameType, pixelBuffer: CVPixelBuffer, tintColor: UIColor?) -> CIImage? {
|
||||
//let calculatedBytesPerRow = (4 * Int(width) + 31) & (~31)
|
||||
let calculatedBytesPerRow = (4 * Int(width) + 31) & (~31)
|
||||
//assert(bytesPerRow == calculatedBytesPerRow)
|
||||
|
||||
|
||||
@ -475,7 +475,7 @@ private func render(context: CIContext, width: Int, height: Int, bytesPerRow: In
|
||||
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
decodeYUVAToRGBA(bytes, dest, Int32(width), Int32(height), Int32(width * 4))
|
||||
decodeYUVAToRGBA(bytes, dest, Int32(width), Int32(height), Int32(calculatedBytesPerRow))
|
||||
}
|
||||
case .argb:
|
||||
data.withUnsafeBytes { buffer -> Void in
|
||||
|
@ -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 {
|
||||
@ -3760,12 +3761,12 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
duration = 5.0
|
||||
|
||||
firstFrame = .single(image)
|
||||
case let .video(path, _, _, _, _, _, _, _, _):
|
||||
case let .video(path, _, _, _, _, _, durationValue, _, _):
|
||||
videoResult = .videoFile(path: path)
|
||||
if let videoTrimRange = mediaEditor.values.videoTrimRange {
|
||||
duration = videoTrimRange.upperBound - videoTrimRange.lowerBound
|
||||
} else {
|
||||
duration = 5.0
|
||||
duration = durationValue
|
||||
}
|
||||
|
||||
firstFrame = Signal<UIImage?, NoError> { subscriber in
|
||||
@ -3823,7 +3824,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
if let videoTrimRange = mediaEditor.values.videoTrimRange {
|
||||
duration = videoTrimRange.upperBound - videoTrimRange.lowerBound
|
||||
} else {
|
||||
duration = 5.0
|
||||
duration = draft.duration ?? 5.0
|
||||
}
|
||||
firstFrame = Signal<UIImage?, NoError> { subscriber in
|
||||
let avAsset = AVURLAsset(url: URL(fileURLWithPath: draft.fullPath()))
|
||||
|
@ -258,6 +258,7 @@ final class StoryPreviewComponent: Component {
|
||||
presentController: { _ in },
|
||||
presentInGlobalOverlay: { _ in },
|
||||
sendMessageAction: { },
|
||||
sendMessageOptionsAction: { },
|
||||
sendStickerAction: { _ in },
|
||||
setMediaRecordingActive: { _, _, _ in },
|
||||
lockMediaRecording: nil,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -360,6 +360,10 @@ final class StoryItemSetContainerSendMessage {
|
||||
view.updateIsProgressPaused()
|
||||
}
|
||||
|
||||
func presentSendMessageOptions(view: StoryItemSetContainerComponent.View) {
|
||||
|
||||
}
|
||||
|
||||
func performSendMessageAction(
|
||||
view: StoryItemSetContainerComponent.View
|
||||
) {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user