mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
Fix build
This commit is contained in:
parent
5193b54aa9
commit
02f04e4c67
@ -721,6 +721,7 @@ public final class MediaStreamComponent: CombinedComponent {
|
|||||||
var infoItem: AnyComponent<Empty>?
|
var infoItem: AnyComponent<Empty>?
|
||||||
if let originInfo = context.state.originInfo {
|
if let originInfo = context.state.originInfo {
|
||||||
infoItem = AnyComponent(OriginInfoComponent(
|
infoItem = AnyComponent(OriginInfoComponent(
|
||||||
|
strings: environment.strings,
|
||||||
memberCount: originInfo.memberCount
|
memberCount: originInfo.memberCount
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -933,6 +934,7 @@ public final class MediaStreamComponent: CombinedComponent {
|
|||||||
|
|
||||||
let sheet = sheet.update(
|
let sheet = sheet.update(
|
||||||
component: StreamSheetComponent(
|
component: StreamSheetComponent(
|
||||||
|
strings: environment.strings,
|
||||||
topOffset: topOffset,
|
topOffset: topOffset,
|
||||||
sheetHeight: sheetHeight,
|
sheetHeight: sheetHeight,
|
||||||
backgroundColor: (isFullscreen && !state.hasVideo) ? .clear : (isFullyDragged ? fullscreenBackgroundColor : panelBackgroundColor),
|
backgroundColor: (isFullscreen && !state.hasVideo) ? .clear : (isFullyDragged ? fullscreenBackgroundColor : panelBackgroundColor),
|
||||||
@ -1691,15 +1693,21 @@ private final class StreamTitleComponent: Component {
|
|||||||
|
|
||||||
|
|
||||||
private final class OriginInfoComponent: CombinedComponent {
|
private final class OriginInfoComponent: CombinedComponent {
|
||||||
|
let strings: PresentationStrings
|
||||||
let participantsCount: Int
|
let participantsCount: Int
|
||||||
|
|
||||||
init(
|
init(
|
||||||
|
strings: PresentationStrings,
|
||||||
memberCount: Int
|
memberCount: Int
|
||||||
) {
|
) {
|
||||||
|
self.strings = strings
|
||||||
self.participantsCount = memberCount
|
self.participantsCount = memberCount
|
||||||
}
|
}
|
||||||
|
|
||||||
static func ==(lhs: OriginInfoComponent, rhs: OriginInfoComponent) -> Bool {
|
static func ==(lhs: OriginInfoComponent, rhs: OriginInfoComponent) -> Bool {
|
||||||
|
if lhs.strings !== rhs.strings {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.participantsCount != rhs.participantsCount {
|
if lhs.participantsCount != rhs.participantsCount {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -1713,6 +1721,7 @@ private final class OriginInfoComponent: CombinedComponent {
|
|||||||
return { context in
|
return { context in
|
||||||
let viewerCounter = viewerCounter.update(
|
let viewerCounter = viewerCounter.update(
|
||||||
component: ParticipantsComponent(
|
component: ParticipantsComponent(
|
||||||
|
strings: context.component.strings,
|
||||||
count: context.component.participantsCount,
|
count: context.component.participantsCount,
|
||||||
showsSubtitle: true,
|
showsSubtitle: true,
|
||||||
fontSize: 18.0,
|
fontSize: 18.0,
|
||||||
|
@ -6,8 +6,10 @@ import AccountContext
|
|||||||
import AVKit
|
import AVKit
|
||||||
import MultilineTextComponent
|
import MultilineTextComponent
|
||||||
import Display
|
import Display
|
||||||
|
import TelegramPresentationData
|
||||||
|
|
||||||
final class StreamSheetComponent: CombinedComponent {
|
final class StreamSheetComponent: CombinedComponent {
|
||||||
|
let strings: PresentationStrings
|
||||||
let sheetHeight: CGFloat
|
let sheetHeight: CGFloat
|
||||||
let topOffset: CGFloat
|
let topOffset: CGFloat
|
||||||
let backgroundColor: UIColor
|
let backgroundColor: UIColor
|
||||||
@ -22,6 +24,7 @@ final class StreamSheetComponent: CombinedComponent {
|
|||||||
let fullscreenBottomComponent: AnyComponent<Empty>
|
let fullscreenBottomComponent: AnyComponent<Empty>
|
||||||
|
|
||||||
init(
|
init(
|
||||||
|
strings: PresentationStrings,
|
||||||
topOffset: CGFloat,
|
topOffset: CGFloat,
|
||||||
sheetHeight: CGFloat,
|
sheetHeight: CGFloat,
|
||||||
backgroundColor: UIColor,
|
backgroundColor: UIColor,
|
||||||
@ -34,6 +37,7 @@ final class StreamSheetComponent: CombinedComponent {
|
|||||||
fullscreenTopComponent: AnyComponent<Empty>,
|
fullscreenTopComponent: AnyComponent<Empty>,
|
||||||
fullscreenBottomComponent: AnyComponent<Empty>
|
fullscreenBottomComponent: AnyComponent<Empty>
|
||||||
) {
|
) {
|
||||||
|
self.strings = strings
|
||||||
self.topOffset = topOffset
|
self.topOffset = topOffset
|
||||||
self.sheetHeight = sheetHeight
|
self.sheetHeight = sheetHeight
|
||||||
self.backgroundColor = backgroundColor
|
self.backgroundColor = backgroundColor
|
||||||
@ -49,6 +53,9 @@ final class StreamSheetComponent: CombinedComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func ==(lhs: StreamSheetComponent, rhs: StreamSheetComponent) -> Bool {
|
static func ==(lhs: StreamSheetComponent, rhs: StreamSheetComponent) -> Bool {
|
||||||
|
if lhs.strings !== rhs.strings {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.topOffset != rhs.topOffset {
|
if lhs.topOffset != rhs.topOffset {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -159,7 +166,7 @@ final class StreamSheetComponent: CombinedComponent {
|
|||||||
)
|
)
|
||||||
|
|
||||||
let viewerCounter = viewerCounter.update(
|
let viewerCounter = viewerCounter.update(
|
||||||
component: ParticipantsComponent(count: context.component.participantsCount, fontSize: 44.0),
|
component: ParticipantsComponent(strings: context.component.strings, count: context.component.participantsCount, fontSize: 44.0),
|
||||||
availableSize: CGSize(width: context.availableSize.width, height: 70),
|
availableSize: CGSize(width: context.availableSize.width, height: 70),
|
||||||
transition: context.transition
|
transition: context.transition
|
||||||
)
|
)
|
||||||
|
@ -574,10 +574,11 @@ final class ChannelAppearanceScreenComponent: Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if resolvedState.changes.contains(.wallpaper) {
|
if resolvedState.changes.contains(.wallpaper) {
|
||||||
signals.append(component.context.engine.themes.setBuiltinChannelWallpaper(peerId: component.peerId, emoji: wallpaperEmoji, wallpaper: self.resolvedCurrentTheme?.wallpaper)
|
let _ = wallpaperEmoji
|
||||||
|
/*signals.append(component.context.engine.themes.setBuiltinChannelWallpaper(peerId: component.peerId, emoji: wallpaperEmoji, wallpaper: self.resolvedCurrentTheme?.wallpaper)
|
||||||
|> mapError { _ -> ApplyError in
|
|> mapError { _ -> ApplyError in
|
||||||
return .generic
|
return .generic
|
||||||
})
|
})*/
|
||||||
}
|
}
|
||||||
|
|
||||||
self.applyDisposable = (combineLatest(signals)
|
self.applyDisposable = (combineLatest(signals)
|
||||||
|
@ -407,299 +407,6 @@ public final class StoryFooterPanelComponent: Component {
|
|||||||
|
|
||||||
self.viewStatsButton.isEnabled = displayViewLists
|
self.viewStatsButton.isEnabled = displayViewLists
|
||||||
|
|
||||||
var rightContentOffset: CGFloat = availableSize.width - 12.0
|
|
||||||
|
|
||||||
if component.isChannel {
|
|
||||||
var likeStatsTransition = transition
|
|
||||||
var forwardStatsTransition = transition
|
|
||||||
|
|
||||||
if transition.animation.isImmediate, !isFirstTime, let previousComponent, previousComponent.storyItem.id == component.storyItem.id, previousComponent.expandFraction == component.expandFraction {
|
|
||||||
likeStatsTransition = .easeInOut(duration: 0.2)
|
|
||||||
forwardStatsTransition = .easeInOut(duration: 0.2)
|
|
||||||
}
|
|
||||||
|
|
||||||
let likeStatsText: AnimatedCountLabelView
|
|
||||||
if let current = self.likeStatsText {
|
|
||||||
likeStatsText = current
|
|
||||||
} else {
|
|
||||||
likeStatsTransition = likeStatsTransition.withAnimation(.none)
|
|
||||||
likeStatsText = AnimatedCountLabelView(frame: CGRect())
|
|
||||||
likeStatsText.isUserInteractionEnabled = false
|
|
||||||
self.likeStatsText = likeStatsText
|
|
||||||
}
|
|
||||||
|
|
||||||
let reactionStatsLayout = likeStatsText.update(
|
|
||||||
size: CGSize(width: availableSize.width, height: size.height),
|
|
||||||
segments: [
|
|
||||||
.number(reactionCount, NSAttributedString(string: "\(reactionCount)", font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white))
|
|
||||||
],
|
|
||||||
transition: (isFirstTime || likeStatsTransition.animation.isImmediate) ? .immediate : ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut)
|
|
||||||
)
|
|
||||||
var likeStatsFrame = CGRect(origin: CGPoint(x: rightContentOffset - reactionStatsLayout.size.width, y: floor((size.height - reactionStatsLayout.size.height) * 0.5)), size: reactionStatsLayout.size)
|
|
||||||
likeStatsFrame.origin.y += component.expandFraction * 45.0
|
|
||||||
|
|
||||||
likeStatsTransition.setPosition(view: likeStatsText, position: likeStatsFrame.center)
|
|
||||||
likeStatsTransition.setBounds(view: likeStatsText, bounds: CGRect(origin: CGPoint(), size: likeStatsFrame.size))
|
|
||||||
var likeStatsAlpha: CGFloat = (1.0 - component.expandFraction)
|
|
||||||
if reactionCount == 0 {
|
|
||||||
likeStatsAlpha = 0.0
|
|
||||||
}
|
|
||||||
likeStatsTransition.setAlpha(view: likeStatsText, alpha: likeStatsAlpha)
|
|
||||||
likeStatsTransition.setScale(view: likeStatsText, scale: reactionCount == 0 ? 0.001 : 1.0)
|
|
||||||
|
|
||||||
if reactionCount != 0 {
|
|
||||||
rightContentOffset -= reactionStatsLayout.size.width + 1.0
|
|
||||||
}
|
|
||||||
|
|
||||||
let likeButton: ComponentView<Empty>
|
|
||||||
if let current = self.likeButton {
|
|
||||||
likeButton = current
|
|
||||||
} else {
|
|
||||||
likeButton = ComponentView()
|
|
||||||
self.likeButton = likeButton
|
|
||||||
}
|
|
||||||
|
|
||||||
let likeButtonSize = likeButton.update(
|
|
||||||
transition: likeStatsTransition,
|
|
||||||
component: AnyComponent(MessageInputActionButtonComponent(
|
|
||||||
mode: .like(reaction: component.myReaction?.reaction, file: component.myReaction?.file, animationFileId: component.myReaction?.animationFileId),
|
|
||||||
storyId: component.storyItem.id,
|
|
||||||
action: { [weak self] _, action, _ in
|
|
||||||
guard let self, let component = self.component else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
guard case .up = action else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
component.likeAction()
|
|
||||||
},
|
|
||||||
longPressAction: nil,
|
|
||||||
switchMediaInputMode: {
|
|
||||||
},
|
|
||||||
updateMediaCancelFraction: { _ in
|
|
||||||
},
|
|
||||||
lockMediaRecording: {
|
|
||||||
},
|
|
||||||
stopAndPreviewMediaRecording: {
|
|
||||||
},
|
|
||||||
moreAction: { _, _ in },
|
|
||||||
context: component.context,
|
|
||||||
theme: component.theme,
|
|
||||||
strings: component.strings,
|
|
||||||
presentController: { _ in },
|
|
||||||
audioRecorder: nil,
|
|
||||||
videoRecordingStatus: nil
|
|
||||||
)),
|
|
||||||
environment: {},
|
|
||||||
containerSize: CGSize(width: 33.0, height: 33.0)
|
|
||||||
)
|
|
||||||
if let likeButtonView = likeButton.view as? MessageInputActionButtonComponent.View {
|
|
||||||
if likeButtonView.superview == nil {
|
|
||||||
self.addSubview(likeButtonView)
|
|
||||||
}
|
|
||||||
var likeButtonFrame = CGRect(origin: CGPoint(x: rightContentOffset - likeButtonSize.width, y: floor((size.height - likeButtonSize.height) * 0.5)), size: likeButtonSize)
|
|
||||||
likeButtonFrame.origin.y += component.expandFraction * 45.0
|
|
||||||
|
|
||||||
if let likeButtonTracingOffsetView = self.likeButtonTracingOffsetView {
|
|
||||||
let difference = CGPoint(x: likeButtonFrame.midX - likeButtonView.layer.position.x, y: likeButtonFrame.midY - likeButtonView.layer.position.y)
|
|
||||||
if difference != CGPoint() {
|
|
||||||
likeStatsTransition.setPosition(view: likeButtonTracingOffsetView, position: likeButtonTracingOffsetView.layer.position.offsetBy(dx: difference.x, dy: difference.y))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
likeStatsTransition.setPosition(view: likeButtonView, position: likeButtonFrame.center)
|
|
||||||
likeStatsTransition.setBounds(view: likeButtonView, bounds: CGRect(origin: CGPoint(), size: likeButtonFrame.size))
|
|
||||||
likeStatsTransition.setAlpha(view: likeButtonView, alpha: 1.0 - component.expandFraction)
|
|
||||||
|
|
||||||
rightContentOffset -= likeButtonSize.width + 14.0
|
|
||||||
|
|
||||||
if likeStatsText.superview == nil {
|
|
||||||
likeButtonView.button.view.addSubview(likeStatsText)
|
|
||||||
}
|
|
||||||
|
|
||||||
likeStatsFrame.origin.x -= likeButtonFrame.minX
|
|
||||||
likeStatsFrame.origin.y -= likeButtonFrame.minY
|
|
||||||
likeStatsTransition.setPosition(view: likeStatsText, position: likeStatsFrame.center)
|
|
||||||
likeStatsTransition.setBounds(view: likeStatsText, bounds: CGRect(origin: CGPoint(), size: likeStatsFrame.size))
|
|
||||||
}
|
|
||||||
|
|
||||||
if component.canShare {
|
|
||||||
let forwardStatsText: AnimatedCountLabelView
|
|
||||||
if let current = self.forwardStatsText {
|
|
||||||
forwardStatsText = current
|
|
||||||
} else {
|
|
||||||
forwardStatsTransition = forwardStatsTransition.withAnimation(.none)
|
|
||||||
forwardStatsText = AnimatedCountLabelView(frame: CGRect())
|
|
||||||
forwardStatsText.isUserInteractionEnabled = false
|
|
||||||
self.forwardStatsText = forwardStatsText
|
|
||||||
}
|
|
||||||
|
|
||||||
let forwardStatsLayout = forwardStatsText.update(
|
|
||||||
size: CGSize(width: availableSize.width, height: size.height),
|
|
||||||
segments: [
|
|
||||||
.number(forwardCount, NSAttributedString(string: "\(forwardCount)", font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white))
|
|
||||||
],
|
|
||||||
transition: (isFirstTime || likeStatsTransition.animation.isImmediate) ? .immediate : ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut)
|
|
||||||
)
|
|
||||||
var forwardStatsFrame = CGRect(origin: CGPoint(x: rightContentOffset - forwardStatsLayout.size.width, y: floor((size.height - forwardStatsLayout.size.height) * 0.5)), size: forwardStatsLayout.size)
|
|
||||||
forwardStatsFrame.origin.y += component.expandFraction * 45.0
|
|
||||||
|
|
||||||
var forwardStatsAlpha: CGFloat = (1.0 - component.expandFraction)
|
|
||||||
if forwardCount == 0 {
|
|
||||||
forwardStatsAlpha = 0.0
|
|
||||||
}
|
|
||||||
forwardStatsTransition.setAlpha(view: forwardStatsText, alpha: forwardStatsAlpha)
|
|
||||||
forwardStatsTransition.setScale(view: forwardStatsText, scale: forwardCount == 0 ? 0.001 : 1.0)
|
|
||||||
|
|
||||||
if forwardCount != 0 {
|
|
||||||
rightContentOffset -= forwardStatsLayout.size.width + 1.0
|
|
||||||
}
|
|
||||||
|
|
||||||
let repostButton: ComponentView<Empty>
|
|
||||||
if let current = self.repostButton {
|
|
||||||
repostButton = current
|
|
||||||
} else {
|
|
||||||
repostButton = ComponentView()
|
|
||||||
self.repostButton = repostButton
|
|
||||||
}
|
|
||||||
|
|
||||||
let forwardButton: ComponentView<Empty>
|
|
||||||
if let current = self.forwardButton {
|
|
||||||
forwardButton = current
|
|
||||||
} else {
|
|
||||||
forwardButton = ComponentView()
|
|
||||||
self.forwardButton = forwardButton
|
|
||||||
}
|
|
||||||
|
|
||||||
let repostButtonSize = repostButton.update(
|
|
||||||
transition: likeStatsTransition,
|
|
||||||
component: AnyComponent(MessageInputActionButtonComponent(
|
|
||||||
mode: .repost,
|
|
||||||
storyId: component.storyItem.id,
|
|
||||||
action: { [weak self] _, action, _ in
|
|
||||||
guard let self, let component = self.component else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
guard case .up = action else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
component.repostAction()
|
|
||||||
},
|
|
||||||
longPressAction: nil,
|
|
||||||
switchMediaInputMode: {
|
|
||||||
},
|
|
||||||
updateMediaCancelFraction: { _ in
|
|
||||||
},
|
|
||||||
lockMediaRecording: {
|
|
||||||
},
|
|
||||||
stopAndPreviewMediaRecording: {
|
|
||||||
},
|
|
||||||
moreAction: { _, _ in },
|
|
||||||
context: component.context,
|
|
||||||
theme: component.theme,
|
|
||||||
strings: component.strings,
|
|
||||||
presentController: { _ in },
|
|
||||||
audioRecorder: nil,
|
|
||||||
videoRecordingStatus: nil
|
|
||||||
)),
|
|
||||||
environment: {},
|
|
||||||
containerSize: CGSize(width: 33.0, height: 33.0)
|
|
||||||
)
|
|
||||||
if let repostButtonView = repostButton.view as? MessageInputActionButtonComponent.View {
|
|
||||||
if repostButtonView.superview == nil {
|
|
||||||
self.addSubview(repostButtonView)
|
|
||||||
}
|
|
||||||
var repostButtonFrame = CGRect(origin: CGPoint(x: rightContentOffset - repostButtonSize.width, y: floor((size.height - repostButtonSize.height) * 0.5)), size: repostButtonSize)
|
|
||||||
repostButtonFrame.origin.y += component.expandFraction * 45.0
|
|
||||||
|
|
||||||
forwardStatsTransition.setPosition(view: repostButtonView, position: repostButtonFrame.center)
|
|
||||||
forwardStatsTransition.setBounds(view: repostButtonView, bounds: CGRect(origin: CGPoint(), size: repostButtonFrame.size))
|
|
||||||
forwardStatsTransition.setAlpha(view: repostButtonView, alpha: 1.0 - component.expandFraction)
|
|
||||||
|
|
||||||
rightContentOffset -= repostButtonSize.width + 14.0
|
|
||||||
|
|
||||||
if forwardStatsText.superview == nil {
|
|
||||||
repostButtonView.button.view.addSubview(forwardStatsText)
|
|
||||||
}
|
|
||||||
|
|
||||||
forwardStatsFrame.origin.x -= repostButtonFrame.minX
|
|
||||||
forwardStatsFrame.origin.y -= repostButtonFrame.minY
|
|
||||||
forwardStatsTransition.setPosition(view: forwardStatsText, position: forwardStatsFrame.center)
|
|
||||||
forwardStatsTransition.setBounds(view: forwardStatsText, bounds: CGRect(origin: CGPoint(), size: forwardStatsFrame.size))
|
|
||||||
}
|
|
||||||
|
|
||||||
let forwardButtonSize = forwardButton.update(
|
|
||||||
transition: likeStatsTransition,
|
|
||||||
component: AnyComponent(MessageInputActionButtonComponent(
|
|
||||||
mode: .forward,
|
|
||||||
storyId: component.storyItem.id,
|
|
||||||
action: { [weak self] _, action, _ in
|
|
||||||
guard let self, let component = self.component else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
guard case .up = action else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
component.forwardAction()
|
|
||||||
},
|
|
||||||
longPressAction: nil,
|
|
||||||
switchMediaInputMode: {
|
|
||||||
},
|
|
||||||
updateMediaCancelFraction: { _ in
|
|
||||||
},
|
|
||||||
lockMediaRecording: {
|
|
||||||
},
|
|
||||||
stopAndPreviewMediaRecording: {
|
|
||||||
},
|
|
||||||
moreAction: { _, _ in },
|
|
||||||
context: component.context,
|
|
||||||
theme: component.theme,
|
|
||||||
strings: component.strings,
|
|
||||||
presentController: { _ in },
|
|
||||||
audioRecorder: nil,
|
|
||||||
videoRecordingStatus: nil
|
|
||||||
)),
|
|
||||||
environment: {},
|
|
||||||
containerSize: CGSize(width: 33.0, height: 33.0)
|
|
||||||
)
|
|
||||||
if let forwardButtonView = forwardButton.view {
|
|
||||||
if forwardButtonView.superview == nil {
|
|
||||||
self.addSubview(forwardButtonView)
|
|
||||||
}
|
|
||||||
var forwardButtonFrame = CGRect(origin: CGPoint(x: rightContentOffset - likeButtonSize.width, y: floor((size.height - forwardButtonSize.height) * 0.5)), size: forwardButtonSize)
|
|
||||||
forwardButtonFrame.origin.y += component.expandFraction * 45.0
|
|
||||||
|
|
||||||
likeStatsTransition.setPosition(view: forwardButtonView, position: forwardButtonFrame.center)
|
|
||||||
likeStatsTransition.setBounds(view: forwardButtonView, bounds: CGRect(origin: CGPoint(), size: forwardButtonFrame.size))
|
|
||||||
likeStatsTransition.setAlpha(view: forwardButtonView, alpha: 1.0 - component.expandFraction)
|
|
||||||
|
|
||||||
rightContentOffset -= forwardButtonSize.width + 8.0
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if let repostButton = self.repostButton {
|
|
||||||
self.repostButton = nil
|
|
||||||
repostButton.view?.removeFromSuperview()
|
|
||||||
}
|
|
||||||
if let forwardButton = self.forwardButton {
|
|
||||||
self.forwardButton = nil
|
|
||||||
forwardButton.view?.removeFromSuperview()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if let likeButton = self.likeButton {
|
|
||||||
self.likeButton = nil
|
|
||||||
likeButton.view?.removeFromSuperview()
|
|
||||||
}
|
|
||||||
if let repostButton = self.repostButton {
|
|
||||||
self.repostButton = nil
|
|
||||||
repostButton.view?.removeFromSuperview()
|
|
||||||
}
|
|
||||||
if let forwardButton = self.forwardButton {
|
|
||||||
self.forwardButton = nil
|
|
||||||
forwardButton.view?.removeFromSuperview()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var regularSegments: [AnimatedCountLabelView.Segment] = []
|
var regularSegments: [AnimatedCountLabelView.Segment] = []
|
||||||
if viewCount != 0 {
|
if viewCount != 0 {
|
||||||
regularSegments.append(.number(viewCount, NSAttributedString(string: countString(Int64(viewCount)), font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white)))
|
regularSegments.append(.number(viewCount, NSAttributedString(string: countString(Int64(viewCount)), font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white)))
|
||||||
@ -986,6 +693,300 @@ public final class StoryFooterPanelComponent: Component {
|
|||||||
contentX += repostsTextSize.width
|
contentX += repostsTextSize.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var rightContentOffset: CGFloat = availableSize.width - 12.0
|
||||||
|
|
||||||
|
if component.isChannel {
|
||||||
|
var likeStatsTransition = transition
|
||||||
|
var forwardStatsTransition = transition
|
||||||
|
|
||||||
|
if transition.animation.isImmediate, !isFirstTime, let previousComponent, previousComponent.storyItem.id == component.storyItem.id, previousComponent.expandFraction == component.expandFraction {
|
||||||
|
likeStatsTransition = .easeInOut(duration: 0.2)
|
||||||
|
forwardStatsTransition = .easeInOut(duration: 0.2)
|
||||||
|
}
|
||||||
|
|
||||||
|
let likeStatsText: AnimatedCountLabelView
|
||||||
|
if let current = self.likeStatsText {
|
||||||
|
likeStatsText = current
|
||||||
|
} else {
|
||||||
|
likeStatsTransition = likeStatsTransition.withAnimation(.none)
|
||||||
|
likeStatsText = AnimatedCountLabelView(frame: CGRect())
|
||||||
|
likeStatsText.isUserInteractionEnabled = false
|
||||||
|
self.likeStatsText = likeStatsText
|
||||||
|
}
|
||||||
|
|
||||||
|
let reactionStatsLayout = likeStatsText.update(
|
||||||
|
size: CGSize(width: availableSize.width, height: size.height),
|
||||||
|
segments: [
|
||||||
|
.number(reactionCount, NSAttributedString(string: "\(reactionCount)", font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white))
|
||||||
|
],
|
||||||
|
transition: (isFirstTime || likeStatsTransition.animation.isImmediate) ? .immediate : ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut)
|
||||||
|
)
|
||||||
|
var likeStatsFrame = CGRect(origin: CGPoint(x: rightContentOffset - reactionStatsLayout.size.width, y: floor((size.height - reactionStatsLayout.size.height) * 0.5)), size: reactionStatsLayout.size)
|
||||||
|
likeStatsFrame.origin.y += component.expandFraction * 45.0
|
||||||
|
//likeStatsFrame.origin.x = (1.0 - component.expandFraction) * likeStatsFrame.origin.x + component.expandFraction * (contentX)
|
||||||
|
|
||||||
|
likeStatsTransition.setPosition(view: likeStatsText, position: likeStatsFrame.center)
|
||||||
|
likeStatsTransition.setBounds(view: likeStatsText, bounds: CGRect(origin: CGPoint(), size: likeStatsFrame.size))
|
||||||
|
var likeStatsAlpha: CGFloat = (1.0 - component.expandFraction)
|
||||||
|
if reactionCount == 0 {
|
||||||
|
likeStatsAlpha = 0.0
|
||||||
|
}
|
||||||
|
likeStatsTransition.setAlpha(view: likeStatsText, alpha: likeStatsAlpha)
|
||||||
|
likeStatsTransition.setScale(view: likeStatsText, scale: reactionCount == 0 ? 0.001 : 1.0)
|
||||||
|
|
||||||
|
if reactionCount != 0 {
|
||||||
|
rightContentOffset -= reactionStatsLayout.size.width + 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
let likeButton: ComponentView<Empty>
|
||||||
|
if let current = self.likeButton {
|
||||||
|
likeButton = current
|
||||||
|
} else {
|
||||||
|
likeButton = ComponentView()
|
||||||
|
self.likeButton = likeButton
|
||||||
|
}
|
||||||
|
|
||||||
|
let likeButtonSize = likeButton.update(
|
||||||
|
transition: likeStatsTransition,
|
||||||
|
component: AnyComponent(MessageInputActionButtonComponent(
|
||||||
|
mode: .like(reaction: component.myReaction?.reaction, file: component.myReaction?.file, animationFileId: component.myReaction?.animationFileId),
|
||||||
|
storyId: component.storyItem.id,
|
||||||
|
action: { [weak self] _, action, _ in
|
||||||
|
guard let self, let component = self.component else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard case .up = action else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
component.likeAction()
|
||||||
|
},
|
||||||
|
longPressAction: nil,
|
||||||
|
switchMediaInputMode: {
|
||||||
|
},
|
||||||
|
updateMediaCancelFraction: { _ in
|
||||||
|
},
|
||||||
|
lockMediaRecording: {
|
||||||
|
},
|
||||||
|
stopAndPreviewMediaRecording: {
|
||||||
|
},
|
||||||
|
moreAction: { _, _ in },
|
||||||
|
context: component.context,
|
||||||
|
theme: component.theme,
|
||||||
|
strings: component.strings,
|
||||||
|
presentController: { _ in },
|
||||||
|
audioRecorder: nil,
|
||||||
|
videoRecordingStatus: nil
|
||||||
|
)),
|
||||||
|
environment: {},
|
||||||
|
containerSize: CGSize(width: 33.0, height: 33.0)
|
||||||
|
)
|
||||||
|
if let likeButtonView = likeButton.view as? MessageInputActionButtonComponent.View {
|
||||||
|
if likeButtonView.superview == nil {
|
||||||
|
self.addSubview(likeButtonView)
|
||||||
|
}
|
||||||
|
var likeButtonFrame = CGRect(origin: CGPoint(x: rightContentOffset - likeButtonSize.width, y: floor((size.height - likeButtonSize.height) * 0.5)), size: likeButtonSize)
|
||||||
|
likeButtonFrame.origin.y += component.expandFraction * 45.0
|
||||||
|
|
||||||
|
if let likeButtonTracingOffsetView = self.likeButtonTracingOffsetView {
|
||||||
|
let difference = CGPoint(x: likeButtonFrame.midX - likeButtonView.layer.position.x, y: likeButtonFrame.midY - likeButtonView.layer.position.y)
|
||||||
|
if difference != CGPoint() {
|
||||||
|
likeStatsTransition.setPosition(view: likeButtonTracingOffsetView, position: likeButtonTracingOffsetView.layer.position.offsetBy(dx: difference.x, dy: difference.y))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
likeStatsTransition.setPosition(view: likeButtonView, position: likeButtonFrame.center)
|
||||||
|
likeStatsTransition.setBounds(view: likeButtonView, bounds: CGRect(origin: CGPoint(), size: likeButtonFrame.size))
|
||||||
|
likeStatsTransition.setAlpha(view: likeButtonView, alpha: 1.0 - component.expandFraction)
|
||||||
|
|
||||||
|
rightContentOffset -= likeButtonSize.width + 14.0
|
||||||
|
|
||||||
|
if likeStatsText.superview == nil {
|
||||||
|
likeButtonView.button.view.addSubview(likeStatsText)
|
||||||
|
}
|
||||||
|
|
||||||
|
likeStatsFrame.origin.x -= likeButtonFrame.minX
|
||||||
|
likeStatsFrame.origin.y -= likeButtonFrame.minY
|
||||||
|
likeStatsTransition.setPosition(view: likeStatsText, position: likeStatsFrame.center)
|
||||||
|
likeStatsTransition.setBounds(view: likeStatsText, bounds: CGRect(origin: CGPoint(), size: likeStatsFrame.size))
|
||||||
|
}
|
||||||
|
|
||||||
|
if component.canShare {
|
||||||
|
let forwardStatsText: AnimatedCountLabelView
|
||||||
|
if let current = self.forwardStatsText {
|
||||||
|
forwardStatsText = current
|
||||||
|
} else {
|
||||||
|
forwardStatsTransition = forwardStatsTransition.withAnimation(.none)
|
||||||
|
forwardStatsText = AnimatedCountLabelView(frame: CGRect())
|
||||||
|
forwardStatsText.isUserInteractionEnabled = false
|
||||||
|
self.forwardStatsText = forwardStatsText
|
||||||
|
}
|
||||||
|
|
||||||
|
let forwardStatsLayout = forwardStatsText.update(
|
||||||
|
size: CGSize(width: availableSize.width, height: size.height),
|
||||||
|
segments: [
|
||||||
|
.number(forwardCount, NSAttributedString(string: "\(forwardCount)", font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white))
|
||||||
|
],
|
||||||
|
transition: (isFirstTime || likeStatsTransition.animation.isImmediate) ? .immediate : ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut)
|
||||||
|
)
|
||||||
|
var forwardStatsFrame = CGRect(origin: CGPoint(x: rightContentOffset - forwardStatsLayout.size.width, y: floor((size.height - forwardStatsLayout.size.height) * 0.5)), size: forwardStatsLayout.size)
|
||||||
|
forwardStatsFrame.origin.y += component.expandFraction * 45.0
|
||||||
|
|
||||||
|
var forwardStatsAlpha: CGFloat = (1.0 - component.expandFraction)
|
||||||
|
if forwardCount == 0 {
|
||||||
|
forwardStatsAlpha = 0.0
|
||||||
|
}
|
||||||
|
forwardStatsTransition.setAlpha(view: forwardStatsText, alpha: forwardStatsAlpha)
|
||||||
|
forwardStatsTransition.setScale(view: forwardStatsText, scale: forwardCount == 0 ? 0.001 : 1.0)
|
||||||
|
|
||||||
|
if forwardCount != 0 {
|
||||||
|
rightContentOffset -= forwardStatsLayout.size.width + 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
let repostButton: ComponentView<Empty>
|
||||||
|
if let current = self.repostButton {
|
||||||
|
repostButton = current
|
||||||
|
} else {
|
||||||
|
repostButton = ComponentView()
|
||||||
|
self.repostButton = repostButton
|
||||||
|
}
|
||||||
|
|
||||||
|
let forwardButton: ComponentView<Empty>
|
||||||
|
if let current = self.forwardButton {
|
||||||
|
forwardButton = current
|
||||||
|
} else {
|
||||||
|
forwardButton = ComponentView()
|
||||||
|
self.forwardButton = forwardButton
|
||||||
|
}
|
||||||
|
|
||||||
|
let repostButtonSize = repostButton.update(
|
||||||
|
transition: likeStatsTransition,
|
||||||
|
component: AnyComponent(MessageInputActionButtonComponent(
|
||||||
|
mode: .repost,
|
||||||
|
storyId: component.storyItem.id,
|
||||||
|
action: { [weak self] _, action, _ in
|
||||||
|
guard let self, let component = self.component else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard case .up = action else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
component.repostAction()
|
||||||
|
},
|
||||||
|
longPressAction: nil,
|
||||||
|
switchMediaInputMode: {
|
||||||
|
},
|
||||||
|
updateMediaCancelFraction: { _ in
|
||||||
|
},
|
||||||
|
lockMediaRecording: {
|
||||||
|
},
|
||||||
|
stopAndPreviewMediaRecording: {
|
||||||
|
},
|
||||||
|
moreAction: { _, _ in },
|
||||||
|
context: component.context,
|
||||||
|
theme: component.theme,
|
||||||
|
strings: component.strings,
|
||||||
|
presentController: { _ in },
|
||||||
|
audioRecorder: nil,
|
||||||
|
videoRecordingStatus: nil
|
||||||
|
)),
|
||||||
|
environment: {},
|
||||||
|
containerSize: CGSize(width: 33.0, height: 33.0)
|
||||||
|
)
|
||||||
|
if let repostButtonView = repostButton.view as? MessageInputActionButtonComponent.View {
|
||||||
|
if repostButtonView.superview == nil {
|
||||||
|
self.addSubview(repostButtonView)
|
||||||
|
}
|
||||||
|
var repostButtonFrame = CGRect(origin: CGPoint(x: rightContentOffset - repostButtonSize.width, y: floor((size.height - repostButtonSize.height) * 0.5)), size: repostButtonSize)
|
||||||
|
repostButtonFrame.origin.y += component.expandFraction * 45.0
|
||||||
|
|
||||||
|
forwardStatsTransition.setPosition(view: repostButtonView, position: repostButtonFrame.center)
|
||||||
|
forwardStatsTransition.setBounds(view: repostButtonView, bounds: CGRect(origin: CGPoint(), size: repostButtonFrame.size))
|
||||||
|
forwardStatsTransition.setAlpha(view: repostButtonView, alpha: 1.0 - component.expandFraction)
|
||||||
|
|
||||||
|
rightContentOffset -= repostButtonSize.width + 14.0
|
||||||
|
|
||||||
|
if forwardStatsText.superview == nil {
|
||||||
|
repostButtonView.button.view.addSubview(forwardStatsText)
|
||||||
|
}
|
||||||
|
|
||||||
|
forwardStatsFrame.origin.x -= repostButtonFrame.minX
|
||||||
|
forwardStatsFrame.origin.y -= repostButtonFrame.minY
|
||||||
|
forwardStatsTransition.setPosition(view: forwardStatsText, position: forwardStatsFrame.center)
|
||||||
|
forwardStatsTransition.setBounds(view: forwardStatsText, bounds: CGRect(origin: CGPoint(), size: forwardStatsFrame.size))
|
||||||
|
}
|
||||||
|
|
||||||
|
let forwardButtonSize = forwardButton.update(
|
||||||
|
transition: likeStatsTransition,
|
||||||
|
component: AnyComponent(MessageInputActionButtonComponent(
|
||||||
|
mode: .forward,
|
||||||
|
storyId: component.storyItem.id,
|
||||||
|
action: { [weak self] _, action, _ in
|
||||||
|
guard let self, let component = self.component else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard case .up = action else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
component.forwardAction()
|
||||||
|
},
|
||||||
|
longPressAction: nil,
|
||||||
|
switchMediaInputMode: {
|
||||||
|
},
|
||||||
|
updateMediaCancelFraction: { _ in
|
||||||
|
},
|
||||||
|
lockMediaRecording: {
|
||||||
|
},
|
||||||
|
stopAndPreviewMediaRecording: {
|
||||||
|
},
|
||||||
|
moreAction: { _, _ in },
|
||||||
|
context: component.context,
|
||||||
|
theme: component.theme,
|
||||||
|
strings: component.strings,
|
||||||
|
presentController: { _ in },
|
||||||
|
audioRecorder: nil,
|
||||||
|
videoRecordingStatus: nil
|
||||||
|
)),
|
||||||
|
environment: {},
|
||||||
|
containerSize: CGSize(width: 33.0, height: 33.0)
|
||||||
|
)
|
||||||
|
if let forwardButtonView = forwardButton.view {
|
||||||
|
if forwardButtonView.superview == nil {
|
||||||
|
self.addSubview(forwardButtonView)
|
||||||
|
}
|
||||||
|
var forwardButtonFrame = CGRect(origin: CGPoint(x: rightContentOffset - likeButtonSize.width, y: floor((size.height - forwardButtonSize.height) * 0.5)), size: forwardButtonSize)
|
||||||
|
forwardButtonFrame.origin.y += component.expandFraction * 45.0
|
||||||
|
|
||||||
|
likeStatsTransition.setPosition(view: forwardButtonView, position: forwardButtonFrame.center)
|
||||||
|
likeStatsTransition.setBounds(view: forwardButtonView, bounds: CGRect(origin: CGPoint(), size: forwardButtonFrame.size))
|
||||||
|
likeStatsTransition.setAlpha(view: forwardButtonView, alpha: 1.0 - component.expandFraction)
|
||||||
|
|
||||||
|
rightContentOffset -= forwardButtonSize.width + 8.0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if let repostButton = self.repostButton {
|
||||||
|
self.repostButton = nil
|
||||||
|
repostButton.view?.removeFromSuperview()
|
||||||
|
}
|
||||||
|
if let forwardButton = self.forwardButton {
|
||||||
|
self.forwardButton = nil
|
||||||
|
forwardButton.view?.removeFromSuperview()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if let likeButton = self.likeButton {
|
||||||
|
self.likeButton = nil
|
||||||
|
likeButton.view?.removeFromSuperview()
|
||||||
|
}
|
||||||
|
if let repostButton = self.repostButton {
|
||||||
|
self.repostButton = nil
|
||||||
|
repostButton.view?.removeFromSuperview()
|
||||||
|
}
|
||||||
|
if let forwardButton = self.forwardButton {
|
||||||
|
self.forwardButton = nil
|
||||||
|
forwardButton.view?.removeFromSuperview()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let statsButtonWidth = availableSize.width - 80.0
|
let statsButtonWidth = availableSize.width - 80.0
|
||||||
|
|
||||||
transition.setFrame(view: self.viewStatsButton, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: statsButtonWidth, height: baseHeight)))
|
transition.setFrame(view: self.viewStatsButton, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: statsButtonWidth, height: baseHeight)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user