Various improvements

This commit is contained in:
Ilya Laktyushin
2023-06-30 03:28:34 +02:00
parent 882680ed4d
commit b6e9138ea7
11 changed files with 515 additions and 36 deletions

View File

@@ -15,6 +15,22 @@ import TelegramUIPreferences
public final class EmojiSuggestionsComponent: Component {
public typealias EnvironmentType = Empty
public struct Theme: Equatable {
let backgroundColor: UIColor
let textColor: UIColor
let placeholderColor: UIColor
public init(
backgroundColor: UIColor,
textColor: UIColor,
placeholderColor: UIColor
) {
self.backgroundColor = backgroundColor
self.textColor = textColor
self.placeholderColor = placeholderColor
}
}
public static func suggestionData(context: AccountContext, isSavedMessages: Bool, query: String) -> Signal<[TelegramMediaFile], NoError> {
let hasPremium: Signal<Bool, NoError>
if isSavedMessages {
@@ -98,7 +114,7 @@ public final class EmojiSuggestionsComponent: Component {
}
public let context: AccountContext
public let theme: PresentationTheme
public let theme: Theme
public let animationCache: AnimationCache
public let animationRenderer: MultiAnimationRenderer
public let files: [TelegramMediaFile]
@@ -107,7 +123,7 @@ public final class EmojiSuggestionsComponent: Component {
public init(
context: AccountContext,
userLocation: MediaResourceUserLocation,
theme: PresentationTheme,
theme: Theme,
animationCache: AnimationCache,
animationRenderer: MultiAnimationRenderer,
files: [TelegramMediaFile],
@@ -125,7 +141,7 @@ public final class EmojiSuggestionsComponent: Component {
if lhs.context !== rhs.context {
return false
}
if lhs.theme !== rhs.theme {
if lhs.theme != rhs.theme {
return false
}
if lhs.animationCache !== rhs.animationCache {
@@ -305,7 +321,7 @@ public final class EmojiSuggestionsComponent: Component {
let itemLayer: InlineStickerItemLayer
if let current = self.visibleLayers[item.fileId] {
itemLayer = current
itemLayer.dynamicColor = component.theme.list.itemPrimaryTextColor
itemLayer.dynamicColor = component.theme.textColor
} else {
itemLayer = InlineStickerItemLayer(
context: component.context,
@@ -315,9 +331,9 @@ public final class EmojiSuggestionsComponent: Component {
file: item,
cache: component.animationCache,
renderer: component.animationRenderer,
placeholderColor: component.theme.list.mediaPlaceholderColor,
placeholderColor: component.theme.placeholderColor,
pointSize: itemFrame.size,
dynamicColor: component.theme.list.itemPrimaryTextColor
dynamicColor: component.theme.textColor
)
self.visibleLayers[item.fileId] = itemLayer
self.scrollView.layer.addSublayer(itemLayer)
@@ -382,10 +398,10 @@ public final class EmojiSuggestionsComponent: Component {
func update(component: EmojiSuggestionsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
let height: CGFloat = 54.0
if self.component?.theme !== component.theme {
if self.component?.theme.backgroundColor != component.theme.backgroundColor {
//self.backgroundLayer.fillColor = component.theme.list.plainBackgroundColor.cgColor
self.backgroundLayer.fillColor = UIColor.black.cgColor
self.blurView.updateColor(color: component.theme.list.plainBackgroundColor.withMultipliedAlpha(0.88), transition: .immediate)
self.blurView.updateColor(color: component.theme.backgroundColor, transition: .immediate)
}
var resetScrollingPosition = false
if self.component?.files != component.files {
@@ -427,3 +443,11 @@ public final class EmojiSuggestionsComponent: Component {
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
}
}
public extension EmojiSuggestionsComponent.Theme {
init(theme: PresentationTheme) {
self.backgroundColor = theme.list.plainBackgroundColor.withMultipliedAlpha(0.88)
self.textColor = theme.list.itemPrimaryTextColor
self.placeholderColor = theme.list.mediaPlaceholderColor
}
}