mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Various improvements
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user