mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Emoji improvements
This commit is contained in:
parent
4d5f899a59
commit
97fefbc7cd
@ -7955,3 +7955,5 @@ Sorry for the inconvenience.";
|
||||
"KeyCommand.SwitchToPIP" = "Switch to Picture-in-Picture";
|
||||
"KeyCommand.EnterFullscreen" = "Enter Fullscreen";
|
||||
"KeyCommand.ExitFullscreen" = "Exit Fullscreen";
|
||||
|
||||
"StickerPacksSettings.SuggestAnimatedEmoji" = "Suggest Animated Emoji";
|
||||
|
@ -32,11 +32,12 @@ private final class InstalledStickerPacksControllerArguments {
|
||||
let openArchived: ([ArchivedStickerPackItem]?) -> Void
|
||||
let openSuggestOptions: () -> Void
|
||||
let toggleAnimatedStickers: (Bool) -> Void
|
||||
let toggleSuggestAnimatedEmoji: (Bool) -> Void
|
||||
let togglePackSelected: (ItemCollectionId) -> Void
|
||||
let expandTrendingPacks: () -> Void
|
||||
let addPack: (StickerPackCollectionInfo) -> Void
|
||||
|
||||
init(account: Account, openStickerPack: @escaping (StickerPackCollectionInfo) -> Void, setPackIdWithRevealedOptions: @escaping (ItemCollectionId?, ItemCollectionId?) -> Void, removePack: @escaping (ArchivedStickerPackItem) -> Void, openStickersBot: @escaping () -> Void, openMasks: @escaping () -> Void, openEmoji: @escaping () -> Void, openQuickReaction: @escaping () -> Void, openFeatured: @escaping () -> Void, openArchived: @escaping ([ArchivedStickerPackItem]?) -> Void, openSuggestOptions: @escaping () -> Void, toggleAnimatedStickers: @escaping (Bool) -> Void, togglePackSelected: @escaping (ItemCollectionId) -> Void, expandTrendingPacks: @escaping () -> Void, addPack: @escaping (StickerPackCollectionInfo) -> Void) {
|
||||
init(account: Account, openStickerPack: @escaping (StickerPackCollectionInfo) -> Void, setPackIdWithRevealedOptions: @escaping (ItemCollectionId?, ItemCollectionId?) -> Void, removePack: @escaping (ArchivedStickerPackItem) -> Void, openStickersBot: @escaping () -> Void, openMasks: @escaping () -> Void, openEmoji: @escaping () -> Void, openQuickReaction: @escaping () -> Void, openFeatured: @escaping () -> Void, openArchived: @escaping ([ArchivedStickerPackItem]?) -> Void, openSuggestOptions: @escaping () -> Void, toggleAnimatedStickers: @escaping (Bool) -> Void, toggleSuggestAnimatedEmoji: @escaping (Bool) -> Void, togglePackSelected: @escaping (ItemCollectionId) -> Void, expandTrendingPacks: @escaping () -> Void, addPack: @escaping (StickerPackCollectionInfo) -> Void) {
|
||||
self.account = account
|
||||
self.openStickerPack = openStickerPack
|
||||
self.setPackIdWithRevealedOptions = setPackIdWithRevealedOptions
|
||||
@ -49,6 +50,7 @@ private final class InstalledStickerPacksControllerArguments {
|
||||
self.openArchived = openArchived
|
||||
self.openSuggestOptions = openSuggestOptions
|
||||
self.toggleAnimatedStickers = toggleAnimatedStickers
|
||||
self.toggleSuggestAnimatedEmoji = toggleSuggestAnimatedEmoji
|
||||
self.togglePackSelected = togglePackSelected
|
||||
self.expandTrendingPacks = expandTrendingPacks
|
||||
self.addPack = addPack
|
||||
@ -89,6 +91,7 @@ private indirect enum InstalledStickerPacksEntry: ItemListNodeEntry {
|
||||
case quickReaction(String, UIImage?)
|
||||
case animatedStickers(PresentationTheme, String, Bool)
|
||||
case animatedStickersInfo(PresentationTheme, String)
|
||||
case suggestAnimatedEmoji(String, Bool)
|
||||
case trendingPacksTitle(PresentationTheme, String)
|
||||
case trendingPack(Int32, PresentationTheme, PresentationStrings, StickerPackCollectionInfo, StickerPackItem?, String, Bool, Bool, Bool)
|
||||
case trendingExpand(PresentationTheme, String)
|
||||
@ -98,7 +101,7 @@ private indirect enum InstalledStickerPacksEntry: ItemListNodeEntry {
|
||||
|
||||
var section: ItemListSectionId {
|
||||
switch self {
|
||||
case .suggestOptions, .trending, .masks, .emoji, .quickReaction, .archived, .animatedStickers, .animatedStickersInfo:
|
||||
case .suggestOptions, .trending, .masks, .emoji, .quickReaction, .archived, .animatedStickers, .animatedStickersInfo, .suggestAnimatedEmoji:
|
||||
return InstalledStickerPacksSection.service.rawValue
|
||||
case .trendingPacksTitle, .trendingPack, .trendingExpand:
|
||||
return InstalledStickerPacksSection.trending.rawValue
|
||||
@ -125,18 +128,20 @@ private indirect enum InstalledStickerPacksEntry: ItemListNodeEntry {
|
||||
return .index(6)
|
||||
case .animatedStickersInfo:
|
||||
return .index(7)
|
||||
case .trendingPacksTitle:
|
||||
case .suggestAnimatedEmoji:
|
||||
return .index(8)
|
||||
case .trendingPacksTitle:
|
||||
return .index(9)
|
||||
case let .trendingPack(_, _, _, info, _, _, _, _, _):
|
||||
return .trendingPack(info.id)
|
||||
case .trendingExpand:
|
||||
return .index(9)
|
||||
case .packsTitle:
|
||||
return .index(10)
|
||||
case .packsTitle:
|
||||
return .index(11)
|
||||
case let .pack(_, _, _, info, _, _, _, _, _, _):
|
||||
return .pack(info.id)
|
||||
case .packsInfo:
|
||||
return .index(11)
|
||||
return .index(12)
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,6 +195,12 @@ private indirect enum InstalledStickerPacksEntry: ItemListNodeEntry {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .suggestAnimatedEmoji(lhsText, lhsValue):
|
||||
if case let .suggestAnimatedEmoji(rhsText, rhsValue) = rhs, lhsValue == rhsValue, lhsText == rhsText {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .trendingPacksTitle(lhsTheme, lhsText):
|
||||
if case let .trendingPacksTitle(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||
return true
|
||||
@ -344,9 +355,16 @@ private indirect enum InstalledStickerPacksEntry: ItemListNodeEntry {
|
||||
default:
|
||||
return true
|
||||
}
|
||||
case .suggestAnimatedEmoji:
|
||||
switch rhs {
|
||||
case .suggestOptions, .trending, .archived, .masks, .emoji, .quickReaction, .animatedStickers, .animatedStickersInfo, .suggestAnimatedEmoji:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
case .trendingPacksTitle:
|
||||
switch rhs {
|
||||
case .suggestOptions, .trending, .masks, .emoji, .quickReaction, .archived, .animatedStickers, .animatedStickersInfo, .trendingPacksTitle:
|
||||
case .suggestOptions, .trending, .masks, .emoji, .quickReaction, .archived, .animatedStickers, .animatedStickersInfo, .suggestAnimatedEmoji, .trendingPacksTitle:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
@ -362,14 +380,14 @@ private indirect enum InstalledStickerPacksEntry: ItemListNodeEntry {
|
||||
}
|
||||
case .trendingExpand:
|
||||
switch rhs {
|
||||
case .suggestOptions, .trending, .masks, .emoji, .quickReaction, .archived, .animatedStickers, .animatedStickersInfo, .trendingPacksTitle, .trendingPack, .trendingExpand:
|
||||
case .suggestOptions, .trending, .masks, .emoji, .quickReaction, .archived, .animatedStickers, .animatedStickersInfo, .suggestAnimatedEmoji, .trendingPacksTitle, .trendingPack, .trendingExpand:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
case .packsTitle:
|
||||
switch rhs {
|
||||
case .suggestOptions, .trending, .masks, .emoji, .quickReaction, .archived, .animatedStickers, .animatedStickersInfo, .trendingPacksTitle, .trendingPack, .trendingExpand, .packsTitle:
|
||||
case .suggestOptions, .trending, .masks, .emoji, .quickReaction, .archived, .animatedStickers, .animatedStickersInfo, .suggestAnimatedEmoji, .trendingPacksTitle, .trendingPack, .trendingExpand, .packsTitle:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
@ -432,6 +450,10 @@ private indirect enum InstalledStickerPacksEntry: ItemListNodeEntry {
|
||||
})
|
||||
case let .animatedStickersInfo(_, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
||||
case let .suggestAnimatedEmoji(text, value):
|
||||
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { value in
|
||||
arguments.toggleSuggestAnimatedEmoji(value)
|
||||
})
|
||||
case let .trendingPacksTitle(_, text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .trendingPack(_, _, _, info, topItem, count, animatedStickers, unread, installed):
|
||||
@ -615,6 +637,8 @@ private func installedStickerPacksControllerEntries(presentationData: Presentati
|
||||
if let archived = archived, !archived.isEmpty {
|
||||
entries.append(.archived(presentationData.theme, presentationData.strings.StickersList_ArchivedEmojiItem, Int32(archived.count), archived))
|
||||
}
|
||||
|
||||
entries.append(.suggestAnimatedEmoji(presentationData.strings.StickerPacksSettings_SuggestAnimatedEmoji, stickerSettings.suggestAnimatedEmoji))
|
||||
}
|
||||
|
||||
if let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [namespaceForMode(mode)])] as? ItemCollectionInfosView {
|
||||
@ -857,6 +881,10 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
let _ = updateStickerSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in
|
||||
return current.withUpdatedLoopAnimatedStickers(value)
|
||||
}).start()
|
||||
}, toggleSuggestAnimatedEmoji: { value in
|
||||
let _ = updateStickerSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in
|
||||
return current.withUpdatedSuggestAnimatedEmoji(value)
|
||||
}).start()
|
||||
}, togglePackSelected: { packId in
|
||||
updateState { state in
|
||||
if var selectedPackIds = state.selectedPackIds {
|
||||
|
@ -21,6 +21,7 @@ swift_library(
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/TextFormat:TextFormat",
|
||||
"//submodules/TelegramUIPreferences:TelegramUIPreferences",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -11,6 +11,7 @@ import Postbox
|
||||
import TelegramPresentationData
|
||||
import EmojiTextAttachmentView
|
||||
import TextFormat
|
||||
import TelegramUIPreferences
|
||||
|
||||
public final class EmojiSuggestionsComponent: Component {
|
||||
public typealias EnvironmentType = Empty
|
||||
@ -33,10 +34,20 @@ public final class EmojiSuggestionsComponent: Component {
|
||||
return combineLatest(
|
||||
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: [], namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000),
|
||||
context.account.viewTracker.featuredEmojiPacks(),
|
||||
hasPremium
|
||||
hasPremium,
|
||||
context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.stickerSettings])
|
||||
)
|
||||
|> take(1)
|
||||
|> map { view, featuredEmojiPacks, hasPremium -> [TelegramMediaFile] in
|
||||
|> map { view, featuredEmojiPacks, hasPremium, sharedData -> [TelegramMediaFile] in
|
||||
var stickerSettings = StickerSettings.defaultSettings
|
||||
if let value = sharedData.entries[ApplicationSpecificSharedDataKeys.stickerSettings]?.get(StickerSettings.self) {
|
||||
stickerSettings = value
|
||||
}
|
||||
|
||||
if !stickerSettings.suggestAnimatedEmoji {
|
||||
return []
|
||||
}
|
||||
|
||||
var result: [TelegramMediaFile] = []
|
||||
|
||||
let normalizedQuery = query.basicEmoji.0
|
||||
@ -160,6 +171,7 @@ public final class EmojiSuggestionsComponent: Component {
|
||||
|
||||
private let blurView: BlurredBackgroundView
|
||||
private let backgroundLayer: SimpleShapeLayer
|
||||
private let shadowLayer: SimpleLayer
|
||||
private let scrollView: UIScrollView
|
||||
|
||||
private var component: EmojiSuggestionsComponent?
|
||||
@ -170,16 +182,18 @@ public final class EmojiSuggestionsComponent: Component {
|
||||
|
||||
override init(frame: CGRect) {
|
||||
self.blurView = BlurredBackgroundView(color: .clear, enableBlur: true)
|
||||
self.blurView.layer.shadowColor = UIColor(white: 0.0, alpha: 1.0).cgColor
|
||||
/*self.blurView.layer.shadowColor = UIColor(white: 0.0, alpha: 1.0).cgColor
|
||||
self.blurView.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
|
||||
self.blurView.layer.shadowRadius = 15.0
|
||||
self.blurView.layer.shadowOpacity = 0.15
|
||||
self.blurView.layer.shadowOpacity = 0.15*/
|
||||
|
||||
self.shadowLayer = SimpleLayer()
|
||||
self.shadowLayer.shadowColor = UIColor(white: 0.0, alpha: 1.0).cgColor
|
||||
self.shadowLayer.shadowOffset = CGSize(width: 0.0, height: 2.0)
|
||||
self.shadowLayer.shadowRadius = 15.0
|
||||
self.shadowLayer.shadowOpacity = 0.15
|
||||
|
||||
self.backgroundLayer = SimpleShapeLayer()
|
||||
/*self.backgroundLayer.shadowColor = UIColor(white: 0.0, alpha: 1.0).cgColor
|
||||
self.backgroundLayer.shadowOffset = CGSize(width: 0.0, height: 2.0)
|
||||
self.backgroundLayer.shadowRadius = 15.0
|
||||
self.backgroundLayer.shadowOpacity = 0.15*/
|
||||
|
||||
self.blurView.layer.mask = self.backgroundLayer
|
||||
|
||||
@ -206,8 +220,9 @@ public final class EmojiSuggestionsComponent: Component {
|
||||
self.scrollView.delegate = self
|
||||
self.scrollView.clipsToBounds = true
|
||||
|
||||
self.layer.addSublayer(self.shadowLayer)
|
||||
self.addSubview(self.blurView)
|
||||
self.layer.addSublayer(self.backgroundLayer)
|
||||
//self.layer.addSublayer(self.backgroundLayer)
|
||||
self.addSubview(self.scrollView)
|
||||
|
||||
self.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:))))
|
||||
@ -327,11 +342,13 @@ public final class EmojiSuggestionsComponent: Component {
|
||||
path.addArc(tangent1End: CGPoint(x: size.width, y: 0.0), tangent2End: CGPoint(x: size.width - radius, y: 0.0), radius: radius)
|
||||
path.addLine(to: CGPoint(x: radius, y: 0.0))
|
||||
|
||||
self.shadowLayer.shadowPath = path
|
||||
self.shadowLayer.frame = CGRect(origin: CGPoint(), size: size)
|
||||
self.blurView.frame = CGRect(origin: CGPoint(), size: size)
|
||||
self.blurView.update(size: size, transition: .immediate)
|
||||
self.backgroundLayer.frame = CGRect(origin: CGPoint(), size: size)
|
||||
self.backgroundLayer.path = path
|
||||
self.backgroundLayer.shadowPath = path
|
||||
//self.blurView.shadowPath = path
|
||||
}
|
||||
|
||||
func update(component: EmojiSuggestionsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
@ -340,7 +357,7 @@ public final class EmojiSuggestionsComponent: Component {
|
||||
if self.component?.theme !== component.theme {
|
||||
//self.backgroundLayer.fillColor = component.theme.list.plainBackgroundColor.cgColor
|
||||
self.backgroundLayer.fillColor = UIColor.black.cgColor
|
||||
self.blurView.updateColor(color: component.theme.list.plainBackgroundColor.withMultipliedAlpha(0.6), transition: .immediate)
|
||||
self.blurView.updateColor(color: component.theme.list.plainBackgroundColor.withMultipliedAlpha(0.88), transition: .immediate)
|
||||
}
|
||||
var resetScrollingPosition = false
|
||||
if self.component?.files != component.files {
|
||||
|
@ -12,14 +12,16 @@ public enum EmojiStickerSuggestionMode: Int32 {
|
||||
public struct StickerSettings: Codable, Equatable {
|
||||
public var emojiStickerSuggestionMode: EmojiStickerSuggestionMode
|
||||
public var loopAnimatedStickers: Bool
|
||||
public var suggestAnimatedEmoji: Bool
|
||||
|
||||
public static var defaultSettings: StickerSettings {
|
||||
return StickerSettings(emojiStickerSuggestionMode: .all, loopAnimatedStickers: true)
|
||||
return StickerSettings(emojiStickerSuggestionMode: .all, loopAnimatedStickers: true, suggestAnimatedEmoji: true)
|
||||
}
|
||||
|
||||
init(emojiStickerSuggestionMode: EmojiStickerSuggestionMode, loopAnimatedStickers: Bool) {
|
||||
init(emojiStickerSuggestionMode: EmojiStickerSuggestionMode, loopAnimatedStickers: Bool, suggestAnimatedEmoji: Bool) {
|
||||
self.emojiStickerSuggestionMode = emojiStickerSuggestionMode
|
||||
self.loopAnimatedStickers = loopAnimatedStickers
|
||||
self.suggestAnimatedEmoji = suggestAnimatedEmoji
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
@ -27,6 +29,7 @@ public struct StickerSettings: Codable, Equatable {
|
||||
|
||||
self.emojiStickerSuggestionMode = EmojiStickerSuggestionMode(rawValue: try container.decode(Int32.self, forKey: "emojiStickerSuggestionMode"))!
|
||||
self.loopAnimatedStickers = try container.decodeIfPresent(Bool.self, forKey: "loopAnimatedStickers") ?? true
|
||||
self.suggestAnimatedEmoji = try container.decodeIfPresent(Bool.self, forKey: "suggestAnimatedEmoji") ?? true
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -34,18 +37,23 @@ public struct StickerSettings: Codable, Equatable {
|
||||
|
||||
try container.encode(self.emojiStickerSuggestionMode.rawValue, forKey: "emojiStickerSuggestionMode")
|
||||
try container.encode(self.loopAnimatedStickers, forKey: "loopAnimatedStickers")
|
||||
try container.encode(self.suggestAnimatedEmoji, forKey: "suggestAnimatedEmoji")
|
||||
}
|
||||
|
||||
public static func ==(lhs: StickerSettings, rhs: StickerSettings) -> Bool {
|
||||
return lhs.emojiStickerSuggestionMode == rhs.emojiStickerSuggestionMode && lhs.loopAnimatedStickers == rhs.loopAnimatedStickers
|
||||
return lhs.emojiStickerSuggestionMode == rhs.emojiStickerSuggestionMode && lhs.loopAnimatedStickers == rhs.loopAnimatedStickers && lhs.suggestAnimatedEmoji == rhs.suggestAnimatedEmoji
|
||||
}
|
||||
|
||||
public func withUpdatedEmojiStickerSuggestionMode(_ emojiStickerSuggestionMode: EmojiStickerSuggestionMode) -> StickerSettings {
|
||||
return StickerSettings(emojiStickerSuggestionMode: emojiStickerSuggestionMode, loopAnimatedStickers: self.loopAnimatedStickers)
|
||||
return StickerSettings(emojiStickerSuggestionMode: emojiStickerSuggestionMode, loopAnimatedStickers: self.loopAnimatedStickers, suggestAnimatedEmoji: self.suggestAnimatedEmoji)
|
||||
}
|
||||
|
||||
public func withUpdatedLoopAnimatedStickers(_ loopAnimatedStickers: Bool) -> StickerSettings {
|
||||
return StickerSettings(emojiStickerSuggestionMode: self.emojiStickerSuggestionMode, loopAnimatedStickers: loopAnimatedStickers)
|
||||
return StickerSettings(emojiStickerSuggestionMode: self.emojiStickerSuggestionMode, loopAnimatedStickers: loopAnimatedStickers, suggestAnimatedEmoji: self.suggestAnimatedEmoji)
|
||||
}
|
||||
|
||||
public func withUpdatedSuggestAnimatedEmoji(_ suggestAnimatedEmoji: Bool) -> StickerSettings {
|
||||
return StickerSettings(emojiStickerSuggestionMode: self.emojiStickerSuggestionMode, loopAnimatedStickers: self.loopAnimatedStickers, suggestAnimatedEmoji: suggestAnimatedEmoji)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user