mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Chart fixes
This commit is contained in:
parent
0453d6f933
commit
eedcd225f0
@ -160,6 +160,8 @@ public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder:
|
|||||||
}
|
}
|
||||||
case let poll as TelegramMediaPoll:
|
case let poll as TelegramMediaPoll:
|
||||||
messageText = "📊 \(poll.text)"
|
messageText = "📊 \(poll.text)"
|
||||||
|
case _ as TelegramMediaDice:
|
||||||
|
messageText = "🎲"
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ public class BaseLinesChartController: BaseChartController {
|
|||||||
|
|
||||||
func setupChartCollection(chartsCollection: ChartsCollection, animated: Bool, isZoomed: Bool) {
|
func setupChartCollection(chartsCollection: ChartsCollection, animated: Bool, isZoomed: Bool) {
|
||||||
if animated {
|
if animated {
|
||||||
TimeInterval.setDefaultSuration(.expandAnimationDuration)
|
TimeInterval.setDefaultDuration(.expandAnimationDuration)
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + .expandAnimationDuration) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + .expandAnimationDuration) {
|
||||||
TimeInterval.setDefaultSuration(.osXDuration)
|
TimeInterval.setDefaultDuration(.osXDuration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,9 +104,9 @@ public class PercentPieChartController: BaseChartController {
|
|||||||
|
|
||||||
func switchToChart(chartsCollection: ChartsCollection, isZoomed: Bool, animated: Bool) {
|
func switchToChart(chartsCollection: ChartsCollection, isZoomed: Bool, animated: Bool) {
|
||||||
if animated {
|
if animated {
|
||||||
TimeInterval.setDefaultSuration(.expandAnimationDuration)
|
TimeInterval.setDefaultDuration(.expandAnimationDuration)
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + .expandAnimationDuration) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + .expandAnimationDuration) {
|
||||||
TimeInterval.setDefaultSuration(.osXDuration)
|
TimeInterval.setDefaultDuration(.osXDuration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,19 +168,10 @@ class PieChartComponentController: GeneralChartComponentController {
|
|||||||
override var currentPreviewRangeRenderer: BaseChartRenderer {
|
override var currentPreviewRangeRenderer: BaseChartRenderer {
|
||||||
return previewBarChartRenderer
|
return previewBarChartRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastInteractionPoint: CGPoint = .zero
|
|
||||||
public override func chartInteractionDidBegin(point: CGPoint) {
|
public override func chartInteractionDidBegin(point: CGPoint) {
|
||||||
lastInteractionPoint = point
|
if let segment = pieChartRenderer.selectedItemIndex(at: point) {
|
||||||
}
|
pieChartRenderer.selectSegmentAt(at: segment, animated: true)
|
||||||
|
|
||||||
public override func chartInteractionDidEnd() {
|
|
||||||
if let segment = pieChartRenderer.selectedItemIndex(at: lastInteractionPoint) {
|
|
||||||
if pieChartRenderer.selectedSegment == segment {
|
|
||||||
pieChartRenderer.selectSegmentAt(at: nil, animated: true)
|
|
||||||
} else {
|
|
||||||
pieChartRenderer.selectSegmentAt(at: segment, animated: true)
|
|
||||||
}
|
|
||||||
updateSelectedDataLabelIfNeeded()
|
updateSelectedDataLabelIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,9 @@ public class DailyBarsChartController: BaseChartController {
|
|||||||
|
|
||||||
func switchToChart(chartsCollection: ChartsCollection, isZoomed: Bool, animated: Bool) {
|
func switchToChart(chartsCollection: ChartsCollection, isZoomed: Bool, animated: Bool) {
|
||||||
if animated {
|
if animated {
|
||||||
TimeInterval.setDefaultSuration(.expandAnimationDuration)
|
TimeInterval.setDefaultDuration(.expandAnimationDuration)
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + .expandAnimationDuration) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + .expandAnimationDuration) {
|
||||||
TimeInterval.setDefaultSuration(.osXDuration)
|
TimeInterval.setDefaultDuration(.osXDuration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ public class StackedBarsChartController: BaseChartController {
|
|||||||
|
|
||||||
func switchToChart(chartsCollection: ChartsCollection, isZoomed: Bool, animated: Bool) {
|
func switchToChart(chartsCollection: ChartsCollection, isZoomed: Bool, animated: Bool) {
|
||||||
if animated {
|
if animated {
|
||||||
TimeInterval.setDefaultSuration(.expandAnimationDuration)
|
TimeInterval.setDefaultDuration(.expandAnimationDuration)
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + .expandAnimationDuration) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + .expandAnimationDuration) {
|
||||||
TimeInterval.setDefaultSuration(.osXDuration)
|
TimeInterval.setDefaultDuration(.osXDuration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +119,8 @@ public class StackedBarsChartController: BaseChartController {
|
|||||||
barsController.willDisappear(animated: animated)
|
barsController.willDisappear(animated: animated)
|
||||||
|
|
||||||
zoomedBarsController.updateChartsVisibility(visibility: barsController.chartVisibility, animated: false)
|
zoomedBarsController.updateChartsVisibility(visibility: barsController.chartVisibility, animated: false)
|
||||||
zoomedBarsController.mainBarsRenderer.setup(verticalRange: zoomedBarsController.currentVerticalMainChartRange, animated: animated, timeFunction: .easeOut)
|
zoomedBarsController.mainBarsRenderer.setup(verticalRange: zoomedBarsController.currentVerticalMainChartRange, animated: animated, timeFunction: .easeInOut)
|
||||||
zoomedBarsController.previewBarsChartRenderer.setup(verticalRange: zoomedBarsController.currentPreviewVerticalRange, animated: animated, timeFunction: .easeOut)
|
zoomedBarsController.previewBarsChartRenderer.setup(verticalRange: zoomedBarsController.currentPreviewVerticalRange, animated: animated, timeFunction: .easeInOut)
|
||||||
} else {
|
} else {
|
||||||
if !zoomedBarsController.chartsCollection.isBlank {
|
if !zoomedBarsController.chartsCollection.isBlank {
|
||||||
barsController.hideDetailsView(animated: false)
|
barsController.hideDetailsView(animated: false)
|
||||||
@ -135,8 +135,8 @@ public class StackedBarsChartController: BaseChartController {
|
|||||||
let targetVerticalRange = verticalVisibleRange.lowerBound...(verticalVisibleRange.upperBound + verticalVisibleRange.distance * 10)
|
let targetVerticalRange = verticalVisibleRange.lowerBound...(verticalVisibleRange.upperBound + verticalVisibleRange.distance * 10)
|
||||||
|
|
||||||
zoomedBarsController.setupMainChart(horizontalRange: toHorizontalRange, animated: animated)
|
zoomedBarsController.setupMainChart(horizontalRange: toHorizontalRange, animated: animated)
|
||||||
zoomedBarsController.mainBarsRenderer.setup(verticalRange: targetVerticalRange, animated: animated, timeFunction: .easeIn)
|
zoomedBarsController.mainBarsRenderer.setup(verticalRange: targetVerticalRange, animated: animated, timeFunction: .easeInOut)
|
||||||
zoomedBarsController.previewBarsChartRenderer.setup(verticalRange: targetVerticalRange, animated: animated, timeFunction: .easeIn)
|
zoomedBarsController.previewBarsChartRenderer.setup(verticalRange: targetVerticalRange, animated: animated, timeFunction: .easeInOut)
|
||||||
zoomedBarsController.previewBarsChartRenderer.setup(horizontalRange: barsController.totalHorizontalRange, animated: animated)
|
zoomedBarsController.previewBarsChartRenderer.setup(horizontalRange: barsController.totalHorizontalRange, animated: animated)
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + .defaultDuration) { [weak self] in
|
DispatchQueue.main.asyncAfter(deadline: .now() + .defaultDuration) { [weak self] in
|
||||||
self?.zoomedBarsController.mainBarsRenderer.setVisible(false, animated: false)
|
self?.zoomedBarsController.mainBarsRenderer.setVisible(false, animated: false)
|
||||||
|
@ -97,9 +97,9 @@ public class StepBarsChartController: BaseChartController {
|
|||||||
|
|
||||||
func switchToChart(chartsCollection: ChartsCollection, isZoomed: Bool, animated: Bool) {
|
func switchToChart(chartsCollection: ChartsCollection, isZoomed: Bool, animated: Bool) {
|
||||||
if animated {
|
if animated {
|
||||||
TimeInterval.setDefaultSuration(.expandAnimationDuration)
|
TimeInterval.setDefaultDuration(.expandAnimationDuration)
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + .expandAnimationDuration) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + .expandAnimationDuration) {
|
||||||
TimeInterval.setDefaultSuration(.osXDuration)
|
TimeInterval.setDefaultDuration(.osXDuration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,8 +126,8 @@ public class StepBarsChartController: BaseChartController {
|
|||||||
barsController.willDisappear(animated: animated)
|
barsController.willDisappear(animated: animated)
|
||||||
|
|
||||||
zoomedBarsController.updateChartsVisibility(visibility: barsController.chartVisibility, animated: false)
|
zoomedBarsController.updateChartsVisibility(visibility: barsController.chartVisibility, animated: false)
|
||||||
zoomedBarsController.mainBarsRenderer.setup(verticalRange: zoomedBarsController.currentVerticalMainChartRange, animated: animated, timeFunction: .easeOut)
|
zoomedBarsController.mainBarsRenderer.setup(verticalRange: zoomedBarsController.currentVerticalMainChartRange, animated: animated, timeFunction: .easeInOut)
|
||||||
zoomedBarsController.previewBarsChartRenderer.setup(verticalRange: zoomedBarsController.currentPreviewVerticalRange, animated: animated, timeFunction: .easeOut)
|
zoomedBarsController.previewBarsChartRenderer.setup(verticalRange: zoomedBarsController.currentPreviewVerticalRange, animated: animated, timeFunction: .easeInOut)
|
||||||
} else {
|
} else {
|
||||||
if !zoomedBarsController.chartsCollection.isBlank {
|
if !zoomedBarsController.chartsCollection.isBlank {
|
||||||
barsController.hideDetailsView(animated: false)
|
barsController.hideDetailsView(animated: false)
|
||||||
@ -143,8 +143,8 @@ public class StepBarsChartController: BaseChartController {
|
|||||||
let targetVerticalRange = verticalVisibleRange.lowerBound...(verticalVisibleRange.upperBound + verticalVisibleRange.distance * 10)
|
let targetVerticalRange = verticalVisibleRange.lowerBound...(verticalVisibleRange.upperBound + verticalVisibleRange.distance * 10)
|
||||||
|
|
||||||
zoomedBarsController.setupMainChart(horizontalRange: toHorizontalRange, animated: animated)
|
zoomedBarsController.setupMainChart(horizontalRange: toHorizontalRange, animated: animated)
|
||||||
zoomedBarsController.mainBarsRenderer.setup(verticalRange: targetVerticalRange, animated: animated, timeFunction: .easeIn)
|
zoomedBarsController.mainBarsRenderer.setup(verticalRange: targetVerticalRange, animated: animated, timeFunction: .easeInOut)
|
||||||
zoomedBarsController.previewBarsChartRenderer.setup(verticalRange: targetVerticalRange, animated: animated, timeFunction: .easeIn)
|
zoomedBarsController.previewBarsChartRenderer.setup(verticalRange: targetVerticalRange, animated: animated, timeFunction: .easeInOut)
|
||||||
zoomedBarsController.previewBarsChartRenderer.setup(horizontalRange: barsController.totalHorizontalRange, animated: animated)
|
zoomedBarsController.previewBarsChartRenderer.setup(horizontalRange: barsController.totalHorizontalRange, animated: animated)
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + .defaultDuration) { [weak self] in
|
DispatchQueue.main.asyncAfter(deadline: .now() + .defaultDuration) { [weak self] in
|
||||||
self?.zoomedBarsController.mainBarsRenderer.setVisible(false, animated: false)
|
self?.zoomedBarsController.mainBarsRenderer.setVisible(false, animated: false)
|
||||||
|
@ -87,8 +87,11 @@ public class TwoAxisStepBarsChartController: BaseLinesChartController {
|
|||||||
controller.verticalScalesRenderer.isRightAligned = (index != 0)
|
controller.verticalScalesRenderer.isRightAligned = (index != 0)
|
||||||
controller.verticalScalesRenderer.isEnabled = true
|
controller.verticalScalesRenderer.isEnabled = true
|
||||||
} else {
|
} else {
|
||||||
controller.mainBarsRenderer.bars = BarChartRenderer.BarsData(barWidth: 0.0, locations: [], components: [])
|
let emptyBars = BarChartRenderer.BarsData(barWidth: 0.0, locations: [], components: [])
|
||||||
controller.previewBarsRenderer.bars = BarChartRenderer.BarsData(barWidth: 0.0, locations: [], components: [])
|
controller.chartBars = emptyBars
|
||||||
|
controller.barsWidth = emptyBars.barWidth
|
||||||
|
controller.mainBarsRenderer.bars = emptyBars
|
||||||
|
controller.previewBarsRenderer.bars = emptyBars
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,9 +122,7 @@ public class TwoAxisStepBarsChartController: BaseLinesChartController {
|
|||||||
public override var mainChartRenderers: [ChartViewRenderer] {
|
public override var mainChartRenderers: [ChartViewRenderer] {
|
||||||
return graphControllers.map { $0.mainBarsRenderer } +
|
return graphControllers.map { $0.mainBarsRenderer } +
|
||||||
graphControllers.flatMap { [$0.verticalScalesRenderer, $0.lineBulletsRenderer] } +
|
graphControllers.flatMap { [$0.verticalScalesRenderer, $0.lineBulletsRenderer] } +
|
||||||
[horizontalScalesRenderer, verticalLineRenderer,
|
[horizontalScalesRenderer, verticalLineRenderer]
|
||||||
// performanceRenderer
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override var navigationRenderers: [ChartViewRenderer] {
|
public override var navigationRenderers: [ChartViewRenderer] {
|
||||||
|
@ -45,7 +45,9 @@ class LineBulletsRenderer: BaseChartRenderer {
|
|||||||
var bulletRadius: CGFloat = 6
|
var bulletRadius: CGFloat = 6
|
||||||
|
|
||||||
func setLineVisible(_ isVisible: Bool, at index: Int, animated: Bool) {
|
func setLineVisible(_ isVisible: Bool, at index: Int, animated: Bool) {
|
||||||
alphaAnimators[index].animate(to: isVisible ? 1 : 0, duration: animated ? .defaultDuration : 0)
|
if alphaAnimators.count > index {
|
||||||
|
alphaAnimators[index].animate(to: isVisible ? 1 : 0, duration: animated ? .defaultDuration : 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func render(context: CGContext, bounds: CGRect, chartFrame: CGRect) {
|
override func render(context: CGContext, bounds: CGRect, chartFrame: CGRect) {
|
@ -50,7 +50,9 @@ class LinesChartRenderer: BaseChartRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setLineVisible(_ isVisible: Bool, at index: Int, animated: Bool) {
|
func setLineVisible(_ isVisible: Bool, at index: Int, animated: Bool) {
|
||||||
linesAlphaAnimators[index].animate(to: isVisible ? 1 : 0, duration: animated ? .defaultDuration : 0)
|
if linesAlphaAnimators.count > index {
|
||||||
|
linesAlphaAnimators[index].animate(to: isVisible ? 1 : 0, duration: animated ? .defaultDuration : 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func render(context: CGContext, bounds: CGRect, chartFrame: CGRect) {
|
override func render(context: CGContext, bounds: CGRect, chartFrame: CGRect) {
|
||||||
|
@ -27,7 +27,9 @@ class VerticalLinesRenderer: BaseChartRenderer {
|
|||||||
var linesWidth: CGFloat = GView.oneDevicePixel
|
var linesWidth: CGFloat = GView.oneDevicePixel
|
||||||
|
|
||||||
func setLineVisible(_ isVisible: Bool, at index: Int, animated: Bool) {
|
func setLineVisible(_ isVisible: Bool, at index: Int, animated: Bool) {
|
||||||
alphaAnimators[index].animate(to: isVisible ? 1 : 0, duration: animated ? .defaultDuration : 0)
|
if alphaAnimators.count > index {
|
||||||
|
alphaAnimators[index].animate(to: isVisible ? 1 : 0, duration: animated ? .defaultDuration : 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func render(context: CGContext, bounds: CGRect, chartFrame: CGRect) {
|
override func render(context: CGContext, bounds: CGRect, chartFrame: CGRect) {
|
||||||
|
@ -21,6 +21,7 @@ enum TimeFunction {
|
|||||||
case linear
|
case linear
|
||||||
case easeOut
|
case easeOut
|
||||||
case easeIn
|
case easeIn
|
||||||
|
case easeInOut
|
||||||
|
|
||||||
func profress(time: TimeInterval, duration: TimeInterval) -> TimeInterval {
|
func profress(time: TimeInterval, duration: TimeInterval) -> TimeInterval {
|
||||||
switch self {
|
switch self {
|
||||||
@ -30,12 +31,19 @@ enum TimeFunction {
|
|||||||
return (pow(2, 10 * (time / duration - 1)) - 0.0009765625) * 1.0009775171065499
|
return (pow(2, 10 * (time / duration - 1)) - 0.0009765625) * 1.0009775171065499
|
||||||
case .easeOut:
|
case .easeOut:
|
||||||
return (-pow(2, -10 * time / duration)) + 1 * 1.0009775171065499
|
return (-pow(2, -10 * time / duration)) + 1 * 1.0009775171065499
|
||||||
|
case .easeInOut:
|
||||||
|
let x = time / duration
|
||||||
|
if x < 1 / 2 {
|
||||||
|
return 4 * x * x * x
|
||||||
|
} else {
|
||||||
|
let f = 2 * x - 2
|
||||||
|
return 1 / 2 * f * f * f + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnimationController<AnimatableObject: Animatable> {
|
class AnimationController<AnimatableObject: Animatable> {
|
||||||
|
|
||||||
private(set) var isAnimating: Bool = false
|
private(set) var isAnimating: Bool = false
|
||||||
private(set) var animationDuration: TimeInterval = 0.0
|
private(set) var animationDuration: TimeInterval = 0.0
|
||||||
private(set) var currentTime: TimeInterval = 0.0
|
private(set) var currentTime: TimeInterval = 0.0
|
||||||
@ -44,7 +52,7 @@ class AnimationController<AnimatableObject: Animatable> {
|
|||||||
private(set) var end: AnimatableObject
|
private(set) var end: AnimatableObject
|
||||||
private(set) var current: AnimatableObject
|
private(set) var current: AnimatableObject
|
||||||
|
|
||||||
var timeFunction: TimeFunction = .linear
|
var timeFunction: TimeFunction = .easeInOut
|
||||||
|
|
||||||
var refreshClosure: (() -> Void)?
|
var refreshClosure: (() -> Void)?
|
||||||
// var updateClosure: ((AnimatableObject) -> Void)?
|
// var updateClosure: ((AnimatableObject) -> Void)?
|
||||||
@ -57,7 +65,7 @@ class AnimationController<AnimatableObject: Animatable> {
|
|||||||
self.refreshClosure = refreshClosure
|
self.refreshClosure = refreshClosure
|
||||||
}
|
}
|
||||||
|
|
||||||
func animate(to: AnimatableObject, duration: TimeInterval, timeFunction: TimeFunction = .linear) {
|
func animate(to: AnimatableObject, duration: TimeInterval, timeFunction: TimeFunction = .easeInOut) {
|
||||||
self.timeFunction = timeFunction
|
self.timeFunction = timeFunction
|
||||||
currentTime = 0
|
currentTime = 0
|
||||||
animationDuration = duration
|
animationDuration = duration
|
||||||
|
@ -26,7 +26,7 @@ public extension TimeInterval {
|
|||||||
}
|
}
|
||||||
private static var innerDefaultDuration: TimeInterval = osXDuration
|
private static var innerDefaultDuration: TimeInterval = osXDuration
|
||||||
|
|
||||||
static func setDefaultSuration(_ duration: TimeInterval) {
|
static func setDefaultDuration(_ duration: TimeInterval) {
|
||||||
innerDefaultDuration = duration
|
innerDefaultDuration = duration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ private func statsControllerEntries(data: ChannelStats?, messages: [Message]?, i
|
|||||||
|
|
||||||
if !data.instantPageInteractionsGraph.isEmpty {
|
if !data.instantPageInteractionsGraph.isEmpty {
|
||||||
entries.append(.instantPageInteractionsTitle(presentationData.theme, presentationData.strings.Stats_InstantViewInteractionsTitle))
|
entries.append(.instantPageInteractionsTitle(presentationData.theme, presentationData.strings.Stats_InstantViewInteractionsTitle))
|
||||||
entries.append(.instantPageInteractionsGraph(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, data.instantPageInteractionsGraph, .step))
|
entries.append(.instantPageInteractionsGraph(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, data.instantPageInteractionsGraph, .twoAxisStep))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ public class StatsMessageItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
let titleFont = Font.regular(item.presentationData.fontSize.itemListBaseFontSize)
|
let titleFont = Font.regular(item.presentationData.fontSize.itemListBaseFontSize)
|
||||||
|
|
||||||
let contentKind = messageContentKind(contentSettings: item.context.currentContentSettings.with { $0 }, message: item.message, strings: item.presentationData.strings, nameDisplayOrder: .firstLast, accountPeerId: item.context.account.peerId)
|
let contentKind = messageContentKind(contentSettings: item.context.currentContentSettings.with { $0 }, message: item.message, strings: item.presentationData.strings, nameDisplayOrder: .firstLast, accountPeerId: item.context.account.peerId)
|
||||||
var text = stringForMediaKind(contentKind, strings: item.presentationData.strings).0
|
var text = !item.message.text.isEmpty ? item.message.text : stringForMediaKind(contentKind, strings: item.presentationData.strings).0
|
||||||
text = foldLineBreaks(text)
|
text = foldLineBreaks(text)
|
||||||
|
|
||||||
var contentImageMedia: Media?
|
var contentImageMedia: Media?
|
||||||
|
@ -16,8 +16,19 @@ func cacheStickerPack(transaction: Transaction, info: StickerPackCollectionInfo,
|
|||||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(info.id)), entry: CachedStickerPack(info: info, items: items.map { $0 as! StickerPackItem }, hash: info.hash), collectionSpec: collectionSpec)
|
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(info.id)), entry: CachedStickerPack(info: info, items: items.map { $0 as! StickerPackItem }, hash: info.hash), collectionSpec: collectionSpec)
|
||||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: info.shortName)), entry: CachedStickerPack(info: info, items: items.map { $0 as! StickerPackItem }, hash: info.hash), collectionSpec: collectionSpec)
|
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: info.shortName)), entry: CachedStickerPack(info: info, items: items.map { $0 as! StickerPackItem }, hash: info.hash), collectionSpec: collectionSpec)
|
||||||
|
|
||||||
if let reference = reference, case .animatedEmoji = reference {
|
if let reference = reference {
|
||||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: Namespaces.ItemCollection.CloudAnimatedEmoji, id: 0))), entry: CachedStickerPack(info: info, items: items.map { $0 as! StickerPackItem }, hash: info.hash), collectionSpec: collectionSpec)
|
var namespace: Int32?
|
||||||
|
switch reference {
|
||||||
|
case .animatedEmoji:
|
||||||
|
namespace = Namespaces.ItemCollection.CloudAnimatedEmoji
|
||||||
|
case .dice:
|
||||||
|
namespace = Namespaces.ItemCollection.CloudDice
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if let namespace = namespace {
|
||||||
|
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: 0))), entry: CachedStickerPack(info: info, items: items.map { $0 as! StickerPackItem }, hash: info.hash), collectionSpec: collectionSpec)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ public enum MessageContentKindKey {
|
|||||||
case expiredVideo
|
case expiredVideo
|
||||||
case poll
|
case poll
|
||||||
case restricted
|
case restricted
|
||||||
|
case dice
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MessageContentKind: Equatable {
|
public enum MessageContentKind: Equatable {
|
||||||
@ -42,6 +43,7 @@ public enum MessageContentKind: Equatable {
|
|||||||
case expiredVideo
|
case expiredVideo
|
||||||
case poll(String)
|
case poll(String)
|
||||||
case restricted(String)
|
case restricted(String)
|
||||||
|
case dice
|
||||||
|
|
||||||
public var key: MessageContentKindKey {
|
public var key: MessageContentKindKey {
|
||||||
switch self {
|
switch self {
|
||||||
@ -77,6 +79,8 @@ public enum MessageContentKind: Equatable {
|
|||||||
return .poll
|
return .poll
|
||||||
case .restricted:
|
case .restricted:
|
||||||
return .restricted
|
return .restricted
|
||||||
|
case .dice:
|
||||||
|
return .dice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,6 +169,8 @@ public func mediaContentKind(_ media: Media, message: Message? = nil, strings: P
|
|||||||
}
|
}
|
||||||
case let poll as TelegramMediaPoll:
|
case let poll as TelegramMediaPoll:
|
||||||
return .poll(poll.text)
|
return .poll(poll.text)
|
||||||
|
case _ as TelegramMediaDice:
|
||||||
|
return .dice
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -212,6 +218,8 @@ public func stringForMediaKind(_ kind: MessageContentKind, strings: Presentation
|
|||||||
return ("📊 \(text)", false)
|
return ("📊 \(text)", false)
|
||||||
case let .restricted(text):
|
case let .restricted(text):
|
||||||
return (text, false)
|
return (text, false)
|
||||||
|
case .dice:
|
||||||
|
return ("🎲", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,9 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
var telegramDice: TelegramMediaDice?
|
var telegramDice: TelegramMediaDice?
|
||||||
private let disposable = MetaDisposable()
|
private let disposable = MetaDisposable()
|
||||||
|
|
||||||
|
private var forwardInfoNode: ChatMessageForwardInfoNode?
|
||||||
|
private var forwardBackgroundNode: ASImageNode?
|
||||||
|
|
||||||
private var viaBotNode: TextNode?
|
private var viaBotNode: TextNode?
|
||||||
private let dateAndStatusNode: ChatMessageDateAndStatusNode
|
private let dateAndStatusNode: ChatMessageDateAndStatusNode
|
||||||
private var replyInfoNode: ChatMessageReplyInfoNode?
|
private var replyInfoNode: ChatMessageReplyInfoNode?
|
||||||
@ -64,6 +67,8 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
|
|
||||||
private var currentSwipeToReplyTranslation: CGFloat = 0.0
|
private var currentSwipeToReplyTranslation: CGFloat = 0.0
|
||||||
|
|
||||||
|
private var appliedForwardInfo: (Peer?, String?)?
|
||||||
|
|
||||||
required init() {
|
required init() {
|
||||||
self.contextSourceNode = ContextExtractedContentContainingNode()
|
self.contextSourceNode = ContextExtractedContentContainingNode()
|
||||||
self.imageNode = TransformImageNode()
|
self.imageNode = TransformImageNode()
|
||||||
@ -153,9 +158,10 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let _ = self.telegramDice {
|
if let _ = self.telegramDice {
|
||||||
let diceEmojis = item.associatedData.animatedEmojiStickers["🎲"] ?? []
|
if let diceEmojis = item.associatedData.animatedEmojiStickers["🎲"] {
|
||||||
let animationNode = ManagedDiceAnimationNode(context: item.context, emojis: diceEmojis.map { $0.file })
|
let animationNode = ManagedDiceAnimationNode(context: item.context, emojis: diceEmojis.map { $0.file })
|
||||||
self.animationNode = animationNode
|
self.animationNode = animationNode
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let animationNode = AnimatedStickerNode()
|
let animationNode = AnimatedStickerNode()
|
||||||
animationNode.started = { [weak self] in
|
animationNode.started = { [weak self] in
|
||||||
@ -203,7 +209,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
} else {
|
} else {
|
||||||
diceNode.setState(.rolling)
|
diceNode.setState(.rolling)
|
||||||
}
|
}
|
||||||
} else if self.telegramFile == nil {
|
} else if self.telegramFile == nil && self.telegramDice == nil {
|
||||||
let (emoji, fitz) = item.message.text.basicEmoji
|
let (emoji, fitz) = item.message.text.basicEmoji
|
||||||
var emojiFile: TelegramMediaFile?
|
var emojiFile: TelegramMediaFile?
|
||||||
|
|
||||||
@ -295,7 +301,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let animationNode = self.animationNode as? ManagedDiceAnimationNode {
|
} else if let animationNode = self.animationNode as? ManagedDiceAnimationNode {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,23 +313,30 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
let displaySize = CGSize(width: 184.0, height: 184.0)
|
let displaySize = CGSize(width: 184.0, height: 184.0)
|
||||||
let telegramFile = self.telegramFile
|
let telegramFile = self.telegramFile
|
||||||
let emojiFile = self.emojiFile
|
let emojiFile = self.emojiFile
|
||||||
|
let telegramDice = self.telegramDice
|
||||||
let layoutConstants = self.layoutConstants
|
let layoutConstants = self.layoutConstants
|
||||||
let imageLayout = self.imageNode.asyncLayout()
|
let imageLayout = self.imageNode.asyncLayout()
|
||||||
let makeDateAndStatusLayout = self.dateAndStatusNode.asyncLayout()
|
let makeDateAndStatusLayout = self.dateAndStatusNode.asyncLayout()
|
||||||
let actionButtonsLayout = ChatMessageActionButtonsNode.asyncLayout(self.actionButtonsNode)
|
let actionButtonsLayout = ChatMessageActionButtonsNode.asyncLayout(self.actionButtonsNode)
|
||||||
|
|
||||||
|
let makeForwardInfoLayout = ChatMessageForwardInfoNode.asyncLayout(self.forwardInfoNode)
|
||||||
|
let currentForwardBackgroundNode = self.forwardBackgroundNode
|
||||||
|
|
||||||
let viaBotLayout = TextNode.asyncLayout(self.viaBotNode)
|
let viaBotLayout = TextNode.asyncLayout(self.viaBotNode)
|
||||||
let makeReplyInfoLayout = ChatMessageReplyInfoNode.asyncLayout(self.replyInfoNode)
|
let makeReplyInfoLayout = ChatMessageReplyInfoNode.asyncLayout(self.replyInfoNode)
|
||||||
let currentReplyBackgroundNode = self.replyBackgroundNode
|
let currentReplyBackgroundNode = self.replyBackgroundNode
|
||||||
let currentShareButtonNode = self.shareButtonNode
|
let currentShareButtonNode = self.shareButtonNode
|
||||||
let currentItem = self.item
|
let currentItem = self.item
|
||||||
|
let currentForwardInfo = self.appliedForwardInfo
|
||||||
|
|
||||||
return { item, params, mergedTop, mergedBottom, dateHeaderAtBottom in
|
return { item, params, mergedTop, mergedBottom, dateHeaderAtBottom in
|
||||||
let layoutConstants = chatMessageItemLayoutConstants(layoutConstants, params: params, presentationData: item.presentationData)
|
let layoutConstants = chatMessageItemLayoutConstants(layoutConstants, params: params, presentationData: item.presentationData)
|
||||||
let incoming = item.message.effectivelyIncoming(item.context.account.peerId)
|
let incoming = item.message.effectivelyIncoming(item.context.account.peerId)
|
||||||
var imageSize: CGSize = CGSize(width: 200.0, height: 200.0)
|
var imageSize: CGSize = CGSize(width: 200.0, height: 200.0)
|
||||||
var isEmoji = false
|
var isEmoji = false
|
||||||
if let telegramFile = telegramFile {
|
if let _ = telegramDice {
|
||||||
|
imageSize = displaySize
|
||||||
|
} else if let telegramFile = telegramFile {
|
||||||
if let dimensions = telegramFile.dimensions {
|
if let dimensions = telegramFile.dimensions {
|
||||||
imageSize = dimensions.cgSize.aspectFitted(displaySize)
|
imageSize = dimensions.cgSize.aspectFitted(displaySize)
|
||||||
} else if let thumbnailSize = telegramFile.previewRepresentations.first?.dimensions {
|
} else if let thumbnailSize = telegramFile.previewRepresentations.first?.dimensions {
|
||||||
@ -482,7 +495,25 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
var replyBackgroundImage: UIImage?
|
var replyBackgroundImage: UIImage?
|
||||||
var replyMarkup: ReplyMarkupMessageAttribute?
|
var replyMarkup: ReplyMarkupMessageAttribute?
|
||||||
|
|
||||||
let availableWidth = max(60.0, params.width - params.leftInset - params.rightInset - max(imageSize.width, 160.0) - 20.0 - layoutConstants.bubble.edgeInset * 2.0 - avatarInset - layoutConstants.bubble.contentInsets.left)
|
var ignoreForward = self.telegramDice == nil
|
||||||
|
var ignoreSource = false
|
||||||
|
|
||||||
|
let availableContentWidth = max(60.0, params.width - params.leftInset - params.rightInset - max(imageSize.width, 160.0) - 20.0 - layoutConstants.bubble.edgeInset * 2.0 - avatarInset - layoutConstants.bubble.contentInsets.left)
|
||||||
|
|
||||||
|
if let forwardInfo = item.message.forwardInfo {
|
||||||
|
if item.message.id.peerId != item.context.account.peerId {
|
||||||
|
for attribute in item.message.attributes {
|
||||||
|
if let attribute = attribute as? SourceReferenceMessageAttribute {
|
||||||
|
if attribute.messageId.peerId == forwardInfo.author?.id {
|
||||||
|
ignoreForward = true
|
||||||
|
} else {
|
||||||
|
ignoreSource = true
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for attribute in item.message.attributes {
|
for attribute in item.message.attributes {
|
||||||
if let attribute = attribute as? InlineBotMessageAttribute {
|
if let attribute = attribute as? InlineBotMessageAttribute {
|
||||||
@ -500,11 +531,11 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
let boldAttributes = MarkdownAttributeSet(font: inlineBotPrefixFont, textColor: inlineBotNameColor)
|
let boldAttributes = MarkdownAttributeSet(font: inlineBotPrefixFont, textColor: inlineBotNameColor)
|
||||||
let botString = addAttributesToStringWithRanges(item.presentationData.strings.Conversation_MessageViaUser("@\(inlineBotNameString)"), body: bodyAttributes, argumentAttributes: [0: boldAttributes])
|
let botString = addAttributesToStringWithRanges(item.presentationData.strings.Conversation_MessageViaUser("@\(inlineBotNameString)"), body: bodyAttributes, argumentAttributes: [0: boldAttributes])
|
||||||
|
|
||||||
viaBotApply = viaBotLayout(TextNodeLayoutArguments(attributedString: botString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0, availableWidth), height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
viaBotApply = viaBotLayout(TextNodeLayoutArguments(attributedString: botString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0, availableContentWidth), height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let replyAttribute = attribute as? ReplyMessageAttribute, let replyMessage = item.message.associatedMessages[replyAttribute.messageId] {
|
if let replyAttribute = attribute as? ReplyMessageAttribute, let replyMessage = item.message.associatedMessages[replyAttribute.messageId] {
|
||||||
replyInfoApply = makeReplyInfoLayout(item.presentationData, item.presentationData.strings, item.context, .standalone, replyMessage, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude))
|
replyInfoApply = makeReplyInfoLayout(item.presentationData, item.presentationData.strings, item.context, .standalone, replyMessage, CGSize(width: availableContentWidth, height: CGFloat.greatestFiniteMagnitude))
|
||||||
} else if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), !attribute.rows.isEmpty {
|
} else if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), !attribute.rows.isEmpty {
|
||||||
replyMarkup = attribute
|
replyMarkup = attribute
|
||||||
}
|
}
|
||||||
@ -517,7 +548,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
let inlineBotNameColor = serviceMessageColorComponents(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper).primaryText
|
let inlineBotNameColor = serviceMessageColorComponents(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper).primaryText
|
||||||
|
|
||||||
let nameString = NSAttributedString(string: sourcePeer.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder), font: inlineBotPrefixFont, textColor: inlineBotNameColor)
|
let nameString = NSAttributedString(string: sourcePeer.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder), font: inlineBotPrefixFont, textColor: inlineBotNameColor)
|
||||||
viaBotApply = viaBotLayout(TextNodeLayoutArguments(attributedString: nameString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0, availableWidth), height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
viaBotApply = viaBotLayout(TextNodeLayoutArguments(attributedString: nameString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0, availableContentWidth), height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -563,6 +594,47 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let contentHeight = max(imageSize.height, layoutConstants.image.minDimensions.height)
|
let contentHeight = max(imageSize.height, layoutConstants.image.minDimensions.height)
|
||||||
|
|
||||||
|
|
||||||
|
var forwardSource: Peer?
|
||||||
|
var forwardAuthorSignature: String?
|
||||||
|
|
||||||
|
var forwardInfoSizeApply: (CGSize, () -> ChatMessageForwardInfoNode)?
|
||||||
|
var updatedForwardBackgroundNode: ASImageNode?
|
||||||
|
var forwardBackgroundImage: UIImage?
|
||||||
|
|
||||||
|
if !ignoreForward, let forwardInfo = item.message.forwardInfo {
|
||||||
|
if let source = forwardInfo.source {
|
||||||
|
forwardSource = source
|
||||||
|
if let authorSignature = forwardInfo.authorSignature {
|
||||||
|
forwardAuthorSignature = authorSignature
|
||||||
|
} else if let forwardInfoAuthor = forwardInfo.author, forwardInfoAuthor.id != source.id {
|
||||||
|
forwardAuthorSignature = forwardInfoAuthor.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||||
|
} else {
|
||||||
|
forwardAuthorSignature = nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if let currentForwardInfo = currentForwardInfo, forwardInfo.author == nil && currentForwardInfo.0 != nil {
|
||||||
|
forwardSource = nil
|
||||||
|
forwardAuthorSignature = currentForwardInfo.0?.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||||
|
} else {
|
||||||
|
forwardSource = forwardInfo.author
|
||||||
|
forwardAuthorSignature = forwardInfo.authorSignature
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let availableWidth = max(60.0, availableContentWidth + 6.0)
|
||||||
|
forwardInfoSizeApply = makeForwardInfoLayout(item.presentationData, item.presentationData.strings, .standalone, forwardSource, forwardAuthorSignature, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude))
|
||||||
|
|
||||||
|
if let currentForwardBackgroundNode = currentForwardBackgroundNode {
|
||||||
|
updatedForwardBackgroundNode = currentForwardBackgroundNode
|
||||||
|
} else {
|
||||||
|
updatedForwardBackgroundNode = ASImageNode()
|
||||||
|
}
|
||||||
|
|
||||||
|
let graphics = PresentationResourcesChat.additionalGraphics(item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper, bubbleCorners: item.presentationData.chatBubbleCorners)
|
||||||
|
forwardBackgroundImage = graphics.chatServiceBubbleFillImage
|
||||||
|
}
|
||||||
|
|
||||||
var maxContentWidth = imageSize.width
|
var maxContentWidth = imageSize.width
|
||||||
var actionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animated: Bool) -> ChatMessageActionButtonsNode))?
|
var actionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animated: Bool) -> ChatMessageActionButtonsNode))?
|
||||||
if let replyMarkup = replyMarkup {
|
if let replyMarkup = replyMarkup {
|
||||||
@ -583,6 +655,8 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
|
|
||||||
return (ListViewItemNodeLayout(contentSize: layoutSize, insets: layoutInsets), { [weak self] animation, _ in
|
return (ListViewItemNodeLayout(contentSize: layoutSize, insets: layoutInsets), { [weak self] animation, _ in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
|
strongSelf.appliedForwardInfo = (forwardSource, forwardAuthorSignature)
|
||||||
|
|
||||||
strongSelf.contextSourceNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
|
strongSelf.contextSourceNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
|
||||||
strongSelf.contextSourceNode.contentNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
|
strongSelf.contextSourceNode.contentNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
|
||||||
|
|
||||||
@ -716,6 +790,31 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let updatedForwardBackgroundNode = updatedForwardBackgroundNode {
|
||||||
|
if strongSelf.forwardBackgroundNode == nil {
|
||||||
|
strongSelf.forwardBackgroundNode = updatedForwardBackgroundNode
|
||||||
|
strongSelf.addSubnode(updatedForwardBackgroundNode)
|
||||||
|
updatedForwardBackgroundNode.image = forwardBackgroundImage
|
||||||
|
}
|
||||||
|
} else if let forwardBackgroundNode = strongSelf.forwardBackgroundNode {
|
||||||
|
forwardBackgroundNode.removeFromSupernode()
|
||||||
|
strongSelf.forwardBackgroundNode = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if let (forwardInfoSize, forwardInfoApply) = forwardInfoSizeApply {
|
||||||
|
let forwardInfoNode = forwardInfoApply()
|
||||||
|
if strongSelf.forwardInfoNode == nil {
|
||||||
|
strongSelf.forwardInfoNode = forwardInfoNode
|
||||||
|
strongSelf.addSubnode(forwardInfoNode)
|
||||||
|
}
|
||||||
|
let forwardInfoFrame = CGRect(origin: CGPoint(x: (!incoming ? (params.leftInset + layoutConstants.bubble.edgeInset + 12.0) : (params.width - params.rightInset - forwardInfoSize.width - layoutConstants.bubble.edgeInset - 12.0)), y: 8.0), size: forwardInfoSize)
|
||||||
|
forwardInfoNode.frame = forwardInfoFrame
|
||||||
|
strongSelf.forwardBackgroundNode?.frame = CGRect(origin: CGPoint(x: forwardInfoFrame.minX - 6.0, y: forwardInfoFrame.minY - 2.0), size: CGSize(width: forwardInfoFrame.size.width + 10.0, height: forwardInfoFrame.size.height + 4.0))
|
||||||
|
} else if let forwardInfoNode = strongSelf.forwardInfoNode {
|
||||||
|
forwardInfoNode.removeFromSupernode()
|
||||||
|
strongSelf.forwardInfoNode = nil
|
||||||
|
}
|
||||||
|
|
||||||
if let actionButtonsSizeAndApply = actionButtonsSizeAndApply {
|
if let actionButtonsSizeAndApply = actionButtonsSizeAndApply {
|
||||||
var animated = false
|
var animated = false
|
||||||
if let _ = strongSelf.actionButtonsNode {
|
if let _ = strongSelf.actionButtonsNode {
|
||||||
@ -842,7 +941,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
if let _ = self.telegramFile {
|
if let _ = self.telegramFile {
|
||||||
let _ = item.controllerInteraction.openMessage(item.message, .default)
|
let _ = item.controllerInteraction.openMessage(item.message, .default)
|
||||||
} else if let _ = self.telegramDice {
|
} else if let _ = self.telegramDice {
|
||||||
item.controllerInteraction.displayMessageTooltip(item.content.firstMessage.id, item.presentationData.strings.Conversation_Dice, self, self.imageNode.frame)
|
item.controllerInteraction.displayMessageTooltip(item.content.firstMessage.id, item.presentationData.strings.Conversation_Dice, self, self.imageNode.frame.offsetBy(dx: 0.0, dy: self.imageNode.frame.height / 3.0))
|
||||||
} else if let _ = self.emojiFile {
|
} else if let _ = self.emojiFile {
|
||||||
if let animationNode = self.animationNode as? AnimatedStickerNode {
|
if let animationNode = self.animationNode as? AnimatedStickerNode {
|
||||||
var startTime: Signal<Double, NoError>
|
var startTime: Signal<Double, NoError>
|
||||||
|
@ -24,7 +24,7 @@ final class ManagedDiceAnimationNode: ManagedAnimationNode, GenericAnimatedStick
|
|||||||
self.context = context
|
self.context = context
|
||||||
self.emojis = emojis
|
self.emojis = emojis
|
||||||
|
|
||||||
super.init(size: CGSize(width: 136.0, height: 136.0))
|
super.init(size: CGSize(width: 184.0, height: 184.0))
|
||||||
|
|
||||||
self.trackTo(item: ManagedAnimationItem(source: .local("Dice_Rolling"), frames: ManagedAnimationFrameRange(startFrame: 0, endFrame: 60), duration: 1.0, loop: true))
|
self.trackTo(item: ManagedAnimationItem(source: .local("Dice_Rolling"), frames: ManagedAnimationFrameRange(startFrame: 0, endFrame: 60), duration: 1.0, loop: true))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user