Various improvements

This commit is contained in:
Isaac 2026-04-07 16:47:08 +02:00
parent 64c23acd43
commit 278f3ca420
2 changed files with 33 additions and 7 deletions

View file

@ -54,6 +54,7 @@ public final class SearchBarPlaceholderContentView: UIView {
let fieldStyle: SearchBarStyle
let plainBackgroundView: UIImageView
let glassBackgroundContainerView: GlassBackgroundContainerView?
let glassBackgroundView: GlassBackgroundView?
private var fillBackgroundColor: UIColor
private var foregroundColor: UIColor
@ -82,8 +83,10 @@ public final class SearchBarPlaceholderContentView: UIView {
switch fieldStyle {
case .legacy, .modern:
self.glassBackgroundContainerView = nil
self.glassBackgroundView = nil
case .inlineNavigation, .glass:
self.glassBackgroundContainerView = GlassBackgroundContainerView()
self.glassBackgroundView = GlassBackgroundView()
}
@ -111,8 +114,9 @@ public final class SearchBarPlaceholderContentView: UIView {
self.plainBackgroundView.addSubview(self.plainIconNode.view)
self.plainBackgroundView.addSubview(self.plainLabelNode.view)
if let glassBackgroundView = self.glassBackgroundView {
self.addSubview(glassBackgroundView)
if let glassBackgroundContainerView = self.glassBackgroundContainerView, let glassBackgroundView = self.glassBackgroundView {
self.addSubview(glassBackgroundContainerView)
glassBackgroundContainerView.contentView.addSubview(glassBackgroundView)
glassBackgroundView.contentView.addSubview(self.iconNode.view)
glassBackgroundView.contentView.addSubview(self.labelNode.view)
@ -300,9 +304,14 @@ public final class SearchBarPlaceholderContentView: UIView {
transition.updateFrame(view: self.plainBackgroundView, frame: CGRect(origin: CGPoint(), size: CGSize(width: params.constrainedSize.width, height: height)))
}
if let glassBackgroundView = self.glassBackgroundView {
transition.updatePosition(layer: glassBackgroundView.layer, position: backgroundFrame.center)
if let glassBackgroundContainerView = self.glassBackgroundContainerView, let glassBackgroundView = self.glassBackgroundView {
transition.updatePosition(layer: glassBackgroundContainerView.layer, position: backgroundFrame.center)
transition.updateBounds(layer: glassBackgroundContainerView.layer, bounds: CGRect(origin: CGPoint(), size: backgroundFrame.size))
transition.updatePosition(layer: glassBackgroundView.layer, position: CGRect(origin: CGPoint(), size: backgroundFrame.size).center)
transition.updateBounds(layer: glassBackgroundView.layer, bounds: CGRect(origin: CGPoint(), size: backgroundFrame.size))
var backgroundAlpha: CGFloat = 1.0
if backgroundFrame.height < 16.0 {
backgroundAlpha = max(0.0, min(1.0, backgroundFrame.height / 16.0))
@ -310,9 +319,10 @@ public final class SearchBarPlaceholderContentView: UIView {
if !params.isActive {
backgroundAlpha = 0.0
}
ComponentTransition(transition).setAlpha(view: glassBackgroundView, alpha: backgroundAlpha)
ComponentTransition(transition).setAlpha(view: glassBackgroundContainerView, alpha: backgroundAlpha)
let isDark = params.backgroundColor.hsb.b < 0.5
if params.isActive {
glassBackgroundContainerView.update(size: backgroundFrame.size, isDark: isDark, transition: ComponentTransition(transition))
glassBackgroundView.update(size: backgroundFrame.size, cornerRadius: backgroundFrame.height * 0.5, isDark: isDark, tintColor: .init(kind: params.preferClearGlass ? .clear : .panel), isInteractive: true, transition: ComponentTransition(transition))
}

View file

@ -445,6 +445,22 @@ func fetchAndPreloadReplyThreadInfo(context: AccountContext, subject: ReplyThrea
}
if preload {
var channelMessage: Signal<Void, NoError> = .single(Void())
if case .channelPost = subject, let channelMessageId = replyThreadMessage.channelMessageId {
channelMessage = context.engine.messages.getMessagesLoadIfNecessary([channelMessageId], strategy: .cloud(skipLocal: false))
|> mapToSignal { result -> Signal<Void, GetMessagesError> in
switch result {
case .progress:
return .never()
case .result:
return .single(Void())
}
}
|> `catch` { _ -> Signal<Void, NoError> in
return .single(Void())
}
}
let preloadSignal = preloadedChatHistoryViewForLocation(
input,
context: context,
@ -455,8 +471,8 @@ func fetchAndPreloadReplyThreadInfo(context: AccountContext, subject: ReplyThrea
tag: nil,
additionalData: []
)
return preloadSignal
|> map { historyView -> Bool? in
return combineLatest(preloadSignal, channelMessage)
|> map { historyView, _ -> Bool? in
switch historyView {
case .Loading:
return nil