mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-01 20:28:05 +00:00
Various fixes
This commit is contained in:
parent
fb50102b06
commit
bd8f2dae27
@ -468,6 +468,7 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem {
|
|||||||
let hasTopGroupInset: Bool
|
let hasTopGroupInset: Bool
|
||||||
let noInsets: Bool
|
let noInsets: Bool
|
||||||
let noCorners: Bool
|
let noCorners: Bool
|
||||||
|
let style: ItemListStyle
|
||||||
public let tag: ItemListItemTag?
|
public let tag: ItemListItemTag?
|
||||||
let header: ListViewItemHeader?
|
let header: ListViewItemHeader?
|
||||||
let shimmering: ItemListPeerItemShimmering?
|
let shimmering: ItemListPeerItemShimmering?
|
||||||
@ -508,6 +509,7 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem {
|
|||||||
hasTopGroupInset: Bool = true,
|
hasTopGroupInset: Bool = true,
|
||||||
noInsets: Bool = false,
|
noInsets: Bool = false,
|
||||||
noCorners: Bool = false,
|
noCorners: Bool = false,
|
||||||
|
style: ItemListStyle = .blocks,
|
||||||
tag: ItemListItemTag? = nil,
|
tag: ItemListItemTag? = nil,
|
||||||
header: ListViewItemHeader? = nil,
|
header: ListViewItemHeader? = nil,
|
||||||
shimmering: ItemListPeerItemShimmering? = nil,
|
shimmering: ItemListPeerItemShimmering? = nil,
|
||||||
@ -547,6 +549,7 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem {
|
|||||||
self.hasTopGroupInset = hasTopGroupInset
|
self.hasTopGroupInset = hasTopGroupInset
|
||||||
self.noInsets = noInsets
|
self.noInsets = noInsets
|
||||||
self.noCorners = noCorners
|
self.noCorners = noCorners
|
||||||
|
self.style = style
|
||||||
self.tag = tag
|
self.tag = tag
|
||||||
self.header = header
|
self.header = header
|
||||||
self.shimmering = shimmering
|
self.shimmering = shimmering
|
||||||
@ -588,6 +591,7 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem {
|
|||||||
hasTopGroupInset: Bool = true,
|
hasTopGroupInset: Bool = true,
|
||||||
noInsets: Bool = false,
|
noInsets: Bool = false,
|
||||||
noCorners: Bool = false,
|
noCorners: Bool = false,
|
||||||
|
style: ItemListStyle = .blocks,
|
||||||
tag: ItemListItemTag? = nil,
|
tag: ItemListItemTag? = nil,
|
||||||
header: ListViewItemHeader? = nil,
|
header: ListViewItemHeader? = nil,
|
||||||
shimmering: ItemListPeerItemShimmering? = nil,
|
shimmering: ItemListPeerItemShimmering? = nil,
|
||||||
@ -627,6 +631,7 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem {
|
|||||||
self.hasTopGroupInset = hasTopGroupInset
|
self.hasTopGroupInset = hasTopGroupInset
|
||||||
self.noInsets = noInsets
|
self.noInsets = noInsets
|
||||||
self.noCorners = noCorners
|
self.noCorners = noCorners
|
||||||
|
self.style = style
|
||||||
self.tag = tag
|
self.tag = tag
|
||||||
self.header = header
|
self.header = header
|
||||||
self.shimmering = shimmering
|
self.shimmering = shimmering
|
||||||
@ -889,7 +894,6 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
|
|||||||
|
|
||||||
return { item, params, neighbors, headerAtTop in
|
return { item, params, neighbors, headerAtTop in
|
||||||
var updateArrowImage: UIImage?
|
var updateArrowImage: UIImage?
|
||||||
var updatedTheme: PresentationTheme?
|
|
||||||
|
|
||||||
let statusFontSize: CGFloat = floor(item.presentationData.fontSize.itemListBaseFontSize * 14.0 / 17.0)
|
let statusFontSize: CGFloat = floor(item.presentationData.fontSize.itemListBaseFontSize * 14.0 / 17.0)
|
||||||
let labelFontSize: CGFloat = floor(item.presentationData.fontSize.itemListBaseFontSize * 13.0 / 17.0)
|
let labelFontSize: CGFloat = floor(item.presentationData.fontSize.itemListBaseFontSize * 13.0 / 17.0)
|
||||||
@ -938,7 +942,6 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
|
|||||||
|
|
||||||
let badgeDiameter: CGFloat = 20.0
|
let badgeDiameter: CGFloat = 20.0
|
||||||
if currentItem?.presentationData.theme !== item.presentationData.theme {
|
if currentItem?.presentationData.theme !== item.presentationData.theme {
|
||||||
updatedTheme = item.presentationData.theme
|
|
||||||
updateArrowImage = PresentationResourcesItemList.disclosureArrowImage(item.presentationData.theme)
|
updateArrowImage = PresentationResourcesItemList.disclosureArrowImage(item.presentationData.theme)
|
||||||
if let badgeColor = badgeColor {
|
if let badgeColor = badgeColor {
|
||||||
updatedLabelBadgeImage = generateStretchableFilledCircleImage(diameter: badgeDiameter, color: badgeColor)
|
updatedLabelBadgeImage = generateStretchableFilledCircleImage(diameter: badgeDiameter, color: badgeColor)
|
||||||
@ -1247,13 +1250,22 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
|
|||||||
strongSelf.labelArrowNode?.image = updateArrowImage
|
strongSelf.labelArrowNode?.image = updateArrowImage
|
||||||
}
|
}
|
||||||
|
|
||||||
if let _ = updatedTheme {
|
let itemBackgroundColor: UIColor
|
||||||
strongSelf.topStripeNode.backgroundColor = item.presentationData.theme.list.itemBlocksSeparatorColor
|
let itemSeparatorColor: UIColor
|
||||||
strongSelf.bottomStripeNode.backgroundColor = item.presentationData.theme.list.itemBlocksSeparatorColor
|
switch item.style {
|
||||||
strongSelf.backgroundNode.backgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor
|
case .plain:
|
||||||
strongSelf.highlightedBackgroundNode.backgroundColor = item.presentationData.theme.list.itemHighlightedBackgroundColor
|
itemBackgroundColor = item.presentationData.theme.list.plainBackgroundColor
|
||||||
|
itemSeparatorColor = item.presentationData.theme.list.itemPlainSeparatorColor
|
||||||
|
case .blocks:
|
||||||
|
itemBackgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor
|
||||||
|
itemSeparatorColor = item.presentationData.theme.list.itemBlocksSeparatorColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strongSelf.topStripeNode.backgroundColor = itemSeparatorColor
|
||||||
|
strongSelf.bottomStripeNode.backgroundColor = itemSeparatorColor
|
||||||
|
strongSelf.backgroundNode.backgroundColor = itemBackgroundColor
|
||||||
|
strongSelf.highlightedBackgroundNode.backgroundColor = item.presentationData.theme.list.itemHighlightedBackgroundColor
|
||||||
|
|
||||||
let revealOffset = strongSelf.revealOffset
|
let revealOffset = strongSelf.revealOffset
|
||||||
|
|
||||||
let transition: ContainedViewLayoutTransition
|
let transition: ContainedViewLayoutTransition
|
||||||
|
|||||||
@ -108,6 +108,17 @@ public enum ChatHistoryEntry: Identifiable, Comparable {
|
|||||||
return MessageIndex.absoluteLowerBound()
|
return MessageIndex.absoluteLowerBound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var timestamp: Int32? {
|
||||||
|
switch self {
|
||||||
|
case let .MessageEntry(message, _, _, _, _, _):
|
||||||
|
return message.timestamp
|
||||||
|
case let .MessageGroupEntry(_, messages, _):
|
||||||
|
return messages[0].0.timestamp
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static func ==(lhs: ChatHistoryEntry, rhs: ChatHistoryEntry) -> Bool {
|
public static func ==(lhs: ChatHistoryEntry, rhs: ChatHistoryEntry) -> Bool {
|
||||||
switch lhs {
|
switch lhs {
|
||||||
|
|||||||
@ -44,7 +44,7 @@ private struct GroupsInCommonListEntry: Comparable, Identifiable {
|
|||||||
}, removePeer: { _ in
|
}, removePeer: { _ in
|
||||||
}, contextAction: { node, gesture in
|
}, contextAction: { node, gesture in
|
||||||
openPeerContextAction(peer, node, gesture)
|
openPeerContextAction(peer, node, gesture)
|
||||||
}, hasTopStripe: false, noInsets: true, noCorners: true)
|
}, hasTopStripe: false, noInsets: true, noCorners: true, style: .plain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,7 @@ private enum RecommendedChannelsListEntry: Comparable, Identifiable {
|
|||||||
}, removePeer: { _ in
|
}, removePeer: { _ in
|
||||||
}, contextAction: { node, gesture in
|
}, contextAction: { node, gesture in
|
||||||
openPeerContextAction(peer._asPeer(), node, gesture)
|
openPeerContextAction(peer._asPeer(), node, gesture)
|
||||||
}, hasTopStripe: false, noInsets: true, noCorners: true, disableInteractiveTransitionIfNecessary: true)
|
}, hasTopStripe: false, noInsets: true, noCorners: true, style: .plain, disableInteractiveTransitionIfNecessary: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ final class PeerInfoRecommendedChannelsPaneNode: ASDisplayNode, PeerInfoPaneNode
|
|||||||
private var unlockText: ComponentView<Empty>?
|
private var unlockText: ComponentView<Empty>?
|
||||||
private var unlockButton: SolidRoundedButtonNode?
|
private var unlockButton: SolidRoundedButtonNode?
|
||||||
|
|
||||||
private var currentParams: (size: CGSize, sideInset: CGFloat, bottomInset: CGFloat, isScrollingLockedAtTop: Bool)?
|
private var currentParams: (size: CGSize, sideInset: CGFloat, bottomInset: CGFloat, isScrollingLockedAtTop: Bool, presentationData: PresentationData)?
|
||||||
|
|
||||||
private var theme: PresentationTheme?
|
private var theme: PresentationTheme?
|
||||||
private let presentationDataPromise = Promise<PresentationData>()
|
private let presentationDataPromise = Promise<PresentationData>()
|
||||||
@ -190,7 +190,7 @@ final class PeerInfoRecommendedChannelsPaneNode: ASDisplayNode, PeerInfoPaneNode
|
|||||||
|
|
||||||
func update(size: CGSize, topInset: CGFloat, sideInset: CGFloat, bottomInset: CGFloat, visibleHeight: CGFloat, isScrollingLockedAtTop: Bool, expandProgress: CGFloat, presentationData: PresentationData, synchronous: Bool, transition: ContainedViewLayoutTransition) {
|
func update(size: CGSize, topInset: CGFloat, sideInset: CGFloat, bottomInset: CGFloat, visibleHeight: CGFloat, isScrollingLockedAtTop: Bool, expandProgress: CGFloat, presentationData: PresentationData, synchronous: Bool, transition: ContainedViewLayoutTransition) {
|
||||||
let isFirstLayout = self.currentParams == nil
|
let isFirstLayout = self.currentParams == nil
|
||||||
self.currentParams = (size, sideInset, bottomInset, isScrollingLockedAtTop)
|
self.currentParams = (size, sideInset, bottomInset, isScrollingLockedAtTop, presentationData)
|
||||||
self.presentationDataPromise.set(.single(presentationData))
|
self.presentationDataPromise.set(.single(presentationData))
|
||||||
|
|
||||||
transition.updateFrame(node: self.listNode, frame: CGRect(origin: CGPoint(), size: size))
|
transition.updateFrame(node: self.listNode, frame: CGRect(origin: CGPoint(), size: size))
|
||||||
@ -237,10 +237,19 @@ final class PeerInfoRecommendedChannelsPaneNode: ASDisplayNode, PeerInfoPaneNode
|
|||||||
self.enqueuedTransactions.append(transaction)
|
self.enqueuedTransactions.append(transaction)
|
||||||
self.dequeueTransaction()
|
self.dequeueTransaction()
|
||||||
|
|
||||||
|
self.layoutUnlockPanel()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func layoutUnlockPanel() {
|
||||||
|
guard let (_, isPremium) = self.currentState, let currentParams = self.currentParams else {
|
||||||
|
return
|
||||||
|
}
|
||||||
if !isPremium {
|
if !isPremium {
|
||||||
guard let size = self.currentParams?.size, let sideInset = self.currentParams?.sideInset, let bottomInset = self.currentParams?.bottomInset else {
|
let size = currentParams.size
|
||||||
return
|
let sideInset = currentParams.sideInset
|
||||||
}
|
let bottomInset = currentParams.bottomInset
|
||||||
|
let presentationData = currentParams.presentationData
|
||||||
|
|
||||||
let themeUpdated = self.theme !== presentationData.theme
|
let themeUpdated = self.theme !== presentationData.theme
|
||||||
self.theme = presentationData.theme
|
self.theme = presentationData.theme
|
||||||
|
|
||||||
@ -281,13 +290,12 @@ final class PeerInfoRecommendedChannelsPaneNode: ASDisplayNode, PeerInfoPaneNode
|
|||||||
}
|
}
|
||||||
|
|
||||||
if themeUpdated {
|
if themeUpdated {
|
||||||
let topColor = presentationData.theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.0)
|
let topColor = presentationData.theme.list.plainBackgroundColor.withAlphaComponent(0.0)
|
||||||
let bottomColor = presentationData.theme.list.itemBlocksBackgroundColor
|
let bottomColor = presentationData.theme.list.plainBackgroundColor
|
||||||
unlockBackground.image = generateGradientImage(size: CGSize(width: 1.0, height: 170.0), colors: [topColor, bottomColor, bottomColor], locations: [0.0, 0.3, 1.0])
|
unlockBackground.image = generateGradientImage(size: CGSize(width: 1.0, height: 170.0), colors: [topColor, bottomColor, bottomColor], locations: [0.0, 0.3, 1.0])
|
||||||
unlockButton.updateTheme(SolidRoundedButtonTheme(theme: presentationData.theme))
|
unlockButton.updateTheme(SolidRoundedButtonTheme(theme: presentationData.theme))
|
||||||
}
|
}
|
||||||
|
|
||||||
let presentationData = self.context.sharedContext.currentPresentationData.with { $0 }
|
|
||||||
let textFont = Font.regular(15.0)
|
let textFont = Font.regular(15.0)
|
||||||
let boldTextFont = Font.semibold(15.0)
|
let boldTextFont = Font.semibold(15.0)
|
||||||
let textColor = presentationData.theme.list.itemSecondaryTextColor
|
let textColor = presentationData.theme.list.itemSecondaryTextColor
|
||||||
@ -296,6 +304,11 @@ final class PeerInfoRecommendedChannelsPaneNode: ASDisplayNode, PeerInfoPaneNode
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var scrollOffset: CGFloat = 0.0
|
||||||
|
if case let .known(offset) = self.listNode.visibleBottomContentOffset() {
|
||||||
|
scrollOffset = min(0.0, offset + bottomInset + 80.0)
|
||||||
|
}
|
||||||
|
|
||||||
let unlockSize = unlockText.update(
|
let unlockSize = unlockText.update(
|
||||||
transition: .immediate,
|
transition: .immediate,
|
||||||
component: AnyComponent(
|
component: AnyComponent(
|
||||||
@ -314,14 +327,14 @@ final class PeerInfoRecommendedChannelsPaneNode: ASDisplayNode, PeerInfoPaneNode
|
|||||||
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.unlockPressed)))
|
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.unlockPressed)))
|
||||||
self.view.addSubview(view)
|
self.view.addSubview(view)
|
||||||
}
|
}
|
||||||
view.frame = CGRect(origin: CGPoint(x: floor((size.width - unlockSize.width) / 2.0), y: size.height - bottomInset - unlockSize.height - 13.0), size: unlockSize)
|
view.frame = CGRect(origin: CGPoint(x: floor((size.width - unlockSize.width) / 2.0), y: size.height - bottomInset - unlockSize.height - 13.0 + scrollOffset), size: unlockSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
unlockBackground.frame = CGRect(x: 0.0, y: size.height - bottomInset - 170.0, width: size.width, height: bottomInset + 170.0)
|
unlockBackground.frame = CGRect(x: 0.0, y: size.height - bottomInset - 170.0 + scrollOffset, width: size.width, height: bottomInset + 170.0)
|
||||||
|
|
||||||
let buttonSideInset = sideInset + 16.0
|
let buttonSideInset = sideInset + 16.0
|
||||||
let buttonSize = CGSize(width: size.width - buttonSideInset * 2.0, height: 50.0)
|
let buttonSize = CGSize(width: size.width - buttonSideInset * 2.0, height: 50.0)
|
||||||
unlockButton.frame = CGRect(origin: CGPoint(x: buttonSideInset, y: size.height - bottomInset - unlockSize.height - buttonSize.height - 26.0), size: buttonSize)
|
unlockButton.frame = CGRect(origin: CGPoint(x: buttonSideInset, y: size.height - bottomInset - unlockSize.height - buttonSize.height - 26.0 + scrollOffset), size: buttonSize)
|
||||||
let _ = unlockButton.updateLayout(width: buttonSize.width, transition: .immediate)
|
let _ = unlockButton.updateLayout(width: buttonSize.width, transition: .immediate)
|
||||||
} else {
|
} else {
|
||||||
self.unlockBackground?.removeFromSuperview()
|
self.unlockBackground?.removeFromSuperview()
|
||||||
|
|||||||
@ -131,12 +131,6 @@ func chatHistoryEntriesForView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let maybeJoinMessage = joinMessage {
|
|
||||||
if message.timestamp > maybeJoinMessage.timestamp, (!view.holeEarlier || count > 0) {
|
|
||||||
entries.append(.MessageEntry(maybeJoinMessage, presentationData, false, nil, .none, ChatMessageEntryAttributes(rank: nil, isContact: false, contentTypeHint: .generic, updatingMedia: nil, isPlaying: false, isCentered: false, authorStoryStats: nil)))
|
|
||||||
joinMessage = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
if let customThreadOutgoingReadState = customThreadOutgoingReadState {
|
if let customThreadOutgoingReadState = customThreadOutgoingReadState {
|
||||||
@ -234,7 +228,7 @@ func chatHistoryEntriesForView(
|
|||||||
entries.append(.MessageEntry(message, presentationData, isRead, entry.location, selection, ChatMessageEntryAttributes(rank: adminRank, isContact: entry.attributes.authorIsContact, contentTypeHint: contentTypeHint, updatingMedia: updatingMedia[message.id], isPlaying: message.index == associatedData.currentlyPlayingMessageId, isCentered: false, authorStoryStats: message.author.flatMap { view.peerStoryStats[$0.id] })))
|
entries.append(.MessageEntry(message, presentationData, isRead, entry.location, selection, ChatMessageEntryAttributes(rank: adminRank, isContact: entry.attributes.authorIsContact, contentTypeHint: contentTypeHint, updatingMedia: updatingMedia[message.id], isPlaying: message.index == associatedData.currentlyPlayingMessageId, isCentered: false, authorStoryStats: message.author.flatMap { view.peerStoryStats[$0.id] })))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !groupBucket.isEmpty {
|
if !groupBucket.isEmpty {
|
||||||
assert(groupMessages || reverseGroupedMessages)
|
assert(groupMessages || reverseGroupedMessages)
|
||||||
if reverseGroupedMessages {
|
if reverseGroupedMessages {
|
||||||
@ -253,11 +247,25 @@ func chatHistoryEntriesForView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let maybeJoinMessage = joinMessage, !view.holeLater {
|
if let lowerTimestamp = view.entries.last?.message.timestamp, let upperTimestamp = view.entries.first?.message.timestamp {
|
||||||
entries.append(.MessageEntry(maybeJoinMessage, presentationData, false, nil, .none, ChatMessageEntryAttributes(rank: nil, isContact: false, contentTypeHint: .generic, updatingMedia: nil, isPlaying: false, isCentered: false, authorStoryStats: nil)))
|
if let joinMessage {
|
||||||
joinMessage = nil
|
var insertAtPosition: Int?
|
||||||
|
if joinMessage.timestamp >= lowerTimestamp && view.laterId == nil {
|
||||||
|
insertAtPosition = entries.count
|
||||||
|
} else if joinMessage.timestamp < lowerTimestamp && joinMessage.timestamp > upperTimestamp {
|
||||||
|
for i in 0 ..< entries.count {
|
||||||
|
if let timestamp = entries[i].timestamp, timestamp > joinMessage.timestamp {
|
||||||
|
insertAtPosition = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let insertAtPosition {
|
||||||
|
entries.insert(.MessageEntry(joinMessage, presentationData, false, nil, .none, ChatMessageEntryAttributes(rank: nil, isContact: false, contentTypeHint: .generic, updatingMedia: nil, isPlaying: false, isCentered: false, authorStoryStats: nil)), at: insertAtPosition)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let maxReadIndex = view.maxReadIndex, includeUnreadEntry {
|
if let maxReadIndex = view.maxReadIndex, includeUnreadEntry {
|
||||||
var i = 0
|
var i = 0
|
||||||
let unreadEntry: ChatHistoryEntry = .UnreadEntry(maxReadIndex, presentationData)
|
let unreadEntry: ChatHistoryEntry = .UnreadEntry(maxReadIndex, presentationData)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user