mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Various fixes
This commit is contained in:
parent
f9f9f20141
commit
0874d92b11
@ -372,8 +372,9 @@ public class AttachmentController: ViewController {
|
||||
self.container.position = startPosition
|
||||
let transition = ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring)
|
||||
transition.animateView(allowUserInteraction: true, {
|
||||
self.animating = false
|
||||
self.container.position = targetPosition
|
||||
}, completion: { _ in
|
||||
self.animating = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
21
submodules/ChatMessageBackground/BUILD
Normal file
21
submodules/ChatMessageBackground/BUILD
Normal file
@ -0,0 +1,21 @@
|
||||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||
|
||||
swift_library(
|
||||
name = "ChatMessageBackground",
|
||||
module_name = "ChatMessageBackground",
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/WallpaperBackgroundNode:WallpaperBackgroundNode",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
22
submodules/ChatMessageBackground/Info.plist
Normal file
22
submodules/ChatMessageBackground/Info.plist
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
</dict>
|
||||
</plist>
|
@ -5,10 +5,10 @@ import Display
|
||||
import TelegramPresentationData
|
||||
import WallpaperBackgroundNode
|
||||
|
||||
enum ChatMessageBackgroundMergeType: Equatable {
|
||||
public enum ChatMessageBackgroundMergeType: Equatable {
|
||||
case None, Side, Top(side: Bool), Bottom, Both, Extracted
|
||||
|
||||
init(top: Bool, bottom: Bool, side: Bool) {
|
||||
public init(top: Bool, bottom: Bool, side: Bool) {
|
||||
if top && bottom {
|
||||
self = .Both
|
||||
} else if top {
|
||||
@ -29,12 +29,12 @@ enum ChatMessageBackgroundMergeType: Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
enum ChatMessageBackgroundType: Equatable {
|
||||
public enum ChatMessageBackgroundType: Equatable {
|
||||
case none
|
||||
case incoming(ChatMessageBackgroundMergeType)
|
||||
case outgoing(ChatMessageBackgroundMergeType)
|
||||
|
||||
static func ==(lhs: ChatMessageBackgroundType, rhs: ChatMessageBackgroundType) -> Bool {
|
||||
public static func ==(lhs: ChatMessageBackgroundType, rhs: ChatMessageBackgroundType) -> Bool {
|
||||
switch lhs {
|
||||
case .none:
|
||||
if case .none = rhs {
|
||||
@ -58,8 +58,8 @@ enum ChatMessageBackgroundType: Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
class ChatMessageBackground: ASDisplayNode {
|
||||
private(set) var type: ChatMessageBackgroundType?
|
||||
public class ChatMessageBackground: ASDisplayNode {
|
||||
public private(set) var type: ChatMessageBackgroundType?
|
||||
private var currentHighlighted: Bool?
|
||||
private var hasWallpaper: Bool?
|
||||
private var graphics: PrincipalThemeEssentialGraphics?
|
||||
@ -68,11 +68,11 @@ class ChatMessageBackground: ASDisplayNode {
|
||||
private let outlineImageNode: ASImageNode
|
||||
private weak var backgroundNode: WallpaperBackgroundNode?
|
||||
|
||||
var hasImage: Bool {
|
||||
public var hasImage: Bool {
|
||||
self.imageNode.image != nil
|
||||
}
|
||||
|
||||
override init() {
|
||||
public override init() {
|
||||
self.imageNode = ASImageNode()
|
||||
self.imageNode.displaysAsynchronously = false
|
||||
self.imageNode.displayWithoutProcessing = true
|
||||
@ -88,23 +88,23 @@ class ChatMessageBackground: ASDisplayNode {
|
||||
self.addSubnode(self.imageNode)
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) {
|
||||
public func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) {
|
||||
transition.updateFrame(node: self.imageNode, frame: CGRect(origin: CGPoint(), size: size).insetBy(dx: -1.0, dy: -1.0))
|
||||
transition.updateFrame(node: self.outlineImageNode, frame: CGRect(origin: CGPoint(), size: size).insetBy(dx: -1.0, dy: -1.0))
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, transition: ListViewItemUpdateAnimation) {
|
||||
public func updateLayout(size: CGSize, transition: ListViewItemUpdateAnimation) {
|
||||
transition.animator.updateFrame(layer: self.imageNode.layer, frame: CGRect(origin: CGPoint(), size: size).insetBy(dx: -1.0, dy: -1.0), completion: nil)
|
||||
transition.animator.updateFrame(layer: self.outlineImageNode.layer, frame: CGRect(origin: CGPoint(), size: size).insetBy(dx: -1.0, dy: -1.0), completion: nil)
|
||||
}
|
||||
|
||||
func setMaskMode(_ maskMode: Bool) {
|
||||
public func setMaskMode(_ maskMode: Bool) {
|
||||
if let type = self.type, let hasWallpaper = self.hasWallpaper, let highlighted = self.currentHighlighted, let graphics = self.graphics, let backgroundNode = self.backgroundNode {
|
||||
self.setType(type: type, highlighted: highlighted, graphics: graphics, maskMode: maskMode, hasWallpaper: hasWallpaper, transition: .immediate, backgroundNode: backgroundNode)
|
||||
}
|
||||
}
|
||||
|
||||
func setType(type: ChatMessageBackgroundType, highlighted: Bool, graphics: PrincipalThemeEssentialGraphics, maskMode: Bool, hasWallpaper: Bool, transition: ContainedViewLayoutTransition, backgroundNode: WallpaperBackgroundNode?) {
|
||||
public func setType(type: ChatMessageBackgroundType, highlighted: Bool, graphics: PrincipalThemeEssentialGraphics, maskMode: Bool, hasWallpaper: Bool, transition: ContainedViewLayoutTransition, backgroundNode: WallpaperBackgroundNode?) {
|
||||
let previousType = self.type
|
||||
if let currentType = previousType, currentType == type, self.currentHighlighted == highlighted, self.graphics === graphics, backgroundNode === self.backgroundNode, self.maskMode == maskMode, self.hasWallpaper == hasWallpaper {
|
||||
return
|
||||
@ -244,7 +244,7 @@ class ChatMessageBackground: ASDisplayNode {
|
||||
self.outlineImageNode.image = outlineImage
|
||||
}
|
||||
|
||||
func animateFrom(sourceView: UIView, transition: CombinedTransition) {
|
||||
public func animateFrom(sourceView: UIView, transition: CombinedTransition) {
|
||||
if transition.isAnimated {
|
||||
self.imageNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.1)
|
||||
self.outlineImageNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.1)
|
||||
@ -262,11 +262,11 @@ class ChatMessageBackground: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
final class ChatMessageShadowNode: ASDisplayNode {
|
||||
public final class ChatMessageShadowNode: ASDisplayNode {
|
||||
private let contentNode: ASImageNode
|
||||
private var graphics: PrincipalThemeEssentialGraphics?
|
||||
|
||||
override init() {
|
||||
public override init() {
|
||||
self.contentNode = ASImageNode()
|
||||
self.contentNode.isLayerBacked = true
|
||||
self.contentNode.displaysAsynchronously = false
|
||||
@ -281,7 +281,7 @@ final class ChatMessageShadowNode: ASDisplayNode {
|
||||
self.addSubnode(self.contentNode)
|
||||
}
|
||||
|
||||
func setType(type: ChatMessageBackgroundType, hasWallpaper: Bool, graphics: PrincipalThemeEssentialGraphics) {
|
||||
public func setType(type: ChatMessageBackgroundType, hasWallpaper: Bool, graphics: PrincipalThemeEssentialGraphics) {
|
||||
let shadowImage: UIImage?
|
||||
|
||||
if hasWallpaper {
|
||||
@ -334,7 +334,8 @@ final class ChatMessageShadowNode: ASDisplayNode {
|
||||
self.contentNode.image = shadowImage
|
||||
}
|
||||
|
||||
func updateLayout(backgroundFrame: CGRect, transition: ContainedViewLayoutTransition) {
|
||||
public func updateLayout(backgroundFrame: CGRect, transition: ContainedViewLayoutTransition) {
|
||||
transition.updateFrame(node: self.contentNode, frame: CGRect(origin: CGPoint(x: backgroundFrame.minX - 10.0, y: backgroundFrame.minY - 10.0), size: CGSize(width: backgroundFrame.width + 20.0, height: backgroundFrame.height + 20.0)))
|
||||
}
|
||||
}
|
||||
|
@ -1646,7 +1646,7 @@
|
||||
|
||||
_selectedPhotosView.frame = CGRectMake(screenEdges.left + TGPhotoEditorToolbarSize + 66 + _safeAreaInset.left, screenEdges.top + 4 + headerInset, photosViewSize, self.frame.size.height - 4 * 2 - headerInset);
|
||||
|
||||
_landscapeToolbarView.frame = CGRectMake(screenEdges.left, screenEdges.top, TGPhotoEditorToolbarSize + _safeAreaInset.left, self.frame.size.height);
|
||||
_landscapeToolbarView.frame = CGRectMake(screenEdges.left + _safeAreaInset.left, screenEdges.top, TGPhotoEditorToolbarSize + _safeAreaInset.left, self.frame.size.height);
|
||||
}];
|
||||
|
||||
_headerWrapperView.frame = CGRectMake(screenEdges.left + TGPhotoEditorToolbarSize + _safeAreaInset.left, screenEdges.top, self.frame.size.width - TGPhotoEditorToolbarSize - _safeAreaInset.left, 64);
|
||||
|
@ -222,13 +222,21 @@
|
||||
_currentEdgeInsets = edgeInsets;
|
||||
|
||||
CGFloat panelHeight = [_inputPanel updateLayoutSize:frame.size sideInset:0.0];
|
||||
_inputPanelView.frame = CGRectMake(edgeInsets.left, frame.size.height - panelHeight - MAX(edgeInsets.bottom, _keyboardHeight), frame.size.width, panelHeight);
|
||||
|
||||
CGFloat y = 0.0;
|
||||
if (frame.size.width > frame.size.height) {
|
||||
y = edgeInsets.top + frame.size.height;
|
||||
} else {
|
||||
y = edgeInsets.top + frame.size.height - panelHeight - MAX(edgeInsets.bottom, _keyboardHeight);
|
||||
}
|
||||
|
||||
_inputPanelView.frame = CGRectMake(edgeInsets.left, y, frame.size.width, panelHeight);
|
||||
|
||||
CGFloat backgroundHeight = panelHeight;
|
||||
if (_keyboardHeight > 0.0) {
|
||||
backgroundHeight += _keyboardHeight - edgeInsets.bottom;
|
||||
}
|
||||
_backgroundView.frame = CGRectMake(edgeInsets.left, frame.size.height - panelHeight - MAX(edgeInsets.bottom, _keyboardHeight), frame.size.width, backgroundHeight);
|
||||
_backgroundView.frame = CGRectMake(edgeInsets.left, y, frame.size.width, backgroundHeight);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -37,6 +37,7 @@ swift_library(
|
||||
"//submodules/PresentationDataUtils:PresentationDataUtils",
|
||||
"//submodules/WallpaperBackgroundNode:WallpaperBackgroundNode",
|
||||
"//submodules/WebSearchUI:WebSearchUI",
|
||||
"//submodules/ChatMessageBackground:ChatMessageBackground",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -74,7 +74,7 @@ enum LegacyMediaPickerGallerySource {
|
||||
case selection(item: TGMediaSelectableItem)
|
||||
}
|
||||
|
||||
func presentLegacyMediaPickerGallery(context: AccountContext, peer: EnginePeer?, chatLocation: ChatLocation?, presentationData: PresentationData, source: LegacyMediaPickerGallerySource, immediateThumbnail: UIImage?, selectionContext: TGMediaSelectionContext?, editingContext: TGMediaEditingContext, hasSilentPosting: Bool, hasSchedule: Bool, hasTimer: Bool, updateHiddenMedia: @escaping (String?) -> Void, initialLayout: ContainerViewLayout?, transitionHostView: @escaping () -> UIView?, transitionView: @escaping (String) -> UIView?, completed: @escaping (TGMediaSelectableItem & TGMediaEditableItem, Bool, Int32?) -> Void, presentStickers: ((@escaping (TelegramMediaFile, Bool, UIView, CGRect) -> Void) -> TGPhotoPaintStickersScreen?)?, presentSchedulePicker: @escaping (Bool, @escaping (Int32) -> Void) -> Void, presentTimerPicker: @escaping (@escaping (Int32) -> Void) -> Void, getCaptionPanelView: @escaping () -> TGCaptionPanelView?, present: @escaping (ViewController, Any?) -> Void, finishedTransitionIn: @escaping () -> Void, dismissAll: @escaping () -> Void) {
|
||||
func presentLegacyMediaPickerGallery(context: AccountContext, peer: EnginePeer?, chatLocation: ChatLocation?, presentationData: PresentationData, source: LegacyMediaPickerGallerySource, immediateThumbnail: UIImage?, selectionContext: TGMediaSelectionContext?, editingContext: TGMediaEditingContext, hasSilentPosting: Bool, hasSchedule: Bool, hasTimer: Bool, updateHiddenMedia: @escaping (String?) -> Void, initialLayout: ContainerViewLayout?, transitionHostView: @escaping () -> UIView?, transitionView: @escaping (String) -> UIView?, completed: @escaping (TGMediaSelectableItem & TGMediaEditableItem, Bool, Int32?) -> Void, presentStickers: ((@escaping (TelegramMediaFile, Bool, UIView, CGRect) -> Void) -> TGPhotoPaintStickersScreen?)?, presentSchedulePicker: @escaping (Bool, @escaping (Int32) -> Void) -> Void, presentTimerPicker: @escaping (@escaping (Int32) -> Void) -> Void, getCaptionPanelView: @escaping () -> TGCaptionPanelView?, present: @escaping (ViewController, Any?) -> Void, finishedTransitionIn: @escaping () -> Void, willTransitionOut: @escaping () -> Void, dismissAll: @escaping () -> Void) {
|
||||
let reminder = peer?.id == context.account.peerId
|
||||
|
||||
let legacyController = LegacyController(presentation: .custom, theme: presentationData.theme, initialLayout: nil)
|
||||
@ -168,6 +168,8 @@ func presentLegacyMediaPickerGallery(context: AccountContext, peer: EnginePeer?,
|
||||
}
|
||||
}
|
||||
controller.beginTransitionOut = { item, itemView in
|
||||
willTransitionOut()
|
||||
|
||||
if let item = item as? TGMediaPickerGalleryItem {
|
||||
if let itemView = itemView as? TGMediaPickerGalleryVideoItemView {
|
||||
itemView.stop()
|
||||
|
@ -500,6 +500,9 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
self?.controller?.present(c, in: .window(.root), with: a)
|
||||
}, finishedTransitionIn: { [weak self] in
|
||||
self?.openingMedia = false
|
||||
self?.cameraView?.pausePreview()
|
||||
}, willTransitionOut: { [weak self] in
|
||||
self?.cameraView?.resumePreview()
|
||||
}, dismissAll: { [weak self] in
|
||||
self?.controller?.dismissAll()
|
||||
})
|
||||
@ -533,6 +536,9 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
self?.controller?.present(c, in: .window(.root), with: a, blockInteraction: true)
|
||||
}, finishedTransitionIn: { [weak self] in
|
||||
self?.openingMedia = false
|
||||
self?.cameraView?.pausePreview()
|
||||
}, willTransitionOut: { [weak self] in
|
||||
self?.cameraView?.resumePreview()
|
||||
}, dismissAll: { [weak self] in
|
||||
self?.controller?.dismissAll()
|
||||
})
|
||||
|
@ -210,6 +210,7 @@ final class MediaPickerSelectedListNode: ASDisplayNode, UIScrollViewDelegate, UI
|
||||
init(context: AccountContext) {
|
||||
self.context = context
|
||||
self.wallpaperBackgroundNode = createWallpaperBackgroundNode(context: context, forChatDisplay: true, useSharedAnimationPhase: false, useExperimentalImplementation: context.sharedContext.immediateExperimentalUISettings.experimentalBackground)
|
||||
self.wallpaperBackgroundNode.backgroundColor = .black
|
||||
self.scrollNode = ASScrollNode()
|
||||
|
||||
super.init()
|
||||
|
@ -264,6 +264,7 @@ swift_library(
|
||||
"//submodules/ChatSendMessageActionUI:ChatSendMessageActionUI",
|
||||
"//submodules/ChatTextLinkEditUI:ChatTextLinkEditUI",
|
||||
"//submodules/MediaPickerUI:MediaPickerUI",
|
||||
"//submodules/ChatMessageBackground:ChatMessageBackground",
|
||||
] + select({
|
||||
"@build_bazel_rules_apple//apple:ios_armv7": [],
|
||||
"@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets,
|
||||
|
@ -4,6 +4,7 @@ import Display
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import WallpaperBackgroundNode
|
||||
import ChatMessageBackground
|
||||
|
||||
private let maskInset: CGFloat = 1.0
|
||||
|
||||
|
@ -2,6 +2,7 @@ import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
@ -21,8 +22,8 @@ import GridMessageSelectionNode
|
||||
import AppBundle
|
||||
import Markdown
|
||||
import WallpaperBackgroundNode
|
||||
import SwiftSignalKit
|
||||
import ChatPresentationInterfaceState
|
||||
import ChatMessageBackground
|
||||
|
||||
enum InternalBubbleTapAction {
|
||||
case action(() -> Void)
|
||||
|
@ -6,6 +6,7 @@ import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import ContextUI
|
||||
import ChatPresentationInterfaceState
|
||||
import ChatMessageBackground
|
||||
|
||||
final class ChatTextInputActionButtonsNode: ASDisplayNode {
|
||||
private let presentationContext: ChatPresentationContext?
|
||||
|
@ -58,10 +58,15 @@ final class HorizontalStickerGridItemNode: GridItemNode {
|
||||
|
||||
private var currentIsPreviewing: Bool = false
|
||||
|
||||
private var setupTimestamp: Double?
|
||||
|
||||
override var isVisibleInGrid: Bool {
|
||||
didSet {
|
||||
if oldValue != self.isVisibleInGrid {
|
||||
if self.isVisibleInGrid {
|
||||
if self.setupTimestamp == nil {
|
||||
self.setupTimestamp = CACurrentMediaTime()
|
||||
}
|
||||
self.animationNode?.visibility = true
|
||||
} else {
|
||||
self.animationNode?.visibility = false
|
||||
@ -158,7 +163,20 @@ final class HorizontalStickerGridItemNode: GridItemNode {
|
||||
self.imageNode.setSignal(chatMessageAnimatedSticker(postbox: account.postbox, file: item.file, small: true, size: fittedDimensions, synchronousLoad: false))
|
||||
}
|
||||
animationNode.started = { [weak self] in
|
||||
self?.imageNode.alpha = 0.0
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
strongSelf.imageNode.alpha = 0.0
|
||||
|
||||
let current = CACurrentMediaTime()
|
||||
if let setupTimestamp = strongSelf.setupTimestamp, current - setupTimestamp > 0.3 {
|
||||
if let placeholderNode = strongSelf.placeholderNode, !placeholderNode.alpha.isZero {
|
||||
strongSelf.removePlaceholder(animated: true)
|
||||
}
|
||||
} else {
|
||||
strongSelf.removePlaceholder(animated: false)
|
||||
}
|
||||
}
|
||||
animationNode.setup(source: AnimatedStickerResourceSource(account: account, resource: item.file.resource, isVideo: item.file.isVideoSticker), width: Int(fittedDimensions.width), height: Int(fittedDimensions.height), mode: .cached)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user