Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-09-10 02:32:17 +03:00
parent 8141cc7672
commit bf7db7c13f
7 changed files with 40 additions and 29 deletions

View File

@ -104,7 +104,8 @@
"PUSH_ALBUM" = "%1$@|sent you an album"; "PUSH_ALBUM" = "%1$@|sent you an album";
"PUSH_MESSAGE_FILES_TEXT_1" = "sent you a file"; "PUSH_MESSAGE_FILES_TEXT_1" = "sent you a file";
"PUSH_MESSAGE_FILES_TEXT_any" = "sent you %d files"; "PUSH_MESSAGE_FILES_TEXT_any" = "sent you %d files";
"PUSH_MESSAGE_THEME" = "%1$@|changed theme to %2$@"; "PUSH_MESSAGE_THEME" = "%1$@|changed chat theme to %2$@";
"PUSH_MESSAGE_NOTHEME" = "%1$@|disabled chat theme";
"PUSH_CHANNEL_MESSAGE_TEXT" = "%1$@|%2$@"; "PUSH_CHANNEL_MESSAGE_TEXT" = "%1$@|%2$@";
"PUSH_CHANNEL_MESSAGE_NOTEXT" = "%1$@|posted a message"; "PUSH_CHANNEL_MESSAGE_NOTEXT" = "%1$@|posted a message";
@ -178,6 +179,7 @@
"PUSH_CHAT_MESSAGE_DOCS_TEXT_1" = "{author} sent a file"; "PUSH_CHAT_MESSAGE_DOCS_TEXT_1" = "{author} sent a file";
"PUSH_CHAT_MESSAGE_DOCS_TEXT_any" = "{author} sent %d files"; "PUSH_CHAT_MESSAGE_DOCS_TEXT_any" = "{author} sent %d files";
"PUSH_CHAT_MESSAGE_THEME" = "%1$@|set theme to %3$@ in the group %2$@"; "PUSH_CHAT_MESSAGE_THEME" = "%1$@|set theme to %3$@ in the group %2$@";
"PUSH_CHAT_MESSAGE_NOTHEME" = "%1$@|disabled theme in the group %2$@";
"PUSH_PINNED_TEXT" = "%1$@|pinned \"%2$@\" "; "PUSH_PINNED_TEXT" = "%1$@|pinned \"%2$@\" ";
"PUSH_PINNED_NOTEXT" = "%1$@|pinned a message"; "PUSH_PINNED_NOTEXT" = "%1$@|pinned a message";

View File

