mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
e207ca65db
commit
b261e67c34
@ -395,7 +395,16 @@ class ChatListStorageInfoItemNode: ItemListRevealOptionsItemNode {
|
||||
}
|
||||
|
||||
let arrowIsHidden = strongSelf.arrowNode.isHidden
|
||||
var hasCloseButton = false
|
||||
if case .xmasPremiumGift = item.notice {
|
||||
hasCloseButton = true
|
||||
} else if case .setupBirthday = item.notice {
|
||||
hasCloseButton = true
|
||||
} else if case .birthdayPremiumGift = item.notice {
|
||||
hasCloseButton = true
|
||||
}
|
||||
|
||||
if hasCloseButton {
|
||||
strongSelf.arrowNode.isHidden = true
|
||||
|
||||
let closeButton: HighlightableButtonNode
|
||||
|
@ -1760,34 +1760,5 @@ public extension TelegramEngine.EngineData.Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct Birthday: TelegramEngineDataItem, TelegramEngineMapKeyDataItem, PostboxViewDataItem {
|
||||
public typealias Result = TelegramBirthday?
|
||||
|
||||
fileprivate var id: EnginePeer.Id
|
||||
public var mapKey: EnginePeer.Id {
|
||||
return self.id
|
||||
}
|
||||
|
||||
public init(id: EnginePeer.Id) {
|
||||
self.id = id
|
||||
}
|
||||
|
||||
var key: PostboxViewKey {
|
||||
return .cachedPeerData(peerId: self.id)
|
||||
}
|
||||
|
||||
func extract(view: PostboxView) -> Result {
|
||||
guard let view = view as? CachedPeerDataView else {
|
||||
preconditionFailure()
|
||||
}
|
||||
if let cachedData = view.cachedPeerData as? CachedUserData {
|
||||
return cachedData.birthday
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,12 @@ public enum CachedStickerPackResult {
|
||||
}
|
||||
|
||||
func cacheStickerPack(transaction: Transaction, info: StickerPackCollectionInfo, items: [StickerPackItem], reference: StickerPackReference? = nil) {
|
||||
if let entry = CodableEntry(CachedStickerPack(info: info, items: items, hash: info.hash)) {
|
||||
guard let entry = CodableEntry(CachedStickerPack(info: info, items: items, hash: info.hash)) else {
|
||||
return
|
||||
}
|
||||
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(info.id)), entry: entry)
|
||||
}
|
||||
if let entry = CodableEntry(CachedStickerPack(info: info, items: items, hash: info.hash)) {
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: info.shortName.lowercased())), entry: entry)
|
||||
}
|
||||
|
||||
if let reference = reference {
|
||||
var namespace: Int32?
|
||||
@ -57,12 +57,10 @@ func cacheStickerPack(transaction: Transaction, info: StickerPackCollectionInfo,
|
||||
id = info.id.id
|
||||
}
|
||||
if let namespace = namespace, let id = id {
|
||||
if let entry = CodableEntry(CachedStickerPack(info: info, items: items, hash: info.hash)) {
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id))), entry: entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_cachedStickerPack(postbox: Postbox, network: Network, reference: StickerPackReference, forceRemote: Bool) -> Signal<CachedStickerPackResult, NoError> {
|
||||
return postbox.transaction { transaction -> CachedStickerPackResult? in
|
||||
|
@ -270,6 +270,11 @@ func _internal_deleteStickerSet(account: Account, packReference: StickerPackRefe
|
||||
}
|
||||
|> mapToSignal { _ in
|
||||
return account.postbox.transaction { transaction in
|
||||
if let (info, _, _) = cachedStickerPack(transaction: transaction, reference: packReference) {
|
||||
transaction.removeItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(info.id)))
|
||||
transaction.removeItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: info.shortName.lowercased())))
|
||||
}
|
||||
|
||||
if case let .id(id, _) = packReference {
|
||||
transaction.removeItemCollection(collectionId: ItemCollectionId(namespace: Namespaces.ItemCollection.CloudStickerPacks, id: id))
|
||||
}
|
||||
|
@ -1149,7 +1149,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
||||
return
|
||||
}
|
||||
guard let file = item.itemFile else {
|
||||
if groupId == AnyHashable("recent"), case .icon(.add) = item.content {
|
||||
if case .icon(.add) = item.content {
|
||||
interaction.openStickerEditor()
|
||||
}
|
||||
return
|
||||
|
@ -1828,6 +1828,7 @@ public extension EmojiPagerContentComponent {
|
||||
}
|
||||
}
|
||||
|
||||
var addedCreateStickerButton = false
|
||||
if let recentStickers = recentStickers {
|
||||
let groupId = "recent"
|
||||
for item in recentStickers.items {
|
||||
@ -1861,7 +1862,7 @@ public extension EmojiPagerContentComponent {
|
||||
}
|
||||
}
|
||||
|
||||
if !forceHasPremium, let groupIndex = itemGroupIndexById[groupId] {
|
||||
if hasEdit && !addedCreateStickerButton, let groupIndex = itemGroupIndexById[groupId] {
|
||||
let resultItem = EmojiPagerContentComponent.Item(
|
||||
animationData: nil,
|
||||
content: .icon(.add),
|
||||
@ -1871,6 +1872,7 @@ public extension EmojiPagerContentComponent {
|
||||
tintMode: .none
|
||||
)
|
||||
itemGroups[groupIndex].items.insert(resultItem, at: 0)
|
||||
addedCreateStickerButton = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -1879,6 +1881,7 @@ public extension EmojiPagerContentComponent {
|
||||
avatarPeer = peerSpecificPack.peer
|
||||
|
||||
var processedIds = Set<MediaId>()
|
||||
let groupId = "peerSpecific"
|
||||
for item in peerSpecificPack.items {
|
||||
if isPremiumDisabled && item.file.isPremiumSticker {
|
||||
continue
|
||||
@ -1903,7 +1906,6 @@ public extension EmojiPagerContentComponent {
|
||||
tintMode: tintMode
|
||||
)
|
||||
|
||||
let groupId = "peerSpecific"
|
||||
if let groupIndex = itemGroupIndexById[groupId] {
|
||||
itemGroups[groupIndex].items.append(resultItem)
|
||||
} else {
|
||||
@ -1911,6 +1913,19 @@ public extension EmojiPagerContentComponent {
|
||||
itemGroups.append(ItemGroup(supergroupId: groupId, id: groupId, title: peerSpecificPack.peer.compactDisplayTitle, subtitle: nil, actionButtonTitle: nil, isPremiumLocked: false, isFeatured: false, displayPremiumBadges: false, hasEdit: false, headerItem: nil, items: [resultItem]))
|
||||
}
|
||||
}
|
||||
|
||||
if hasEdit && !addedCreateStickerButton, let groupIndex = itemGroupIndexById[groupId] {
|
||||
let resultItem = EmojiPagerContentComponent.Item(
|
||||
animationData: nil,
|
||||
content: .icon(.add),
|
||||
itemFile: nil,
|
||||
subgroupId: nil,
|
||||
icon: .none,
|
||||
tintMode: .none
|
||||
)
|
||||
itemGroups[groupIndex].items.insert(resultItem, at: 0)
|
||||
addedCreateStickerButton = true
|
||||
}
|
||||
}
|
||||
|
||||
for entry in view.entries {
|
||||
@ -1971,6 +1986,19 @@ public extension EmojiPagerContentComponent {
|
||||
}
|
||||
}
|
||||
itemGroups.append(ItemGroup(supergroupId: groupId, id: groupId, title: title, subtitle: nil, actionButtonTitle: nil, isPremiumLocked: false, isFeatured: false, displayPremiumBadges: true, hasEdit: hasEdit && groupHasEdit, headerItem: headerItem, items: [resultItem]))
|
||||
|
||||
if hasEdit && !addedCreateStickerButton, let groupIndex = itemGroupIndexById[groupId] {
|
||||
let resultItem = EmojiPagerContentComponent.Item(
|
||||
animationData: nil,
|
||||
content: .icon(.add),
|
||||
itemFile: nil,
|
||||
subgroupId: nil,
|
||||
icon: .none,
|
||||
tintMode: .none
|
||||
)
|
||||
itemGroups[groupIndex].items.insert(resultItem, at: 0)
|
||||
addedCreateStickerButton = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ private class TextField: UITextField, UIScrollViewDelegate {
|
||||
override func deleteBackward() {
|
||||
super.deleteBackward()
|
||||
|
||||
if let scrollView = self.scrollView {
|
||||
if let scrollView = self.scrollView, self.fixEditingRect {
|
||||
if scrollView.contentSize.width <= scrollView.frame.width && scrollView.contentOffset.x > -scrollView.contentInset.left {
|
||||
scrollView.contentOffset = CGPoint(x: max(scrollView.contentOffset.x - 5.0, -scrollView.contentInset.left), y: 0.0)
|
||||
self.updatePrefixPosition()
|
||||
@ -116,6 +116,9 @@ private class TextField: UITextField, UIScrollViewDelegate {
|
||||
|
||||
var fixAutoScroll: CGPoint?
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
guard self.fixEditingRect else {
|
||||
return
|
||||
}
|
||||
if let fixAutoScroll = self.fixAutoScroll {
|
||||
self.scrollView?.setContentOffset(fixAutoScroll, animated: true)
|
||||
self.scrollView?.setContentOffset(fixAutoScroll, animated: false)
|
||||
@ -161,6 +164,7 @@ private class TextField: UITextField, UIScrollViewDelegate {
|
||||
}
|
||||
|
||||
override func textRect(forBounds bounds: CGRect) -> CGRect {
|
||||
if self.fixEditingRect {
|
||||
if bounds.size.width.isZero {
|
||||
return CGRect(origin: CGPoint(), size: CGSize())
|
||||
}
|
||||
@ -179,10 +183,18 @@ private class TextField: UITextField, UIScrollViewDelegate {
|
||||
}
|
||||
rect.size.width = max(rect.size.width, 10.0)
|
||||
return rect
|
||||
} else {
|
||||
return super.textRect(forBounds: bounds)
|
||||
}
|
||||
}
|
||||
|
||||
var fixEditingRect = false
|
||||
override func editingRect(forBounds bounds: CGRect) -> CGRect {
|
||||
if self.fixEditingRect {
|
||||
return self.textRect(forBounds: bounds)
|
||||
} else {
|
||||
return super.editingRect(forBounds: bounds)
|
||||
}
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
@ -196,14 +208,16 @@ private class TextField: UITextField, UIScrollViewDelegate {
|
||||
let textRect = self.textRect(forBounds: bounds)
|
||||
|
||||
let labelSize = self.placeholderLabel.updateLayout(textRect.size)
|
||||
self.placeholderLabel.frame = CGRect(origin: CGPoint(x: textRect.minX + 3.0, y: floorToScreenPixels((bounds.height - labelSize.height) / 2.0)), size: labelSize)
|
||||
self.placeholderLabel.frame = CGRect(origin: CGPoint(x: textRect.minX + (self.fixEditingRect ? 3.0 : 0.0), y: floorToScreenPixels((bounds.height - labelSize.height) / 2.0)), size: labelSize)
|
||||
|
||||
let prefixSize = self.prefixLabel.updateLayout(CGSize(width: floor(bounds.size.width * 0.7), height: bounds.size.height))
|
||||
let prefixBounds = bounds.insetBy(dx: 4.0, dy: 4.0)
|
||||
self.prefixLabel.frame = CGRect(origin: CGPoint(x: self.prefixPosition ?? prefixBounds.minX, y: floorToScreenPixels((bounds.height - prefixSize.height) / 2.0)), size: prefixSize)
|
||||
if self.fixEditingRect {
|
||||
self.updatePrefixWidth(prefixSize.width + 3.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private let validIdentifierSet: CharacterSet = {
|
||||
var set = CharacterSet(charactersIn: "a".unicodeScalars.first! ... "z".unicodeScalars.first!)
|
||||
@ -276,6 +290,7 @@ private final class ImportStickerPackTitleInputFieldNode: ASDisplayNode, UITextF
|
||||
self.textInputNode.autocorrectionType = .default
|
||||
self.textInputNode.tintColor = theme.actionSheet.controlAccentColor
|
||||
self.textInputNode.textColor = theme.actionSheet.inputTextColor
|
||||
self.textInputNode.fixEditingRect = hasClearButton
|
||||
|
||||
self.clearButton = HighlightableButtonNode()
|
||||
self.clearButton.imageNode.displaysAsynchronously = false
|
||||
@ -325,7 +340,7 @@ private final class ImportStickerPackTitleInputFieldNode: ASDisplayNode, UITextF
|
||||
let backgroundFrame = CGRect(origin: CGPoint(x: backgroundInsets.left, y: backgroundInsets.top), size: CGSize(width: width - backgroundInsets.left - backgroundInsets.right, height: panelHeight - backgroundInsets.top - backgroundInsets.bottom))
|
||||
transition.updateFrame(node: self.backgroundNode, frame: backgroundFrame)
|
||||
|
||||
transition.updateFrame(view: self.textInputNode, frame: CGRect(origin: CGPoint(x: backgroundFrame.minX + inputInsets.left, y: backgroundFrame.minY), size: CGSize(width: backgroundFrame.size.width - inputInsets.left - inputInsets.right - 22.0, height: backgroundFrame.size.height)))
|
||||
transition.updateFrame(view: self.textInputNode, frame: CGRect(origin: CGPoint(x: backgroundFrame.minX + inputInsets.left, y: backgroundFrame.minY), size: CGSize(width: backgroundFrame.size.width - inputInsets.left - inputInsets.right - (self.clearButton.supernode != nil ? 22.0 : 0.0), height: backgroundFrame.size.height)))
|
||||
|
||||
if let image = self.clearButton.image(for: []) {
|
||||
transition.updateFrame(node: self.clearButton, frame: CGRect(origin: CGPoint(x: backgroundFrame.maxX - 8.0 - image.size.width, y: backgroundFrame.minY + floor((backgroundFrame.size.height - image.size.height) / 2.0)), size: image.size))
|
||||
|
@ -11771,6 +11771,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
switch action {
|
||||
case .info:
|
||||
let context = self.context
|
||||
var replaceImpl: ((ViewController) -> Void)?
|
||||
let controller = context.sharedContext.makePremiumDemoController(context: context, subject: .fasterDownload, action: {
|
||||
let controller = context.sharedContext.makePremiumIntroController(context: context, source: .fasterDownload, forceDark: false, dismissed: nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user