Various fixes

This commit is contained in:
Ilya Laktyushin 2024-02-15 16:23:47 -04:00
parent e709318560
commit cc4089ab07
5 changed files with 44 additions and 18 deletions

View File

@ -277,13 +277,16 @@ public final class AvatarNode: ASDisplayNode {
private struct Params: Equatable {
let peerId: EnginePeer.Id?
let resourceId: String?
let clipStyle: AvatarNodeClipStyle
init(
peerId: EnginePeer.Id?,
resourceId: String?
resourceId: String?,
clipStyle: AvatarNodeClipStyle
) {
self.peerId = peerId
self.resourceId = resourceId
self.clipStyle = clipStyle
}
}
@ -315,6 +318,15 @@ public final class AvatarNode: ASDisplayNode {
private var params: Params?
private var loadDisposable: Disposable?
var clipStyle: AvatarNodeClipStyle {
if let params = self.params {
return params.clipStyle
} else if case let .peerAvatar(_, _, _, _, clipStyle) = self.state {
return clipStyle
}
return .none
}
public var badgeView: AvatarBadgeView? {
didSet {
if self.badgeView !== oldValue {
@ -516,6 +528,7 @@ public final class AvatarNode: ASDisplayNode {
} else if peer?.restrictionText(platform: "ios", contentSettings: contentSettings) == nil {
representation = peer?.smallProfileImage
}
let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? EnginePeer.Id(0), peer?.nameColor, peer?.displayLetters ?? [], representation, clipStyle)
if updatedState != self.state || overrideImage != self.overrideImage || theme !== self.theme {
self.state = updatedState
@ -599,7 +612,8 @@ public final class AvatarNode: ASDisplayNode {
let smallProfileImage = peer?.smallProfileImage
let params = Params(
peerId: peer?.id,
resourceId: smallProfileImage?.resource.id.stringRepresentation
resourceId: smallProfileImage?.resource.id.stringRepresentation,
clipStyle: clipStyle
)
if self.params == params {
return
@ -689,6 +703,7 @@ public final class AvatarNode: ASDisplayNode {
} else if peer?.restrictionText(platform: "ios", contentSettings: genericContext.currentContentSettings.with { $0 }) == nil {
representation = peer?.smallProfileImage
}
let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? EnginePeer.Id(0), peer?.nameColor, peer?.displayLetters ?? [], representation, clipStyle)
if updatedState != self.state || overrideImage != self.overrideImage || theme !== self.theme {
self.state = updatedState
@ -1236,7 +1251,7 @@ public final class AvatarNode: ASDisplayNode {
}
let size = self.bounds.size
if let storyStats = self.storyStats {
let activeLineWidth = storyPresentationParams.lineWidth
let inactiveLineWidth = storyPresentationParams.inactiveLineWidth
@ -1274,7 +1289,8 @@ public final class AvatarNode: ASDisplayNode {
totalCount: storyStats.totalCount,
unseenCount: storyStats.unseenCount
),
progress: mappedProgress
progress: mappedProgress,
isRoundedRect: self.contentNode.clipStyle == .roundedRect
)),
environment: {},
containerSize: indicatorSize

View File

@ -50,6 +50,7 @@ public final class AvatarStoryIndicatorComponent: Component {
public let inactiveLineWidth: CGFloat
public let counters: Counters?
public let progress: Progress?
public let isRoundedRect: Bool
public init(
hasUnseen: Bool,
@ -58,7 +59,8 @@ public final class AvatarStoryIndicatorComponent: Component {
activeLineWidth: CGFloat,
inactiveLineWidth: CGFloat,
counters: Counters?,
progress: Progress? = nil
progress: Progress? = nil,
isRoundedRect: Bool = false
) {
self.hasUnseen = hasUnseen
self.hasUnseenCloseFriendsItems = hasUnseenCloseFriendsItems
@ -67,6 +69,7 @@ public final class AvatarStoryIndicatorComponent: Component {
self.inactiveLineWidth = inactiveLineWidth
self.counters = counters
self.progress = progress
self.isRoundedRect = isRoundedRect
}
public static func ==(lhs: AvatarStoryIndicatorComponent, rhs: AvatarStoryIndicatorComponent) -> Bool {
@ -91,6 +94,9 @@ public final class AvatarStoryIndicatorComponent: Component {
if lhs.progress != rhs.progress {
return false
}
if lhs.isRoundedRect != rhs.isRoundedRect {
return false
}
return true
}
@ -211,7 +217,7 @@ public final class AvatarStoryIndicatorComponent: Component {
}
}
func update(size: CGSize, radius: CGFloat, lineWidth: CGFloat, value: Value, transition: Transition) {
func update(size: CGSize, radius: CGFloat, isRoundedRect: Bool, lineWidth: CGFloat, value: Value, transition: Transition) {
let params = Params(
size: size,
lineWidth: lineWidth,
@ -295,7 +301,7 @@ public final class AvatarStoryIndicatorComponent: Component {
var locations: [CGFloat] = [0.0, 1.0]
if let counters = component.counters, counters.totalCount > 1 {
if let counters = component.counters, counters.totalCount > 1, !component.isRoundedRect {
let center = CGPoint(x: size.width * 0.5, y: size.height * 0.5)
let spacing: CGFloat = component.activeLineWidth * 2.0
let angularSpacing: CGFloat = spacing / radius
@ -347,7 +353,11 @@ public final class AvatarStoryIndicatorComponent: Component {
} else {
let lineWidth: CGFloat = component.hasUnseen ? component.activeLineWidth : component.inactiveLineWidth
context.setLineWidth(lineWidth)
context.addEllipse(in: CGRect(origin: CGPoint(x: size.width * 0.5 - diameter * 0.5, y: size.height * 0.5 - diameter * 0.5), size: size).insetBy(dx: lineWidth * 0.5, dy: lineWidth * 0.5))
if component.isRoundedRect {
context.addPath(UIBezierPath(roundedRect: CGRect(origin: CGPoint(x: size.width * 0.5 - diameter * 0.5, y: size.height * 0.5 - diameter * 0.5), size: size).insetBy(dx: lineWidth * 0.5, dy: lineWidth * 0.5), cornerRadius: floor(diameter * 0.25)).cgPath)
} else {
context.addEllipse(in: CGRect(origin: CGPoint(x: size.width * 0.5 - diameter * 0.5, y: size.height * 0.5 - diameter * 0.5), size: size).insetBy(dx: lineWidth * 0.5, dy: lineWidth * 0.5))
}
context.replacePathWithStrokedPath()
context.clip()
@ -369,7 +379,7 @@ public final class AvatarStoryIndicatorComponent: Component {
transition.setFrame(view: self.indicatorView, frame: indicatorFrame)
let progressTransition = Transition(animation: .curve(duration: 0.3, curve: .easeInOut))
if let progress = component.progress {
if let progress = component.progress, !component.isRoundedRect {
let colorLayer: SimpleGradientLayer
if let current = self.colorLayer {
colorLayer = current
@ -415,7 +425,7 @@ public final class AvatarStoryIndicatorComponent: Component {
mappedProgress = .progress(value)
}
progressLayer.update(size: indicatorFrame.size, radius: radius, lineWidth: lineWidth, value: mappedProgress, transition: .immediate)
progressLayer.update(size: indicatorFrame.size, radius: radius, isRoundedRect: component.isRoundedRect, lineWidth: lineWidth, value: mappedProgress, transition: .immediate)
} else {
progressTransition.setAlpha(view: self.indicatorView, alpha: 1.0)

View File

@ -966,7 +966,7 @@ public class VideoMessageCameraScreen: ViewController {
if let controller = self.controller, let layout = self.validLayout {
let insets = layout.insets(options: .input)
if point.y > layout.size.height - insets.bottom - controller.inputPanelFrame.height {
if point.y > layout.size.height - insets.bottom - controller.inputPanelFrame.0.height {
if layout.metrics.isTablet {
if point.x < layout.size.width * 0.33 {
return result
@ -1111,9 +1111,9 @@ public class VideoMessageCameraScreen: ViewController {
self.didAppear()
}
var backgroundFrame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: controller.inputPanelFrame.minY))
if backgroundFrame.maxY < layout.size.height - 100.0 && (layout.inputHeight ?? 0.0).isZero {
backgroundFrame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: layout.size.height - layout.intrinsicInsets.bottom - controller.inputPanelFrame.height))
var backgroundFrame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: controller.inputPanelFrame.0.minY))
if backgroundFrame.maxY < layout.size.height - 100.0 && (layout.inputHeight ?? 0.0).isZero && !controller.inputPanelFrame.1 {
backgroundFrame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: layout.size.height - layout.intrinsicInsets.bottom - controller.inputPanelFrame.0.height))
}
transition.setPosition(view: self.backgroundView, position: backgroundFrame.center)
@ -1266,7 +1266,7 @@ public class VideoMessageCameraScreen: ViewController {
private let context: AccountContext
private let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?
private let inputPanelFrame: CGRect
private let inputPanelFrame: (CGRect, Bool)
fileprivate var allowLiveUpload: Bool
fileprivate var viewOnceAvailable: Bool
@ -1417,7 +1417,7 @@ public class VideoMessageCameraScreen: ViewController {
updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?,
allowLiveUpload: Bool,
viewOnceAvailable: Bool,
inputPanelFrame: CGRect,
inputPanelFrame: (CGRect, Bool),
chatNode: ASDisplayNode?,
completion: @escaping (EnqueueMessage?, Bool?, Int32?) -> Void
) {

View File

@ -14087,7 +14087,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
updatedPresentationData: self.updatedPresentationData,
allowLiveUpload: peerId.namespace != Namespaces.Peer.SecretChat,
viewOnceAvailable: !isScheduledMessages && peerId.namespace == Namespaces.Peer.CloudUser && peerId != self.context.account.peerId && !isBot,
inputPanelFrame: currentInputPanelFrame,
inputPanelFrame: (currentInputPanelFrame, self.chatDisplayNode.inputNode != nil),
chatNode: self.chatDisplayNode.historyNode,
completion: { [weak self] message, silentPosting, scheduleTime in
guard let self, let videoController = self.videoRecorderValue else {

View File

@ -188,7 +188,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
private let inputContextOverTextPanelContainer: ChatControllerTitlePanelNodeContainer
private var overlayContextPanelNode: ChatInputContextPanelNode?
private var inputNode: ChatInputNode?
private(set) var inputNode: ChatInputNode?
private var disappearingNode: ChatInputNode?
private(set) var textInputPanelNode: ChatTextInputPanelNode?