Various improvements
This commit is contained in:
parent
64c23acd43
commit
278f3ca420
2 changed files with 33 additions and 7 deletions
|
|
@ -54,6 +54,7 @@ public final class SearchBarPlaceholderContentView: UIView {
|
||||||
|
|
||||||
let fieldStyle: SearchBarStyle
|
let fieldStyle: SearchBarStyle
|
||||||
let plainBackgroundView: UIImageView
|
let plainBackgroundView: UIImageView
|
||||||
|
let glassBackgroundContainerView: GlassBackgroundContainerView?
|
||||||
let glassBackgroundView: GlassBackgroundView?
|
let glassBackgroundView: GlassBackgroundView?
|
||||||
private var fillBackgroundColor: UIColor
|
private var fillBackgroundColor: UIColor
|
||||||
private var foregroundColor: UIColor
|
private var foregroundColor: UIColor
|
||||||
|
|
@ -82,8 +83,10 @@ public final class SearchBarPlaceholderContentView: UIView {
|
||||||
|
|
||||||
switch fieldStyle {
|
switch fieldStyle {
|
||||||
case .legacy, .modern:
|
case .legacy, .modern:
|
||||||
|
self.glassBackgroundContainerView = nil
|
||||||
self.glassBackgroundView = nil
|
self.glassBackgroundView = nil
|
||||||
case .inlineNavigation, .glass:
|
case .inlineNavigation, .glass:
|
||||||
|
self.glassBackgroundContainerView = GlassBackgroundContainerView()
|
||||||
self.glassBackgroundView = GlassBackgroundView()
|
self.glassBackgroundView = GlassBackgroundView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,8 +114,9 @@ public final class SearchBarPlaceholderContentView: UIView {
|
||||||
self.plainBackgroundView.addSubview(self.plainIconNode.view)
|
self.plainBackgroundView.addSubview(self.plainIconNode.view)
|
||||||
self.plainBackgroundView.addSubview(self.plainLabelNode.view)
|
self.plainBackgroundView.addSubview(self.plainLabelNode.view)
|
||||||
|
|
||||||
if let glassBackgroundView = self.glassBackgroundView {
|
if let glassBackgroundContainerView = self.glassBackgroundContainerView, let glassBackgroundView = self.glassBackgroundView {
|
||||||
self.addSubview(glassBackgroundView)
|
self.addSubview(glassBackgroundContainerView)
|
||||||
|
glassBackgroundContainerView.contentView.addSubview(glassBackgroundView)
|
||||||
|
|
||||||
glassBackgroundView.contentView.addSubview(self.iconNode.view)
|
glassBackgroundView.contentView.addSubview(self.iconNode.view)
|
||||||
glassBackgroundView.contentView.addSubview(self.labelNode.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)))
|
transition.updateFrame(view: self.plainBackgroundView, frame: CGRect(origin: CGPoint(), size: CGSize(width: params.constrainedSize.width, height: height)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if let glassBackgroundView = self.glassBackgroundView {
|
if let glassBackgroundContainerView = self.glassBackgroundContainerView, let glassBackgroundView = self.glassBackgroundView {
|
||||||
transition.updatePosition(layer: glassBackgroundView.layer, position: backgroundFrame.center)
|
|
||||||
|
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))
|
transition.updateBounds(layer: glassBackgroundView.layer, bounds: CGRect(origin: CGPoint(), size: backgroundFrame.size))
|
||||||
|
|
||||||
var backgroundAlpha: CGFloat = 1.0
|
var backgroundAlpha: CGFloat = 1.0
|
||||||
if backgroundFrame.height < 16.0 {
|
if backgroundFrame.height < 16.0 {
|
||||||
backgroundAlpha = max(0.0, min(1.0, 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 {
|
if !params.isActive {
|
||||||
backgroundAlpha = 0.0
|
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
|
let isDark = params.backgroundColor.hsb.b < 0.5
|
||||||
if params.isActive {
|
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))
|
glassBackgroundView.update(size: backgroundFrame.size, cornerRadius: backgroundFrame.height * 0.5, isDark: isDark, tintColor: .init(kind: params.preferClearGlass ? .clear : .panel), isInteractive: true, transition: ComponentTransition(transition))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -445,6 +445,22 @@ func fetchAndPreloadReplyThreadInfo(context: AccountContext, subject: ReplyThrea
|
||||||
}
|
}
|
||||||
|
|
||||||
if preload {
|
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(
|
let preloadSignal = preloadedChatHistoryViewForLocation(
|
||||||
input,
|
input,
|
||||||
context: context,
|
context: context,
|
||||||
|
|
@ -455,8 +471,8 @@ func fetchAndPreloadReplyThreadInfo(context: AccountContext, subject: ReplyThrea
|
||||||
tag: nil,
|
tag: nil,
|
||||||
additionalData: []
|
additionalData: []
|
||||||
)
|
)
|
||||||
return preloadSignal
|
return combineLatest(preloadSignal, channelMessage)
|
||||||
|> map { historyView -> Bool? in
|
|> map { historyView, _ -> Bool? in
|
||||||
switch historyView {
|
switch historyView {
|
||||||
case .Loading:
|
case .Loading:
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue