mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-08 19:10:53 +00:00
Video editor fixes
This commit is contained in:
parent
b38b88ae25
commit
b4deaf2e4f
@ -13,6 +13,7 @@
|
||||
|
||||
@protocol TGPhotoPaintStickerRenderView <NSObject>
|
||||
|
||||
- (void)setIsVisible:(bool)isVisible;
|
||||
- (int64_t)documentId;
|
||||
- (UIImage *)image;
|
||||
|
||||
|
@ -13,6 +13,8 @@
|
||||
@property (nonatomic, copy) void (^entitySelected)(TGPhotoPaintEntityView *);
|
||||
@property (nonatomic, copy) void (^entityRemoved)(TGPhotoPaintEntityView *);
|
||||
|
||||
- (void)updateVisibility:(bool)visible;
|
||||
|
||||
- (void)setupWithPaintingData:(TGPaintingData *)paintingData;
|
||||
- (TGPhotoPaintEntityView *)createEntityViewWithEntity:(TGPhotoPaintEntity *)entity;
|
||||
|
||||
|
@ -27,6 +27,19 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)updateVisibility:(bool)visible
|
||||
{
|
||||
for (TGPhotoPaintEntityView *view in self.subviews)
|
||||
{
|
||||
if (![view isKindOfClass:[TGPhotoPaintEntityView class]])
|
||||
continue;
|
||||
|
||||
if ([view isKindOfClass:[TGPhotoStickerEntityView class]]) {
|
||||
[(TGPhotoStickerEntityView *)view updateVisibility:visible];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)__unused gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)__unused otherGestureRecognizer
|
||||
{
|
||||
return false;
|
||||
|
@ -1019,12 +1019,14 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f;
|
||||
__strong TGPhotoPaintController *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.controlVideoPlayback(false);
|
||||
[strongSelf->_entitiesContainerView updateVisibility:false];
|
||||
}
|
||||
};
|
||||
_stickersScreen.screenWillDisappear = ^{
|
||||
__strong TGPhotoPaintController *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.controlVideoPlayback(true);
|
||||
[strongSelf->_entitiesContainerView updateVisibility:true];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
- (void)mirror;
|
||||
- (UIImage *)image;
|
||||
|
||||
- (void)updateVisibility:(bool)visible;
|
||||
|
||||
- (CGRect)realBounds;
|
||||
|
||||
@end
|
||||
|
@ -170,6 +170,10 @@ const CGFloat TGPhotoStickerSelectionViewHandleSide = 30.0f;
|
||||
return CGRectMake((self.bounds.size.width - side) / 2.0f, (self.bounds.size.height - side) / 2.0f, side, side);
|
||||
}
|
||||
|
||||
- (void)updateVisibility:(bool)visible {
|
||||
[_stickerView setIsVisible:visible];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -86,14 +86,25 @@ class LegacyPaintStickerView: UIView, TGPhotoPaintStickerRenderView {
|
||||
}
|
||||
}
|
||||
|
||||
var isVisible: Bool = true
|
||||
func setIsVisible(_ visible: Bool) {
|
||||
self.isVisible = visible
|
||||
updateVisibility()
|
||||
}
|
||||
|
||||
var isPlaying = false
|
||||
func updateVisibility() {
|
||||
if !self.didSetUpAnimationNode {
|
||||
self.didSetUpAnimationNode = true
|
||||
let isPlaying = self.isVisible
|
||||
if self.isPlaying != isPlaying {
|
||||
self.isPlaying = isPlaying
|
||||
|
||||
self.animationNode?.visibility = true
|
||||
let dimensions = self.file.dimensions ?? PixelDimensions(width: 512, height: 512)
|
||||
let fittedDimensions = dimensions.cgSize.aspectFitted(CGSize(width: 512.0, height: 512.0))
|
||||
self.animationNode?.setup(source: AnimatedStickerResourceSource(account: self.context.account, resource: self.file.resource), width: Int(fittedDimensions.width), height: Int(fittedDimensions.height), mode: .cached)
|
||||
self.animationNode?.visibility = isPlaying
|
||||
if isPlaying && !self.didSetUpAnimationNode {
|
||||
self.didSetUpAnimationNode = true
|
||||
let dimensions = self.file.dimensions ?? PixelDimensions(width: 512, height: 512)
|
||||
let fittedDimensions = dimensions.cgSize.aspectFitted(CGSize(width: 512.0, height: 512.0))
|
||||
self.animationNode?.setup(source: AnimatedStickerResourceSource(account: self.context.account, resource: self.file.resource), width: Int(fittedDimensions.width), height: Int(fittedDimensions.height), mode: .cached)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ enum ChatMediaInputGridEntryIndex: Equatable, Comparable {
|
||||
enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
|
||||
case search(theme: PresentationTheme, strings: PresentationStrings)
|
||||
case peerSpecificSetup(theme: PresentationTheme, strings: PresentationStrings, dismissed: Bool)
|
||||
case sticker(index: ItemCollectionViewEntryIndex, stickerItem: StickerPackItem, stickerPackInfo: StickerPackCollectionInfo?, canManagePeerSpecificPack: Bool?, theme: PresentationTheme)
|
||||
case sticker(index: ItemCollectionViewEntryIndex, stickerItem: StickerPackItem, stickerPackInfo: StickerPackCollectionInfo?, canManagePeerSpecificPack: Bool?, maybeManageable: Bool, theme: PresentationTheme)
|
||||
case trending(TrendingPanePackEntry)
|
||||
|
||||
var index: ChatMediaInputGridEntryIndex {
|
||||
@ -96,7 +96,7 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
|
||||
return .search
|
||||
case let .peerSpecificSetup(_, _, dismissed):
|
||||
return .peerSpecificSetup(dismissed: dismissed)
|
||||
case let .sticker(index, _, _, _, _):
|
||||
case let .sticker(index, _, _, _, _, _):
|
||||
return .collectionIndex(index)
|
||||
case let .trending(entry):
|
||||
return .trending(entry.info.id, entry.index)
|
||||
@ -127,8 +127,8 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .sticker(lhsIndex, lhsStickerItem, lhsStickerPackInfo, lhsCanManagePeerSpecificPack, lhsTheme):
|
||||
if case let .sticker(rhsIndex, rhsStickerItem, rhsStickerPackInfo, rhsCanManagePeerSpecificPack, rhsTheme) = rhs {
|
||||
case let .sticker(lhsIndex, lhsStickerItem, lhsStickerPackInfo, lhsCanManagePeerSpecificPack, lhsMaybeManageable, lhsTheme):
|
||||
if case let .sticker(rhsIndex, rhsStickerItem, rhsStickerPackInfo, rhsCanManagePeerSpecificPack, rhsMaybeManageable, rhsTheme) = rhs {
|
||||
if lhsIndex != rhsIndex {
|
||||
return false
|
||||
}
|
||||
@ -141,6 +141,9 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
|
||||
if lhsCanManagePeerSpecificPack != rhsCanManagePeerSpecificPack {
|
||||
return false
|
||||
}
|
||||
if lhsMaybeManageable != rhsMaybeManageable {
|
||||
return false
|
||||
}
|
||||
if lhsTheme !== rhsTheme {
|
||||
return false
|
||||
}
|
||||
@ -173,8 +176,8 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
|
||||
}, dismiss: dismissed ? nil : {
|
||||
inputNodeInteraction.dismissPeerSpecificSettings()
|
||||
})
|
||||
case let .sticker(index, stickerItem, stickerPackInfo, canManagePeerSpecificPack, theme):
|
||||
return ChatMediaInputStickerGridItem(account: account, collectionId: index.collectionId, stickerPackInfo: stickerPackInfo, index: index, stickerItem: stickerItem, canManagePeerSpecificPack: canManagePeerSpecificPack, interfaceInteraction: interfaceInteraction, inputNodeInteraction: inputNodeInteraction, theme: theme, selected: { })
|
||||
case let .sticker(index, stickerItem, stickerPackInfo, canManagePeerSpecificPack, maybeManageable, theme):
|
||||
return ChatMediaInputStickerGridItem(account: account, collectionId: index.collectionId, stickerPackInfo: stickerPackInfo, index: index, stickerItem: stickerItem, canManagePeerSpecificPack: canManagePeerSpecificPack, interfaceInteraction: interfaceInteraction, inputNodeInteraction: inputNodeInteraction, hasAccessory: maybeManageable, theme: theme, selected: { })
|
||||
case let .trending(entry):
|
||||
return entry.item(account: account, interaction: trendingInteraction, grid: false)
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ func preparedChatMediaInputGridEntryTransition(account: Account, view: ItemColle
|
||||
return ChatMediaInputGridTransition(deletions: deletions, insertions: insertions, updates: updates, updateFirstIndexInSectionOffset: firstIndexInSectionOffset, stationaryItems: stationaryItems, scrollToItem: scrollToItem, updateOpaqueState: opaqueState, animated: animated)
|
||||
}
|
||||
|
||||
func chatMediaInputPanelEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, hasUnreadTrending: Bool?, theme: PresentationTheme, hasGifs: Bool = true) -> [ChatMediaInputPanelEntry] {
|
||||
func chatMediaInputPanelEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, hasUnreadTrending: Bool?, theme: PresentationTheme, hasGifs: Bool = true, hasSettings: Bool = true) -> [ChatMediaInputPanelEntry] {
|
||||
var entries: [ChatMediaInputPanelEntry] = []
|
||||
if hasGifs {
|
||||
entries.append(.recentGifs(theme))
|
||||
@ -213,7 +213,9 @@ func chatMediaInputPanelEntries(view: ItemCollectionsView, savedStickers: Ordere
|
||||
entries.append(.peerSpecific(theme: theme, peer: peer))
|
||||
}
|
||||
|
||||
entries.append(.settings(theme))
|
||||
if hasSettings {
|
||||
entries.append(.settings(theme))
|
||||
}
|
||||
return entries
|
||||
}
|
||||
|
||||
@ -230,7 +232,7 @@ func chatMediaInputPanelGifModeEntries(theme: PresentationTheme, reactions: [Str
|
||||
return entries
|
||||
}
|
||||
|
||||
func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, hasSearch: Bool = true, strings: PresentationStrings, theme: PresentationTheme) -> [ChatMediaInputGridEntry] {
|
||||
func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, hasSearch: Bool = true, hasAccessories: Bool = true, strings: PresentationStrings, theme: PresentationTheme) -> [ChatMediaInputGridEntry] {
|
||||
var entries: [ChatMediaInputGridEntry] = []
|
||||
|
||||
if hasSearch && view.lower == nil {
|
||||
@ -253,7 +255,7 @@ func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: Ordered
|
||||
savedStickerIds.insert(item.file.fileId.id)
|
||||
let index = ItemCollectionItemIndex(index: Int32(i), id: item.file.fileId.id)
|
||||
let stickerItem = StickerPackItem(index: index, file: item.file, indexKeys: [])
|
||||
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -3, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, canManagePeerSpecificPack: nil, theme: theme))
|
||||
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -3, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, canManagePeerSpecificPack: nil, maybeManageable: hasAccessories, theme: theme))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,7 +271,7 @@ func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: Ordered
|
||||
if !savedStickerIds.contains(mediaId.id) {
|
||||
let index = ItemCollectionItemIndex(index: Int32(i), id: mediaId.id)
|
||||
let stickerItem = StickerPackItem(index: index, file: file, indexKeys: [])
|
||||
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -2, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, canManagePeerSpecificPack: nil, theme: theme))
|
||||
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -2, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, canManagePeerSpecificPack: nil, maybeManageable: hasAccessories, theme: theme))
|
||||
addedCount += 1
|
||||
}
|
||||
}
|
||||
@ -292,7 +294,7 @@ func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: Ordered
|
||||
if let item = peerSpecificPack.items[i] as? StickerPackItem {
|
||||
let index = ItemCollectionItemIndex(index: Int32(i), id: item.file.fileId.id)
|
||||
let stickerItem = StickerPackItem(index: index, file: item.file, indexKeys: [])
|
||||
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -1, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, canManagePeerSpecificPack: canManagePeerSpecificPack, theme: theme))
|
||||
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -1, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, canManagePeerSpecificPack: canManagePeerSpecificPack, maybeManageable: hasAccessories, theme: theme))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,7 +302,7 @@ func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: Ordered
|
||||
|
||||
for entry in view.entries {
|
||||
if let item = entry.item as? StickerPackItem {
|
||||
entries.append(.sticker(index: entry.index, stickerItem: item, stickerPackInfo: stickerPackInfos[entry.index.collectionId], canManagePeerSpecificPack: false, theme: theme))
|
||||
entries.append(.sticker(index: entry.index, stickerItem: item, stickerPackInfo: stickerPackInfos[entry.index.collectionId], canManagePeerSpecificPack: false, maybeManageable: hasAccessories, theme: theme))
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,6 +369,7 @@ final class ChatMediaInputNodeInteraction {
|
||||
var previewedStickerPackItem: StickerPreviewPeekItem?
|
||||
var appearanceTransition: CGFloat = 1.0
|
||||
var displayStickerPlaceholder = true
|
||||
var displayStickerPackManageControls = true
|
||||
|
||||
init(navigateToCollectionId: @escaping (ItemCollectionId) -> Void, navigateBackToStickers: @escaping () -> Void, setGifMode: @escaping (ChatMediaInputGifMode) -> Void, openSettings: @escaping () -> Void, toggleSearch: @escaping (Bool, ChatMediaInputSearchMode?, String) -> Void, openPeerSpecificSettings: @escaping () -> Void, dismissPeerSpecificSettings: @escaping () -> Void, clearRecentlyUsedStickers: @escaping () -> Void) {
|
||||
self.navigateToCollectionId = navigateToCollectionId
|
||||
|
@ -126,7 +126,7 @@ final class ChatMediaInputStickerGridItem: GridItem {
|
||||
|
||||
let section: GridSection?
|
||||
|
||||
init(account: Account, collectionId: ItemCollectionId, stickerPackInfo: StickerPackCollectionInfo?, index: ItemCollectionViewEntryIndex, stickerItem: StickerPackItem, canManagePeerSpecificPack: Bool?, interfaceInteraction: ChatControllerInteraction?, inputNodeInteraction: ChatMediaInputNodeInteraction, theme: PresentationTheme, selected: @escaping () -> Void) {
|
||||
init(account: Account, collectionId: ItemCollectionId, stickerPackInfo: StickerPackCollectionInfo?, index: ItemCollectionViewEntryIndex, stickerItem: StickerPackItem, canManagePeerSpecificPack: Bool?, interfaceInteraction: ChatControllerInteraction?, inputNodeInteraction: ChatMediaInputNodeInteraction, hasAccessory: Bool, theme: PresentationTheme, selected: @escaping () -> Void) {
|
||||
self.account = account
|
||||
self.index = index
|
||||
self.stickerItem = stickerItem
|
||||
@ -138,9 +138,9 @@ final class ChatMediaInputStickerGridItem: GridItem {
|
||||
self.section = nil
|
||||
} else {
|
||||
let accessory: ChatMediaInputStickerGridSectionAccessory
|
||||
if stickerPackInfo?.id.namespace == ChatMediaInputPanelAuxiliaryNamespace.peerSpecific.rawValue, let canManage = canManagePeerSpecificPack, canManage {
|
||||
if hasAccessory && stickerPackInfo?.id.namespace == ChatMediaInputPanelAuxiliaryNamespace.peerSpecific.rawValue, let canManage = canManagePeerSpecificPack, canManage {
|
||||
accessory = .setup
|
||||
} else if stickerPackInfo?.id.namespace == ChatMediaInputPanelAuxiliaryNamespace.recentStickers.rawValue {
|
||||
} else if hasAccessory && stickerPackInfo?.id.namespace == ChatMediaInputPanelAuxiliaryNamespace.recentStickers.rawValue {
|
||||
accessory = .clear
|
||||
} else {
|
||||
accessory = .none
|
||||
|
@ -585,8 +585,8 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
|
||||
}
|
||||
}
|
||||
|
||||
let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasUnreadTrending: nil, theme: theme, hasGifs: false)
|
||||
let gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasSearch: false, strings: strings, theme: theme)
|
||||
let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasUnreadTrending: nil, theme: theme, hasGifs: false, hasSettings: false)
|
||||
let gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasSearch: false, hasAccessories: false, strings: strings, theme: theme)
|
||||
|
||||
// if view.higher == nil {
|
||||
// var hasTopSeparator = true
|
||||
@ -636,8 +636,8 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
|
||||
installedPacks.insert(info.0)
|
||||
}
|
||||
|
||||
let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: nil, recentStickers: nil, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasUnreadTrending: nil, theme: theme, hasGifs: false)
|
||||
let gridEntries = chatMediaInputGridEntries(view: view, savedStickers: nil, recentStickers: nil, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasSearch: false, strings: strings, theme: theme)
|
||||
let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: nil, recentStickers: nil, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasUnreadTrending: nil, theme: theme, hasGifs: false, hasSettings: false)
|
||||
let gridEntries = chatMediaInputGridEntries(view: view, savedStickers: nil, recentStickers: nil, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasSearch: false, hasAccessories: false, strings: strings, theme: theme)
|
||||
|
||||
let (previousPanelEntries, previousGridEntries) = previousMaskEntries.swap((panelEntries, gridEntries))
|
||||
return (view, preparedChatMediaInputPanelEntryTransition(context: context, from: previousPanelEntries, to: panelEntries, inputNodeInteraction: masksInputNodeInteraction), previousPanelEntries.isEmpty, preparedChatMediaInputGridEntryTransition(account: context.account, view: view, from: previousGridEntries, to: gridEntries, update: update, interfaceInteraction: controllerInteraction, inputNodeInteraction: masksInputNodeInteraction, trendingInteraction: trendingInteraction), previousGridEntries.isEmpty)
|
||||
|
Loading…
x
Reference in New Issue
Block a user