Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-08-31 13:08:46 +03:00
parent 8aefa19d31
commit dacdd9e1ae
4 changed files with 28 additions and 20 deletions

View File

@ -162,7 +162,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) 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?, temporaryPackOrder: [ItemCollectionId]? = nil, trendingIsDismissed: Bool = false, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, theme: PresentationTheme, strings: PresentationStrings, hasGifs: Bool = true, hasSettings: Bool = true, expanded: Bool = false) -> [ChatMediaInputPanelEntry] { func chatMediaInputPanelEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, temporaryPackOrder: [ItemCollectionId]? = nil, trendingIsDismissed: Bool = false, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, theme: PresentationTheme, strings: PresentationStrings, hasGifs: Bool = true, hasSettings: Bool = true, expanded: Bool = false, reorderable: Bool = false) -> [ChatMediaInputPanelEntry] {
var entries: [ChatMediaInputPanelEntry] = [] var entries: [ChatMediaInputPanelEntry] = []
if hasGifs { if hasGifs {
entries.append(.recentGifs(theme, strings, expanded)) entries.append(.recentGifs(theme, strings, expanded))
@ -227,7 +227,7 @@ func chatMediaInputPanelEntries(view: ItemCollectionsView, savedStickers: Ordere
} }
for (_, info, topItem) in sortedPacks { for (_, info, topItem) in sortedPacks {
entries.append(.stickerPack(index: index, info: info, topItem: topItem, theme: theme, expanded: expanded)) entries.append(.stickerPack(index: index, info: info, topItem: topItem, theme: theme, expanded: expanded, reorderable: reorderable))
index += 1 index += 1
} }
@ -624,7 +624,7 @@ final class ChatMediaInputNode: ChatInputNode {
self?.lastReorderItemIndex = toIndex self?.lastReorderItemIndex = toIndex
let fromEntry = entries[fromIndex] let fromEntry = entries[fromIndex]
guard case let .stickerPack(_, fromPackInfo, _, _, _) = fromEntry else { guard case let .stickerPack(_, fromPackInfo, _, _, _, _) = fromEntry else {
return .single(false) return .single(false)
} }
var referenceId: ItemCollectionId? var referenceId: ItemCollectionId?
@ -632,7 +632,7 @@ final class ChatMediaInputNode: ChatInputNode {
var afterAll = false var afterAll = false
if toIndex < entries.count { if toIndex < entries.count {
switch entries[toIndex] { switch entries[toIndex] {
case let .stickerPack(_, toPackInfo, _, _, _): case let .stickerPack(_, toPackInfo, _, _, _, _):
referenceId = toPackInfo.id referenceId = toPackInfo.id
default: default:
if entries[toIndex] < fromEntry { if entries[toIndex] < fromEntry {
@ -648,7 +648,7 @@ final class ChatMediaInputNode: ChatInputNode {
var currentIds: [ItemCollectionId] = [] var currentIds: [ItemCollectionId] = []
for entry in entries { for entry in entries {
switch entry { switch entry {
case let .stickerPack(_, info, _, _, _): case let .stickerPack(_, info, _, _, _, _):
currentIds.append(info.id) currentIds.append(info.id)
default: default:
break break
@ -705,7 +705,7 @@ final class ChatMediaInputNode: ChatInputNode {
var currentIds: [ItemCollectionId] = [] var currentIds: [ItemCollectionId] = []
for entry in entries { for entry in entries {
switch entry { switch entry {
case let .stickerPack(_, info, _, _, _): case let .stickerPack(_, info, _, _, _, _):
currentIds.append(info.id) currentIds.append(info.id)
default: default:
break break
@ -1139,7 +1139,7 @@ final class ChatMediaInputNode: ChatInputNode {
trendingIsDismissed = true trendingIsDismissed = true
} }
let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, temporaryPackOrder: temporaryPackOrder, trendingIsDismissed: trendingIsDismissed, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, theme: theme, strings: strings, expanded: panelExpanded) let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, temporaryPackOrder: temporaryPackOrder, trendingIsDismissed: trendingIsDismissed, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, theme: theme, strings: strings, expanded: panelExpanded, reorderable: true)
let gifPaneEntries = chatMediaInputPanelGifModeEntries(theme: theme, strings: strings, reactions: reactions, animatedEmojiStickers: animatedEmojiStickers, expanded: panelExpanded) let gifPaneEntries = chatMediaInputPanelGifModeEntries(theme: theme, strings: strings, reactions: reactions, animatedEmojiStickers: animatedEmojiStickers, expanded: panelExpanded)
var gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, trendingPacks: trendingPacks, installedPacks: installedPacks, trendingIsDismissed: trendingIsDismissed, strings: strings, theme: theme) var gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, trendingPacks: trendingPacks, installedPacks: installedPacks, trendingIsDismissed: trendingIsDismissed, strings: strings, theme: theme)

View File

@ -37,7 +37,7 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable {
case trending(Bool, PresentationTheme, PresentationStrings, Bool) case trending(Bool, PresentationTheme, PresentationStrings, Bool)
case settings(PresentationTheme, PresentationStrings, Bool) case settings(PresentationTheme, PresentationStrings, Bool)
case peerSpecific(theme: PresentationTheme, peer: Peer, expanded: Bool) case peerSpecific(theme: PresentationTheme, peer: Peer, expanded: Bool)
case stickerPack(index: Int, info: StickerPackCollectionInfo, topItem: StickerPackItem?, theme: PresentationTheme, expanded: Bool) case stickerPack(index: Int, info: StickerPackCollectionInfo, topItem: StickerPackItem?, theme: PresentationTheme, expanded: Bool, reorderable: Bool)
case stickersMode(PresentationTheme, PresentationStrings, Bool) case stickersMode(PresentationTheme, PresentationStrings, Bool)
case savedGifs(PresentationTheme, PresentationStrings, Bool) case savedGifs(PresentationTheme, PresentationStrings, Bool)
@ -58,7 +58,7 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable {
return .settings return .settings
case .peerSpecific: case .peerSpecific:
return .peerSpecific return .peerSpecific
case let .stickerPack(_, info, _, _, _): case let .stickerPack(_, info, _, _, _, _):
return .stickerPack(info.id.id) return .stickerPack(info.id.id)
case .stickersMode: case .stickersMode:
return .stickersMode return .stickersMode
@ -109,8 +109,8 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable {
} else { } else {
return false return false
} }
case let .stickerPack(index, info, topItem, lhsTheme, lhsExpanded): case let .stickerPack(index, info, topItem, lhsTheme, lhsExpanded, lhsReorderable):
if case let .stickerPack(rhsIndex, rhsInfo, rhsTopItem, rhsTheme, rhsExpanded) = rhs, index == rhsIndex, info == rhsInfo, topItem == rhsTopItem, lhsTheme === rhsTheme, lhsExpanded == rhsExpanded { if case let .stickerPack(rhsIndex, rhsInfo, rhsTopItem, rhsTheme, rhsExpanded, rhsReorderable) = rhs, index == rhsIndex, info == rhsInfo, topItem == rhsTopItem, lhsTheme === rhsTheme, lhsExpanded == rhsExpanded, lhsReorderable == rhsReorderable {
return true return true
} else { } else {
return false return false
@ -134,7 +134,7 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable {
return false return false
} }
case let .gifEmotion(lhsIndex, lhsTheme, lhsStrings, lhsEmoji, lhsFile, lhsExpanded): case let .gifEmotion(lhsIndex, lhsTheme, lhsStrings, lhsEmoji, lhsFile, lhsExpanded):
if case let .gifEmotion(rhsIndex, rhsTheme, rhsStrings, rhsEmoji, rhsFile, rhsExpanded) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsEmoji == rhsEmoji, lhsExpanded == rhsExpanded { if case let .gifEmotion(rhsIndex, rhsTheme, rhsStrings, rhsEmoji, rhsFile, rhsExpanded) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsEmoji == rhsEmoji, lhsExpanded == rhsExpanded {
if let lhsFile = lhsFile, let rhsFile = rhsFile { if let lhsFile = lhsFile, let rhsFile = rhsFile {
if !lhsFile.isEqual(to: rhsFile) { if !lhsFile.isEqual(to: rhsFile) {
return false return false
@ -185,7 +185,7 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable {
default: default:
return true return true
} }
case let .stickerPack(lhsIndex, lhsInfo, _, _, _): case let .stickerPack(lhsIndex, lhsInfo, _, _, _, _):
switch rhs { switch rhs {
case .recentGifs, .savedStickers, .recentPacks, .peerSpecific: case .recentGifs, .savedStickers, .recentPacks, .peerSpecific:
return false return false
@ -197,7 +197,7 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable {
} }
case .settings: case .settings:
return true return true
case let .stickerPack(rhsIndex, rhsInfo, _, _, _): case let .stickerPack(rhsIndex, rhsInfo, _, _, _, _):
if lhsIndex == rhsIndex { if lhsIndex == rhsIndex {
return lhsInfo.id.id < rhsInfo.id.id return lhsInfo.id.id < rhsInfo.id.id
} else { } else {
@ -286,8 +286,8 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable {
return ChatMediaInputPeerSpecificItem(context: context, inputNodeInteraction: inputNodeInteraction, collectionId: collectionId, peer: peer, theme: theme, expanded: expanded, selected: { return ChatMediaInputPeerSpecificItem(context: context, inputNodeInteraction: inputNodeInteraction, collectionId: collectionId, peer: peer, theme: theme, expanded: expanded, selected: {
inputNodeInteraction.navigateToCollectionId(collectionId) inputNodeInteraction.navigateToCollectionId(collectionId)
}) })
case let .stickerPack(index, info, topItem, theme, expanded): case let .stickerPack(index, info, topItem, theme, expanded, reorderable):
return ChatMediaInputStickerPackItem(account: context.account, inputNodeInteraction: inputNodeInteraction, collectionId: info.id, collectionInfo: info, stickerPackItem: topItem, index: index, theme: theme, expanded: expanded, selected: { return ChatMediaInputStickerPackItem(account: context.account, inputNodeInteraction: inputNodeInteraction, collectionId: info.id, collectionInfo: info, stickerPackItem: topItem, index: index, theme: theme, expanded: expanded, reorderable: reorderable, selected: {
inputNodeInteraction.navigateToCollectionId(info.id) inputNodeInteraction.navigateToCollectionId(info.id)
}) })
case let .stickersMode(theme, strings, expanded): case let .stickersMode(theme, strings, expanded):

View File

@ -22,12 +22,13 @@ final class ChatMediaInputStickerPackItem: ListViewItem {
let index: Int let index: Int
let theme: PresentationTheme let theme: PresentationTheme
let expanded: Bool let expanded: Bool
let reorderable: Bool
var selectable: Bool { var selectable: Bool {
return true return true
} }
init(account: Account, inputNodeInteraction: ChatMediaInputNodeInteraction, collectionId: ItemCollectionId, collectionInfo: StickerPackCollectionInfo, stickerPackItem: StickerPackItem?, index: Int, theme: PresentationTheme, expanded: Bool, selected: @escaping () -> Void) { init(account: Account, inputNodeInteraction: ChatMediaInputNodeInteraction, collectionId: ItemCollectionId, collectionInfo: StickerPackCollectionInfo, stickerPackItem: StickerPackItem?, index: Int, theme: PresentationTheme, expanded: Bool, reorderable: Bool, selected: @escaping () -> Void) {
self.account = account self.account = account
self.inputNodeInteraction = inputNodeInteraction self.inputNodeInteraction = inputNodeInteraction
self.collectionId = collectionId self.collectionId = collectionId
@ -37,6 +38,7 @@ final class ChatMediaInputStickerPackItem: ListViewItem {
self.index = index self.index = index
self.theme = theme self.theme = theme
self.expanded = expanded self.expanded = expanded
self.reorderable = reorderable
} }
func nodeConfiguredForParams(async: @escaping (@escaping () -> Void) -> Void, params: ListViewItemLayoutParams, synchronousLoads: Bool, previousItem: ListViewItem?, nextItem: ListViewItem?, completion: @escaping (ListViewItemNode, @escaping () -> (Signal<Void, NoError>?, (ListViewItemApply) -> Void)) -> Void) { func nodeConfiguredForParams(async: @escaping (@escaping () -> Void) -> Void, params: ListViewItemLayoutParams, synchronousLoads: Bool, previousItem: ListViewItem?, nextItem: ListViewItem?, completion: @escaping (ListViewItemNode, @escaping () -> (Signal<Void, NoError>?, (ListViewItemApply) -> Void)) -> Void) {
@ -48,7 +50,7 @@ final class ChatMediaInputStickerPackItem: ListViewItem {
Queue.mainQueue().async { Queue.mainQueue().async {
completion(node, { completion(node, {
return (nil, { _ in return (nil, { _ in
node.updateStickerPackItem(account: self.account, info: self.collectionInfo, item: self.stickerPackItem, collectionId: self.collectionId, theme: self.theme, expanded: self.expanded) node.updateStickerPackItem(account: self.account, info: self.collectionInfo, item: self.stickerPackItem, collectionId: self.collectionId, theme: self.theme, expanded: self.expanded, reorderable: self.reorderable)
node.updateAppearanceTransition(transition: .immediate) node.updateAppearanceTransition(transition: .immediate)
}) })
}) })
@ -59,7 +61,7 @@ final class ChatMediaInputStickerPackItem: ListViewItem {
public func updateNode(async: @escaping (@escaping () -> Void) -> Void, node: @escaping () -> ListViewItemNode, params: ListViewItemLayoutParams, previousItem: ListViewItem?, nextItem: ListViewItem?, animation: ListViewItemUpdateAnimation, completion: @escaping (ListViewItemNodeLayout, @escaping (ListViewItemApply) -> Void) -> Void) { public func updateNode(async: @escaping (@escaping () -> Void) -> Void, node: @escaping () -> ListViewItemNode, params: ListViewItemLayoutParams, previousItem: ListViewItem?, nextItem: ListViewItem?, animation: ListViewItemUpdateAnimation, completion: @escaping (ListViewItemNodeLayout, @escaping (ListViewItemApply) -> Void) -> Void) {
Queue.mainQueue().async { Queue.mainQueue().async {
completion(ListViewItemNodeLayout(contentSize: self.expanded ? expandedBoundingSize : boundingSize, insets: ChatMediaInputNode.setupPanelIconInsets(item: self, previousItem: previousItem, nextItem: nextItem)), { _ in completion(ListViewItemNodeLayout(contentSize: self.expanded ? expandedBoundingSize : boundingSize, insets: ChatMediaInputNode.setupPanelIconInsets(item: self, previousItem: previousItem, nextItem: nextItem)), { _ in
(node() as? ChatMediaInputStickerPackItemNode)?.updateStickerPackItem(account: self.account, info: self.collectionInfo, item: self.stickerPackItem, collectionId: self.collectionId, theme: self.theme, expanded: self.expanded) (node() as? ChatMediaInputStickerPackItemNode)?.updateStickerPackItem(account: self.account, info: self.collectionInfo, item: self.stickerPackItem, collectionId: self.collectionId, theme: self.theme, expanded: self.expanded, reorderable: self.reorderable)
}) })
} }
} }
@ -91,6 +93,7 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode {
private var currentThumbnailItem: StickerPackThumbnailItem? private var currentThumbnailItem: StickerPackThumbnailItem?
private var currentExpanded = false private var currentExpanded = false
private var theme: PresentationTheme? private var theme: PresentationTheme?
private var reorderable = false
private let stickerFetchedDisposable = MetaDisposable() private let stickerFetchedDisposable = MetaDisposable()
@ -171,9 +174,10 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode {
} }
} }
func updateStickerPackItem(account: Account, info: StickerPackCollectionInfo, item: StickerPackItem?, collectionId: ItemCollectionId, theme: PresentationTheme, expanded: Bool) { func updateStickerPackItem(account: Account, info: StickerPackCollectionInfo, item: StickerPackItem?, collectionId: ItemCollectionId, theme: PresentationTheme, expanded: Bool, reorderable: Bool) {
self.currentCollectionId = collectionId self.currentCollectionId = collectionId
self.account = account self.account = account
self.reorderable = reorderable
var themeUpdated = false var themeUpdated = false
if self.theme !== theme { if self.theme !== theme {
self.theme = theme self.theme = theme
@ -319,6 +323,9 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode {
} }
override func isReorderable(at point: CGPoint) -> Bool { override func isReorderable(at point: CGPoint) -> Bool {
guard self.reorderable else {
return false
}
if self.bounds.inset(by: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: -28.0)).contains(point) { if self.bounds.inset(by: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: -28.0)).contains(point) {
return true return true
} }

View File

@ -62,6 +62,7 @@ final class WebpagePreviewAccessoryPanelNode: AccessoryPanelNode {
self.addSubnode(self.closeButton) self.addSubnode(self.closeButton)
self.addSubnode(self.lineNode) self.addSubnode(self.lineNode)
self.addSubnode(self.iconNode)
self.addSubnode(self.titleNode) self.addSubnode(self.titleNode)
self.addSubnode(self.textNode) self.addSubnode(self.textNode)