mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Merge branch 'beta'
This commit is contained in:
commit
c1f4ab8b0e
143 changed files with 667 additions and 492 deletions
|
|
@ -408,6 +408,7 @@ public protocol SharedAccountContext: class {
|
|||
|
||||
var currentAutomaticMediaDownloadSettings: Atomic<MediaAutoDownloadSettings> { get }
|
||||
var automaticMediaDownloadSettings: Signal<MediaAutoDownloadSettings, NoError> { get }
|
||||
var currentAutodownloadSettings: Atomic<AutodownloadSettings> { get }
|
||||
var immediateExperimentalUISettings: ExperimentalUISettings { get }
|
||||
var currentInAppNotificationSettings: Atomic<InAppNotificationSettings> { get }
|
||||
var currentMediaInputSettings: Atomic<MediaInputSettings> { get }
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public final class OpenChatMessageParams {
|
|||
public let modal: Bool
|
||||
public let dismissInput: () -> Void
|
||||
public let present: (ViewController, Any?) -> Void
|
||||
public let transitionNode: (MessageId, Media) -> (ASDisplayNode, () -> (UIView?, UIView?))?
|
||||
public let transitionNode: (MessageId, Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))?
|
||||
public let addToTransitionSurface: (UIView) -> Void
|
||||
public let openUrl: (String) -> Void
|
||||
public let openPeer: (Peer, ChatControllerInteractionNavigateToPeer) -> Void
|
||||
|
|
@ -46,7 +46,7 @@ public final class OpenChatMessageParams {
|
|||
modal: Bool = false,
|
||||
dismissInput: @escaping () -> Void,
|
||||
present: @escaping (ViewController, Any?) -> Void,
|
||||
transitionNode: @escaping (MessageId, Media) -> (ASDisplayNode, () -> (UIView?, UIView?))?,
|
||||
transitionNode: @escaping (MessageId, Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))?,
|
||||
addToTransitionSurface: @escaping (UIView) -> Void,
|
||||
openUrl: @escaping (String) -> Void,
|
||||
openPeer: @escaping (Peer, ChatControllerInteractionNavigateToPeer) -> Void,
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ private func measureString(_ string: String) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
private let badgeFont = Font.regular(14.0)
|
||||
|
||||
final class ChatListBadgeNode: ASDisplayNode {
|
||||
private let backgroundNode: ASImageNode
|
||||
private let textNode: TextNode
|
||||
|
|
@ -63,13 +61,13 @@ final class ChatListBadgeNode: ASDisplayNode {
|
|||
self.addSubnode(self.textNode)
|
||||
}
|
||||
|
||||
func asyncLayout() -> (CGSize, UIImage?, ChatListBadgeContent) -> (CGSize, (Bool, Bool) -> Void) {
|
||||
func asyncLayout() -> (CGSize, CGFloat, UIFont, UIImage?, ChatListBadgeContent) -> (CGSize, (Bool, Bool) -> Void) {
|
||||
let textLayout = TextNode.asyncLayout(self.textNode)
|
||||
let measureTextLayout = TextNode.asyncLayout(self.measureTextNode)
|
||||
|
||||
let currentContent = self.content
|
||||
|
||||
return { [weak self] boundingSize, backgroundImage, content in
|
||||
return { [weak self] boundingSize, imageWidth, badgeFont, backgroundImage, content in
|
||||
var badgeWidth: CGFloat = 0.0
|
||||
|
||||
var textLayoutAndApply: (TextNodeLayout, () -> TextNode)?
|
||||
|
|
@ -79,14 +77,14 @@ final class ChatListBadgeNode: ASDisplayNode {
|
|||
|
||||
let (measureLayout, _) = measureTextLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: measureString(text.string), font: badgeFont, textColor: .black), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: boundingSize, alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
badgeWidth = max(20.0, measureLayout.size.width + 10.0)
|
||||
badgeWidth = max(imageWidth, measureLayout.size.width + imageWidth / 2.0)
|
||||
case .mention, .blank:
|
||||
badgeWidth = 20.0
|
||||
badgeWidth = imageWidth
|
||||
case .none:
|
||||
badgeWidth = 0.0
|
||||
}
|
||||
|
||||
return (CGSize(width: badgeWidth, height: 20.0), { animated, bounce in
|
||||
return (CGSize(width: badgeWidth, height: imageWidth), { animated, bounce in
|
||||
if let strongSelf = self {
|
||||
strongSelf.content = content
|
||||
|
||||
|
|
@ -98,7 +96,7 @@ final class ChatListBadgeNode: ASDisplayNode {
|
|||
return
|
||||
}
|
||||
|
||||
let badgeWidth = max(20.0, badgeWidth)
|
||||
let badgeWidth = max(imageWidth, badgeWidth)
|
||||
let previousBadgeWidth = !strongSelf.backgroundNode.frame.width.isZero ? strongSelf.backgroundNode.frame.width : badgeWidth
|
||||
|
||||
var animateTextNode = false
|
||||
|
|
|
|||
|
|
@ -654,7 +654,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
let titleFont = Font.medium(floor(item.presentationData.fontSize.itemListBaseFontSize * 16.0 / 17.0))
|
||||
let textFont = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 15.0 / 17.0))
|
||||
let dateFont = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 14.0 / 17.0))
|
||||
let badgeFont = Font.regular(14.0)
|
||||
let badgeFont = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 14.0 / 17.0))
|
||||
|
||||
let account = item.context.account
|
||||
var message: Message?
|
||||
|
|
@ -777,9 +777,11 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
|
||||
let enableChatListPhotos = item.context.sharedContext.immediateExperimentalUISettings.chatListPhotos
|
||||
|
||||
let avatarDiameter = floor(item.presentationData.fontSize.baseDisplaySize * 60.0 / 17.0)
|
||||
let avatarDiameter = min(60.0, floor(item.presentationData.fontSize.baseDisplaySize * 60.0 / 17.0))
|
||||
let avatarLeftInset = 18.0 + avatarDiameter
|
||||
|
||||
let badgeDiameter = floor(item.presentationData.fontSize.baseDisplaySize * 20.0 / 17.0)
|
||||
|
||||
let leftInset: CGFloat = params.leftInset + avatarLeftInset
|
||||
|
||||
enum ContentData {
|
||||
|
|
@ -995,10 +997,10 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
} else {
|
||||
let badgeTextColor: UIColor
|
||||
if unreadCount.muted {
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundInactive(item.presentationData.theme)
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundInactive(item.presentationData.theme, diameter: badgeDiameter)
|
||||
badgeTextColor = theme.unreadBadgeInactiveTextColor
|
||||
} else {
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundActive(item.presentationData.theme)
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundActive(item.presentationData.theme, diameter: badgeDiameter)
|
||||
badgeTextColor = theme.unreadBadgeActiveTextColor
|
||||
}
|
||||
let unreadCountText = compactNumericCountString(Int(unreadCount.count), decimalSeparator: item.presentationData.dateTimeFormat.decimalSeparator)
|
||||
|
|
@ -1012,7 +1014,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
|
||||
if let mutedCount = unreadCount.mutedCount, mutedCount > 0 {
|
||||
let mutedUnreadCountText = compactNumericCountString(Int(mutedCount), decimalSeparator: item.presentationData.dateTimeFormat.decimalSeparator)
|
||||
currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundInactive(item.presentationData.theme)
|
||||
currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundInactive(item.presentationData.theme, diameter: badgeDiameter)
|
||||
mentionBadgeContent = .text(NSAttributedString(string: mutedUnreadCountText, font: badgeFont, textColor: theme.unreadBadgeInactiveTextColor))
|
||||
}
|
||||
}
|
||||
|
|
@ -1024,13 +1026,13 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
if !isPeerGroup {
|
||||
if totalMentionCount > 0 {
|
||||
if Namespaces.PeerGroup.archive == item.peerGroupId {
|
||||
currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundInactiveMention(item.presentationData.theme)
|
||||
currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundInactiveMention(item.presentationData.theme, diameter: badgeDiameter)
|
||||
} else {
|
||||
currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundMention(item.presentationData.theme)
|
||||
currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundMention(item.presentationData.theme, diameter: badgeDiameter)
|
||||
}
|
||||
mentionBadgeContent = .mention
|
||||
} else if item.index.pinningIndex != nil && !isAd && currentBadgeBackgroundImage == nil {
|
||||
currentPinnedIconImage = PresentationResourcesChatList.badgeBackgroundPinned(item.presentationData.theme)
|
||||
currentPinnedIconImage = PresentationResourcesChatList.badgeBackgroundPinned(item.presentationData.theme, diameter: badgeDiameter)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1105,9 +1107,9 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
|
||||
let (dateLayout, dateApply) = dateLayout(TextNodeLayoutArguments(attributedString: dateAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: rawContentWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
let (badgeLayout, badgeApply) = badgeLayout(CGSize(width: rawContentWidth, height: CGFloat.greatestFiniteMagnitude), currentBadgeBackgroundImage, badgeContent)
|
||||
let (badgeLayout, badgeApply) = badgeLayout(CGSize(width: rawContentWidth, height: CGFloat.greatestFiniteMagnitude), badgeDiameter, badgeFont, currentBadgeBackgroundImage, badgeContent)
|
||||
|
||||
let (mentionBadgeLayout, mentionBadgeApply) = mentionBadgeLayout(CGSize(width: rawContentWidth, height: CGFloat.greatestFiniteMagnitude), currentMentionBadgeImage, mentionBadgeContent)
|
||||
let (mentionBadgeLayout, mentionBadgeApply) = mentionBadgeLayout(CGSize(width: rawContentWidth, height: CGFloat.greatestFiniteMagnitude), badgeDiameter, badgeFont, currentMentionBadgeImage, mentionBadgeContent)
|
||||
|
||||
var badgeSize: CGFloat = 0.0
|
||||
if !badgeLayout.width.isZero {
|
||||
|
|
@ -1656,7 +1658,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
transition.updateFrame(node: reorderControlNode, frame: reorderControlFrame)
|
||||
}
|
||||
|
||||
let avatarDiameter = floor(item.presentationData.fontSize.baseDisplaySize * 60.0 / 17.0)
|
||||
let avatarDiameter = min(60.0, floor(item.presentationData.fontSize.baseDisplaySize * 60.0 / 17.0))
|
||||
let avatarLeftInset = 18.0 + avatarDiameter
|
||||
|
||||
let leftInset: CGFloat = params.leftInset + avatarLeftInset
|
||||
|
|
|
|||
|
|
@ -591,10 +591,10 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||
let badgeTextColor: UIColor
|
||||
switch badge.type {
|
||||
case .inactive:
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundInactive(item.presentationData.theme)
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundInactive(item.presentationData.theme, diameter: 20.0)
|
||||
badgeTextColor = item.presentationData.theme.chatList.unreadBadgeInactiveTextColor
|
||||
case .active:
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundActive(item.presentationData.theme)
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundActive(item.presentationData.theme, diameter: 20.0)
|
||||
badgeTextColor = item.presentationData.theme.chatList.unreadBadgeActiveTextColor
|
||||
}
|
||||
let badgeAttributedString = NSAttributedString(string: badge.count > 0 ? "\(badge.count)" : " ", font: badgeFont, textColor: badgeTextColor)
|
||||
|
|
|
|||
|
|
@ -1773,8 +1773,14 @@ public final class SqliteValueBox: ValueBox {
|
|||
statement.reset()
|
||||
}
|
||||
|
||||
public func fullTextRemove(_ table: ValueBoxFullTextTable, itemId: String) {
|
||||
public func fullTextRemove(_ table: ValueBoxFullTextTable, itemId: String, secure: Bool) {
|
||||
if let _ = self.fullTextTables[table.id] {
|
||||
if secure != self.secureDeleteEnabled {
|
||||
self.secureDeleteEnabled = secure
|
||||
let result = database.execute("PRAGMA secure_delete=\(secure ? 1 : 0)")
|
||||
precondition(result)
|
||||
}
|
||||
|
||||
guard let itemIdData = itemId.data(using: .utf8) else {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public protocol ValueBox {
|
|||
func removeRange(_ table: ValueBoxTable, start: ValueBoxKey, end: ValueBoxKey)
|
||||
func fullTextSet(_ table: ValueBoxFullTextTable, collectionId: String, itemId: String, contents: String, tags: String)
|
||||
func fullTextMatch(_ table: ValueBoxFullTextTable, collectionId: String?, query: String, tags: String?, values: (String, String) -> Bool)
|
||||
func fullTextRemove(_ table: ValueBoxFullTextTable, itemId: String)
|
||||
func fullTextRemove(_ table: ValueBoxFullTextTable, itemId: String, secure: Bool)
|
||||
func removeAllFromTable(_ table: ValueBoxTable)
|
||||
func removeTable(_ table: ValueBoxTable)
|
||||
func renameTable(_ table: ValueBoxTable, to toTable: ValueBoxTable)
|
||||
|
|
|
|||
|
|
@ -246,6 +246,10 @@ private final class WindowRootViewController: UIViewController, UIViewController
|
|||
self.previousPreviewingHostView = nil
|
||||
}
|
||||
}
|
||||
|
||||
override public func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) {
|
||||
super.present(viewControllerToPresent, animated: flag, completion: completion)
|
||||
}
|
||||
}
|
||||
|
||||
private final class NativeWindow: UIWindow, WindowHost {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,12 @@ public struct TransformImageArguments: Equatable {
|
|||
|
||||
public var drawingRect: CGRect {
|
||||
let cornersExtendedEdges = self.corners.extendedEdges
|
||||
return CGRect(x: cornersExtendedEdges.left + self.intrinsicInsets.left, y: cornersExtendedEdges.top + self.intrinsicInsets.top, width: self.boundingSize.width, height: self.boundingSize.height);
|
||||
return CGRect(x: cornersExtendedEdges.left + self.intrinsicInsets.left, y: cornersExtendedEdges.top + self.intrinsicInsets.top, width: self.boundingSize.width, height: self.boundingSize.height)
|
||||
}
|
||||
|
||||
public var imageRect: CGRect {
|
||||
let drawingRect = self.drawingRect
|
||||
return CGRect(x: drawingRect.minX + floor((drawingRect.width - self.imageSize.width) / 2.0), y: drawingRect.minX + floor((drawingRect.height - self.imageSize.height) / 2.0), width: self.imageSize.width, height: self.imageSize.height)
|
||||
}
|
||||
|
||||
public var insets: UIEdgeInsets {
|
||||
|
|
|
|||
|
|
@ -457,8 +457,7 @@ public enum ViewControllerNavigationPresentation {
|
|||
}
|
||||
|
||||
override open func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) {
|
||||
super.present(viewControllerToPresent, animated: flag, completion: completion)
|
||||
return
|
||||
self.view.window?.rootViewController?.present(viewControllerToPresent, animated: flag, completion: completion)
|
||||
}
|
||||
|
||||
override open func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
|
||||
|
|
|
|||
|
|
@ -222,10 +222,10 @@ public func galleryItemForEntry(context: AccountContext, presentationData: Prese
|
|||
}
|
||||
|
||||
public final class GalleryTransitionArguments {
|
||||
public let transitionNode: (ASDisplayNode, () -> (UIView?, UIView?))
|
||||
public let transitionNode: (ASDisplayNode, CGRect, () -> (UIView?, UIView?))
|
||||
public let addToTransitionSurface: (UIView) -> Void
|
||||
|
||||
public init(transitionNode: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: @escaping (UIView) -> Void) {
|
||||
public init(transitionNode: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: @escaping (UIView) -> Void) {
|
||||
self.transitionNode = transitionNode
|
||||
self.addToTransitionSurface = addToTransitionSurface
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ open class GalleryControllerNode: ASDisplayNode, UIScrollViewDelegate, UIGesture
|
|||
public let footerNode: GalleryFooterNode
|
||||
public var currentThumbnailContainerNode: GalleryThumbnailContainerNode?
|
||||
public var overlayNode: ASDisplayNode?
|
||||
public var transitionDataForCentralItem: (() -> ((ASDisplayNode, () -> (UIView?, UIView?))?, (UIView) -> Void)?)?
|
||||
public var transitionDataForCentralItem: (() -> ((ASDisplayNode, CGRect, () -> (UIView?, UIView?))?, (UIView) -> Void)?)?
|
||||
public var dismiss: (() -> Void)?
|
||||
|
||||
public var containerLayout: (CGFloat, ContainerViewLayout)?
|
||||
|
|
|
|||
|
|
@ -80,10 +80,10 @@ open class GalleryItemNode: ASDisplayNode {
|
|||
open func visibilityUpdated(isVisible: Bool) {
|
||||
}
|
||||
|
||||
open func animateIn(from node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
open func animateIn(from node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
}
|
||||
|
||||
open func animateOut(to node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
open func animateOut(to node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
}
|
||||
|
||||
open func contentSize() -> CGSize? {
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ final class ChatAnimationGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
}))
|
||||
}
|
||||
|
||||
override func animateIn(from node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
override func animateIn(from node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.containerNode.view)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.containerNode.view.superview)
|
||||
|
||||
|
|
@ -254,7 +254,7 @@ final class ChatAnimationGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
self.statusNodeContainer.layer.animateScale(from: 0.5, to: 1.0, duration: 0.25, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
}
|
||||
|
||||
override func animateOut(to node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
override func animateOut(to node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.containerNode.view)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.containerNode.view.superview)
|
||||
let transformedSelfFrame = node.0.view.convert(node.0.view.bounds, to: self.view)
|
||||
|
|
@ -264,7 +264,7 @@ final class ChatAnimationGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
var boundsCompleted = false
|
||||
var copyCompleted = false
|
||||
|
||||
let (maybeCopyView, copyViewBackgrond) = node.1()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.2()
|
||||
copyViewBackgrond?.alpha = 0.0
|
||||
let copyView = maybeCopyView!
|
||||
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ class ChatDocumentGalleryItemNode: ZoomableContentGalleryItemNode, WKNavigationD
|
|||
return self._title.get()
|
||||
}
|
||||
|
||||
override func animateIn(from node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
override func animateIn(from node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.webView)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.webView.superview)
|
||||
|
||||
|
|
@ -323,7 +323,7 @@ class ChatDocumentGalleryItemNode: ZoomableContentGalleryItemNode, WKNavigationD
|
|||
self.statusNodeContainer.layer.animateScale(from: 0.5, to: 1.0, duration: 0.25, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
}
|
||||
|
||||
override func animateOut(to node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
override func animateOut(to node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.webView)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.webView.superview)
|
||||
let transformedSelfFrame = node.0.view.convert(node.0.view.bounds, to: self.view)
|
||||
|
|
@ -333,7 +333,7 @@ class ChatDocumentGalleryItemNode: ZoomableContentGalleryItemNode, WKNavigationD
|
|||
var boundsCompleted = false
|
||||
var copyCompleted = false
|
||||
|
||||
let (maybeCopyView, copyViewBackgrond) = node.1()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.2()
|
||||
copyViewBackgrond?.alpha = 0.0
|
||||
let copyView = maybeCopyView!
|
||||
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ class ChatExternalFileGalleryItemNode: GalleryItemNode {
|
|||
return self._title.get()
|
||||
}
|
||||
|
||||
override func animateIn(from node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
override func animateIn(from node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.containerNode.view)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.containerNode.view.superview)
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ class ChatExternalFileGalleryItemNode: GalleryItemNode {
|
|||
self.statusNodeContainer.layer.animateScale(from: 0.5, to: 1.0, duration: 0.25, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
}
|
||||
|
||||
override func animateOut(to node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
override func animateOut(to node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.containerNode.view)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.containerNode.view.superview)
|
||||
let transformedSelfFrame = node.0.view.convert(node.0.view.bounds, to: self.view)
|
||||
|
|
@ -268,7 +268,7 @@ class ChatExternalFileGalleryItemNode: GalleryItemNode {
|
|||
var boundsCompleted = false
|
||||
var copyCompleted = false
|
||||
|
||||
let (maybeCopyView, copyViewBackgrond) = node.1()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.2()
|
||||
copyViewBackgrond?.alpha = 0.0
|
||||
let copyView = maybeCopyView!
|
||||
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
}
|
||||
let baseNavigationController = strongSelf.baseNavigationController()
|
||||
baseNavigationController?.view.endEditing(true)
|
||||
let controller = StickerPackScreen(context: context, stickerPacks: packs, sendSticker: nil)
|
||||
let controller = StickerPackScreen(context: context, mainStickerPack: packs[0], stickerPacks: packs, sendSticker: nil)
|
||||
(baseNavigationController?.topViewController as? ViewController)?.present(controller, in: .window(.root), with: nil)
|
||||
})
|
||||
}
|
||||
|
|
@ -350,14 +350,20 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
}))
|
||||
}
|
||||
|
||||
override func animateIn(from node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
override func animateIn(from node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view.superview)
|
||||
let transformedSelfFrame = node.0.view.convert(node.0.view.bounds, to: self.view)
|
||||
let transformedCopyViewFinalFrame = self.imageNode.view.convert(self.imageNode.view.bounds, to: self.view)
|
||||
|
||||
let (maybeSurfaceCopyView, _) = node.1()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.1()
|
||||
/*let projectedScale = CGPoint(x: self.imageNode.view.bounds.width / node.1.width, y: self.imageNode.view.bounds.height / node.1.height)
|
||||
let scaledLocalImageViewBounds = CGRect(x: -node.1.minX * projectedScale.x, y: -node.1.minY * projectedScale.y, width: node.0.bounds.width * projectedScale.x, height: node.0.bounds.height * projectedScale.y)*/
|
||||
|
||||
let scaledLocalImageViewBounds = self.imageNode.view.bounds
|
||||
|
||||
let transformedCopyViewFinalFrame = self.imageNode.view.convert(scaledLocalImageViewBounds, to: self.view)
|
||||
|
||||
let (maybeSurfaceCopyView, _) = node.2()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.2()
|
||||
copyViewBackgrond?.alpha = 0.0
|
||||
let surfaceCopyView = maybeSurfaceCopyView!
|
||||
let copyView = maybeCopyView!
|
||||
|
|
@ -368,7 +374,7 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
var transformedSurfaceFinalFrame: CGRect?
|
||||
if let contentSurface = surfaceCopyView.superview {
|
||||
transformedSurfaceFrame = node.0.view.convert(node.0.view.bounds, to: contentSurface)
|
||||
transformedSurfaceFinalFrame = self.imageNode.view.convert(self.imageNode.view.bounds, to: contentSurface)
|
||||
transformedSurfaceFinalFrame = self.imageNode.view.convert(scaledLocalImageViewBounds, to: contentSurface)
|
||||
}
|
||||
|
||||
if let transformedSurfaceFrame = transformedSurfaceFrame {
|
||||
|
|
@ -378,7 +384,7 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
self.view.insertSubview(copyView, belowSubview: self.scrollNode.view)
|
||||
copyView.frame = transformedSelfFrame
|
||||
|
||||
copyView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2, removeOnCompletion: false)
|
||||
copyView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
||||
|
||||
surfaceCopyView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, removeOnCompletion: false)
|
||||
|
||||
|
|
@ -409,7 +415,7 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
self.statusNodeContainer.layer.animateScale(from: 0.5, to: 1.0, duration: 0.25, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
}
|
||||
|
||||
override func animateOut(to node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
override func animateOut(to node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
self.fetchDisposable.set(nil)
|
||||
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view)
|
||||
|
|
@ -421,8 +427,8 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
var boundsCompleted = false
|
||||
var copyCompleted = false
|
||||
|
||||
let (maybeSurfaceCopyView, _) = node.1()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.1()
|
||||
let (maybeSurfaceCopyView, _) = node.2()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.2()
|
||||
copyViewBackgrond?.alpha = 0.0
|
||||
let surfaceCopyView = maybeSurfaceCopyView!
|
||||
let copyView = maybeCopyView!
|
||||
|
|
|
|||
|
|
@ -747,7 +747,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
}
|
||||
}
|
||||
|
||||
override func animateIn(from node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
override func animateIn(from node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
guard let videoNode = self.videoNode else {
|
||||
return
|
||||
}
|
||||
|
|
@ -773,8 +773,8 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
var transformedSelfFrame = node.0.view.convert(node.0.view.bounds, to: self.view)
|
||||
let transformedCopyViewFinalFrame = videoNode.view.convert(videoNode.view.bounds, to: self.view)
|
||||
|
||||
let (maybeSurfaceCopyView, _) = node.1()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.1()
|
||||
let (maybeSurfaceCopyView, _) = node.2()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.2()
|
||||
copyViewBackgrond?.alpha = 0.0
|
||||
let surfaceCopyView = maybeSurfaceCopyView!
|
||||
let copyView = maybeCopyView!
|
||||
|
|
@ -859,7 +859,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
}
|
||||
}
|
||||
|
||||
override func animateOut(to node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
override func animateOut(to node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
guard let videoNode = self.videoNode else {
|
||||
completion()
|
||||
return
|
||||
|
|
@ -875,8 +875,8 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
var boundsCompleted = true
|
||||
var copyCompleted = false
|
||||
|
||||
let (maybeSurfaceCopyView, _) = node.1()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.1()
|
||||
let (maybeSurfaceCopyView, _) = node.2()
|
||||
let (maybeCopyView, copyViewBackgrond) = node.2()
|
||||
copyViewBackgrond?.alpha = 0.0
|
||||
let surfaceCopyView = maybeSurfaceCopyView!
|
||||
let copyView = maybeCopyView!
|
||||
|
|
@ -1169,14 +1169,14 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
|
||||
(baseNavigationController?.topViewController as? ViewController)?.present(gallery, in: .window(.root), with: GalleryControllerPresentationArguments(transitionArguments: { id, media in
|
||||
if let overlayNode = overlayNode, let overlaySupernode = overlayNode.supernode {
|
||||
return GalleryTransitionArguments(transitionNode: (overlayNode, { [weak overlayNode] in
|
||||
return GalleryTransitionArguments(transitionNode: (overlayNode, overlayNode.bounds, { [weak overlayNode] in
|
||||
return (overlayNode?.view.snapshotContentTree(), nil)
|
||||
}), addToTransitionSurface: { [weak overlaySupernode, weak overlayNode] view in
|
||||
overlaySupernode?.view.addSubview(view)
|
||||
overlayNode?.canAttachContent = false
|
||||
})
|
||||
} else if let info = context.sharedContext.mediaManager.galleryHiddenMediaManager.findTarget(messageId: id, media: media) {
|
||||
return GalleryTransitionArguments(transitionNode: (info.1, {
|
||||
return GalleryTransitionArguments(transitionNode: (info.1, info.1.bounds, {
|
||||
return info.2()
|
||||
}), addToTransitionSurface: info.0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,10 +148,10 @@ public final class HorizontalPeerItemNode: ListViewItemNode {
|
|||
let badgeTextColor: UIColor
|
||||
let (unreadCount, isMuted) = unreadBadge
|
||||
if isMuted {
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundInactive(item.theme)
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundInactive(item.theme, diameter: 20.0)
|
||||
badgeTextColor = item.theme.chatList.unreadBadgeInactiveTextColor
|
||||
} else {
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundActive(item.theme)
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundActive(item.theme, diameter: 20.0)
|
||||
badgeTextColor = item.theme.chatList.unreadBadgeActiveTextColor
|
||||
}
|
||||
badgeAttributedString = NSAttributedString(string: unreadCount > 0 ? "\(unreadCount)" : " ", font: badgeFont, textColor: badgeTextColor)
|
||||
|
|
|
|||
|
|
@ -161,14 +161,14 @@ final class InstantImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
self.footerContentNode.setShareMedia(fileReference.abstract)
|
||||
}
|
||||
|
||||
override func animateIn(from node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
override func animateIn(from node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view.superview)
|
||||
let transformedSelfFrame = node.0.view.convert(node.0.view.bounds, to: self.view)
|
||||
let transformedCopyViewFinalFrame = self.imageNode.view.convert(self.imageNode.view.bounds, to: self.view)
|
||||
|
||||
let surfaceCopyView = node.1().0!
|
||||
let copyView = node.1().0!
|
||||
let surfaceCopyView = node.2().0!
|
||||
let copyView = node.2().0!
|
||||
|
||||
addToTransitionSurface(surfaceCopyView)
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ final class InstantImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
self.statusNodeContainer.layer.animateScale(from: 0.5, to: 1.0, duration: 0.25, timingFunction: kCAMediaTimingFunctionSpring)*/
|
||||
}
|
||||
|
||||
override func animateOut(to node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
override func animateOut(to node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
self.fetchDisposable.set(nil)
|
||||
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view)
|
||||
|
|
@ -229,8 +229,8 @@ final class InstantImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
var boundsCompleted = false
|
||||
var copyCompleted = false
|
||||
|
||||
let copyView = node.1().0!
|
||||
let surfaceCopyView = node.1().0!
|
||||
let copyView = node.2().0!
|
||||
let surfaceCopyView = node.2().0!
|
||||
|
||||
addToTransitionSurface(surfaceCopyView)
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ final class InstantPageArticleNode: ASDisplayNode, InstantPageNode {
|
|||
func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) {
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ final class InstantPageAudioNode: ASDisplayNode, InstantPageNode {
|
|||
}
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ final class InstantPageContentNode : ASDisplayNode {
|
|||
self.requestLayoutUpdate?(animated)
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
for (_, itemNode) in self.visibleItemsWithNodes {
|
||||
if let transitionNode = itemNode.transitionNode(media: media) {
|
||||
return transitionNode
|
||||
|
|
|
|||
|
|
@ -891,7 +891,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||
self.present(controller, ContextMenuControllerPresentationArguments(sourceNodeAndRect: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
for (_, itemNode) in strongSelf.visibleItemsWithNodes {
|
||||
if let (node, _) = itemNode.transitionNode(media: media) {
|
||||
if let (node, _, _) = itemNode.transitionNode(media: media) {
|
||||
return (strongSelf.scrollNode, node.convert(node.bounds, to: strongSelf.scrollNode), strongSelf, strongSelf.bounds)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ final class InstantPageDetailsNode: ASDisplayNode, InstantPageNode {
|
|||
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
return self.contentNode.transitionNode(media: media)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ final class InstantPageFeedbackNode: ASDisplayNode, InstantPageNode {
|
|||
func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) {
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -245,10 +245,10 @@ final class InstantPageImageNode: ASDisplayNode, InstantPageNode {
|
|||
}
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
if media == self.media {
|
||||
let imageNode = self.imageNode
|
||||
return (self.imageNode, { [weak imageNode] in
|
||||
return (self.imageNode, self.imageNode.bounds, { [weak imageNode] in
|
||||
return (imageNode?.view.snapshotContentTree(unhide: true), nil)
|
||||
})
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import TelegramPresentationData
|
|||
protocol InstantPageNode {
|
||||
func updateIsVisible(_ isVisible: Bool)
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))?
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))?
|
||||
func updateHiddenMedia(media: InstantPageMedia?)
|
||||
func update(strings: PresentationStrings, theme: InstantPageTheme)
|
||||
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ final class InstantPagePeerReferenceNode: ASDisplayNode, InstantPageNode {
|
|||
}
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -149,9 +149,9 @@ final class InstantPagePlayableVideoNode: ASDisplayNode, InstantPageNode, Galler
|
|||
}
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
if media == self.media {
|
||||
return (self, { [weak self] in
|
||||
return (self, self.bounds, { [weak self] in
|
||||
return (self?.view.snapshotContentTree(unhide: true), nil)
|
||||
})
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ final class InstantPageScrollableNode: ASScrollNode, InstantPageNode {
|
|||
func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) {
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ private final class InstantPageSlideshowItemNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
if let node = self.contentNode as? InstantPageNode {
|
||||
return node.transitionNode(media: media)
|
||||
}
|
||||
|
|
@ -363,7 +363,7 @@ private final class InstantPageSlideshowPagerNode: ASDisplayNode, UIScrollViewDe
|
|||
}
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
for node in self.itemNodes {
|
||||
if let transitionNode = node.transitionNode(media: media) {
|
||||
return transitionNode
|
||||
|
|
@ -422,7 +422,7 @@ final class InstantPageSlideshowNode: ASDisplayNode, InstantPageNode {
|
|||
}
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
return self.pagerNode.transitionNode(media: media)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ final class InstantPageWebEmbedNode: ASDisplayNode, InstantPageNode {
|
|||
self.webView?.frame = self.bounds
|
||||
}
|
||||
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, () -> (UIView?, UIView?))? {
|
||||
func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1078,9 +1078,9 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
|
|||
}
|
||||
}
|
||||
|
||||
public func avatarTransitionNode() -> ((ASDisplayNode, () -> (UIView?, UIView?)), CGRect) {
|
||||
public func avatarTransitionNode() -> ((ASDisplayNode, CGRect, () -> (UIView?, UIView?)), CGRect) {
|
||||
let avatarNode = self.avatarNode
|
||||
return ((self.avatarNode, { [weak avatarNode] in
|
||||
return ((self.avatarNode, self.avatarNode.bounds, { [weak avatarNode] in
|
||||
return (avatarNode?.view.snapshotContentTree(unhide: true), nil)
|
||||
}), self.avatarNode.bounds)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#import <LegacyComponents/TGMediaAsset.h>
|
||||
|
||||
#import <LegacyComponents/TGMediaAssetsUtils.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGMediaSelectionContext;
|
||||
@class TGMediaEditingContext;
|
||||
|
|
@ -52,6 +53,7 @@
|
|||
@property (nonatomic, assign) bool collapsed;
|
||||
|
||||
@property (nonatomic, strong) NSString *recipientName;
|
||||
@property (nonatomic, assign) TGMediaVideoConversionPreset defaultVideoPreset;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context camera:(bool)hasCamera selfPortrait:(bool)selfPortrait forProfilePhoto:(bool)forProfilePhoto assetType:(TGMediaAssetType)assetType saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping;
|
||||
|
||||
|
|
|
|||
|
|
@ -801,7 +801,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
|||
if ([cell isKindOfClass:[TGAttachmentAssetCell class]])
|
||||
thumbnailImage = cell.imageView.image;
|
||||
|
||||
TGMediaPickerModernGalleryMixin *mixin = [[TGMediaPickerModernGalleryMixin alloc] initWithContext:_context item:asset fetchResult:_fetchResult parentController:self.parentController thumbnailImage:thumbnailImage selectionContext:_selectionContext editingContext:_editingContext suggestionContext:self.suggestionContext hasCaptions:(_allowCaptions && !_forProfilePhoto) allowCaptionEntities:self.allowCaptionEntities hasTimer:self.hasTimer onlyCrop:self.onlyCrop inhibitDocumentCaptions:_inhibitDocumentCaptions inhibitMute:self.inhibitMute asFile:self.asFile itemsLimit:TGAttachmentDisplayedAssetLimit recipientName:self.recipientName hasSilentPosting:self.hasSilentPosting hasSchedule:self.hasSchedule reminder:self.reminder];
|
||||
TGMediaPickerModernGalleryMixin *mixin = [[TGMediaPickerModernGalleryMixin alloc] initWithContext:_context item:asset fetchResult:_fetchResult parentController:self.parentController thumbnailImage:thumbnailImage selectionContext:_selectionContext editingContext:_editingContext suggestionContext:self.suggestionContext hasCaptions:(_allowCaptions && !_forProfilePhoto) allowCaptionEntities:self.allowCaptionEntities hasTimer:self.hasTimer onlyCrop:self.onlyCrop inhibitDocumentCaptions:_inhibitDocumentCaptions inhibitMute:self.inhibitMute asFile:self.asFile itemsLimit:TGAttachmentDisplayedAssetLimit recipientName:self.recipientName defaultVideoPreset:self.defaultVideoPreset hasSilentPosting:self.hasSilentPosting hasSchedule:self.hasSchedule reminder:self.reminder];
|
||||
mixin.presentScheduleController = self.presentScheduleController;
|
||||
__weak TGAttachmentCarouselItemView *weakSelf = self;
|
||||
mixin.thumbnailSignalForItem = ^SSignal *(id item)
|
||||
|
|
@ -864,7 +864,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
|||
{
|
||||
id<LegacyComponentsOverlayWindowManager> windowManager = [_context makeOverlayWindowManager];
|
||||
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:asset intent:_disableStickers ? TGPhotoEditorControllerSignupAvatarIntent : TGPhotoEditorControllerAvatarIntent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:asset intent:_disableStickers ? TGPhotoEditorControllerSignupAvatarIntent : TGPhotoEditorControllerAvatarIntent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab defaultVideoPreset:_defaultVideoPreset];
|
||||
controller.editingContext = _editingContext;
|
||||
controller.dontHideStatusBar = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#import <LegacyComponents/TGOverlayController.h>
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGMediaSelectionContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class PGCamera;
|
||||
@class TGCameraPreviewView;
|
||||
|
|
@ -45,6 +46,7 @@ typedef enum {
|
|||
@property (nonatomic, strong) NSArray *forcedEntities;
|
||||
|
||||
@property (nonatomic, strong) NSString *recipientName;
|
||||
@property (nonatomic, assign) TGMediaVideoConversionPreset defaultVideoPreset;
|
||||
|
||||
@property (nonatomic, copy) void(^finishedWithResults)(TGOverlayController *controller, TGMediaSelectionContext *selectionContext, TGMediaEditingContext *editingContext, id<TGMediaSelectableItem> currentItem, bool silentPosting, int32_t scheduleTime);
|
||||
@property (nonatomic, copy) void(^finishedWithPhoto)(TGOverlayController *controller, UIImage *resultImage, NSString *caption, NSArray *entities, NSArray *stickers, NSNumber *timer);
|
||||
|
|
|
|||
|
|
@ -1247,7 +1247,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
|||
}];
|
||||
|
||||
bool hasCamera = !self.inhibitMultipleCapture && ((_intent == TGCameraControllerGenericIntent && !_shortcut) || (_intent == TGCameraControllerPassportMultipleIntent));
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:galleryItems focusItem:focusItem selectionContext:_items.count > 1 ? selectionContext : nil editingContext:editingContext hasCaptions:self.allowCaptions allowCaptionEntities:self.allowCaptionEntities hasTimer:self.hasTimer onlyCrop:_intent == TGCameraControllerPassportIntent || _intent == TGCameraControllerPassportIdIntent || _intent == TGCameraControllerPassportMultipleIntent inhibitDocumentCaptions:self.inhibitDocumentCaptions hasSelectionPanel:true hasCamera:hasCamera recipientName:self.recipientName];
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:galleryItems focusItem:focusItem selectionContext:_items.count > 1 ? selectionContext : nil editingContext:editingContext hasCaptions:self.allowCaptions allowCaptionEntities:self.allowCaptionEntities hasTimer:self.hasTimer onlyCrop:_intent == TGCameraControllerPassportIntent || _intent == TGCameraControllerPassportIdIntent || _intent == TGCameraControllerPassportMultipleIntent inhibitDocumentCaptions:self.inhibitDocumentCaptions hasSelectionPanel:true hasCamera:hasCamera recipientName:self.recipientName defaultVideoPreset:self.defaultVideoPreset];
|
||||
model.inhibitMute = self.inhibitMute;
|
||||
model.controller = galleryController;
|
||||
model.suggestionContext = self.suggestionContext;
|
||||
|
|
@ -1651,7 +1651,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
|||
if (_intent == TGCameraControllerSignupAvatarIntent) {
|
||||
intent = TGPhotoEditorControllerSignupAvatarIntent;
|
||||
}
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:windowContext item:image intent:(TGPhotoEditorControllerFromCameraIntent | intent) adjustments:nil caption:nil screenImage:image availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:windowContext item:image intent:(TGPhotoEditorControllerFromCameraIntent | intent) adjustments:nil caption:nil screenImage:image availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab defaultVideoPreset:_defaultVideoPreset];
|
||||
__weak TGPhotoEditorController *weakController = controller;
|
||||
controller.beginTransitionIn = ^UIView *(CGRect *referenceFrame, __unused UIView **parentView)
|
||||
{
|
||||
|
|
@ -1735,7 +1735,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
|||
|
||||
default:
|
||||
{
|
||||
TGCameraPhotoPreviewController *controller = _shortcut ? [[TGCameraPhotoPreviewController alloc] initWithContext:windowContext image:image metadata:metadata recipientName:self.recipientName backButtonTitle:TGLocalized(@"Camera.Retake") doneButtonTitle:TGLocalized(@"Common.Next") saveCapturedMedia:_saveCapturedMedia saveEditedPhotos:_saveEditedPhotos] : [[TGCameraPhotoPreviewController alloc] initWithContext:windowContext image:image metadata:metadata recipientName:self.recipientName saveCapturedMedia:_saveCapturedMedia saveEditedPhotos:_saveEditedPhotos];
|
||||
TGCameraPhotoPreviewController *controller = _shortcut ? [[TGCameraPhotoPreviewController alloc] initWithContext:windowContext image:image metadata:metadata recipientName:self.recipientName backButtonTitle:TGLocalized(@"Camera.Retake") doneButtonTitle:TGLocalized(@"Common.Next") saveCapturedMedia:_saveCapturedMedia saveEditedPhotos:_saveEditedPhotos defaultVideoPreset:_defaultVideoPreset] : [[TGCameraPhotoPreviewController alloc] initWithContext:windowContext image:image metadata:metadata recipientName:self.recipientName saveCapturedMedia:_saveCapturedMedia saveEditedPhotos:_saveEditedPhotos defaultVideoPreset:_defaultVideoPreset];
|
||||
controller.allowCaptions = self.allowCaptions;
|
||||
controller.shouldStoreAssets = self.shouldStoreCapturedAssets;
|
||||
controller.suggestionContext = self.suggestionContext;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#import <LegacyComponents/TGOverlayController.h>
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class PGCameraShotMetadata;
|
||||
@class PGPhotoEditorValues;
|
||||
|
|
@ -26,8 +27,8 @@
|
|||
@property (nonatomic, assign) bool hasSilentPosting;
|
||||
@property (nonatomic, assign) bool hasSchedule;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName backButtonTitle:(NSString *)backButtonTitle doneButtonTitle:(NSString *)doneButtonTitle saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName backButtonTitle:(NSString *)backButtonTitle doneButtonTitle:(NSString *)doneButtonTitle saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@
|
|||
bool _saveEditedPhotos;
|
||||
|
||||
id<LegacyComponentsContext> _context;
|
||||
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@property (nonatomic, weak) TGPhotoEditorController *editorController;
|
||||
|
|
@ -88,12 +90,12 @@
|
|||
|
||||
@implementation TGCameraPhotoPreviewController
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
{
|
||||
return [self initWithContext:context image:image metadata:metadata recipientName:recipientName backButtonTitle:TGLocalized(@"Camera.Retake") doneButtonTitle:TGLocalized(@"MediaPicker.Send") saveCapturedMedia:saveCapturedMedia saveEditedPhotos:saveEditedPhotos];
|
||||
return [self initWithContext:context image:image metadata:metadata recipientName:recipientName backButtonTitle:TGLocalized(@"Camera.Retake") doneButtonTitle:TGLocalized(@"MediaPicker.Send") saveCapturedMedia:saveCapturedMedia saveEditedPhotos:saveEditedPhotos defaultVideoPreset:defaultVideoPreset];
|
||||
}
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName backButtonTitle:(NSString *)backButtonTitle doneButtonTitle:(NSString *)doneButtonTitle saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName backButtonTitle:(NSString *)backButtonTitle doneButtonTitle:(NSString *)doneButtonTitle saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
{
|
||||
self = [super initWithContext:context];
|
||||
if (self != nil)
|
||||
|
|
@ -103,6 +105,7 @@
|
|||
_metadata = metadata;
|
||||
_imageSize = image.size;
|
||||
_recipientName = recipientName;
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
|
||||
_editingContext = [[TGMediaEditingContext alloc] init];
|
||||
|
||||
|
|
@ -884,7 +887,7 @@
|
|||
PGPhotoEditorValues *editorValues = (PGPhotoEditorValues *)[_editingContext adjustmentsForItem:_image];
|
||||
NSString *caption = [_editingContext captionForItem:_image];
|
||||
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:editableMediaItem intent:TGPhotoEditorControllerFromCameraIntent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_portraitToolbarView.currentTabs selectedTab:tab];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:editableMediaItem intent:TGPhotoEditorControllerFromCameraIntent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_portraitToolbarView.currentTabs selectedTab:tab defaultVideoPreset:_defaultVideoPreset];
|
||||
controller.editingContext = _editingContext;
|
||||
self.editorController = controller;
|
||||
controller.metadata = _metadata;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#import <LegacyComponents/TGModernGalleryController.h>
|
||||
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGClipboardGalleryPhotoItem;
|
||||
|
||||
|
|
@ -19,7 +20,7 @@
|
|||
@property (nonatomic, copy) void (^editorOpened)(void);
|
||||
@property (nonatomic, copy) void (^editorClosed)(void);
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image images:(NSArray *)images parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image images:(NSArray *)images parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
|
||||
- (void)present;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
@implementation TGClipboardGalleryMixin
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image images:(NSArray *)images parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image images:(NSArray *)images parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
}
|
||||
}];
|
||||
|
||||
TGClipboardGalleryModel *model = [[TGClipboardGalleryModel alloc] initWithContext:_context images:images focusIndex:focusIndex selectionContext:selectionContext editingContext:editingContext hasCaptions:hasCaptions hasTimer:hasTimer hasSelectionPanel:false recipientName:recipientName];
|
||||
TGClipboardGalleryModel *model = [[TGClipboardGalleryModel alloc] initWithContext:_context images:images focusIndex:focusIndex selectionContext:selectionContext editingContext:editingContext hasCaptions:hasCaptions hasTimer:hasTimer hasSelectionPanel:false recipientName:recipientName defaultVideoPreset:defaultVideoPreset];
|
||||
_galleryModel = model;
|
||||
model.controller = modernGallery;
|
||||
model.suggestionContext = suggestionContext;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#import <LegacyComponents/TGPhotoEditorController.h>
|
||||
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@interface TGClipboardGalleryModel : TGModernGalleryModel
|
||||
|
||||
|
|
@ -26,6 +27,6 @@
|
|||
@property (nonatomic, readonly) TGMediaSelectionContext *selectionContext;
|
||||
@property (nonatomic, strong) TGSuggestionContext *suggestionContext;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context images:(NSArray *)images focusIndex:(NSUInteger)focusIndex selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer hasSelectionPanel:(bool)hasSelectionPanel recipientName:(NSString *)recipientName;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context images:(NSArray *)images focusIndex:(NSUInteger)focusIndex selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer hasSelectionPanel:(bool)hasSelectionPanel recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
TGMediaEditingContext *_editingContext;
|
||||
|
||||
id<LegacyComponentsContext> _context;
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@property (nonatomic, weak) TGPhotoEditorController *editorController;
|
||||
|
|
@ -34,12 +35,13 @@
|
|||
|
||||
@implementation TGClipboardGalleryModel
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context images:(NSArray *)images focusIndex:(NSUInteger)focusIndex selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer hasSelectionPanel:(bool)hasSelectionPanel recipientName:(NSString *)recipientName
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context images:(NSArray *)images focusIndex:(NSUInteger)focusIndex selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer hasSelectionPanel:(bool)hasSelectionPanel recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_context = context;
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
|
||||
NSMutableArray *items = [[NSMutableArray alloc] init];
|
||||
TGClipboardGalleryPhotoItem *focusItem = nil;
|
||||
|
|
@ -77,7 +79,7 @@
|
|||
};
|
||||
}
|
||||
|
||||
_interfaceView = [[TGMediaPickerGalleryInterfaceView alloc] initWithContext:_context focusItem:focusItem selectionContext:selectionContext editingContext:editingContext hasSelectionPanel:hasSelectionPanel hasCameraButton:false recipientName:recipientName];
|
||||
_interfaceView = [[TGMediaPickerGalleryInterfaceView alloc] initWithContext:_context focusItem:focusItem selectionContext:selectionContext editingContext:editingContext hasSelectionPanel:hasSelectionPanel hasCameraButton:false recipientName:recipientName defaultVideoPreset:defaultVideoPreset];
|
||||
_interfaceView.hasCaptions = hasCaptions;
|
||||
_interfaceView.hasTimer = hasTimer;
|
||||
[_interfaceView setEditorTabPressed:^(TGPhotoEditorTab tab)
|
||||
|
|
@ -320,7 +322,7 @@
|
|||
}
|
||||
|
||||
TGPhotoEditorControllerIntent intent = isVideo ? TGPhotoEditorControllerVideoIntent : TGPhotoEditorControllerGenericIntent;
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:item.editableMediaItem intent:intent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_interfaceView.currentTabs selectedTab:tab];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:item.editableMediaItem intent:intent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_interfaceView.currentTabs selectedTab:tab defaultVideoPreset:_defaultVideoPreset];
|
||||
controller.editingContext = _editingContext;
|
||||
self.editorController = controller;
|
||||
controller.suggestionContext = self.suggestionContext;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGViewController;
|
||||
@class TGMenuSheetController;
|
||||
|
|
@ -12,7 +13,7 @@
|
|||
|
||||
@interface TGClipboardMenu : NSObject
|
||||
|
||||
+ (TGMenuSheetController *)presentInParentController:(TGViewController *)parentController context:(id<LegacyComponentsContext>)context images:(NSArray *)images hasCaption:(bool)hasCaption hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName completed:(void (^)(TGMediaSelectionContext *selectionContext, TGMediaEditingContext *editingContext, id<TGMediaSelectableItem> currentItem))completed dismissed:(void (^)(void))dismissed sourceView:(UIView *)sourceView sourceRect:(CGRect (^)(void))sourceRect;
|
||||
+ (TGMenuSheetController *)presentInParentController:(TGViewController *)parentController context:(id<LegacyComponentsContext>)context images:(NSArray *)images hasCaption:(bool)hasCaption hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset completed:(void (^)(TGMediaSelectionContext *selectionContext, TGMediaEditingContext *editingContext, id<TGMediaSelectableItem> currentItem))completed dismissed:(void (^)(void))dismissed sourceView:(UIView *)sourceView sourceRect:(CGRect (^)(void))sourceRect;
|
||||
|
||||
+ (NSArray *)resultSignalsForSelectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext currentItem:(id<TGMediaSelectableItem>)currentItem descriptionGenerator:(id (^)(id, NSString *, NSArray *, NSString *))descriptionGenerator;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
@implementation TGClipboardMenu
|
||||
|
||||
+ (TGMenuSheetController *)presentInParentController:(TGViewController *)parentController context:(id<LegacyComponentsContext>)context images:(NSArray *)images hasCaption:(bool)hasCaption hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName completed:(void (^)(TGMediaSelectionContext *selectionContext, TGMediaEditingContext *editingContext, id<TGMediaSelectableItem> currentItem))completed dismissed:(void (^)(void))dismissed sourceView:(UIView *)sourceView sourceRect:(CGRect (^)(void))sourceRect
|
||||
+ (TGMenuSheetController *)presentInParentController:(TGViewController *)parentController context:(id<LegacyComponentsContext>)context images:(NSArray *)images hasCaption:(bool)hasCaption hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset completed:(void (^)(TGMediaSelectionContext *selectionContext, TGMediaEditingContext *editingContext, id<TGMediaSelectableItem> currentItem))completed dismissed:(void (^)(void))dismissed sourceView:(UIView *)sourceView sourceRect:(CGRect (^)(void))sourceRect
|
||||
{
|
||||
bool centered = false;
|
||||
if (sourceRect == nil)
|
||||
|
|
@ -46,6 +46,7 @@
|
|||
previewItem.allowCaptions = hasCaption;
|
||||
previewItem.hasTimer = hasTimer;
|
||||
previewItem.recipientName = recipientName;
|
||||
previewItem.defaultVideoPreset = defaultVideoPreset;
|
||||
previewItem.sendPressed = ^(UIImage *currentItem)
|
||||
{
|
||||
__strong TGClipboardPreviewItemView *strongPreviewItem = weakPreviewItem;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
@property (nonatomic, assign) bool allowCaptions;
|
||||
@property (nonatomic, assign) bool hasTimer;
|
||||
@property (nonatomic, strong) NSString *recipientName;
|
||||
@property (nonatomic, assign) TGMediaVideoConversionPreset defaultVideoPreset;
|
||||
|
||||
@property (nonatomic, readonly) TGMediaSelectionContext *selectionContext;
|
||||
@property (nonatomic, readonly) TGMediaEditingContext *editingContext;
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ const CGFloat TGClipboardPreviewEdgeInset = 8.0f;
|
|||
if ([cell isKindOfClass:[TGClipboardPreviewCell class]])
|
||||
thumbnailImage = cell.imageView.image;
|
||||
|
||||
TGClipboardGalleryMixin *mixin = [[TGClipboardGalleryMixin alloc] initWithContext:_context image:image images:_images parentController:self.parentController thumbnailImage:thumbnailImage selectionContext:_selectionContext editingContext:_editingContext suggestionContext:self.suggestionContext hasCaptions:self.allowCaptions hasTimer:self.hasTimer recipientName:self.recipientName];
|
||||
TGClipboardGalleryMixin *mixin = [[TGClipboardGalleryMixin alloc] initWithContext:_context image:image images:_images parentController:self.parentController thumbnailImage:thumbnailImage selectionContext:_selectionContext editingContext:_editingContext suggestionContext:self.suggestionContext hasCaptions:self.allowCaptions hasTimer:self.hasTimer recipientName:self.recipientName defaultVideoPreset:self.defaultVideoPreset];
|
||||
|
||||
[self _setupGalleryMixin:mixin];
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#import <LegacyComponents/TGMediaAssetsUtils.h>
|
||||
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGMediaAssetsPickerController;
|
||||
@class TGViewController;
|
||||
|
||||
|
|
@ -91,8 +93,8 @@ typedef enum
|
|||
|
||||
- (void)dismiss;
|
||||
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping selectionLimit:(int)selectionLimit;
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit;
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping selectionLimit:(int)selectionLimit;
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit;
|
||||
|
||||
+ (TGMediaAssetType)assetTypeForIntent:(TGMediaAssetsControllerIntent)intent;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,12 +58,12 @@
|
|||
|
||||
@implementation TGMediaAssetsController
|
||||
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping selectionLimit:(int)selectionLimit
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping selectionLimit:(int)selectionLimit
|
||||
{
|
||||
return [self controllerWithContext:context assetGroup:assetGroup intent:intent recipientName:recipientName saveEditedPhotos:saveEditedPhotos allowGrouping:allowGrouping inhibitSelection:false selectionLimit:selectionLimit];
|
||||
return [self controllerWithContext:context assetGroup:assetGroup intent:intent recipientName:recipientName defaultVideoPreset:defaultVideoPreset saveEditedPhotos:saveEditedPhotos allowGrouping:allowGrouping inhibitSelection:false selectionLimit:selectionLimit];
|
||||
}
|
||||
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit
|
||||
{
|
||||
if (intent != TGMediaAssetsControllerSendMediaIntent)
|
||||
allowGrouping = false;
|
||||
|
|
@ -106,7 +106,7 @@
|
|||
|
||||
if ([group isKindOfClass:[TGMediaAssetGroup class]])
|
||||
{
|
||||
pickerController = [[TGMediaAssetsPickerController alloc] initWithContext:strongController->_context assetsLibrary:strongController.assetsLibrary assetGroup:group intent:intent selectionContext:inhibitSelection ? nil : strongController->_selectionContext editingContext:strongController->_editingContext saveEditedPhotos:strongController->_saveEditedPhotos];
|
||||
pickerController = [[TGMediaAssetsPickerController alloc] initWithContext:strongController->_context assetsLibrary:strongController.assetsLibrary assetGroup:group intent:intent selectionContext:inhibitSelection ? nil : strongController->_selectionContext editingContext:strongController->_editingContext saveEditedPhotos:strongController->_saveEditedPhotos defaultVideoPreset:defaultVideoPreset];
|
||||
pickerController.pallete = strongController.pallete;
|
||||
}
|
||||
pickerController.suggestionContext = strongController.suggestionContext;
|
||||
|
|
@ -118,6 +118,7 @@
|
|||
pickerController.liveVideoUploadEnabled = strongController.liveVideoUploadEnabled;
|
||||
pickerController.catchToolbarView = catchToolbarView;
|
||||
pickerController.recipientName = recipientName;
|
||||
pickerController.defaultVideoPreset = defaultVideoPreset;
|
||||
pickerController.hasTimer = strongController.hasTimer;
|
||||
pickerController.onlyCrop = strongController.onlyCrop;
|
||||
pickerController.hasSilentPosting = strongController.hasSilentPosting;
|
||||
|
|
@ -128,7 +129,7 @@
|
|||
};
|
||||
[groupsController loadViewIfNeeded];
|
||||
|
||||
TGMediaAssetsPickerController *pickerController = [[TGMediaAssetsPickerController alloc] initWithContext:context assetsLibrary:assetsController.assetsLibrary assetGroup:assetGroup intent:intent selectionContext:inhibitSelection ? nil : assetsController->_selectionContext editingContext:assetsController->_editingContext saveEditedPhotos:saveEditedPhotos];
|
||||
TGMediaAssetsPickerController *pickerController = [[TGMediaAssetsPickerController alloc] initWithContext:context assetsLibrary:assetsController.assetsLibrary assetGroup:assetGroup intent:intent selectionContext:inhibitSelection ? nil : assetsController->_selectionContext editingContext:assetsController->_editingContext saveEditedPhotos:saveEditedPhotos defaultVideoPreset:defaultVideoPreset];
|
||||
pickerController.pallete = assetsController.pallete;
|
||||
pickerController.catchToolbarView = catchToolbarView;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#import <LegacyComponents/TGMediaPickerController.h>
|
||||
#import <LegacyComponents/TGMediaAssetsController.h>
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGMediaAssetsPreheatMixin;
|
||||
@class TGMediaPickerModernGalleryMixin;
|
||||
|
|
@ -14,6 +15,6 @@
|
|||
@property (nonatomic, assign) bool liveVideoUploadEnabled;
|
||||
@property (nonatomic, readonly) TGMediaAssetGroup *assetGroup;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context assetsLibrary:(TGMediaAssetsLibrary *)assetsLibrary assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext saveEditedPhotos:(bool)saveEditedPhotos;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context assetsLibrary:(TGMediaAssetsLibrary *)assetsLibrary assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -46,13 +46,15 @@
|
|||
|
||||
id<LegacyComponentsContext> _context;
|
||||
bool _saveEditedPhotos;
|
||||
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation TGMediaAssetsPickerController
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context assetsLibrary:(TGMediaAssetsLibrary *)assetsLibrary assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext saveEditedPhotos:(bool)saveEditedPhotos
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context assetsLibrary:(TGMediaAssetsLibrary *)assetsLibrary assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
{
|
||||
bool hasSelection = false;
|
||||
bool hasEditing = false;
|
||||
|
|
@ -88,6 +90,7 @@
|
|||
_assetsLibrary = assetsLibrary;
|
||||
_assetGroup = assetGroup;
|
||||
_intent = intent;
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
|
||||
[self setTitle:_assetGroup.title];
|
||||
|
||||
|
|
@ -323,7 +326,7 @@
|
|||
|
||||
- (TGMediaPickerModernGalleryMixin *)_galleryMixinForContext:(id<LegacyComponentsContext>)context item:(id)item thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities inhibitDocumentCaptions:(bool)inhibitDocumentCaptions asFile:(bool)asFile
|
||||
{
|
||||
return [[TGMediaPickerModernGalleryMixin alloc] initWithContext:context item:item fetchResult:_fetchResult parentController:self thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:self.hasTimer onlyCrop:self.onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:self.inhibitMute asFile:asFile itemsLimit:0 recipientName:self.recipientName hasSilentPosting:self.hasSilentPosting hasSchedule:self.hasSchedule reminder:self.reminder];
|
||||
return [[TGMediaPickerModernGalleryMixin alloc] initWithContext:context item:item fetchResult:_fetchResult parentController:self thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:self.hasTimer onlyCrop:self.onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:self.inhibitMute asFile:asFile itemsLimit:0 recipientName:self.recipientName defaultVideoPreset:self.defaultVideoPreset hasSilentPosting:self.hasSilentPosting hasSchedule:self.hasSchedule reminder:self.reminder];
|
||||
}
|
||||
|
||||
- (TGMediaPickerModernGalleryMixin *)galleryMixinForIndexPath:(NSIndexPath *)indexPath previewMode:(bool)previewMode outAsset:(TGMediaAsset **)outAsset
|
||||
|
|
@ -395,7 +398,7 @@
|
|||
if (_intent == TGMediaAssetsControllerSetSignupProfilePhotoIntent) {
|
||||
intent = TGPhotoEditorControllerSignupAvatarIntent;
|
||||
}
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:asset intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:asset intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab defaultVideoPreset:_defaultVideoPreset];
|
||||
controller.editingContext = self.editingContext;
|
||||
controller.didFinishRenderingFullSizeImage = ^(UIImage *resultImage)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@
|
|||
if (strongSelf == nil)
|
||||
return nil;
|
||||
|
||||
TGMediaAssetsController *controller = [TGMediaAssetsController controllerWithContext:context assetGroup:group intent:strongSelf->_signup ? TGMediaAssetsControllerSetSignupProfilePhotoIntent : TGMediaAssetsControllerSetProfilePhotoIntent recipientName:nil saveEditedPhotos:strongSelf->_saveEditedPhotos allowGrouping:false selectionLimit:10];
|
||||
TGMediaAssetsController *controller = [TGMediaAssetsController controllerWithContext:context assetGroup:group intent:strongSelf->_signup ? TGMediaAssetsControllerSetSignupProfilePhotoIntent : TGMediaAssetsControllerSetProfilePhotoIntent recipientName:nil defaultVideoPreset:TGMediaVideoConversionPresetCompressedDefault saveEditedPhotos:strongSelf->_saveEditedPhotos allowGrouping:false selectionLimit:10];
|
||||
__weak TGMediaAssetsController *weakController = controller;
|
||||
controller.avatarCompletionBlock = ^(UIImage *resultImage)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#import <LegacyComponents/TGSuggestionContext.h>
|
||||
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGMediaPickerLayoutMetrics;
|
||||
@class TGMediaSelectionContext;
|
||||
@class TGMediaEditingContext;
|
||||
|
|
@ -27,6 +29,7 @@
|
|||
@property (nonatomic, assign) bool onlyCrop;
|
||||
@property (nonatomic, assign) bool inhibitMute;
|
||||
@property (nonatomic, strong) NSString *recipientName;
|
||||
@property (nonatomic, assign) TGMediaVideoConversionPreset defaultVideoPreset;
|
||||
@property (nonatomic, assign) bool hasSilentPosting;
|
||||
@property (nonatomic, assign) bool hasSchedule;
|
||||
@property (nonatomic, assign) bool reminder;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
{
|
||||
_selectionContext = selectionContext;
|
||||
_editingContext = editingContext;
|
||||
_defaultVideoPreset = TGMediaVideoConversionPresetCompressedDefault;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#import <LegacyComponents/TGPhotoToolbarView.h>
|
||||
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGMediaSelectionContext;
|
||||
@class TGMediaEditingContext;
|
||||
|
|
@ -37,7 +38,7 @@
|
|||
|
||||
@property (nonatomic, readonly) UIView *timerButton;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasSelectionPanel:(bool)hasSelectionPanel hasCameraButton:(bool)hasCameraButton recipientName:(NSString *)recipientName;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasSelectionPanel:(bool)hasSelectionPanel hasCameraButton:(bool)hasCameraButton recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
|
||||
- (void)setSelectedItemsModel:(TGMediaPickerGallerySelectedItemsModel *)selectedItemsModel;
|
||||
- (void)setEditorTabPressed:(void (^)(TGPhotoEditorTab tab))editorTabPressed;
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@
|
|||
id<LegacyComponentsContext> _context;
|
||||
|
||||
bool _ignoreSelectionUpdates;
|
||||
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) ASHandle *actionHandle;
|
||||
|
|
@ -103,7 +105,7 @@
|
|||
|
||||
@synthesize safeAreaInset = _safeAreaInset;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasSelectionPanel:(bool)hasSelectionPanel hasCameraButton:(bool)hasCameraButton recipientName:(NSString *)recipientName
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasSelectionPanel:(bool)hasSelectionPanel hasCameraButton:(bool)hasCameraButton recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
{
|
||||
self = [super initWithFrame:CGRectZero];
|
||||
if (self != nil)
|
||||
|
|
@ -116,6 +118,8 @@
|
|||
|
||||
_hasSwipeGesture = true;
|
||||
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
|
||||
_itemHeaderViews = [[NSMutableArray alloc] init];
|
||||
_itemFooterViews = [[NSMutableArray alloc] init];
|
||||
|
||||
|
|
@ -850,11 +854,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
NSNumber *presetValue = [[NSUserDefaults standardUserDefaults] objectForKey:@"TG_preferredVideoPreset_v0"];
|
||||
if (presetValue != nil)
|
||||
preset = (TGMediaVideoConversionPreset)[presetValue integerValue];
|
||||
else
|
||||
preset = TGMediaVideoConversionPresetCompressedMedium;
|
||||
preset = _defaultVideoPreset;
|
||||
}
|
||||
|
||||
TGMediaVideoConversionPreset bestPreset = [TGMediaVideoConverter bestAvailablePresetForDimensions:dimensions];
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#import <LegacyComponents/TGMediaAssetsUtils.h>
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGModernGalleryController;
|
||||
@class TGMediaPickerGallerySelectedItemsModel;
|
||||
|
|
@ -45,6 +46,6 @@
|
|||
@property (nonatomic, readonly) TGMediaSelectionContext *selectionContext;
|
||||
@property (nonatomic, strong) TGSuggestionContext *suggestionContext;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context items:(NSArray *)items focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions hasSelectionPanel:(bool)hasSelectionPanel hasCamera:(bool)hasCamera recipientName:(NSString *)recipientName;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context items:(NSArray *)items focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions hasSelectionPanel:(bool)hasSelectionPanel hasCamera:(bool)hasCamera recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
bool _inhibitDocumentCaptions;
|
||||
NSString *_recipientName;
|
||||
bool _hasCamera;
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@property (nonatomic, weak) TGPhotoEditorController *editorController;
|
||||
|
|
@ -46,7 +47,7 @@
|
|||
|
||||
@implementation TGMediaPickerGalleryModel
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context items:(NSArray *)items focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions hasSelectionPanel:(bool)hasSelectionPanel hasCamera:(bool)hasCamera recipientName:(NSString *)recipientName
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context items:(NSArray *)items focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions hasSelectionPanel:(bool)hasSelectionPanel hasCamera:(bool)hasCamera recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
|
|
@ -66,6 +67,7 @@
|
|||
_hasSelectionPanel = hasSelectionPanel;
|
||||
_inhibitDocumentCaptions = inhibitDocumentCaptions;
|
||||
_recipientName = recipientName;
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
_hasCamera = hasCamera;
|
||||
|
||||
__weak TGMediaPickerGalleryModel *weakSelf = self;
|
||||
|
|
@ -182,7 +184,7 @@
|
|||
if (_interfaceView == nil)
|
||||
{
|
||||
__weak TGMediaPickerGalleryModel *weakSelf = self;
|
||||
_interfaceView = [[TGMediaPickerGalleryInterfaceView alloc] initWithContext:_context focusItem:_initialFocusItem selectionContext:_selectionContext editingContext:_editingContext hasSelectionPanel:_hasSelectionPanel hasCameraButton:_hasCamera recipientName:_recipientName];
|
||||
_interfaceView = [[TGMediaPickerGalleryInterfaceView alloc] initWithContext:_context focusItem:_initialFocusItem selectionContext:_selectionContext editingContext:_editingContext hasSelectionPanel:_hasSelectionPanel hasCameraButton:_hasCamera recipientName:_recipientName defaultVideoPreset:_defaultVideoPreset];
|
||||
[_interfaceView setSuggestionContext:_suggestionContext];
|
||||
_interfaceView.hasCaptions = _hasCaptions;
|
||||
_interfaceView.allowCaptionEntities = _allowCaptionEntities;
|
||||
|
|
@ -385,7 +387,7 @@
|
|||
self.storeOriginalImageForItem(item.editableMediaItem, screenImage);
|
||||
|
||||
TGPhotoEditorControllerIntent intent = isVideo ? TGPhotoEditorControllerVideoIntent : TGPhotoEditorControllerGenericIntent;
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:item.editableMediaItem intent:intent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_interfaceView.currentTabs selectedTab:tab];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:item.editableMediaItem intent:intent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_interfaceView.currentTabs selectedTab:tab defaultVideoPreset:_defaultVideoPreset];
|
||||
controller.editingContext = _editingContext;
|
||||
self.editorController = controller;
|
||||
controller.suggestionContext = self.suggestionContext;
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@
|
|||
|
||||
@property (nonatomic, copy) void (^presentScheduleController)(void (^)(int32_t));
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder;
|
||||
|
||||
- (void)present;
|
||||
- (void)updateWithFetchResult:(TGMediaAssetFetchResult *)fetchResult;
|
||||
|
|
|
|||
|
|
@ -41,17 +41,17 @@
|
|||
|
||||
@implementation TGMediaPickerModernGalleryMixin
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
{
|
||||
return [self initWithContext:context item:item fetchResult:fetchResult momentList:nil parentController:parentController thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:inhibitMute asFile:asFile itemsLimit:itemsLimit recipientName:recipientName hasSilentPosting:hasSilentPosting hasSchedule:hasSchedule reminder:reminder];
|
||||
return [self initWithContext:context item:item fetchResult:fetchResult momentList:nil parentController:parentController thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:inhibitMute asFile:asFile itemsLimit:itemsLimit recipientName:recipientName defaultVideoPreset:defaultVideoPreset hasSilentPosting:hasSilentPosting hasSchedule:hasSchedule reminder:reminder];
|
||||
}
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
{
|
||||
return [self initWithContext:context item:item fetchResult:nil momentList:momentList parentController:parentController thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:inhibitMute asFile:asFile itemsLimit:itemsLimit recipientName:nil hasSilentPosting:hasSilentPosting hasSchedule:hasSchedule reminder:reminder];
|
||||
return [self initWithContext:context item:item fetchResult:nil momentList:momentList parentController:parentController thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:inhibitMute asFile:asFile itemsLimit:itemsLimit recipientName:nil defaultVideoPreset:defaultVideoPreset hasSilentPosting:hasSilentPosting hasSchedule:hasSchedule reminder:reminder];
|
||||
}
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
|
|
@ -83,7 +83,7 @@
|
|||
|
||||
NSArray *galleryItems = fetchResult != nil ? [self prepareGalleryItemsForFetchResult:fetchResult selectionContext:selectionContext editingContext:editingContext asFile:asFile enumerationBlock:enumerationBlock] : [self prepareGalleryItemsForMomentList:momentList selectionContext:selectionContext editingContext:editingContext asFile:asFile enumerationBlock:enumerationBlock];
|
||||
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:[_windowManager context] items:galleryItems focusItem:focusItem selectionContext:selectionContext editingContext:editingContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions hasSelectionPanel:true hasCamera:false recipientName:recipientName];
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:[_windowManager context] items:galleryItems focusItem:focusItem selectionContext:selectionContext editingContext:editingContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions hasSelectionPanel:true hasCamera:false recipientName:recipientName defaultVideoPreset:defaultVideoPreset];
|
||||
_galleryModel = model;
|
||||
model.inhibitMute = inhibitMute;
|
||||
model.controller = modernGallery;
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@
|
|||
TGMediaAssetsControllerIntent assetsIntent = (intent == TGPassportAttachIntentMultiple) ? TGMediaAssetsControllerPassportMultipleIntent : TGMediaAssetsControllerPassportIntent;
|
||||
|
||||
[strongParentController presentWithContext:^UIViewController *(id<LegacyComponentsContext> context) {
|
||||
TGMediaAssetsController *controller = [TGMediaAssetsController controllerWithContext:context assetGroup:group intent:assetsIntent recipientName:nil saveEditedPhotos:false allowGrouping:false selectionLimit:10];
|
||||
TGMediaAssetsController *controller = [TGMediaAssetsController controllerWithContext:context assetGroup:group intent:assetsIntent recipientName:nil defaultVideoPreset:TGMediaVideoConversionPresetCompressedDefault saveEditedPhotos:false allowGrouping:false selectionLimit:10];
|
||||
controller.onlyCrop = true;
|
||||
__weak TGMediaAssetsController *weakController = controller;
|
||||
controller.singleCompletionBlock = ^(id<TGMediaEditableItem> currentItem, TGMediaEditingContext *editingContext) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ typedef enum {
|
|||
@property (nonatomic, assign) bool dontHideStatusBar;
|
||||
@property (nonatomic, strong) PGCameraShotMetadata *metadata;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id<TGMediaEditableItem>)item intent:(TGPhotoEditorControllerIntent)intent adjustments:(id<TGMediaEditAdjustments>)adjustments caption:(NSString *)caption screenImage:(UIImage *)screenImage availableTabs:(TGPhotoEditorTab)availableTabs selectedTab:(TGPhotoEditorTab)selectedTab;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id<TGMediaEditableItem>)item intent:(TGPhotoEditorControllerIntent)intent adjustments:(id<TGMediaEditAdjustments>)adjustments caption:(NSString *)caption screenImage:(UIImage *)screenImage availableTabs:(TGPhotoEditorTab)availableTabs selectedTab:(TGPhotoEditorTab)selectedTab defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
|
||||
- (void)dismissEditor;
|
||||
- (void)applyEditor;
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@
|
|||
TGMessageImageViewOverlayView *_progressView;
|
||||
|
||||
id<LegacyComponentsContext> _context;
|
||||
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@property (nonatomic, weak) UIImage *fullSizeImage;
|
||||
|
|
@ -98,7 +100,7 @@
|
|||
|
||||
@synthesize actionHandle = _actionHandle;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id<TGMediaEditableItem>)item intent:(TGPhotoEditorControllerIntent)intent adjustments:(id<TGMediaEditAdjustments>)adjustments caption:(NSString *)caption screenImage:(UIImage *)screenImage availableTabs:(TGPhotoEditorTab)availableTabs selectedTab:(TGPhotoEditorTab)selectedTab
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id<TGMediaEditableItem>)item intent:(TGPhotoEditorControllerIntent)intent adjustments:(id<TGMediaEditAdjustments>)adjustments caption:(NSString *)caption screenImage:(UIImage *)screenImage availableTabs:(TGPhotoEditorTab)availableTabs selectedTab:(TGPhotoEditorTab)selectedTab defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
{
|
||||
self = [super initWithContext:context];
|
||||
if (self != nil)
|
||||
|
|
@ -120,6 +122,8 @@
|
|||
_initialAdjustments = adjustments;
|
||||
_screenImage = screenImage;
|
||||
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
|
||||
_queue = [[SQueue alloc] init];
|
||||
_photoEditor = [[PGPhotoEditor alloc] initWithOriginalSize:_item.originalSize adjustments:adjustments forVideo:(intent == TGPhotoEditorControllerVideoIntent) enableStickers:(intent & TGPhotoEditorControllerSignupAvatarIntent) == 0];
|
||||
if ([self presentedForAvatarCreation])
|
||||
|
|
@ -1114,7 +1118,7 @@
|
|||
{
|
||||
_ignoreDefaultPreviewViewTransitionIn = true;
|
||||
|
||||
TGPhotoQualityController *qualityController = [[TGPhotoQualityController alloc] initWithContext:_context photoEditor:_photoEditor previewView:_previewView];
|
||||
TGPhotoQualityController *qualityController = [[TGPhotoQualityController alloc] initWithContext:_context photoEditor:_photoEditor previewView:_previewView defaultPreset:_defaultVideoPreset];
|
||||
qualityController.item = _item;
|
||||
qualityController.toolbarLandscapeSize = TGPhotoEditorToolbarSize;
|
||||
qualityController.beginTransitionIn = ^UIView *(CGRect *referenceFrame, UIView **parentView, bool *noTransitionView)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
@property (nonatomic, readonly) TGMediaVideoConversionPreset preset;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView defaultPreset:(TGMediaVideoConversionPreset)defaultPreset;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f;
|
|||
|
||||
@implementation TGPhotoQualityController
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView defaultPreset:(TGMediaVideoConversionPreset)defaultPreset
|
||||
{
|
||||
self = [super initWithContext:context];
|
||||
if (self != nil)
|
||||
|
|
@ -89,11 +89,7 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f;
|
|||
}
|
||||
else
|
||||
{
|
||||
NSNumber *presetValue = [[NSUserDefaults standardUserDefaults] objectForKey:@"TG_preferredVideoPreset_v0"];
|
||||
if (presetValue != nil)
|
||||
value = [presetValue integerValue];
|
||||
else
|
||||
value = TGMediaVideoConversionPresetCompressedMedium;
|
||||
value = defaultPreset;
|
||||
}
|
||||
|
||||
_disposable = [[SMetaDisposable alloc] init];
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
@interface TGPhotoVideoEditor : NSObject
|
||||
|
||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller caption:(NSString *)caption entities:(NSArray *)entities withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion;
|
||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller caption:(NSString *)caption entities:(NSArray *)entities withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
@implementation TGPhotoVideoEditor
|
||||
|
||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller caption:(NSString *)caption entities:(NSArray *)entities withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion
|
||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller caption:(NSString *)caption entities:(NSArray *)entities withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion
|
||||
{
|
||||
id<LegacyComponentsOverlayWindowManager> windowManager = [context makeOverlayWindowManager];
|
||||
id<LegacyComponentsContext> windowContext = [windowManager context];
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
galleryItem = [[TGMediaPickerGalleryPhotoItem alloc] initWithAsset:item];
|
||||
galleryItem.editingContext = editingContext;
|
||||
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:@[galleryItem] focusItem:galleryItem selectionContext:nil editingContext:editingContext hasCaptions:true allowCaptionEntities:true hasTimer:false onlyCrop:false inhibitDocumentCaptions:false hasSelectionPanel:false hasCamera:false recipientName:recipientName];
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:@[galleryItem] focusItem:galleryItem selectionContext:nil editingContext:editingContext hasCaptions:true allowCaptionEntities:true hasTimer:false onlyCrop:false inhibitDocumentCaptions:false hasSelectionPanel:false hasCamera:false recipientName:recipientName defaultVideoPreset:defaultVideoPreset];
|
||||
model.controller = galleryController;
|
||||
//model.suggestionContext = self.suggestionContext;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,47 @@ import DeviceAccess
|
|||
import AccountContext
|
||||
import LegacyUI
|
||||
|
||||
public func defaultVideoPresetForContext(_ context: AccountContext) -> TGMediaVideoConversionPreset {
|
||||
var networkType: NetworkType = .wifi
|
||||
let _ = (context.account.networkType
|
||||
|> take(1)).start(next: { value in
|
||||
networkType = value
|
||||
})
|
||||
|
||||
let autodownloadSettings = context.sharedContext.currentAutodownloadSettings.with { $0 }
|
||||
let presetSettings: AutodownloadPresetSettings
|
||||
switch networkType {
|
||||
case .wifi:
|
||||
presetSettings = autodownloadSettings.highPreset
|
||||
default:
|
||||
presetSettings = autodownloadSettings.mediumPreset
|
||||
}
|
||||
|
||||
let effectiveValue: Int
|
||||
if presetSettings.videoUploadMaxbitrate == 0 {
|
||||
effectiveValue = 0
|
||||
} else {
|
||||
effectiveValue = Int(presetSettings.videoUploadMaxbitrate) * 5 / 100
|
||||
}
|
||||
|
||||
switch effectiveValue {
|
||||
case 0:
|
||||
return TGMediaVideoConversionPresetCompressedMedium
|
||||
case 1:
|
||||
return TGMediaVideoConversionPresetCompressedVeryLow
|
||||
case 2:
|
||||
return TGMediaVideoConversionPresetCompressedLow
|
||||
case 3:
|
||||
return TGMediaVideoConversionPresetCompressedMedium
|
||||
case 4:
|
||||
return TGMediaVideoConversionPresetCompressedHigh
|
||||
case 5:
|
||||
return TGMediaVideoConversionPresetCompressedVeryLow
|
||||
default:
|
||||
return TGMediaVideoConversionPresetCompressedMedium
|
||||
}
|
||||
}
|
||||
|
||||
public struct LegacyAttachmentMenuMediaEditing: OptionSet {
|
||||
public var rawValue: Int32
|
||||
|
||||
|
|
@ -62,6 +103,7 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO
|
|||
carouselItemView = carouselItem
|
||||
carouselItem.suggestionContext = legacySuggestionContext(context: context, peerId: peer.id)
|
||||
carouselItem.recipientName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
carouselItem.defaultVideoPreset = defaultVideoPresetForContext(context)
|
||||
carouselItem.cameraPressed = { [weak controller] cameraView in
|
||||
if let controller = controller {
|
||||
DeviceAccess.authorizeAccess(to: .camera, presentationData: context.sharedContext.currentPresentationData.with { $0 }, present: context.sharedContext.presentGlobalController, openSettings: context.sharedContext.applicationBindings.openSettings, { value in
|
||||
|
|
@ -218,7 +260,7 @@ public func presentLegacyPasteMenu(context: AccountContext, peer: Peer, saveEdit
|
|||
|
||||
legacyController.enableSizeClassSignal = true
|
||||
|
||||
let controller = TGClipboardMenu.present(inParentController: emptyController, context: legacyController.context, images: images, hasCaption: true, hasTimer: hasTimer, recipientName: recipientName, completed: { selectionContext, editingContext, currentItem in
|
||||
let controller = TGClipboardMenu.present(inParentController: emptyController, context: legacyController.context, images: images, hasCaption: true, hasTimer: hasTimer, recipientName: recipientName, defaultVideoPreset: defaultVideoPresetForContext(context), completed: { selectionContext, editingContext, currentItem in
|
||||
let signals = TGClipboardMenu.resultSignals(for: selectionContext, editingContext: editingContext, currentItem: currentItem, descriptionGenerator: legacyAssetPickerItemGenerator())
|
||||
sendMessagesWithSignals(signals)
|
||||
}, dismissed: { [weak legacyController] in
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public func legacyAssetPicker(context: AccountContext, presentationData: Present
|
|||
|
||||
return Signal { subscriber in
|
||||
let intent = fileMode ? TGMediaAssetsControllerSendFileIntent : TGMediaAssetsControllerSendMediaIntent
|
||||
let defaultVideoPreset = defaultVideoPresetForContext(context)
|
||||
|
||||
DeviceAccess.authorizeAccess(to: .mediaLibrary(.send), presentationData: presentationData, present: context.sharedContext.presentGlobalController, openSettings: context.sharedContext.applicationBindings.openSettings, { value in
|
||||
if !value {
|
||||
|
|
@ -70,7 +71,7 @@ public func legacyAssetPicker(context: AccountContext, presentationData: Present
|
|||
} else {
|
||||
Queue.mainQueue().async {
|
||||
subscriber.putNext({ context in
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: group, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, inhibitSelection: editingMedia, selectionLimit: Int32(selectionLimit))
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: group, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), defaultVideoPreset: defaultVideoPreset, saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, inhibitSelection: editingMedia, selectionLimit: Int32(selectionLimit))
|
||||
return controller!
|
||||
})
|
||||
subscriber.putCompletion()
|
||||
|
|
@ -79,7 +80,7 @@ public func legacyAssetPicker(context: AccountContext, presentationData: Present
|
|||
})
|
||||
} else {
|
||||
subscriber.putNext({ context in
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, selectionLimit: Int32(selectionLimit))
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), defaultVideoPreset: defaultVideoPreset, saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, selectionLimit: Int32(selectionLimit))
|
||||
return controller!
|
||||
})
|
||||
subscriber.putCompletion()
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public func legacyWallpaperPicker(context: AccountContext, presentationData: Pre
|
|||
} else {
|
||||
Queue.mainQueue().async {
|
||||
subscriber.putNext({ context in
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: group, intent: intent, recipientName: nil, saveEditedPhotos: false, allowGrouping: false, selectionLimit: 1)
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: group, intent: intent, recipientName: nil, defaultVideoPreset: TGMediaVideoConversionPresetCompressedDefault, saveEditedPhotos: false, allowGrouping: false, selectionLimit: 1)
|
||||
return controller!
|
||||
})
|
||||
subscriber.putCompletion()
|
||||
|
|
@ -33,7 +33,7 @@ public func legacyWallpaperPicker(context: AccountContext, presentationData: Pre
|
|||
})
|
||||
} else {
|
||||
subscriber.putNext({ context in
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: nil, saveEditedPhotos: false, allowGrouping: false, selectionLimit: 1)
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: nil, defaultVideoPreset: TGMediaVideoConversionPresetCompressedDefault, saveEditedPhotos: false, allowGrouping: false, selectionLimit: 1)
|
||||
return controller!
|
||||
})
|
||||
subscriber.putCompletion()
|
||||
|
|
|
|||
|
|
@ -3037,7 +3037,7 @@ final class SecureIdDocumentFormControllerNode: FormControllerNode<SecureIdDocum
|
|||
for itemNode in strongSelf.itemNodes {
|
||||
if let itemNode = itemNode as? SecureIdValueFormFileItemNode, let item = itemNode.item, let document = item.document {
|
||||
if document.resource.isEqual(to: entry.resource) {
|
||||
return GalleryTransitionArguments(transitionNode: (itemNode.imageNode, {
|
||||
return GalleryTransitionArguments(transitionNode: (itemNode.imageNode, itemNode.imageNode.bounds, {
|
||||
return (itemNode.imageNode.view.snapshotContentTree(unhide: true), nil)
|
||||
}), addToTransitionSurface: { view in
|
||||
self?.view.addSubview(view)
|
||||
|
|
|
|||
|
|
@ -131,13 +131,13 @@ final class SecureIdDocumentGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
self.contextAndMedia = (context, secureIdContext, resource)
|
||||
}
|
||||
|
||||
override func animateIn(from node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
override func animateIn(from node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view.superview)
|
||||
let transformedSelfFrame = node.0.view.convert(node.0.view.bounds, to: self.view)
|
||||
let transformedCopyViewFinalFrame = self.imageNode.view.convert(self.imageNode.view.bounds, to: self.view)
|
||||
|
||||
let copyView = node.1().0!
|
||||
let copyView = node.2().0!
|
||||
|
||||
self.view.insertSubview(copyView, belowSubview: self.scrollNode.view)
|
||||
copyView.frame = transformedSelfFrame
|
||||
|
|
@ -157,7 +157,7 @@ final class SecureIdDocumentGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
self.imageNode.layer.animateBounds(from: transformedFrame, to: self.imageNode.layer.bounds, duration: 0.25, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
}
|
||||
|
||||
override func animateOut(to node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
override func animateOut(to node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view.superview)
|
||||
let transformedSelfFrame = node.0.view.convert(node.0.view.bounds, to: self.view)
|
||||
|
|
@ -167,7 +167,7 @@ final class SecureIdDocumentGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
var boundsCompleted = false
|
||||
var copyCompleted = false
|
||||
|
||||
let copyView = node.1().0!
|
||||
let copyView = node.2().0!
|
||||
|
||||
self.view.insertSubview(copyView, belowSubview: self.scrollNode.view)
|
||||
copyView.frame = transformedSelfFrame
|
||||
|
|
|
|||
|
|
@ -229,13 +229,13 @@ final class PeerAvatarImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
}
|
||||
}
|
||||
|
||||
override func animateIn(from node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
override func animateIn(from node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view.superview)
|
||||
let transformedSelfFrame = node.0.view.convert(node.0.view.bounds, to: self.view)
|
||||
let transformedCopyViewFinalFrame = self.imageNode.view.convert(self.imageNode.view.bounds, to: self.view)
|
||||
|
||||
let copyView = node.1().0!
|
||||
let copyView = node.2().0!
|
||||
|
||||
self.view.insertSubview(copyView, belowSubview: self.scrollNode.view)
|
||||
copyView.frame = transformedSelfFrame
|
||||
|
|
@ -269,7 +269,7 @@ final class PeerAvatarImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
self.statusNodeContainer.layer.animateScale(from: 0.5, to: 1.0, duration: 0.25, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
}
|
||||
|
||||
override func animateOut(to node: (ASDisplayNode, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
override func animateOut(to node: (ASDisplayNode, CGRect, () -> (UIView?, UIView?)), addToTransitionSurface: (UIView) -> Void, completion: @escaping () -> Void) {
|
||||
var transformedFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view)
|
||||
let transformedSuperFrame = node.0.view.convert(node.0.view.bounds, to: self.imageNode.view.superview)
|
||||
let transformedSelfFrame = node.0.view.convert(node.0.view.bounds, to: self.view)
|
||||
|
|
@ -279,7 +279,7 @@ final class PeerAvatarImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
var boundsCompleted = false
|
||||
var copyCompleted = false
|
||||
|
||||
let copyView = node.1().0!
|
||||
let copyView = node.2().0!
|
||||
|
||||
self.view.insertSubview(copyView, belowSubview: self.scrollNode.view)
|
||||
copyView.frame = transformedSelfFrame
|
||||
|
|
|
|||
|
|
@ -1063,12 +1063,17 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|
|||
return current.withUpdatedUpdating(true)
|
||||
}
|
||||
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(account: context.account, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(flags: updateFlags), rank: updateRank) |> deliverOnMainQueue).start(error: { error in
|
||||
if case let .addMemberError(error) = error, case .restricted = error, let admin = adminView.peers[adminView.peerId] {
|
||||
var text = presentationData.strings.Privacy_GroupsAndChannels_InviteToChannelError(admin.compactDisplayTitle, admin.compactDisplayTitle).0
|
||||
if case .group = channel.info {
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(admin.compactDisplayTitle, admin.compactDisplayTitle).0
|
||||
if case let .addMemberError(error) = error, let admin = adminView.peers[adminView.peerId] {
|
||||
if case .restricted = error {
|
||||
var text = presentationData.strings.Privacy_GroupsAndChannels_InviteToChannelError(admin.compactDisplayTitle, admin.compactDisplayTitle).0
|
||||
if case .group = channel.info {
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(admin.compactDisplayTitle, admin.compactDisplayTitle).0
|
||||
}
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
} else if case .tooMuchJoined = error {
|
||||
let text = presentationData.strings.Invite_ChannelsTooMuch
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
}
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
}
|
||||
dismissImpl?()
|
||||
}, completed: {
|
||||
|
|
|
|||
|
|
@ -1124,7 +1124,7 @@ public func channelInfoController(context: AccountContext, peerId: PeerId) -> Vi
|
|||
}
|
||||
avatarGalleryTransitionArguments = { [weak controller] entry in
|
||||
if let controller = controller {
|
||||
var result: ((ASDisplayNode, () -> (UIView?, UIView?)), CGRect)?
|
||||
var result: ((ASDisplayNode, CGRect, () -> (UIView?, UIView?)), CGRect)?
|
||||
controller.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ItemListAvatarAndNameInfoItemNode {
|
||||
result = itemNode.avatarTransitionNode()
|
||||
|
|
|
|||
|
|
@ -1755,6 +1755,26 @@ public func groupInfoController(context: AccountContext, peerId originalPeerId:
|
|||
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(peer.compactDisplayTitle, peer.compactDisplayTitle).0, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
})
|
||||
|
||||
updateState { state in
|
||||
var temporaryParticipants = state.temporaryParticipants
|
||||
for i in 0 ..< temporaryParticipants.count {
|
||||
if temporaryParticipants[i].peer.id == memberId {
|
||||
temporaryParticipants.remove(at: i)
|
||||
break
|
||||
}
|
||||
}
|
||||
var successfullyAddedParticipantIds = state.successfullyAddedParticipantIds
|
||||
successfullyAddedParticipantIds.remove(memberId)
|
||||
|
||||
return state.withUpdatedTemporaryParticipants(temporaryParticipants).withUpdatedSuccessfullyAddedParticipantIds(successfullyAddedParticipantIds)
|
||||
}
|
||||
return .complete()
|
||||
case .tooManyChannels:
|
||||
let _ = (context.account.postbox.loadedPeerWithId(memberId)
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Invite_ChannelsTooMuch, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
})
|
||||
|
||||
updateState { state in
|
||||
var temporaryParticipants = state.temporaryParticipants
|
||||
for i in 0 ..< temporaryParticipants.count {
|
||||
|
|
@ -2467,7 +2487,7 @@ public func groupInfoController(context: AccountContext, peerId originalPeerId:
|
|||
|
||||
avatarGalleryTransitionArguments = { [weak controller] entry in
|
||||
if let controller = controller {
|
||||
var result: ((ASDisplayNode, () -> (UIView?, UIView?)), CGRect)?
|
||||
var result: ((ASDisplayNode, CGRect, () -> (UIView?, UIView?)), CGRect)?
|
||||
controller.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ItemListAvatarAndNameInfoItemNode {
|
||||
result = itemNode.avatarTransitionNode()
|
||||
|
|
|
|||
|
|
@ -490,7 +490,8 @@ public func groupStickerPackSetupController(context: AccountContext, peerId: Pee
|
|||
}
|
||||
presentStickerPackController = { [weak controller] info in
|
||||
dismissInputImpl?()
|
||||
presentControllerImpl?(StickerPackScreen(context: context, stickerPacks: [.id(id: info.id.id, accessHash: info.accessHash)], parentNavigationController: controller?.navigationController as? NavigationController), nil)
|
||||
let packReference: StickerPackReference = .id(id: info.id.id, accessHash: info.accessHash)
|
||||
presentControllerImpl?(StickerPackScreen(context: context, mainStickerPack: packReference, stickerPacks: [packReference], parentNavigationController: controller?.navigationController as? NavigationController), nil)
|
||||
}
|
||||
navigateToChatControllerImpl = { [weak controller] peerId in
|
||||
if let controller = controller, let navigationController = controller.navigationController as? NavigationController {
|
||||
|
|
|
|||
|
|
@ -1463,7 +1463,7 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe
|
|||
}
|
||||
avatarGalleryTransitionArguments = { [weak controller] entry in
|
||||
if let controller = controller {
|
||||
var result: ((ASDisplayNode, () -> (UIView?, UIView?)), CGRect)?
|
||||
var result: ((ASDisplayNode, CGRect, () -> (UIView?, UIView?)), CGRect)?
|
||||
controller.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ItemListAvatarAndNameInfoItemNode {
|
||||
result = itemNode.avatarTransitionNode()
|
||||
|
|
|
|||
|
|
@ -1380,7 +1380,7 @@ final class MessageHistoryTable: Table {
|
|||
}
|
||||
}
|
||||
|
||||
self.valueBox.remove(self.table, key: self.key(index), secure: false)
|
||||
self.valueBox.remove(self.table, key: self.key(index), secure: true)
|
||||
|
||||
let updatedIndex = message.index
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ final class MessageHistoryTextIndexTable {
|
|||
}
|
||||
|
||||
func remove(messageId: MessageId) {
|
||||
self.valueBox.fullTextRemove(self.table, itemId: itemId(messageId))
|
||||
self.valueBox.fullTextRemove(self.table, itemId: itemId(messageId), secure: true)
|
||||
}
|
||||
|
||||
func search(peerId: PeerId?, text: String, tags: MessageTags?) -> [MessageId] {
|
||||
|
|
|
|||
|
|
@ -1764,8 +1764,14 @@ public final class SqliteValueBox: ValueBox {
|
|||
statement.reset()
|
||||
}
|
||||
|
||||
public func fullTextRemove(_ table: ValueBoxFullTextTable, itemId: String) {
|
||||
public func fullTextRemove(_ table: ValueBoxFullTextTable, itemId: String, secure: Bool) {
|
||||
if let _ = self.fullTextTables[table.id] {
|
||||
if secure != self.secureDeleteEnabled {
|
||||
self.secureDeleteEnabled = secure
|
||||
let result = database.execute("PRAGMA secure_delete=\(secure ? 1 : 0)")
|
||||
precondition(result)
|
||||
}
|
||||
|
||||
guard let itemIdData = itemId.data(using: .utf8) else {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public protocol ValueBox {
|
|||
func removeRange(_ table: ValueBoxTable, start: ValueBoxKey, end: ValueBoxKey)
|
||||
func fullTextSet(_ table: ValueBoxFullTextTable, collectionId: String, itemId: String, contents: String, tags: String)
|
||||
func fullTextMatch(_ table: ValueBoxFullTextTable, collectionId: String?, query: String, tags: String?, values: (String, String) -> Bool)
|
||||
func fullTextRemove(_ table: ValueBoxFullTextTable, itemId: String)
|
||||
func fullTextRemove(_ table: ValueBoxFullTextTable, itemId: String, secure: Bool)
|
||||
func removeAllFromTable(_ table: ValueBoxTable)
|
||||
func removeTable(_ table: ValueBoxTable)
|
||||
func renameTable(_ table: ValueBoxTable, to toTable: ValueBoxTable)
|
||||
|
|
|
|||
|
|
@ -447,7 +447,7 @@ func autodownloadMediaCategoryController(context: AccountContext, connectionType
|
|||
case .wifi:
|
||||
preset = .high
|
||||
}
|
||||
let settings = AutodownloadPresetSettings(disabled: false, photoSizeMax: categories.photo.sizeLimit, videoSizeMax: categories.video.sizeLimit, fileSizeMax: categories.file.sizeLimit, preloadLargeVideo: categories.video.predownload, lessDataForPhoneCalls: false)
|
||||
let settings = AutodownloadPresetSettings(disabled: false, photoSizeMax: categories.photo.sizeLimit, videoSizeMax: categories.video.sizeLimit, fileSizeMax: categories.file.sizeLimit, preloadLargeVideo: categories.video.predownload, lessDataForPhoneCalls: false, videoUploadMaxbitrate: 0)
|
||||
return saveAutodownloadSettings(account: context.account, preset: preset, settings: settings)
|
||||
}
|
||||
return .complete()
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ func editSettingsController(context: AccountContext, currentName: ItemListAvatar
|
|||
}
|
||||
avatarGalleryTransitionArguments = { [weak controller] entry in
|
||||
if let controller = controller {
|
||||
var result: ((ASDisplayNode, () -> (UIView?, UIView?)), CGRect)?
|
||||
var result: ((ASDisplayNode, CGRect, () -> (UIView?, UIView?)), CGRect)?
|
||||
controller.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ItemListAvatarAndNameInfoItemNode {
|
||||
result = itemNode.avatarTransitionNode()
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ private func privacySearchableItems(context: AccountContext, privacySettings: Ac
|
|||
}),
|
||||
SettingsSearchableItem(id: .privacy(7), title: passcodeTitle, alternate: passcodeAlternate, icon: icon, breadcrumbs: [strings.Settings_PrivacySettings], present: { context, _, present in
|
||||
let _ = passcodeOptionsAccessController(context: context, pushController: { c in
|
||||
|
||||
present(.push, c)
|
||||
}, completion: { animated in
|
||||
let controller = passcodeOptionsController(context: context)
|
||||
if animated {
|
||||
|
|
@ -537,7 +537,7 @@ private func privacySearchableItems(context: AccountContext, privacySettings: Ac
|
|||
}
|
||||
}).start(next: { controller in
|
||||
if let controller = controller {
|
||||
present(.modal, controller)
|
||||
present(.push, controller)
|
||||
}
|
||||
})
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -1547,7 +1547,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM
|
|||
}
|
||||
avatarGalleryTransitionArguments = { [weak controller] entry in
|
||||
if let controller = controller {
|
||||
var result: ((ASDisplayNode, () -> (UIView?, UIView?)), CGRect)?
|
||||
var result: ((ASDisplayNode, CGRect, () -> (UIView?, UIView?)), CGRect)?
|
||||
controller.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ItemListAvatarAndNameInfoItemNode {
|
||||
result = itemNode.avatarTransitionNode()
|
||||
|
|
|
|||
|
|
@ -430,7 +430,8 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
|
|||
}
|
||||
|
||||
presentStickerPackController = { [weak controller] info in
|
||||
presentControllerImpl?(StickerPackScreen(context: context, stickerPacks: [.id(id: info.id.id, accessHash: info.accessHash)], parentNavigationController: controller?.navigationController as? NavigationController), nil)
|
||||
let packReference: StickerPackReference = .id(id: info.id.id, accessHash: info.accessHash)
|
||||
presentControllerImpl?(StickerPackScreen(context: context, mainStickerPack: packReference, stickerPacks: [packReference], parentNavigationController: controller?.navigationController as? NavigationController), nil)
|
||||
}
|
||||
|
||||
return controller
|
||||
|
|
|
|||
|
|
@ -264,7 +264,8 @@ public func featuredStickerPacksController(context: AccountContext) -> ViewContr
|
|||
}
|
||||
|
||||
presentStickerPackController = { [weak controller] info in
|
||||
presentControllerImpl?(StickerPackScreen(context: context, stickerPacks: [.id(id: info.id.id, accessHash: info.accessHash)], parentNavigationController: controller?.navigationController as? NavigationController), nil)
|
||||
let packReference: StickerPackReference = .id(id: info.id.id, accessHash: info.accessHash)
|
||||
presentControllerImpl?(StickerPackScreen(context: context, mainStickerPack: packReference, stickerPacks: [packReference], parentNavigationController: controller?.navigationController as? NavigationController), nil)
|
||||
}
|
||||
|
||||
return controller
|
||||
|
|
|
|||
|
|
@ -783,22 +783,25 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
guard let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [namespaceForMode(mode)])] as? ItemCollectionInfosView, let entries = stickerPacksView.entriesByNamespace[namespaceForMode(mode)] else {
|
||||
return
|
||||
}
|
||||
var mainStickerPack: StickerPackReference?
|
||||
var packs: [StickerPackReference] = []
|
||||
var selectedIndex: Int = 0
|
||||
var foundSelected = false
|
||||
for entry in entries {
|
||||
if let listInfo = entry.info as? StickerPackCollectionInfo {
|
||||
let packReference: StickerPackReference = .id(id: listInfo.id.id, accessHash: listInfo.accessHash)
|
||||
if listInfo.id == info.id {
|
||||
foundSelected = true
|
||||
selectedIndex = packs.count
|
||||
mainStickerPack = packReference
|
||||
}
|
||||
packs.append(.id(id: listInfo.id.id, accessHash: listInfo.accessHash))
|
||||
packs.append(packReference)
|
||||
}
|
||||
}
|
||||
if !foundSelected {
|
||||
packs.insert(.id(id: info.id.id, accessHash: info.accessHash), at: 0)
|
||||
if mainStickerPack == nil {
|
||||
let packReference: StickerPackReference = .id(id: info.id.id, accessHash: info.accessHash)
|
||||
mainStickerPack = packReference
|
||||
packs.insert(packReference, at: 0)
|
||||
}
|
||||
if let mainStickerPack = mainStickerPack {
|
||||
presentControllerImpl?(StickerPackScreen(context: context, mainStickerPack: mainStickerPack, stickerPacks: packs, parentNavigationController: controller?.navigationController as? NavigationController), nil)
|
||||
}
|
||||
presentControllerImpl?(StickerPackScreen(context: context, stickerPacks: packs, selectedStickerPackIndex: selectedIndex, parentNavigationController: controller?.navigationController as? NavigationController), nil)
|
||||
})
|
||||
}
|
||||
pushControllerImpl = { [weak controller] c in
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@ public final class StickerPackPreviewController: ViewController, StandalonePrese
|
|||
private var animatedIn = false
|
||||
private var dismissed = false
|
||||
|
||||
private let _ready = Promise<Bool>()
|
||||
override public var ready: Promise<Bool> {
|
||||
return self._ready
|
||||
}
|
||||
|
||||
private let context: AccountContext
|
||||
private let mode: StickerPackPreviewControllerMode
|
||||
private weak var parentNavigationController: NavigationController?
|
||||
|
|
@ -79,15 +74,7 @@ public final class StickerPackPreviewController: ViewController, StandalonePrese
|
|||
|
||||
self.statusBar.statusBarStyle = .Ignore
|
||||
|
||||
#if false && DEBUG
|
||||
self.stickerPackContents.set(.single(.fetching)
|
||||
|> then(
|
||||
loadedStickerPack(postbox: context.account.postbox, network: context.account.network, reference: stickerPack, forceActualized: true)
|
||||
|> delay(1.0, queue: .mainQueue())
|
||||
))
|
||||
#else
|
||||
self.stickerPackContents.set(loadedStickerPack(postbox: context.account.postbox, network: context.account.network, reference: stickerPack, forceActualized: true))
|
||||
#endif
|
||||
|
||||
self.presentationDataDisposable = (context.sharedContext.presentationData
|
||||
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
||||
|
|
@ -122,7 +109,7 @@ public final class StickerPackPreviewController: ViewController, StandalonePrese
|
|||
}
|
||||
}
|
||||
}
|
||||
self.displayNode = StickerPackPreviewControllerNode(controller: self, context: self.context, openShare: openShareImpl, openMention: { [weak self] mention in
|
||||
self.displayNode = StickerPackPreviewControllerNode(context: self.context, openShare: openShareImpl, openMention: { [weak self] mention in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ private struct StickerPackPreviewGridTransaction {
|
|||
}
|
||||
|
||||
final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
|
||||
private weak var controller: StickerPackPreviewController?
|
||||
private let context: AccountContext
|
||||
private let openShare: (() -> Void)?
|
||||
private var presentationData: PresentationData
|
||||
|
|
@ -60,11 +59,10 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
private let contentContainerNode: ASDisplayNode
|
||||
private let contentBackgroundNode: ASImageNode
|
||||
private let contentGridNode: GridNode
|
||||
private let actionsSeparatorNode: ASDisplayNode
|
||||
private let actionsBackgroundNode: ASDisplayNode
|
||||
private let installActionButtonNode: HighlightTrackingButtonNode
|
||||
private var installActionButtonIsRemove = false
|
||||
private let shareActionButtonNode: HighlightTrackingButtonNode
|
||||
private let installActionButtonNode: ASButtonNode
|
||||
private let installActionSeparatorNode: ASDisplayNode
|
||||
private let shareActionButtonNode: ASButtonNode
|
||||
private let shareActionSeparatorNode: ASDisplayNode
|
||||
private let contentTitleNode: ImmediateTextNode
|
||||
private let contentSeparatorNode: ASDisplayNode
|
||||
|
||||
|
|
@ -89,8 +87,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
|
||||
private var hapticFeedback: HapticFeedback?
|
||||
|
||||
init(controller: StickerPackPreviewController, context: AccountContext, openShare: (() -> Void)?, openMention: @escaping (String) -> Void) {
|
||||
self.controller = controller
|
||||
init(context: AccountContext, openShare: (() -> Void)?, openMention: @escaping (String) -> Void) {
|
||||
self.context = context
|
||||
self.openShare = openShare
|
||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
|
@ -131,9 +128,13 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
self.contentSeparatorNode = ASDisplayNode()
|
||||
self.contentSeparatorNode.isLayerBacked = true
|
||||
|
||||
self.actionsSeparatorNode = ASDisplayNode()
|
||||
self.actionsSeparatorNode.isLayerBacked = true
|
||||
self.actionsBackgroundNode = ASDisplayNode()
|
||||
self.installActionSeparatorNode = ASDisplayNode()
|
||||
self.installActionSeparatorNode.isLayerBacked = true
|
||||
self.installActionSeparatorNode.displaysAsynchronously = false
|
||||
|
||||
self.shareActionSeparatorNode = ASDisplayNode()
|
||||
self.shareActionSeparatorNode.isLayerBacked = true
|
||||
self.shareActionSeparatorNode.displaysAsynchronously = false
|
||||
|
||||
super.init()
|
||||
|
||||
|
|
@ -148,49 +149,25 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
self.wrappingScrollNode.view.delegate = self
|
||||
self.addSubnode(self.wrappingScrollNode)
|
||||
|
||||
self.wrappingScrollNode.addSubnode(self.cancelButtonNode)
|
||||
self.cancelButtonNode.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside)
|
||||
|
||||
self.installActionButtonNode.addTarget(self, action: #selector(self.installActionButtonPressed), forControlEvents: .touchUpInside)
|
||||
self.installActionButtonNode.highligthedChanged = { [weak self] highlighted in
|
||||
if let strongSelf = self {
|
||||
if highlighted {
|
||||
strongSelf.installActionButtonNode.layer.removeAnimation(forKey: "opacity")
|
||||
strongSelf.installActionButtonNode.alpha = 0.8
|
||||
} else {
|
||||
strongSelf.installActionButtonNode.alpha = 1.0
|
||||
strongSelf.installActionButtonNode.layer.animateAlpha(from: 0.8, to: 1.0, duration: 0.3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.shareActionButtonNode.addTarget(self, action: #selector(self.sharePressed), forControlEvents: .touchUpInside)
|
||||
self.shareActionButtonNode.highligthedChanged = { [weak self] highlighted in
|
||||
if let strongSelf = self {
|
||||
if highlighted {
|
||||
strongSelf.shareActionButtonNode.layer.removeAnimation(forKey: "opacity")
|
||||
strongSelf.shareActionButtonNode.alpha = 0.8
|
||||
} else {
|
||||
strongSelf.shareActionButtonNode.alpha = 1.0
|
||||
strongSelf.shareActionButtonNode.layer.animateAlpha(from: 0.8, to: 1.0, duration: 0.3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.wrappingScrollNode.clipsToBounds = false
|
||||
self.wrappingScrollNode.addSubnode(self.contentBackgroundNode)
|
||||
|
||||
self.wrappingScrollNode.addSubnode(self.contentContainerNode)
|
||||
self.contentContainerNode.addSubnode(self.contentGridNode)
|
||||
|
||||
self.wrappingScrollNode.addSubnode(self.actionsBackgroundNode)
|
||||
self.wrappingScrollNode.addSubnode(self.actionsSeparatorNode)
|
||||
self.wrappingScrollNode.addSubnode(self.installActionButtonNode)
|
||||
self.wrappingScrollNode.addSubnode(self.shareActionButtonNode)
|
||||
|
||||
self.contentContainerNode.addSubnode(self.installActionSeparatorNode)
|
||||
self.contentContainerNode.addSubnode(self.installActionButtonNode)
|
||||
if openShare != nil {
|
||||
self.contentContainerNode.addSubnode(self.shareActionSeparatorNode)
|
||||
self.contentContainerNode.addSubnode(self.shareActionButtonNode)
|
||||
}
|
||||
self.wrappingScrollNode.addSubnode(self.contentTitleNode)
|
||||
self.wrappingScrollNode.addSubnode(self.contentSeparatorNode)
|
||||
|
||||
self.wrappingScrollNode.addSubnode(self.cancelButtonNode)
|
||||
self.cancelButtonNode.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside)
|
||||
|
||||
self.contentGridNode.presentationLayoutUpdated = { [weak self] presentationLayout, transition in
|
||||
self?.gridPresentationLayoutUpdated(presentationLayout, transition: transition)
|
||||
}
|
||||
|
|
@ -286,28 +263,53 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
context.setFillColor(theme.actionSheet.opaqueItemBackgroundColor.cgColor)
|
||||
context.fill(CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height)))
|
||||
})?.stretchableImage(withLeftCapWidth: 1, topCapHeight: 1)
|
||||
})?.stretchableImage(withLeftCapWidth: 16, topCapHeight: 1)
|
||||
|
||||
let roundedBackground = generateStretchableFilledCircleImage(radius: 10.0, color: presentationData.theme.actionSheet.opaqueItemBackgroundColor)
|
||||
let highlightedSolidBackground = generateImage(CGSize(width: 1.0, height: 1.0), rotatedContext: { size, context in
|
||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
context.setFillColor(theme.actionSheet.opaqueItemHighlightedBackgroundColor.cgColor)
|
||||
context.fill(CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height)))
|
||||
})?.stretchableImage(withLeftCapWidth: 16, topCapHeight: 1)
|
||||
|
||||
let halfRoundedBackground = generateImage(CGSize(width: 32.0, height: 32.0), rotatedContext: { size, context in
|
||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
context.setFillColor(theme.actionSheet.opaqueItemBackgroundColor.cgColor)
|
||||
context.fillEllipse(in: CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height)))
|
||||
context.fill(CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height / 2.0)))
|
||||
})?.stretchableImage(withLeftCapWidth: 16, topCapHeight: 1)
|
||||
|
||||
let highlightedHalfRoundedBackground = generateImage(CGSize(width: 32.0, height: 32.0), rotatedContext: { size, context in
|
||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
context.setFillColor(theme.actionSheet.opaqueItemHighlightedBackgroundColor.cgColor)
|
||||
context.fillEllipse(in: CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height)))
|
||||
context.fill(CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height / 2.0)))
|
||||
})?.stretchableImage(withLeftCapWidth: 16, topCapHeight: 1)
|
||||
|
||||
let roundedBackground = generateStretchableFilledCircleImage(radius: 16.0, color: presentationData.theme.actionSheet.opaqueItemBackgroundColor)
|
||||
let highlightedRoundedBackground = generateStretchableFilledCircleImage(radius: 16.0, color: presentationData.theme.actionSheet.opaqueItemHighlightedBackgroundColor)
|
||||
|
||||
self.contentBackgroundNode.image = roundedBackground
|
||||
|
||||
if !self.installActionButtonIsRemove {
|
||||
let roundedAccentBackground = generateImage(CGSize(width: 50.0, height: 50.0), rotatedContext: { size, context in
|
||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
context.setFillColor(self.presentationData.theme.list.itemCheckColors.fillColor.cgColor)
|
||||
context.fillEllipse(in: CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height)))
|
||||
})?.stretchableImage(withLeftCapWidth: 25, topCapHeight: 25)
|
||||
self.installActionButtonNode.setBackgroundImage(roundedAccentBackground, for: [])
|
||||
self.cancelButtonNode.setBackgroundImage(roundedBackground, for: .normal)
|
||||
self.cancelButtonNode.setBackgroundImage(highlightedRoundedBackground, for: .highlighted)
|
||||
|
||||
if self.shareActionButtonNode.supernode != nil {
|
||||
self.installActionButtonNode.setBackgroundImage(solidBackground, for: .normal)
|
||||
self.installActionButtonNode.setBackgroundImage(highlightedSolidBackground, for: .highlighted)
|
||||
} else {
|
||||
self.installActionButtonNode.setBackgroundImage(halfRoundedBackground, for: .normal)
|
||||
self.installActionButtonNode.setBackgroundImage(highlightedHalfRoundedBackground, for: .highlighted)
|
||||
}
|
||||
|
||||
self.shareActionButtonNode.setTitle(presentationData.strings.Conversation_ContextMenuShare.uppercased(), with: Font.semibold(17.0), with: presentationData.theme.actionSheet.controlAccentColor, for: .normal)
|
||||
self.shareActionButtonNode.setBackgroundImage(halfRoundedBackground, for: .normal)
|
||||
self.shareActionButtonNode.setBackgroundImage(highlightedHalfRoundedBackground, for: .highlighted)
|
||||
self.shareActionButtonNode.setTitle(presentationData.strings.Conversation_ContextMenuShare, with: Font.regular(20.0), with: presentationData.theme.actionSheet.controlAccentColor, for: .normal)
|
||||
|
||||
self.contentSeparatorNode.backgroundColor = presentationData.theme.actionSheet.opaqueItemSeparatorColor
|
||||
self.actionsSeparatorNode.backgroundColor = presentationData.theme.actionSheet.opaqueItemSeparatorColor
|
||||
self.actionsBackgroundNode.backgroundColor = presentationData.theme.actionSheet.opaqueItemBackgroundColor
|
||||
self.installActionSeparatorNode.backgroundColor = presentationData.theme.actionSheet.opaqueItemSeparatorColor
|
||||
self.shareActionSeparatorNode.backgroundColor = presentationData.theme.actionSheet.opaqueItemSeparatorColor
|
||||
|
||||
self.cancelButtonNode.setTitle(presentationData.strings.Common_Cancel.uppercased(), with: Font.semibold(17.0), with: presentationData.theme.actionSheet.standardActionTextColor, for: .normal)
|
||||
self.cancelButtonNode.setTitle(presentationData.strings.Common_Cancel, with: Font.medium(20.0), with: presentationData.theme.actionSheet.standardActionTextColor, for: .normal)
|
||||
|
||||
self.contentTitleNode.linkHighlightColor = presentationData.theme.actionSheet.controlAccentColor.withAlphaComponent(0.5)
|
||||
|
||||
|
|
@ -322,7 +324,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
transition.updateFrame(node: self.wrappingScrollNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
||||
|
||||
var insets = layout.insets(options: [.statusBar])
|
||||
insets.top = 10.0 + insets.top
|
||||
insets.top = max(10.0, insets.top)
|
||||
let cleanInsets = layout.insets(options: [.statusBar])
|
||||
let hasShareButton = self.shareActionButtonNode.supernode != nil
|
||||
|
||||
|
|
@ -330,30 +332,23 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
|
||||
var bottomInset: CGFloat = 10.0 + cleanInsets.bottom
|
||||
if insets.bottom > 0 {
|
||||
bottomInset -= 0.0
|
||||
bottomInset -= 12.0
|
||||
}
|
||||
|
||||
let buttonHeight: CGFloat = 50.0
|
||||
let actionAreaTopInset: CGFloat = 15.0
|
||||
let buttonSpacing: CGFloat = 10.0
|
||||
let buttonHeight: CGFloat = 57.0
|
||||
let sectionSpacing: CGFloat = 8.0
|
||||
let titleAreaHeight: CGFloat = 54.0
|
||||
let titleAreaHeight: CGFloat = 51.0
|
||||
|
||||
let width = horizontalContainerFillingSizeForLayout(layout: layout, sideInset: 0.0)
|
||||
let width = horizontalContainerFillingSizeForLayout(layout: layout, sideInset: 10.0 + layout.safeInsets.left)
|
||||
|
||||
let sideInset: CGFloat = 0.0
|
||||
let sideInset = floor((layout.size.width - width) / 2.0)
|
||||
|
||||
//transition.updateFrame(node: self.cancelButtonNode, frame: CGRect(origin: CGPoint(x: sideInset, y: layout.size.height - bottomInset - buttonHeight), size: CGSize(width: width, height: buttonHeight)))
|
||||
transition.updateFrame(node: self.cancelButtonNode, frame: CGRect(origin: CGPoint(x: sideInset, y: layout.size.height - bottomInset - buttonHeight), size: CGSize(width: width, height: buttonHeight)))
|
||||
|
||||
var actionAreaHeight = bottomInset + buttonHeight + actionAreaTopInset
|
||||
|
||||
transition.updateFrame(node: self.actionsBackgroundNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - actionAreaHeight), size: CGSize(width: layout.size.width, height: actionAreaHeight)))
|
||||
transition.updateFrame(node: self.actionsSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - actionAreaHeight), size: CGSize(width: layout.size.width, height: UIScreenPixel)))
|
||||
|
||||
let maximumContentHeight = layout.size.height - insets.top
|
||||
let maximumContentHeight = layout.size.height - insets.top - bottomInset - buttonHeight - sectionSpacing
|
||||
|
||||
let contentContainerFrame = CGRect(origin: CGPoint(x: sideInset, y: insets.top), size: CGSize(width: width, height: maximumContentHeight))
|
||||
let contentFrame = contentContainerFrame.insetBy(dx: 0.0, dy: 0.0)
|
||||
let contentFrame = contentContainerFrame.insetBy(dx: 12.0, dy: 0.0)
|
||||
|
||||
var transaction: StickerPackPreviewGridTransaction?
|
||||
|
||||
|
|
@ -384,7 +379,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
|
||||
if self.currentItems.isEmpty && !updatedItems.isEmpty {
|
||||
let entities = generateTextEntities(info.title, enabledTypes: [.mention])
|
||||
let font = Font.semibold(17.0)
|
||||
let font = Font.medium(20.0)
|
||||
self.contentTitleNode.attributedText = stringWithAppliedEntities(info.title, entities: entities, baseColor: self.presentationData.theme.actionSheet.primaryTextColor, linkColor: self.presentationData.theme.actionSheet.controlAccentColor, baseFont: font, linkFont: font, boldFont: font, italicFont: font, boldItalicFont: font, fixedFont: font, blockQuoteFont: font)
|
||||
animateIn = true
|
||||
}
|
||||
|
|
@ -394,7 +389,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
}
|
||||
|
||||
let titleSize = self.contentTitleNode.updateLayout(CGSize(width: contentContainerFrame.size.width - 24.0, height: CGFloat.greatestFiniteMagnitude))
|
||||
let titleFrame = CGRect(origin: CGPoint(x: contentContainerFrame.minX + floor((contentContainerFrame.size.width - titleSize.width) / 2.0), y: self.contentBackgroundNode.frame.minY + floor((titleAreaHeight - titleSize.height) / 2.0)), size: titleSize)
|
||||
let titleFrame = CGRect(origin: CGPoint(x: contentContainerFrame.minX + floor((contentContainerFrame.size.width - titleSize.width) / 2.0), y: self.contentBackgroundNode.frame.minY + 15.0), size: titleSize)
|
||||
let deltaTitlePosition = CGPoint(x: titleFrame.midX - self.contentTitleNode.frame.midX, y: titleFrame.midY - self.contentTitleNode.frame.midY)
|
||||
self.contentTitleNode.frame = titleFrame
|
||||
transition.animatePosition(node: self.contentTitleNode, from: CGPoint(x: titleFrame.midX + deltaTitlePosition.x, y: titleFrame.midY + deltaTitlePosition.y))
|
||||
|
|
@ -406,40 +401,38 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
let itemWidth = floor(contentFrame.size.width / CGFloat(itemsPerRow))
|
||||
let rowCount = itemCount / itemsPerRow + (itemCount % itemsPerRow != 0 ? 1 : 0)
|
||||
|
||||
let minimallyRevealedRowCount: CGFloat = 4.5
|
||||
let minimallyRevealedRowCount: CGFloat = 3.5
|
||||
let initiallyRevealedRowCount = min(minimallyRevealedRowCount, CGFloat(rowCount))
|
||||
|
||||
let topInset = max(0.0, contentFrame.size.height - initiallyRevealedRowCount * itemWidth - titleAreaHeight - actionAreaHeight)
|
||||
let topInset = max(0.0, contentFrame.size.height - initiallyRevealedRowCount * itemWidth - titleAreaHeight - buttonHeight)
|
||||
let bottomGridInset = hasShareButton ? buttonHeight * 2.0 : buttonHeight
|
||||
|
||||
transition.updateFrame(node: self.contentContainerNode, frame: contentContainerFrame)
|
||||
|
||||
if let activityIndicator = self.activityIndicator {
|
||||
let indicatorSize = activityIndicator.calculateSizeThatFits(layout.size)
|
||||
|
||||
transition.updateFrame(node: activityIndicator, frame: CGRect(origin: CGPoint(x: contentFrame.minX + floor((contentFrame.width - indicatorSize.width) / 2.0), y: contentFrame.maxY - indicatorSize.height - 54.0), size: indicatorSize))
|
||||
transition.updateFrame(node: activityIndicator, frame: CGRect(origin: CGPoint(x: contentFrame.minX + floor((contentFrame.width - indicatorSize.width) / 2.0), y: contentFrame.maxY - indicatorSize.height - 30.0), size: indicatorSize))
|
||||
}
|
||||
|
||||
var actionsOffset: CGFloat = layout.size.height - bottomInset
|
||||
transition.updateFrame(node: self.installActionButtonNode, frame: CGRect(origin: CGPoint(x: 16.0, y: actionsOffset - buttonHeight), size: CGSize(width: contentContainerFrame.size.width - 16.0 * 2.0, height: buttonHeight)))
|
||||
actionsOffset -= buttonHeight
|
||||
let installButtonOffset = hasShareButton ? buttonHeight * 2.0 : buttonHeight
|
||||
transition.updateFrame(node: self.installActionButtonNode, frame: CGRect(origin: CGPoint(x: 0.0, y: contentContainerFrame.size.height - installButtonOffset), size: CGSize(width: contentContainerFrame.size.width, height: buttonHeight)))
|
||||
transition.updateFrame(node: self.installActionSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: contentContainerFrame.size.height - installButtonOffset - UIScreenPixel), size: CGSize(width: contentContainerFrame.size.width, height: UIScreenPixel)))
|
||||
|
||||
//transition.updateFrame(node: self.installActionSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: contentContainerFrame.size.height - installButtonOffset - UIScreenPixel - bottomAreaHeight), size: CGSize(width: contentContainerFrame.size.width, height: UIScreenPixel)))
|
||||
transition.updateFrame(node: self.shareActionButtonNode, frame: CGRect(origin: CGPoint(x: 0.0, y: contentContainerFrame.size.height - buttonHeight), size: CGSize(width: contentContainerFrame.size.width, height: buttonHeight)))
|
||||
transition.updateFrame(node: self.shareActionSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: contentContainerFrame.size.height - buttonHeight - UIScreenPixel), size: CGSize(width: contentContainerFrame.size.width, height: UIScreenPixel)))
|
||||
|
||||
//transition.updateFrame(node: self.shareActionButtonNode, frame: CGRect(origin: CGPoint(x: 0.0, y: contentContainerFrame.size.height - buttonHeight - bottomAreaHeight), size: CGSize(width: contentContainerFrame.size.width, height: buttonHeight)))
|
||||
let gridSize = CGSize(width: contentFrame.size.width, height: max(32.0, contentFrame.size.height - titleAreaHeight))
|
||||
|
||||
//transition.updateFrame(node: self.shareActionSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: contentContainerFrame.size.height - buttonHeight - UIScreenPixel - bottomAreaHeight), size: CGSize(width: contentContainerFrame.size.width, height: UIScreenPixel)))
|
||||
|
||||
let gridSize = CGSize(width: contentFrame.size.width, height: max(32.0, contentFrame.size.height - titleAreaHeight - actionAreaHeight))
|
||||
|
||||
self.contentGridNode.transaction(GridNodeTransaction(deleteItems: transaction?.deletions ?? [], insertItems: transaction?.insertions ?? [], updateItems: transaction?.updates ?? [], scrollToItem: nil, updateLayout: GridNodeUpdateLayout(layout: GridNodeLayout(size: gridSize, insets: UIEdgeInsets(top: topInset, left: 0.0, bottom: 0.0, right: 0.0), preloadSize: 80.0, type: .fixed(itemSize: CGSize(width: itemWidth, height: itemWidth), fillWidth: nil, lineSpacing: 0.0, itemSpacing: nil)), transition: transition), itemTransition: .immediate, stationaryItems: .none, updateFirstIndexInSectionOffset: nil), completion: { _ in })
|
||||
self.contentGridNode.transaction(GridNodeTransaction(deleteItems: transaction?.deletions ?? [], insertItems: transaction?.insertions ?? [], updateItems: transaction?.updates ?? [], scrollToItem: nil, updateLayout: GridNodeUpdateLayout(layout: GridNodeLayout(size: gridSize, insets: UIEdgeInsets(top: topInset, left: 0.0, bottom: bottomGridInset, right: 0.0), preloadSize: 80.0, type: .fixed(itemSize: CGSize(width: itemWidth, height: itemWidth), fillWidth: nil, lineSpacing: 0.0, itemSpacing: nil)), transition: transition), itemTransition: .immediate, stationaryItems: .none, updateFirstIndexInSectionOffset: nil), completion: { _ in })
|
||||
transition.updateFrame(node: self.contentGridNode, frame: CGRect(origin: CGPoint(x: floor((contentContainerFrame.size.width - contentFrame.size.width) / 2.0), y: titleAreaHeight), size: gridSize))
|
||||
|
||||
if animateIn {
|
||||
self.contentGridNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
self.installActionButtonNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
self.shareActionButtonNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
self.actionsSeparatorNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
self.actionsBackgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
self.installActionButtonNode.titleNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
self.installActionSeparatorNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
self.shareActionButtonNode.titleNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
self.shareActionSeparatorNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
}
|
||||
|
||||
if let _ = self.stickerPack, self.stickerPackUpdated {
|
||||
|
|
@ -450,30 +443,26 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
private func gridPresentationLayoutUpdated(_ presentationLayout: GridNodeCurrentPresentationLayout, transition: ContainedViewLayoutTransition) {
|
||||
if let (layout, _) = self.containerLayout {
|
||||
var insets = layout.insets(options: [.statusBar])
|
||||
insets.top = 10.0 + insets.top
|
||||
insets.top = max(10.0, insets.top)
|
||||
let cleanInsets = layout.insets(options: [.statusBar])
|
||||
|
||||
var bottomInset: CGFloat = 10.0 + cleanInsets.bottom
|
||||
if insets.bottom > 0 {
|
||||
bottomInset -= 0.0
|
||||
bottomInset -= 12.0
|
||||
}
|
||||
|
||||
let buttonHeight: CGFloat = 50.0
|
||||
let actionAreaTopInset: CGFloat = 15.0
|
||||
let buttonSpacing: CGFloat = 10.0
|
||||
let buttonHeight: CGFloat = 57.0
|
||||
let sectionSpacing: CGFloat = 8.0
|
||||
let titleAreaHeight: CGFloat = 54.0
|
||||
let titleAreaHeight: CGFloat = 51.0
|
||||
|
||||
let width = horizontalContainerFillingSizeForLayout(layout: layout, sideInset: 0.0)
|
||||
let width = horizontalContainerFillingSizeForLayout(layout: layout, sideInset: 10.0 + layout.safeInsets.left)
|
||||
|
||||
let sideInset: CGFloat = 0.0
|
||||
let sideInset = floor((layout.size.width - width) / 2.0)
|
||||
|
||||
var actionAreaHeight = bottomInset + buttonHeight + actionAreaTopInset
|
||||
|
||||
let maximumContentHeight = layout.size.height - insets.top
|
||||
let maximumContentHeight = layout.size.height - insets.top - bottomInset - buttonHeight - sectionSpacing
|
||||
let contentFrame = CGRect(origin: CGPoint(x: sideInset, y: insets.top), size: CGSize(width: width, height: maximumContentHeight))
|
||||
|
||||
var backgroundFrame = CGRect(origin: CGPoint(x: contentFrame.minX, y: contentFrame.minY - presentationLayout.contentOffset.y), size: CGSize(width: contentFrame.size.width, height: contentFrame.size.height + 500.0))
|
||||
var backgroundFrame = CGRect(origin: CGPoint(x: contentFrame.minX, y: contentFrame.minY - presentationLayout.contentOffset.y), size: contentFrame.size)
|
||||
if backgroundFrame.minY < contentFrame.minY {
|
||||
backgroundFrame.origin.y = contentFrame.minY
|
||||
}
|
||||
|
|
@ -489,29 +478,23 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
compactFrame = false
|
||||
}
|
||||
if compactFrame {
|
||||
backgroundFrame = CGRect(origin: CGPoint(x: contentFrame.minX, y: contentFrame.maxY - buttonHeight - 64.0), size: CGSize(width: contentFrame.size.width, height: buttonHeight + 64.0))
|
||||
backgroundFrame = CGRect(origin: CGPoint(x: contentFrame.minX, y: contentFrame.maxY - buttonHeight - 32.0), size: CGSize(width: contentFrame.size.width, height: buttonHeight + 32.0))
|
||||
}
|
||||
let backgroundDeltaY = backgroundFrame.minY - self.contentBackgroundNode.frame.minY
|
||||
transition.updateFrame(node: self.contentBackgroundNode, frame: backgroundFrame)
|
||||
transition.animatePositionAdditive(node: self.contentGridNode, offset: CGPoint(x: 0.0, y: -backgroundDeltaY))
|
||||
|
||||
let titleSize = self.contentTitleNode.bounds.size
|
||||
let titleFrame = CGRect(origin: CGPoint(x: contentFrame.minX + floor((contentFrame.size.width - titleSize.width) / 2.0), y: backgroundFrame.minY + floor((titleAreaHeight - titleSize.height) / 2.0)), size: titleSize)
|
||||
let titleFrame = CGRect(origin: CGPoint(x: contentFrame.minX + floor((contentFrame.size.width - titleSize.width) / 2.0), y: backgroundFrame.minY + 15.0), size: titleSize)
|
||||
transition.updateFrame(node: self.contentTitleNode, frame: titleFrame)
|
||||
|
||||
transition.updateFrame(node: self.contentSeparatorNode, frame: CGRect(origin: CGPoint(x: contentFrame.minX, y: backgroundFrame.minY + titleAreaHeight), size: CGSize(width: contentFrame.size.width, height: UIScreenPixel)))
|
||||
|
||||
var modalStyleOverlayTransitionFactor: CGFloat = 0.0
|
||||
if !compactFrame && presentationLayout.contentOffset.y >= 0.0 {
|
||||
if !compactFrame && CGFloat(0.0).isLessThanOrEqualTo(presentationLayout.contentOffset.y) {
|
||||
self.contentSeparatorNode.alpha = 1.0
|
||||
} else {
|
||||
self.contentSeparatorNode.alpha = 0.0
|
||||
}
|
||||
let activationDistance: CGFloat = 100.0
|
||||
let offsetFactor = (activationDistance - min(max(0.0, -presentationLayout.contentOffset.y), activationDistance)) / activationDistance
|
||||
|
||||
self.controller?.updateModalStyleOverlayTransitionFactor(offsetFactor, transition: transition)
|
||||
//self.controller?.updateModalStyleOverlayTransitionFactor(offsetFactor.isZero ? 0.0 : 1.0, transition: .animated(duration: 0.4, curve: .spring))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -528,7 +511,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
@objc func installActionButtonPressed() {
|
||||
let dismissOnAction: Bool
|
||||
if let initiallyInstalled = self.stickerPackInitiallyInstalled, initiallyInstalled {
|
||||
dismissOnAction = true
|
||||
dismissOnAction = false
|
||||
} else {
|
||||
dismissOnAction = true
|
||||
}
|
||||
|
|
@ -598,22 +581,19 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
if let _ = self.containerLayout {
|
||||
self.dequeueUpdateStickerPack()
|
||||
}
|
||||
|
||||
switch stickerPack {
|
||||
case .none, .fetching:
|
||||
self.actionsSeparatorNode.alpha = 0.0
|
||||
self.installActionSeparatorNode.alpha = 0.0
|
||||
self.shareActionSeparatorNode.alpha = 0.0
|
||||
self.shareActionButtonNode.alpha = 0.0
|
||||
self.actionsBackgroundNode.alpha = 0.0
|
||||
self.installActionButtonNode.alpha = 0.0
|
||||
self.installActionButtonNode.setTitle("", with: Font.semibold(17.0), with: self.presentationData.theme.list.itemCheckColors.foregroundColor, for: .normal)
|
||||
self.installActionButtonIsRemove = true
|
||||
self.installActionButtonNode.setBackgroundImage(nil, for: [])
|
||||
self.installActionButtonNode.setTitle("", with: Font.medium(20.0), with: self.presentationData.theme.actionSheet.standardActionTextColor, for: .normal)
|
||||
case let .result(info, _, installed):
|
||||
if self.stickerPackInitiallyInstalled == nil {
|
||||
self.stickerPackInitiallyInstalled = installed
|
||||
}
|
||||
self.actionsSeparatorNode.alpha = 1.0
|
||||
self.actionsBackgroundNode.alpha = 1.0
|
||||
self.installActionSeparatorNode.alpha = 1.0
|
||||
self.shareActionSeparatorNode.alpha = 1.0
|
||||
self.shareActionButtonNode.alpha = 1.0
|
||||
self.installActionButtonNode.alpha = 1.0
|
||||
if installed {
|
||||
|
|
@ -623,9 +603,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
} else {
|
||||
text = self.presentationData.strings.StickerPack_RemoveMaskCount(info.count)
|
||||
}
|
||||
self.installActionButtonNode.setTitle(text.uppercased(), with: Font.semibold(17.0), with: self.presentationData.theme.list.itemDestructiveColor, for: .normal)
|
||||
self.installActionButtonIsRemove = true
|
||||
self.installActionButtonNode.setBackgroundImage(nil, for: [])
|
||||
self.installActionButtonNode.setTitle(text, with: Font.regular(20.0), with: self.presentationData.theme.actionSheet.destructiveActionTextColor, for: .normal)
|
||||
} else {
|
||||
let text: String
|
||||
if info.id.namespace == Namespaces.ItemCollection.CloudStickerPacks {
|
||||
|
|
@ -633,14 +611,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
} else {
|
||||
text = self.presentationData.strings.StickerPack_AddMaskCount(info.count)
|
||||
}
|
||||
self.installActionButtonNode.setTitle(text.uppercased(), with: Font.semibold(17.0), with: self.presentationData.theme.list.itemCheckColors.foregroundColor, for: .normal)
|
||||
self.installActionButtonIsRemove = false
|
||||
let roundedAccentBackground = generateImage(CGSize(width: 50.0, height: 50.0), rotatedContext: { size, context in
|
||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
context.setFillColor(self.presentationData.theme.list.itemCheckColors.fillColor.cgColor)
|
||||
context.fillEllipse(in: CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height)))
|
||||
})?.stretchableImage(withLeftCapWidth: 25, topCapHeight: 25)
|
||||
self.installActionButtonNode.setBackgroundImage(roundedAccentBackground, for: [])
|
||||
self.installActionButtonNode.setTitle(text, with: Font.regular(20.0), with: self.presentationData.theme.actionSheet.controlAccentColor, for: .normal)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -676,32 +647,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
|||
return self.dimNode.view
|
||||
}
|
||||
}
|
||||
|
||||
let result = super.hitTest(point, with: event)
|
||||
|
||||
var currentParent: UIView? = result
|
||||
var enableScrolling = true
|
||||
while true {
|
||||
if currentParent == nil {
|
||||
break
|
||||
}
|
||||
if let scrollView = currentParent as? UIScrollView {
|
||||
if scrollView === self.wrappingScrollNode.view {
|
||||
break
|
||||
}
|
||||
if scrollView.disablesInteractiveModalDismiss {
|
||||
enableScrolling = false
|
||||
break
|
||||
} else {
|
||||
if scrollView.isDecelerating && scrollView.contentOffset.y < -scrollView.contentInset.top {
|
||||
return self.wrappingScrollNode.view
|
||||
}
|
||||
}
|
||||
}
|
||||
currentParent = currentParent?.superview
|
||||
}
|
||||
|
||||
return result
|
||||
return super.hitTest(point, with: event)
|
||||
}
|
||||
|
||||
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
|
||||
|
|
|
|||
|
|
@ -764,7 +764,7 @@ private final class StickerPackScreenNode: ViewControllerTracingNode {
|
|||
}
|
||||
}
|
||||
|
||||
public final class StickerPackScreen: ViewController {
|
||||
public final class StickerPackScreenImpl: ViewController {
|
||||
private let context: AccountContext
|
||||
private let stickerPacks: [StickerPackReference]
|
||||
private let initialSelectedStickerPackIndex: Int
|
||||
|
|
@ -841,3 +841,9 @@ public final class StickerPackScreen: ViewController {
|
|||
self.controllerNode.containerLayoutUpdated(layout, transition: transition)
|
||||
}
|
||||
}
|
||||
|
||||
public func StickerPackScreen(context: AccountContext, mainStickerPack: StickerPackReference, stickerPacks: [StickerPackReference], parentNavigationController: NavigationController? = nil, sendSticker: ((FileMediaReference, ASDisplayNode, CGRect) -> Bool)? = nil) -> ViewController {
|
||||
let controller = StickerPackPreviewController(context: context, stickerPack: mainStickerPack, mode: .default, parentNavigationController: parentNavigationController)
|
||||
controller.sendSticker = sendSticker
|
||||
return controller
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,14 +13,16 @@ public struct AutodownloadPresetSettings: PostboxCoding, Equatable {
|
|||
public let fileSizeMax: Int32
|
||||
public let preloadLargeVideo: Bool
|
||||
public let lessDataForPhoneCalls: Bool
|
||||
public let videoUploadMaxbitrate: Int32
|
||||
|
||||
public init(disabled: Bool, photoSizeMax: Int32, videoSizeMax: Int32, fileSizeMax: Int32, preloadLargeVideo: Bool, lessDataForPhoneCalls: Bool) {
|
||||
public init(disabled: Bool, photoSizeMax: Int32, videoSizeMax: Int32, fileSizeMax: Int32, preloadLargeVideo: Bool, lessDataForPhoneCalls: Bool, videoUploadMaxbitrate: Int32) {
|
||||
self.disabled = disabled
|
||||
self.photoSizeMax = photoSizeMax
|
||||
self.videoSizeMax = videoSizeMax
|
||||
self.fileSizeMax = fileSizeMax
|
||||
self.preloadLargeVideo = preloadLargeVideo
|
||||
self.lessDataForPhoneCalls = lessDataForPhoneCalls
|
||||
self.videoUploadMaxbitrate = videoUploadMaxbitrate
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
|
|
@ -30,6 +32,7 @@ public struct AutodownloadPresetSettings: PostboxCoding, Equatable {
|
|||
self.fileSizeMax = decoder.decodeInt32ForKey("fileSizeMax", orElse: 0)
|
||||
self.preloadLargeVideo = decoder.decodeInt32ForKey("preloadLargeVideo", orElse: 0) != 0
|
||||
self.lessDataForPhoneCalls = decoder.decodeInt32ForKey("lessDataForPhoneCalls", orElse: 0) != 0
|
||||
self.videoUploadMaxbitrate = decoder.decodeInt32ForKey("videoUploadMaxbitrate", orElse: 0)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
|
|
@ -39,6 +42,7 @@ public struct AutodownloadPresetSettings: PostboxCoding, Equatable {
|
|||
encoder.encodeInt32(self.fileSizeMax, forKey: "fileSizeMax")
|
||||
encoder.encodeInt32(self.preloadLargeVideo ? 1 : 0, forKey: "preloadLargeVideo")
|
||||
encoder.encodeInt32(self.lessDataForPhoneCalls ? 1 : 0, forKey: "lessDataForPhoneCalls")
|
||||
encoder.encodeInt32(self.videoUploadMaxbitrate, forKey: "videoUploadMaxbitrate")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -48,9 +52,10 @@ public struct AutodownloadSettings: PreferencesEntry, Equatable {
|
|||
public let highPreset: AutodownloadPresetSettings
|
||||
|
||||
public static var defaultSettings: AutodownloadSettings {
|
||||
return AutodownloadSettings(lowPreset: AutodownloadPresetSettings(disabled: false, photoSizeMax: 1 * 1024 * 1024, videoSizeMax: 0, fileSizeMax: 0, preloadLargeVideo: false, lessDataForPhoneCalls: true),
|
||||
mediumPreset: AutodownloadPresetSettings(disabled: false, photoSizeMax: 1 * 1024 * 1024, videoSizeMax: Int32(2.5 * 1024 * 1024), fileSizeMax: 1 * 1024 * 1024, preloadLargeVideo: false, lessDataForPhoneCalls: false),
|
||||
highPreset: AutodownloadPresetSettings(disabled: false, photoSizeMax: 1 * 1024 * 1024, videoSizeMax: 10 * 1024 * 1024, fileSizeMax: 3 * 1024 * 1024, preloadLargeVideo: false, lessDataForPhoneCalls: false))
|
||||
return AutodownloadSettings(
|
||||
lowPreset: AutodownloadPresetSettings(disabled: false, photoSizeMax: 1 * 1024 * 1024, videoSizeMax: 0, fileSizeMax: 0, preloadLargeVideo: false, lessDataForPhoneCalls: true, videoUploadMaxbitrate: 0),
|
||||
mediumPreset: AutodownloadPresetSettings(disabled: false, photoSizeMax: 1 * 1024 * 1024, videoSizeMax: Int32(2.5 * 1024 * 1024), fileSizeMax: 1 * 1024 * 1024, preloadLargeVideo: false, lessDataForPhoneCalls: false, videoUploadMaxbitrate: 0),
|
||||
highPreset: AutodownloadPresetSettings(disabled: false, photoSizeMax: 1 * 1024 * 1024, videoSizeMax: 10 * 1024 * 1024, fileSizeMax: 3 * 1024 * 1024, preloadLargeVideo: false, lessDataForPhoneCalls: false, videoUploadMaxbitrate: 0))
|
||||
}
|
||||
|
||||
public init(lowPreset: AutodownloadPresetSettings, mediumPreset: AutodownloadPresetSettings, highPreset: AutodownloadPresetSettings) {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||
dict[1202287072] = { return Api.StatsURL.parse_statsURL($0) }
|
||||
dict[1516793212] = { return Api.ChatInvite.parse_chatInviteAlready($0) }
|
||||
dict[-540871282] = { return Api.ChatInvite.parse_chatInvite($0) }
|
||||
dict[-767099577] = { return Api.AutoDownloadSettings.parse_autoDownloadSettings($0) }
|
||||
dict[-532532493] = { return Api.AutoDownloadSettings.parse_autoDownloadSettings($0) }
|
||||
dict[-767099577] = { return Api.AutoDownloadSettings.parse_autoDownloadSettingsLegacy($0) }
|
||||
dict[1678812626] = { return Api.StickerSetCovered.parse_stickerSetCovered($0) }
|
||||
dict[872932635] = { return Api.StickerSetCovered.parse_stickerSetMultiCovered($0) }
|
||||
dict[1189204285] = { return Api.RecentMeUrl.parse_recentMeUrlUnknown($0) }
|
||||
|
|
|
|||
|
|
@ -1908,11 +1908,22 @@ public extension Api {
|
|||
|
||||
}
|
||||
public enum AutoDownloadSettings: TypeConstructorDescription {
|
||||
case autoDownloadSettings(flags: Int32, photoSizeMax: Int32, videoSizeMax: Int32, fileSizeMax: Int32)
|
||||
case autoDownloadSettings(flags: Int32, photoSizeMax: Int32, videoSizeMax: Int32, fileSizeMax: Int32, videoUploadMaxbitrate: Int32)
|
||||
case autoDownloadSettingsLegacy(flags: Int32, photoSizeMax: Int32, videoSizeMax: Int32, fileSizeMax: Int32)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .autoDownloadSettings(let flags, let photoSizeMax, let videoSizeMax, let fileSizeMax):
|
||||
case .autoDownloadSettings(let flags, let photoSizeMax, let videoSizeMax, let fileSizeMax, let videoUploadMaxbitrate):
|
||||
if boxed {
|
||||
buffer.appendInt32(-532532493)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(photoSizeMax, buffer: buffer, boxed: false)
|
||||
serializeInt32(videoSizeMax, buffer: buffer, boxed: false)
|
||||
serializeInt32(fileSizeMax, buffer: buffer, boxed: false)
|
||||
serializeInt32(videoUploadMaxbitrate, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .autoDownloadSettingsLegacy(let flags, let photoSizeMax, let videoSizeMax, let fileSizeMax):
|
||||
if boxed {
|
||||
buffer.appendInt32(-767099577)
|
||||
}
|
||||
|
|
@ -1926,12 +1937,37 @@ public extension Api {
|
|||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .autoDownloadSettings(let flags, let photoSizeMax, let videoSizeMax, let fileSizeMax):
|
||||
return ("autoDownloadSettings", [("flags", flags), ("photoSizeMax", photoSizeMax), ("videoSizeMax", videoSizeMax), ("fileSizeMax", fileSizeMax)])
|
||||
case .autoDownloadSettings(let flags, let photoSizeMax, let videoSizeMax, let fileSizeMax, let videoUploadMaxbitrate):
|
||||
return ("autoDownloadSettings", [("flags", flags), ("photoSizeMax", photoSizeMax), ("videoSizeMax", videoSizeMax), ("fileSizeMax", fileSizeMax), ("videoUploadMaxbitrate", videoUploadMaxbitrate)])
|
||||
case .autoDownloadSettingsLegacy(let flags, let photoSizeMax, let videoSizeMax, let fileSizeMax):
|
||||
return ("autoDownloadSettingsLegacy", [("flags", flags), ("photoSizeMax", photoSizeMax), ("videoSizeMax", videoSizeMax), ("fileSizeMax", fileSizeMax)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_autoDownloadSettings(_ reader: BufferReader) -> AutoDownloadSettings? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: Int32?
|
||||
_4 = reader.readInt32()
|
||||
var _5: Int32?
|
||||
_5 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
||||
return Api.AutoDownloadSettings.autoDownloadSettings(flags: _1!, photoSizeMax: _2!, videoSizeMax: _3!, fileSizeMax: _4!, videoUploadMaxbitrate: _5!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_autoDownloadSettingsLegacy(_ reader: BufferReader) -> AutoDownloadSettings? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
|
|
@ -1945,7 +1981,7 @@ public extension Api {
|
|||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.AutoDownloadSettings.autoDownloadSettings(flags: _1!, photoSizeMax: _2!, videoSizeMax: _3!, fileSizeMax: _4!)
|
||||
return Api.AutoDownloadSettings.autoDownloadSettingsLegacy(flags: _1!, photoSizeMax: _2!, videoSizeMax: _3!, fileSizeMax: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ public enum AddGroupMemberError {
|
|||
case generic
|
||||
case groupFull
|
||||
case privacy
|
||||
case tooManyChannels
|
||||
}
|
||||
|
||||
public func addGroupMember(account: Account, peerId: PeerId, memberId: PeerId) -> Signal<Void, AddGroupMemberError> {
|
||||
|
|
@ -19,12 +20,14 @@ public func addGroupMember(account: Account, peerId: PeerId, memberId: PeerId) -
|
|||
return account.network.request(Api.functions.messages.addChatUser(chatId: group.id.id, userId: inputUser, fwdLimit: 100))
|
||||
|> mapError { error -> AddGroupMemberError in
|
||||
switch error.errorDescription {
|
||||
case "USERS_TOO_MUCH":
|
||||
return .groupFull
|
||||
case "USER_PRIVACY_RESTRICTED":
|
||||
return .privacy
|
||||
default:
|
||||
return .generic
|
||||
case "USERS_TOO_MUCH":
|
||||
return .groupFull
|
||||
case "USER_PRIVACY_RESTRICTED":
|
||||
return .privacy
|
||||
case "USER_CHANNELS_TOO_MUCH":
|
||||
return .tooManyChannels
|
||||
default:
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Void, AddGroupMemberError> in
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ public func updateAutodownloadSettingsInteractively(accountManager: AccountManag
|
|||
extension AutodownloadPresetSettings {
|
||||
init(apiAutodownloadSettings: Api.AutoDownloadSettings) {
|
||||
switch apiAutodownloadSettings {
|
||||
case let .autoDownloadSettings(flags, photoSizeMax, videoSizeMax, fileSizeMax):
|
||||
self.init(disabled: (flags & (1 << 0)) != 0, photoSizeMax: photoSizeMax, videoSizeMax: videoSizeMax, fileSizeMax: fileSizeMax, preloadLargeVideo: (flags & (1 << 1)) != 0, lessDataForPhoneCalls: (flags & (1 << 3)) != 0)
|
||||
case let .autoDownloadSettings(flags, photoSizeMax, videoSizeMax, fileSizeMax, videoUploadMaxbitrate):
|
||||
self.init(disabled: (flags & (1 << 0)) != 0, photoSizeMax: photoSizeMax, videoSizeMax: videoSizeMax, fileSizeMax: fileSizeMax, preloadLargeVideo: (flags & (1 << 1)) != 0, lessDataForPhoneCalls: (flags & (1 << 3)) != 0, videoUploadMaxbitrate: videoUploadMaxbitrate)
|
||||
case let .autoDownloadSettingsLegacy(flags, photoSizeMax, videoSizeMax, fileSizeMax):
|
||||
self.init(disabled: (flags & (1 << 0)) != 0, photoSizeMax: photoSizeMax, videoSizeMax: videoSizeMax, fileSizeMax: fileSizeMax, preloadLargeVideo: (flags & (1 << 1)) != 0, lessDataForPhoneCalls: (flags & (1 << 3)) != 0, videoUploadMaxbitrate: 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -48,6 +50,6 @@ func apiAutodownloadPresetSettings(_ autodownloadPresetSettings: AutodownloadPre
|
|||
if autodownloadPresetSettings.lessDataForPhoneCalls {
|
||||
flags |= (1 << 3)
|
||||
}
|
||||
return .autoDownloadSettings(flags: flags, photoSizeMax: autodownloadPresetSettings.photoSizeMax, videoSizeMax: autodownloadPresetSettings.videoSizeMax, fileSizeMax: autodownloadPresetSettings.fileSizeMax)
|
||||
return .autoDownloadSettings(flags: flags, photoSizeMax: autodownloadPresetSettings.photoSizeMax, videoSizeMax: autodownloadPresetSettings.videoSizeMax, fileSizeMax: autodownloadPresetSettings.fileSizeMax, videoUploadMaxbitrate: autodownloadPresetSettings.videoUploadMaxbitrate)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -195,6 +195,8 @@ public func updateChannelAdminRights(account: Account, peerId: PeerId, adminId:
|
|||
)
|
||||
} else if error.errorDescription == "USER_PRIVACY_RESTRICTED" {
|
||||
return .fail(.addMemberError(.restricted))
|
||||
} else if error.errorDescription == "USER_CHANNELS_TOO_MUCH" {
|
||||
return .fail(.addMemberError(.tooMuchJoined))
|
||||
}
|
||||
return .fail(.generic)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,14 +165,16 @@ private func currentPersonNameSortOrder() -> PresentationPersonNameOrder {
|
|||
public final class InitialPresentationDataAndSettings {
|
||||
public let presentationData: PresentationData
|
||||
public let automaticMediaDownloadSettings: MediaAutoDownloadSettings
|
||||
public let autodownloadSettings: AutodownloadSettings
|
||||
public let callListSettings: CallListSettings
|
||||
public let inAppNotificationSettings: InAppNotificationSettings
|
||||
public let mediaInputSettings: MediaInputSettings
|
||||
public let experimentalUISettings: ExperimentalUISettings
|
||||
|
||||
public init(presentationData: PresentationData, automaticMediaDownloadSettings: MediaAutoDownloadSettings, callListSettings: CallListSettings, inAppNotificationSettings: InAppNotificationSettings, mediaInputSettings: MediaInputSettings, experimentalUISettings: ExperimentalUISettings) {
|
||||
public init(presentationData: PresentationData, automaticMediaDownloadSettings: MediaAutoDownloadSettings, autodownloadSettings: AutodownloadSettings, callListSettings: CallListSettings, inAppNotificationSettings: InAppNotificationSettings, mediaInputSettings: MediaInputSettings, experimentalUISettings: ExperimentalUISettings) {
|
||||
self.presentationData = presentationData
|
||||
self.automaticMediaDownloadSettings = automaticMediaDownloadSettings
|
||||
self.autodownloadSettings = autodownloadSettings
|
||||
self.callListSettings = callListSettings
|
||||
self.inAppNotificationSettings = inAppNotificationSettings
|
||||
self.mediaInputSettings = mediaInputSettings
|
||||
|
|
@ -203,6 +205,13 @@ public func currentPresentationDataAndSettings(accountManager: AccountManager, s
|
|||
automaticMediaDownloadSettings = MediaAutoDownloadSettings.defaultSettings
|
||||
}
|
||||
|
||||
let autodownloadSettings: AutodownloadSettings
|
||||
if let value = transaction.getSharedData(SharedDataKeys.autodownloadSettings) as? AutodownloadSettings {
|
||||
autodownloadSettings = value
|
||||
} else {
|
||||
autodownloadSettings = .defaultSettings
|
||||
}
|
||||
|
||||
let callListSettings: CallListSettings
|
||||
if let value = transaction.getSharedData(ApplicationSpecificSharedDataKeys.callListSettings) as? CallListSettings {
|
||||
callListSettings = value
|
||||
|
|
@ -253,7 +262,7 @@ public func currentPresentationDataAndSettings(accountManager: AccountManager, s
|
|||
}
|
||||
let nameDisplayOrder = contactSettings.nameDisplayOrder
|
||||
let nameSortOrder = currentPersonNameSortOrder()
|
||||
return InitialPresentationDataAndSettings(presentationData: PresentationData(strings: stringsValue, theme: theme, autoNightModeTriggered: autoNightModeTriggered, chatWallpaper: effectiveChatWallpaper, fontSize: resolveFontSize(settings: themeSettings), dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, nameSortOrder: nameSortOrder, disableAnimations: themeSettings.disableAnimations, largeEmoji: themeSettings.largeEmoji), automaticMediaDownloadSettings: automaticMediaDownloadSettings, callListSettings: callListSettings, inAppNotificationSettings: inAppNotificationSettings, mediaInputSettings: mediaInputSettings, experimentalUISettings: experimentalUISettings)
|
||||
return InitialPresentationDataAndSettings(presentationData: PresentationData(strings: stringsValue, theme: theme, autoNightModeTriggered: autoNightModeTriggered, chatWallpaper: effectiveChatWallpaper, fontSize: resolveFontSize(settings: themeSettings), dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, nameSortOrder: nameSortOrder, disableAnimations: themeSettings.disableAnimations, largeEmoji: themeSettings.largeEmoji), automaticMediaDownloadSettings: automaticMediaDownloadSettings, autodownloadSettings: autodownloadSettings, callListSettings: callListSettings, inAppNotificationSettings: inAppNotificationSettings, mediaInputSettings: mediaInputSettings, experimentalUISettings: experimentalUISettings)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue