Various fixes

This commit is contained in:
Ilya Laktyushin 2023-11-27 16:51:22 +04:00
parent c8d483a2c7
commit bb7d91cd35
10 changed files with 69 additions and 19 deletions

View File

@ -294,8 +294,6 @@ public final class AvatarNode: ASDisplayNode {
private var theme: PresentationTheme?
private var overrideImage: AvatarNodeImageOverride?
public let imageNode: ImageNode
private var animationBackgroundNode: ImageNode?
private var animationNode: AnimationNode?
public var editOverlayNode: AvatarEditOverlayNode?
private let imageReadyDisposable = MetaDisposable()
@ -438,6 +436,20 @@ public final class AvatarNode: ASDisplayNode {
self.imageNode.isHidden = true
}
public func playRepostAnimation() {
let animationNode = AnimationNode(animation: "anim_storyrepost", colors: [:], scale: 0.11)
animationNode.isUserInteractionEnabled = false
self.addSubnode(animationNode)
if var size = animationNode.preferredSize() {
size = CGSize(width: ceil(size.width), height: ceil(size.height))
animationNode.frame = CGRect(x: floor((self.bounds.width - size.width) / 2.0), y: floor((self.bounds.height - size.height) / 2.0) + 1.0, width: size.width, height: size.height)
Queue.mainQueue().after(0.15, {
animationNode.play()
})
}
}
public func setPeer(
accountPeerId: EnginePeer.Id,
postbox: Postbox,
@ -852,13 +864,15 @@ public final class AvatarNode: ASDisplayNode {
context.draw(savedMessagesIcon.cgImage!, in: CGRect(origin: CGPoint(x: floor((bounds.size.width - savedMessagesIcon.size.width) / 2.0), y: floor((bounds.size.height - savedMessagesIcon.size.height) / 2.0)), size: savedMessagesIcon.size))
}
} else if case .repostIcon = parameters.icon {
let factor = bounds.size.width / 60.0
context.translateBy(x: bounds.size.width / 2.0, y: bounds.size.height / 2.0)
context.scaleBy(x: factor, y: -factor)
context.translateBy(x: -bounds.size.width / 2.0, y: -bounds.size.height / 2.0)
if let repostStoryIcon = repostStoryIcon {
context.draw(repostStoryIcon.cgImage!, in: CGRect(origin: CGPoint(x: floor((bounds.size.width - repostStoryIcon.size.width) / 2.0), y: floor((bounds.size.height - repostStoryIcon.size.height) / 2.0)), size: repostStoryIcon.size))
if !"".isEmpty {
let factor = bounds.size.width / 60.0
context.translateBy(x: bounds.size.width / 2.0, y: bounds.size.height / 2.0)
context.scaleBy(x: factor, y: -factor)
context.translateBy(x: -bounds.size.width / 2.0, y: -bounds.size.height / 2.0)
if let repostStoryIcon = repostStoryIcon {
context.draw(repostStoryIcon.cgImage!, in: CGRect(origin: CGPoint(x: floor((bounds.size.width - repostStoryIcon.size.width) / 2.0), y: floor((bounds.size.height - repostStoryIcon.size.height) / 2.0)), size: repostStoryIcon.size))
}
}
} else if case .repliesIcon = parameters.icon {
let factor = bounds.size.width / 60.0
@ -1031,6 +1045,10 @@ public final class AvatarNode: ASDisplayNode {
self.contentNode.playArchiveAnimation()
}
public func playRepostAnimation() {
self.contentNode.playRepostAnimation()
}
public func setPeer(
accountPeerId: EnginePeer.Id,
postbox: Postbox,

View File

@ -101,6 +101,7 @@ open class TooltipController: ViewController, StandalonePresentableController {
public private(set) var content: TooltipControllerContent
private let baseFontSize: CGFloat
private let balancedTextLayout: Bool
private let isBlurred: Bool
open func updateContent(_ content: TooltipControllerContent, animated: Bool, extendTimer: Bool, arrowOnBottom: Bool = true) {
if self.content != content {
@ -131,10 +132,11 @@ open class TooltipController: ViewController, StandalonePresentableController {
public var dismissed: ((Bool) -> Void)?
public init(content: TooltipControllerContent, baseFontSize: CGFloat, balancedTextLayout: Bool = false, timeout: Double = 2.0, dismissByTapOutside: Bool = false, dismissByTapOutsideSource: Bool = false, dismissImmediatelyOnLayoutUpdate: Bool = false, arrowOnBottom: Bool = true, padding: CGFloat = 8.0, innerPadding: UIEdgeInsets = UIEdgeInsets()) {
public init(content: TooltipControllerContent, baseFontSize: CGFloat, balancedTextLayout: Bool = false, isBlurred: Bool = false, timeout: Double = 2.0, dismissByTapOutside: Bool = false, dismissByTapOutsideSource: Bool = false, dismissImmediatelyOnLayoutUpdate: Bool = false, arrowOnBottom: Bool = true, padding: CGFloat = 8.0, innerPadding: UIEdgeInsets = UIEdgeInsets()) {
self.content = content
self.baseFontSize = baseFontSize
self.balancedTextLayout = balancedTextLayout
self.isBlurred = isBlurred
self.timeout = timeout
self.dismissByTapOutside = dismissByTapOutside
self.dismissByTapOutsideSource = dismissByTapOutsideSource
@ -157,7 +159,7 @@ open class TooltipController: ViewController, StandalonePresentableController {
}
override open func loadDisplayNode() {
self.displayNode = TooltipControllerNode(content: self.content, baseFontSize: self.baseFontSize, balancedTextLayout: self.balancedTextLayout, dismiss: { [weak self] tappedInside in
self.displayNode = TooltipControllerNode(content: self.content, baseFontSize: self.baseFontSize, balancedTextLayout: self.balancedTextLayout, isBlurred: self.isBlurred, dismiss: { [weak self] tappedInside in
self?.dismiss(tappedInside: tappedInside)
}, dismissByTapOutside: self.dismissByTapOutside, dismissByTapOutsideSource: self.dismissByTapOutsideSource)
self.controllerNode.padding = self.padding

View File

@ -26,15 +26,17 @@ final class TooltipControllerNode: ASDisplayNode {
private var dismissedByTouchOutside = false
private var dismissByTapOutsideSource = false
init(content: TooltipControllerContent, baseFontSize: CGFloat, balancedTextLayout: Bool, dismiss: @escaping (Bool) -> Void, dismissByTapOutside: Bool, dismissByTapOutsideSource: Bool) {
init(content: TooltipControllerContent, baseFontSize: CGFloat, balancedTextLayout: Bool, isBlurred: Bool, dismiss: @escaping (Bool) -> Void, dismissByTapOutside: Bool, dismissByTapOutsideSource: Bool) {
self.baseFontSize = baseFontSize
self.balancedTextLayout = balancedTextLayout
self.dismissByTapOutside = dismissByTapOutside
self.dismissByTapOutsideSource = dismissByTapOutsideSource
self.containerNode = ContextMenuContainerNode(isBlurred: false, isDark: true)
self.containerNode.containerNode.backgroundColor = UIColor(white: 0.0, alpha: 0.8)
self.containerNode = ContextMenuContainerNode(isBlurred: isBlurred, isDark: true)
if !isBlurred {
self.containerNode.containerNode.backgroundColor = UIColor(white: 0.0, alpha: 0.8)
}
self.imageNode = ASImageNode()
self.imageNode.image = content.image

View File

@ -119,7 +119,6 @@ public final class SelectablePeerNode: ASDisplayNode {
self.avatarNode = AvatarNode(font: avatarFont)
self.avatarNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: 60.0, height: 60.0))
self.avatarNode.isLayerBacked = !smartInvertColorsEnabled()
self.textNode = ImmediateTextNode()
self.textNode.isUserInteractionEnabled = false
@ -178,6 +177,7 @@ public final class SelectablePeerNode: ASDisplayNode {
self.textNode.attributedText = NSAttributedString(string: strings.Share_RepostStory, font: textFont, textColor: self.theme.textColor, paragraphAlignment: .center)
self.avatarNode.setPeer(accountPeerId: accountPeerId, postbox: postbox, network: network, contentSettings: ContentSettings.default, theme: theme, peer: nil, overrideImage: .repostIcon, emptyColor: self.theme.avatarPlaceholderColor, clipStyle: .round, synchronousLoad: synchronousLoad)
self.avatarNode.playRepostAnimation()
}
public func setup(accountPeerId: EnginePeer.Id, postbox: Postbox, network: Network, energyUsageSettings: EnergyUsageSettings, contentSettings: ContentSettings, animationCache: AnimationCache, animationRenderer: MultiAnimationRenderer, resolveInlineStickers: @escaping ([Int64]) -> Signal<[Int64: TelegramMediaFile], NoError>, theme: PresentationTheme, strings: PresentationStrings, peer: EngineRenderedPeer, customTitle: String? = nil, iconId: Int64? = nil, iconColor: Int32? = nil, online: Bool = false, numberOfLines: Int = 2, synchronousLoad: Bool) {

View File

@ -1182,7 +1182,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
if case .background = self.mode, toolbarBottomInset.isZero {
toolbarBottomInset = 16.0
}
if case .peer = self.resultMode {
if case .peer = self.resultMode, !self.state.displayPatternPanel {
toolbarBottomInset += 58.0
}
let toolbarHeight = 49.0 + toolbarBottomInset

View File

@ -288,7 +288,9 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode, WallpaperGalleryToolbar
}
self.applyButton.updateTitle(applyTitle, theme: theme)
self.applyForBothButton.updateTitle(applyForBothTitle ?? "", theme: theme)
if let applyForBothTitle {
self.applyForBothButton.updateTitle(applyForBothTitle, theme: theme)
}
self.applyForBothButton.isLocked = applyForBothLocked
}
@ -301,6 +303,12 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode, WallpaperGalleryToolbar
let applyFrame = CGRect(origin: CGPoint(x: inset, y: 2.0), size: CGSize(width: size.width - inset * 2.0, height: buttonHeight))
let applyForBothFrame = CGRect(origin: CGPoint(x: inset, y: applyFrame.maxY + spacing), size: CGSize(width: size.width - inset * 2.0, height: buttonHeight))
var showApplyForBothButton = false
if case .setPeer = self.doneButtonType {
showApplyForBothButton = true
}
transition.updateAlpha(node: self.applyForBothButton, alpha: showApplyForBothButton ? 1.0 : 0.0)
self.applyButton.frame = applyFrame
self.applyButton.updateSize(applyFrame.size)
self.applyForBothButton.frame = applyForBothFrame

View File

@ -730,7 +730,7 @@ final class StoryContentCaptionComponent: Component {
if let self, case let .known(peer, _, _) = forwardInfo, let story = self.forwardInfoStory {
self.component?.openStory(peer, story)
} else if let controller = self?.component?.controller() as? StoryContainerScreen {
let tooltipController = TooltipController(content: .text(component.strings.Story_ForwardAuthorHiddenTooltip), baseFontSize: 17.0, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true)
let tooltipController = TooltipController(content: .text(component.strings.Story_ForwardAuthorHiddenTooltip), baseFontSize: 17.0, isBlurred: true, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true)
controller.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceNodeAndRect: { [weak self, weak controller] in
if let self, let controller, let forwardInfoPanel = self.forwardInfoPanel?.view {
return (controller.node, forwardInfoPanel.convert(forwardInfoPanel.bounds, to: controller.view))

View File

@ -83,6 +83,7 @@ final class StoryItemContentComponent: Component {
private let overlaysView: StoryItemOverlaysView
private var videoNode: UniversalVideoNode?
private var loadingEffectView: StoryItemLoadingEffectView?
private var loadingEffectAppearanceTimer: SwiftSignalKit.Timer?
private var mediaAreasEffectView: StoryItemLoadingEffectView?
@ -826,11 +827,29 @@ final class StoryItemContentComponent: Component {
loadingEffectView = current
} else {
loadingEffectView = StoryItemLoadingEffectView(effectAlpha: 0.1, borderAlpha: 0.2, duration: 1.0, hasCustomBorder: false, playOnce: false)
loadingEffectView.alpha = 0.0
self.loadingEffectView = loadingEffectView
self.addSubview(loadingEffectView)
if self.loadingEffectAppearanceTimer == nil {
let timer = SwiftSignalKit.Timer(timeout: 0.2, repeat: false, completion: { [weak self] in
guard let self else {
return
}
if let loadingEffectView = self.loadingEffectView {
loadingEffectView.alpha = 1.0
loadingEffectView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.18)
}
self.loadingEffectAppearanceTimer = nil
}, queue: Queue.mainQueue())
timer.start()
self.loadingEffectAppearanceTimer = timer
}
}
loadingEffectView.update(size: availableSize, transition: transition)
} else if let loadingEffectView = self.loadingEffectView {
self.loadingEffectAppearanceTimer?.invalidate()
self.loadingEffectAppearanceTimer = nil
self.loadingEffectView = nil
loadingEffectView.layer.animateAlpha(from: loadingEffectView.alpha, to: 0.0, duration: 0.18, removeOnCompletion: false, completion: { [weak loadingEffectView] _ in
loadingEffectView?.removeFromSuperview()

View File

@ -2960,7 +2960,7 @@ public final class StoryItemSetContainerComponent: Component {
let rect = view.convert(view.bounds, to: nil)
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
let text = presentationData.strings.Conversation_VoiceMessagesRestricted(component.slice.peer.compactDisplayTitle).string
let controller = TooltipController(content: .text(text), baseFontSize: presentationData.listsFontSize.baseDisplaySize, padding: 2.0)
let controller = TooltipController(content: .text(text), baseFontSize: presentationData.listsFontSize.baseDisplaySize, isBlurred: true, padding: 2.0)
controller.dismissed = { [weak self] _ in
if let self {
self.voiceMessagesRestrictedTooltipController = nil

File diff suppressed because one or more lines are too long