@ -288,8 +288,11 @@ public class ItemListVenueItemNode: ListViewItemNode, ItemListItemNode {
let iconApply = iconLayout(TransformImageArguments(corners: ImageCorners(), imageSize: CGSize(width: iconSize, height: iconSize), boundingSize: CGSize(width: iconSize, height: iconSize), intrinsicInsets: UIEdgeInsets())) let iconApply = iconLayout(TransformImageArguments(corners: ImageCorners(), imageSize: CGSize(width: iconSize, height: iconSize), boundingSize: CGSize(width: iconSize, height: iconSize), intrinsicInsets: UIEdgeInsets()))
iconApply() iconApply()
let placeholderBackgroundColor: UIColor
switch item.style { switch item.style {
case .plain: case .plain:
placeholderBackgroundColor = item.presentationData.theme.list.plainBackgroundColor
if strongSelf.backgroundNode.supernode != nil { if strongSelf.backgroundNode.supernode != nil {
strongSelf.backgroundNode.removeFromSupernode() strongSelf.backgroundNode.removeFromSupernode()
} }
@ -297,7 +300,7 @@ public class ItemListVenueItemNode: ListViewItemNode, ItemListItemNode {
strongSelf.topStripeNode.removeFromSupernode() strongSelf.topStripeNode.removeFromSupernode()
} }
if strongSelf.bottomStripeNode.supernode == nil { if strongSelf.bottomStripeNode.supernode == nil {
strongSelf.insertSubnode(strongSelf.bottomStripeNode, at: 0) strongSelf.addSubnode(strongSelf.bottomStripeNode)
} }
if strongSelf.maskNode.supernode != nil { if strongSelf.maskNode.supernode != nil {
strongSelf.maskNode.removeFromSupernode() strongSelf.maskNode.removeFromSupernode()
@ -312,6 +315,7 @@ public class ItemListVenueItemNode: ListViewItemNode, ItemListItemNode {
strongSelf.bottomStripeNode.frame = CGRect(origin: CGPoint(x: stripeInset, y: contentSize.height - separatorHeight), size: CGSize(width: params.width - stripeInset, height: separatorHeight)) strongSelf.bottomStripeNode.frame = CGRect(origin: CGPoint(x: stripeInset, y: contentSize.height - separatorHeight), size: CGSize(width: params.width - stripeInset, height: separatorHeight))
strongSelf.bottomStripeNode.isHidden = last strongSelf.bottomStripeNode.isHidden = last
case .blocks: case .blocks:
placeholderBackgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor
if strongSelf.backgroundNode.supernode == nil { if strongSelf.backgroundNode.supernode == nil {
strongSelf.insertSubnode(strongSelf.backgroundNode, at: 0) strongSelf.insertSubnode(strongSelf.backgroundNode, at: 0)
} }
@ -395,8 +399,8 @@ public class ItemListVenueItemNode: ListViewItemNode, ItemListItemNode {
let subtitleFrame = strongSelf.addressNode.frame let subtitleFrame = strongSelf.addressNode.frame
shapes.append(.roundedRectLine(startPoint: CGPoint(x: subtitleFrame.minX, y: subtitleFrame.minY + floor((subtitleFrame.height - lineDiameter) / 2.0)), width: subtitleLineWidth, diameter: lineDiameter)) shapes.append(.roundedRectLine(startPoint: CGPoint(x: subtitleFrame.minX, y: subtitleFrame.minY + floor((subtitleFrame.height - lineDiameter) / 2.0)), width: subtitleLineWidth, diameter: lineDiameter))
shimmerNode.update(backgroundColor: item.presentationData.theme.list.itemBlocksBackgroundColor, foregroundColor: item.presentationData.theme.list.mediaPlaceholderColor, shimmeringColor: item.presentationData.theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4), shapes: shapes, size: layout.contentSize) shimmerNode.update(backgroundColor: placeholderBackgroundColor, foregroundColor: item.presentationData.theme.list.mediaPlaceholderColor, shimmeringColor: item.presentationData.theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4), shapes: shapes, size: layout.contentSize)
} else if let shimmerNode = strongSelf.placeholderNode { } else if let shimmerNode = strongSelf.placeholderNode {
strongSelf.placeholderNode = nil strongSelf.placeholderNode = nil
shimmerNode.removeFromSupernode() shimmerNode.removeFromSupernode()

View File

@ -5913,7 +5913,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|> deliverOnMainQueue).start(next: { [weak self] searchResult in |> deliverOnMainQueue).start(next: { [weak self] searchResult in
if let strongSelf = self, let (searchResult, searchState, searchLocation) = searchResult { if let strongSelf = self, let (searchResult, searchState, searchLocation) = searchResult {
let controller = ChatSearchResultsController(context: strongSelf.context, location: searchLocation, searchQuery: searchData.query, searchResult: searchResult, searchState: searchState, navigateToMessageIndex: { index in let controller = ChatSearchResultsController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, location: searchLocation, searchQuery: searchData.query, searchResult: searchResult, searchState: searchState, navigateToMessageIndex: { index in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }

View File

@ -25,9 +25,9 @@ final class ChatSearchResultsController: ViewController {
private var presentationDataDisposable: Disposable? private var presentationDataDisposable: Disposable?
init(context: AccountContext, location: SearchMessagesLocation, searchQuery: String, searchResult: SearchMessagesResult, searchState: SearchMessagesState, navigateToMessageIndex: @escaping (Int) -> Void, resultsUpdated: @escaping (SearchMessagesResult, SearchMessagesState) -> Void) { init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, location: SearchMessagesLocation, searchQuery: String, searchResult: SearchMessagesResult, searchState: SearchMessagesState, navigateToMessageIndex: @escaping (Int) -> Void, resultsUpdated: @escaping (SearchMessagesResult, SearchMessagesState) -> Void) {
self.context = context self.context = context
self.presentationData = context.sharedContext.currentPresentationData.with { $0 } self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 }
self.location = location self.location = location
self.searchQuery = searchQuery self.searchQuery = searchQuery
self.navigateToMessageIndex = navigateToMessageIndex self.navigateToMessageIndex = navigateToMessageIndex
@ -39,7 +39,7 @@ final class ChatSearchResultsController: ViewController {
self.navigationPresentation = .modal self.navigationPresentation = .modal
self.presentationDataDisposable = (context.sharedContext.presentationData self.presentationDataDisposable = ((updatedPresentationData?.signal ?? context.sharedContext.presentationData)
|> deliverOnMainQueue).start(next: { [weak self] presentationData in |> deliverOnMainQueue).start(next: { [weak self] presentationData in
if let strongSelf = self { if let strongSelf = self {
strongSelf.presentationData = presentationData strongSelf.presentationData = presentationData

View File

@ -239,6 +239,7 @@ private func generateBorderImage(theme: PresentationTheme, bordered: Bool, selec
private final class ThemeSettingsThemeItemIconNode : ListViewItemNode { private final class ThemeSettingsThemeItemIconNode : ListViewItemNode {
private let containerNode: ASDisplayNode private let containerNode: ASDisplayNode
private let emojiContainerNode: ASDisplayNode
private let imageNode: TransformImageNode private let imageNode: TransformImageNode
private let overlayNode: ASImageNode private let overlayNode: ASImageNode
private let textNode: TextNode private let textNode: TextNode
@ -268,6 +269,7 @@ private final class ThemeSettingsThemeItemIconNode : ListViewItemNode {
init() { init() {
self.containerNode = ASDisplayNode() self.containerNode = ASDisplayNode()
self.emojiContainerNode = ASDisplayNode()
self.imageNode = TransformImageNode() self.imageNode = TransformImageNode()
self.imageNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: 82.0, height: 108.0)) self.imageNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: 82.0, height: 108.0))
@ -295,8 +297,11 @@ private final class ThemeSettingsThemeItemIconNode : ListViewItemNode {
self.containerNode.addSubnode(self.imageNode) self.containerNode.addSubnode(self.imageNode)
self.containerNode.addSubnode(self.overlayNode) self.containerNode.addSubnode(self.overlayNode)
self.containerNode.addSubnode(self.textNode) self.containerNode.addSubnode(self.textNode)
self.containerNode.addSubnode(self.emojiNode)
self.containerNode.addSubnode(self.placeholderNode) self.addSubnode(self.emojiContainerNode)
self.emojiContainerNode.addSubnode(self.emojiNode)
self.emojiContainerNode.addSubnode(self.emojiImageNode)
self.emojiContainerNode.addSubnode(self.placeholderNode)
var firstTime = true var firstTime = true
self.emojiImageNode.imageUpdated = { [weak self] image in self.emojiImageNode.imageUpdated = { [weak self] image in
@ -341,11 +346,15 @@ private final class ThemeSettingsThemeItemIconNode : ListViewItemNode {
let currentItem = self.item let currentItem = self.item
return { [weak self] item, params in return { [weak self] item, params in
var updatedEmoticon = false
var updatedThemeReference = false var updatedThemeReference = false
var updatedTheme = false var updatedTheme = false
var updatedWallpaper = false var updatedWallpaper = false
var updatedSelected = false var updatedSelected = false
if currentItem?.emoticon != item.emoticon {
updatedEmoticon = true
}
if currentItem?.themeReference != item.themeReference { if currentItem?.themeReference != item.themeReference {
updatedThemeReference = true updatedThemeReference = true
} }
@ -396,6 +405,9 @@ private final class ThemeSettingsThemeItemIconNode : ListViewItemNode {
strongSelf.containerNode.transform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0) strongSelf.containerNode.transform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
strongSelf.containerNode.frame = CGRect(origin: CGPoint(x: 15.0, y: -15.0), size: CGSize(width: 90.0, height: 120.0)) strongSelf.containerNode.frame = CGRect(origin: CGPoint(x: 15.0, y: -15.0), size: CGSize(width: 90.0, height: 120.0))
strongSelf.emojiContainerNode.transform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
strongSelf.emojiContainerNode.frame = CGRect(origin: CGPoint(x: 15.0, y: -15.0), size: CGSize(width: 90.0, height: 120.0))
let _ = textApply() let _ = textApply()
let _ = emojiApply() let _ = emojiApply()
@ -408,7 +420,7 @@ private final class ThemeSettingsThemeItemIconNode : ListViewItemNode {
strongSelf.emojiNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 79.0), size: CGSize(width: 90.0, height: 30.0)) strongSelf.emojiNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 79.0), size: CGSize(width: 90.0, height: 30.0))
let emojiFrame = CGRect(origin: CGPoint(x: 33.0, y: 79.0), size: CGSize(width: 24.0, height: 24.0)) let emojiFrame = CGRect(origin: CGPoint(x: 33.0, y: 79.0), size: CGSize(width: 24.0, height: 24.0))
if let file = item.emojiFile { if let file = item.emojiFile, updatedEmoticon {
let imageApply = strongSelf.emojiImageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: emojiFrame.size, boundingSize: emojiFrame.size, intrinsicInsets: UIEdgeInsets())) let imageApply = strongSelf.emojiImageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: emojiFrame.size, boundingSize: emojiFrame.size, intrinsicInsets: UIEdgeInsets()))
imageApply() imageApply()
strongSelf.emojiImageNode.setSignal(chatMessageStickerPackThumbnail(postbox: item.context.account.postbox, resource: file.resource, animated: true, nilIfEmpty: true)) strongSelf.emojiImageNode.setSignal(chatMessageStickerPackThumbnail(postbox: item.context.account.postbox, resource: file.resource, animated: true, nilIfEmpty: true))
@ -423,8 +435,9 @@ private final class ThemeSettingsThemeItemIconNode : ListViewItemNode {
self?.emojiImageNode.isHidden = true self?.emojiImageNode.isHidden = true
} }
strongSelf.animatedStickerNode = animatedStickerNode strongSelf.animatedStickerNode = animatedStickerNode
strongSelf.containerNode.insertSubnode(animatedStickerNode, belowSubnode: strongSelf.placeholderNode) strongSelf.emojiContainerNode.insertSubnode(animatedStickerNode, belowSubnode: strongSelf.placeholderNode)
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: item.context.account, resource: file.resource), width: 128, height: 128, mode: .cached) let pathPrefix = item.context.account.postbox.mediaBox.shortLivedResourceCachePathPrefix(file.resource.id)
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: item.context.account, resource: file.resource), width: 96, height: 96, mode: .direct(cachePathPrefix: pathPrefix))
} }
animatedStickerNode.visibility = strongSelf.visibilityStatus animatedStickerNode.visibility = strongSelf.visibilityStatus
@ -445,8 +458,10 @@ private final class ThemeSettingsThemeItemIconNode : ListViewItemNode {
} }
func crossfade() { func crossfade() {
if let snapshotView = self.view.snapshotView(afterScreenUpdates: false) { if let snapshotView = self.containerNode.view.snapshotView(afterScreenUpdates: false) {
self.view.addSubview(snapshotView) snapshotView.transform = self.containerNode.view.transform
snapshotView.frame = self.containerNode.view.frame
self.view.insertSubview(snapshotView, aboveSubview: self.containerNode.view)
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, delay: 0.2, removeOnCompletion: false, completion: { [weak snapshotView] _ in snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, delay: 0.2, removeOnCompletion: false, completion: { [weak snapshotView] _ in
snapshotView?.removeFromSuperview() snapshotView?.removeFromSuperview()

View File

@ -3489,20 +3489,9 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
let filteredButtons = allHeaderButtons.subtracting(headerButtons) let filteredButtons = allHeaderButtons.subtracting(headerButtons)
var canChangeColors = true var canChangeColors = false
// if let peer = peer as? TelegramUser, self.data?.encryptionKeyFingerprint == nil { if peer is TelegramUser, self.data?.encryptionKeyFingerprint == nil {
// canChangeColors = true canChangeColors = true
// }
if let peer = peer as? TelegramChannel {
if case .broadcast = peer.info {
canChangeColors = false
} else {
canChangeColors = peer.hasPermission(.changeInfo)
}
} else if let peer = peer as? TelegramGroup, case .member = peer.role {
canChangeColors = !peer.hasBannedPermission(.banChangeInfo)
} else if self.data?.encryptionKeyFingerprint != nil {
canChangeColors = false
} }
if canChangeColors { if canChangeColors {

View File

@ -78,6 +78,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
var displayUndo = true var displayUndo = true
var undoText = presentationData.strings.Undo_Undo var undoText = presentationData.strings.Undo_Undo
var undoTextColor = UIColor(rgb: 0x5ac8fa) var undoTextColor = UIColor(rgb: 0x5ac8fa)
undoTextColor = presentationData.theme.list.itemAccentColor.withMultiplied(hue: 1.0, saturation: 0.64, brightness: 1.08)
if presentationData.theme.overallDarkAppearance { if presentationData.theme.overallDarkAppearance {
self.animationBackgroundColor = presentationData.theme.rootController.tabBar.backgroundColor self.animationBackgroundColor = presentationData.theme.rootController.tabBar.backgroundColor