diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 3be4062005..a4d279a4db 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -104,6 +104,7 @@ "PUSH_ALBUM" = "%1$@|sent you an album"; "PUSH_MESSAGE_FILES_TEXT_1" = "sent you a file"; "PUSH_MESSAGE_FILES_TEXT_any" = "sent you %d files"; +"PUSH_MESSAGE_THEME" = "%1$@|changed theme to %2$@"; "PUSH_CHANNEL_MESSAGE_TEXT" = "%1$@|%2$@"; "PUSH_CHANNEL_MESSAGE_NOTEXT" = "%1$@|posted a message"; @@ -176,6 +177,7 @@ "PUSH_CHAT_ALBUM" = "%2$@|%1$@ sent an album"; "PUSH_CHAT_MESSAGE_DOCS_TEXT_1" = "{author} sent a file"; "PUSH_CHAT_MESSAGE_DOCS_TEXT_any" = "{author} sent %d files"; +"PUSH_CHAT_MESSAGE_THEME" = "%1$@|set theme to %3$@ in the group %2$@"; "PUSH_PINNED_TEXT" = "%1$@|pinned \"%2$@\" "; "PUSH_PINNED_NOTEXT" = "%1$@|pinned a message"; @@ -6708,3 +6710,6 @@ Sorry for the inconvenience."; "Appstore.Secure.Chat.Name" = "**Little Sister**"; "Conversation.ReplyMessagePanelTitle" = "Reply to %@"; + +"Channel.AdminLog.MessageChangedThemeSet" = "%1$@ changed chat theme to %2$@"; +"Channel.AdminLog.MessageChangedThemeRemove" = "%1$@ disabled chat theme"; diff --git a/submodules/Display/Source/ListView.swift b/submodules/Display/Source/ListView.swift index b1cd926fca..a68dfc94e2 100644 --- a/submodules/Display/Source/ListView.swift +++ b/submodules/Display/Source/ListView.swift @@ -328,6 +328,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture private var reorderInProgress: Bool = false private var reorderingItemsCompleted: (() -> Void)? private var reorderScrollStartTimestamp: Double? + private var reorderLastTimestamp: Double? public var reorderedItemHasShadow = true private let waitingForNodesDisposable = MetaDisposable() @@ -562,14 +563,23 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture return } + let timestamp = CACurrentMediaTime() if let reorderItemNode = reorderNode.itemNode, let reorderItemIndex = reorderItemNode.index, reorderItemNode.supernode == self { let verticalOffset = verticalTopOffset var closestIndex: (Int, CGFloat)? for i in 0 ..< self.itemNodes.count { if let itemNodeIndex = self.itemNodes[i].index, itemNodeIndex != reorderItemIndex { let itemFrame = self.itemNodes[i].apparentContentFrame - let itemOffset = itemFrame.midY - let deltaOffset = itemOffset - verticalOffset +// let itemOffset = itemFrame.midY + let offsetToMin = itemFrame.minY - verticalOffset + let offsetToMax = itemFrame.maxY - verticalOffset + let deltaOffset: CGFloat + if abs(offsetToMin) > abs(offsetToMax) { + deltaOffset = offsetToMax + } else { + deltaOffset = offsetToMin + } +// let deltaOffset = min(itemFrame.minY - verticalOffset, itemFrame.maxY - verticalOffset) if let (_, closestOffset) = closestIndex { if abs(deltaOffset) < abs(closestOffset) { closestIndex = (itemNodeIndex, deltaOffset) @@ -594,7 +604,12 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture } } if toIndex != reorderItemNode.index { + if let reorderLastTimestamp = self.reorderLastTimestamp, timestamp < reorderLastTimestamp + 0.1 { + return + } if reorderNode.currentState?.0 != reorderItemIndex || reorderNode.currentState?.1 != toIndex { + self.reorderLastTimestamp = timestamp + reorderNode.currentState = (reorderItemIndex, toIndex) //print("reorder \(reorderItemIndex) to \(toIndex) offset \(offset)") if self.reorderFeedbackDisposable == nil { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift index a5e20578a5..f6a6a051f5 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift @@ -63,6 +63,7 @@ public enum AdminLogEventAction { case editExportedInvitation(previous: ExportedInvitation, updated: ExportedInvitation) case participantJoinedViaInvite(ExportedInvitation) case changeHistoryTTL(previousValue: Int32?, updatedValue: Int32?) + case changeTheme(previous: String?, updated: String?) } public enum ChannelAdminLogEventError { @@ -249,8 +250,8 @@ func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: PeerId, m action = .groupCallUpdateParticipantVolume(peerId: parsedParticipant.peerId, volume: parsedParticipant.volume ?? 10000) case let .channelAdminLogEventActionChangeHistoryTTL(prevValue, newValue): action = .changeHistoryTTL(previousValue: prevValue, updatedValue: newValue) - case .channelAdminLogEventActionChangeTheme: - action = nil + case let .channelAdminLogEventActionChangeTheme(prevValue, newValue): + action = .changeTheme(previous: prevValue, updated: newValue) } let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) if let action = action { diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift index 5c6a24eae8..81d4daea79 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift @@ -696,8 +696,10 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres let buttonStrokeColor = accentColor.withMultiplied(hue: 1.014, saturation: 0.56, brightness: 0.64).withAlphaComponent(0.15) let incomingFillColor = mainBackgroundColor.withMultipliedAlpha(0.9) + let incomingBubbleAlpha: CGFloat = 0.9 + let message = PresentationThemeChatMessage( - incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: [incomingFillColor], highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: [incomingFillColor], highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil)), primaryTextColor: .white, secondaryTextColor: mainSecondaryTextColor.withAlphaComponent(0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: UIColor(rgb: 0xff6767), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: accentColor, accentControlColor: accentColor, accentControlDisabledColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.5), mediaControlInnerBackgroundColor: mainBackgroundColor, pendingActivityColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileTitleColor: accentColor, fileDescriptionColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileDurationColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23), polls: PresentationThemeChatBubblePolls(radioButton: accentColor.withMultiplied(hue: 0.995, saturation: 0.317, brightness: 0.51), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: mainSeparatorColor, bar: accentColor, barIconForeground: .white, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: accentColor.withAlphaComponent(0.2), textSelectionKnobColor: accentColor), + incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: [incomingFillColor.withAlphaComponent(incomingBubbleAlpha)], highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: [incomingFillColor.withAlphaComponent(incomingBubbleAlpha)], highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil)), primaryTextColor: .white, secondaryTextColor: mainSecondaryTextColor.withAlphaComponent(0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: UIColor(rgb: 0xff6767), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: accentColor, accentControlColor: accentColor, accentControlDisabledColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.5), mediaControlInnerBackgroundColor: mainBackgroundColor, pendingActivityColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileTitleColor: accentColor, fileDescriptionColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileDurationColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23), polls: PresentationThemeChatBubblePolls(radioButton: accentColor.withMultiplied(hue: 0.995, saturation: 0.317, brightness: 0.51), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: mainSeparatorColor, bar: accentColor, barIconForeground: .white, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: accentColor.withAlphaComponent(0.2), textSelectionKnobColor: accentColor), outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColors, highlightedFill: highlightedOutgoingBubbleColor, stroke: outgoingBubbleFillColors[0], shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColors, highlightedFill: highlightedOutgoingBubbleColor, stroke: outgoingBubbleFillColors[0], shadow: nil)), primaryTextColor: outgoingPrimaryTextColor, secondaryTextColor: outgoingSecondaryTextColor, linkTextColor: outgoingLinkTextColor, linkHighlightColor: UIColor.white.withAlphaComponent(0.5), scamColor: outgoingScamColor, textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: outgoingPrimaryTextColor, accentControlColor: outgoingPrimaryTextColor, accentControlDisabledColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaActiveControlColor: outgoingPrimaryTextColor, mediaInactiveControlColor: outgoingSecondaryTextColor, mediaControlInnerBackgroundColor: outgoingBubbleFillColors[0], pendingActivityColor: outgoingSecondaryTextColor, fileTitleColor: outgoingPrimaryTextColor, fileDescriptionColor: outgoingSecondaryTextColor, fileDurationColor: outgoingSecondaryTextColor, mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.804, brightness: 0.51), polls: PresentationThemeChatBubblePolls(radioButton: outgoingPrimaryTextColor, radioProgress: accentColor.withMultiplied(hue: 0.99, saturation: 0.56, brightness: 1.0), highlight: accentColor.withMultiplied(hue: 0.99, saturation: 0.56, brightness: 1.0).withAlphaComponent(0.12), separator: mainSeparatorColor, bar: outgoingPrimaryTextColor, barIconForeground: .clear, barPositive: outgoingPrimaryTextColor, barNegative: outgoingPrimaryTextColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: UIColor.white.withAlphaComponent(0.2), textSelectionKnobColor: UIColor.white), freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: [mainBackgroundColor], highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: [mainBackgroundColor], highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil)), infoPrimaryTextColor: UIColor(rgb: 0xffffff), diff --git a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift index 0ae9557afe..b550d7e44c 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift @@ -55,14 +55,14 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, specialMode: Bool if specialMode, bubbleColors.count < 3, let color = bubbleColors.first.flatMap({ UIColor(rgb: $0) }) { let colorHSB = color.hsb if colorHSB.b > 0.9 { - let bubbleColor = color.withMultiplied(hue: 0.93, saturation: 1.0, brightness: 1.0) + let bubbleColor = color.withMultiplied(hue: 0.9, saturation: 1.3, brightness: 1.0) bubbleColors = [bubbleColor.rgb] let colorPairs: [(UInt32, UInt32)] = [ - (0xe8f9d7, 0x6cd516), - (0xe7faff, 0x43b6f9), + (0xe5f9d7, 0x6cd516), + (0xe7f5ff, 0x43b6f9), (0xe3f7f5, 0x4ccbb8), - (0xfff3cf, 0xe8b816), + (0xfff6cf, 0xe8b816), (0xfffac9, 0xe2c714), (0xc5a61e, 0xd6b534) ] @@ -83,10 +83,10 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, specialMode: Bool if let colors = nearest?.color { let colorHsb = color.hsb let similarColorHsb = UIColor(rgb: colors.0).hsb - let complementingColorHsb = UIColor(rgb: colors.1).hsb + let accentColorHsb = UIColor(rgb: colors.1).hsb let correction = (similarColorHsb.0 > 0.0 ? colorHsb.0 / similarColorHsb.0 : 1.0, similarColorHsb.1 > 0.0 ? colorHsb.1 / similarColorHsb.1 : 1.0, similarColorHsb.2 > 0.0 ? colorHsb.2 / similarColorHsb.2 : 1.0) - let correctedComplementingColor = UIColor(hue: min(1.0, complementingColorHsb.0 * correction.0), saturation: min(1.0, complementingColorHsb.1 * correction.1), brightness: min(1.0, complementingColorHsb.2 * correction.2), alpha: 1.0) + let correctedComplementingColor = UIColor(hue: min(1.0, accentColorHsb.0 * correction.0), saturation: min(1.0, accentColorHsb.1 * correction.1), brightness: min(1.0, accentColorHsb.2 * correction.2), alpha: 1.0) return correctedComplementingColor } else { return color @@ -94,48 +94,12 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, specialMode: Bool } outgoingAccent = generateAccentColor(color: color) -// color.withMultiplied(hue: 1.01, saturation: 7.8, brightness: 0.9) } else { let bubbleColor = color.withMultiplied(hue: 1.014, saturation: 0.12, brightness: 1.29) bubbleColors = [bubbleColor.rgb] outgoingAccent = color } - -// float[] colorHsv = getTempHsv(5); -// Color.colorToHSV(color, colorHsv); -// -// final float diffH = Math.min(Math.abs(colorHsv[0] - baseHsv[0]), Math.abs(colorHsv[0] - baseHsv[0] - 360f)); -// if (diffH > 30f) { -// return color; -// } -// -// float dist = Math.min(1.5f * colorHsv[1] / baseHsv[1], 1f); -// -// colorHsv[0] = colorHsv[0] + accentHsv[0] - baseHsv[0]; -// colorHsv[1] = colorHsv[1] * accentHsv[1] / baseHsv[1]; -// colorHsv[2] = colorHsv[2] * (1f - dist + dist * accentHsv[2] / baseHsv[2]); -// -// int newColor = Color.HSVToColor(Color.alpha(color), colorHsv); -// -// float origBrightness = AndroidUtilities.computePerceivedBrightness(color); -// float newBrightness = AndroidUtilities.computePerceivedBrightness(newColor); -// -// // We need to keep colors lighter in dark themes and darker in light themes -// boolean needRevertBrightness = isDarkTheme ? origBrightness > newBrightness : origBrightness < newBrightness; -// -// if (needRevertBrightness) { -// float amountOfNew = 0.6f; -// float fallbackAmount = (1f - amountOfNew) * origBrightness / newBrightness + amountOfNew; -// newColor = changeBrightness(newColor, fallbackAmount); -// } -// -// return newColor; - -// outgoingAccent = color.withMultiplied(hue: 1.035, saturation: 4.294, brightness: 1.289) -// -// let bubbleColor = color.withMultiplied(hue: 1.014, saturation: 0.101, brightness: 1.289) -// bubbleColors = [bubbleColor.rgb] } else { if bubbleColors.isEmpty, editing { if day { diff --git a/submodules/TelegramUI/Sources/AccessoryPanelNode.swift b/submodules/TelegramUI/Sources/AccessoryPanelNode.swift index 28f7651ef3..26ee9bb518 100644 --- a/submodules/TelegramUI/Sources/AccessoryPanelNode.swift +++ b/submodules/TelegramUI/Sources/AccessoryPanelNode.swift @@ -11,6 +11,6 @@ class AccessoryPanelNode: ASDisplayNode { func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) { } - func updateState(size: CGSize, interfaceState: ChatPresentationInterfaceState) { + func updateState(size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState) { } } diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 0fa6e44650..bf20ed831b 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -1050,7 +1050,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { if let accessoryPanelNode = accessoryPanelForChatPresentationIntefaceState(self.chatPresentationInterfaceState, context: self.context, currentPanel: self.accessoryPanelNode, interfaceInteraction: self.interfaceInteraction) { accessoryPanelSize = accessoryPanelNode.measure(CGSize(width: layout.size.width, height: layout.size.height)) - accessoryPanelNode.updateState(size: CGSize(width: layout.size.width, height: layout.size.height), interfaceState: self.chatPresentationInterfaceState) + accessoryPanelNode.updateState(size: layout.size, inset: layout.safeInsets.left, interfaceState: self.chatPresentationInterfaceState) if accessoryPanelNode !== self.accessoryPanelNode { dismissedAccessoryPanelNode = self.accessoryPanelNode diff --git a/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift b/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift index 1d6d49925d..329080b595 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift @@ -319,7 +319,7 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode { } override func isReorderable(at point: CGPoint) -> Bool { - if self.bounds.contains(point) { + if self.bounds.inset(by: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: -28.0)).contains(point) { return true } return false diff --git a/submodules/TelegramUI/Sources/ChatMessageBackground.swift b/submodules/TelegramUI/Sources/ChatMessageBackground.swift index 6a82be5f98..e8acf53139 100644 --- a/submodules/TelegramUI/Sources/ChatMessageBackground.swift +++ b/submodules/TelegramUI/Sources/ChatMessageBackground.swift @@ -101,6 +101,7 @@ class ChatMessageBackground: ASDisplayNode { func setType(type: ChatMessageBackgroundType, highlighted: Bool, graphics: PrincipalThemeEssentialGraphics, maskMode: Bool, hasWallpaper: Bool, transition: ContainedViewLayoutTransition, backgroundNode: WallpaperBackgroundNode?) { let previousType = self.type + let previousHighlighted = self.currentHighlighted if let currentType = previousType, currentType == type, self.currentHighlighted == highlighted, self.graphics === graphics, backgroundNode === self.backgroundNode, self.maskMode == maskMode, self.hasWallpaper == hasWallpaper { return } @@ -228,11 +229,11 @@ class ChatMessageBackground: ASDisplayNode { }) } } else if transition.isAnimated { -// if let previousContents = self.imageNode.layer.contents, let image = image { -// if (previousContents as AnyObject) !== image.cgImage { -// self.imageNode.layer.animate(from: previousContents as AnyObject, to: image.cgImage! as AnyObject, keyPath: "contents", timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, duration: 0.42) -// } -// } + if let previousContents = self.imageNode.layer.contents, let image = image { + if (previousContents as AnyObject) !== image.cgImage { + self.imageNode.layer.animate(from: previousContents as AnyObject, to: image.cgImage! as AnyObject, keyPath: "contents", timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, duration: 0.42) + } + } } self.imageNode.image = image diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift index 065c706c98..c86f900f60 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift @@ -1365,6 +1365,37 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { let action = TelegramMediaActionType.customText(text: text, entities: entities) + let message = Message(stableId: self.entry.stableId, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: Int32(bitPattern: self.entry.stableId)), globallyUniqueId: self.entry.event.id, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: self.entry.event.date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: author, text: "", attributes: [], media: [TelegramMediaAction(action: action)], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: []) + return ChatMessageItem(presentationData: self.presentationData, context: context, chatLocation: .peer(peer.id), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .channel, automaticDownloadNetworkType: .cellular, isRecentActions: true), controllerInteraction: controllerInteraction, content: .message(message: message, read: true, selection: .none, attributes: ChatMessageEntryAttributes())) + case let .changeTheme(_, updatedValue): + var peers = SimpleDictionary() + var author: Peer? + if let peer = self.entry.peers[self.entry.event.peerId] { + author = peer + peers[peer.id] = peer + } + + var text: String = "" + var entities: [MessageTextEntity] = [] + + let rawText: PresentationStrings.FormattedString + if let updatedValue = updatedValue { + rawText = self.presentationData.strings.Channel_AdminLog_MessageChangedThemeSet(author?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", updatedValue) + } else { + rawText = self.presentationData.strings.Channel_AdminLog_MessageChangedThemeRemove(author?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "") + } + + appendAttributedText(text: rawText, generateEntities: { index in + if index == 0, let author = author { + return [.TextMention(peerId: author.id)] + } else if index == 1 { + return [.Bold] + } + return [] + }, to: &text, entities: &entities) + + let action = TelegramMediaActionType.customText(text: text, entities: entities) + let message = Message(stableId: self.entry.stableId, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: Int32(bitPattern: self.entry.stableId)), globallyUniqueId: self.entry.event.id, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: self.entry.event.date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: author, text: "", attributes: [], media: [TelegramMediaAction(action: action)], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: []) return ChatMessageItem(presentationData: self.presentationData, context: context, chatLocation: .peer(peer.id), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .channel, automaticDownloadNetworkType: .cellular, isRecentActions: true), controllerInteraction: controllerInteraction, content: .message(message: message, read: true, selection: .none, attributes: ChatMessageEntryAttributes())) } diff --git a/submodules/TelegramUI/Sources/DrawingStickersScreen.swift b/submodules/TelegramUI/Sources/DrawingStickersScreen.swift index 6cc86fdb8a..4a4e35b5fb 100644 --- a/submodules/TelegramUI/Sources/DrawingStickersScreen.swift +++ b/submodules/TelegramUI/Sources/DrawingStickersScreen.swift @@ -960,14 +960,8 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode { let panelHeight: CGFloat let isExpanded: Bool = true -// switch expanded { -// case .content: - panelHeight = maximumHeight -// case let .search(mode): -// panelHeight = maximumHeight -// displaySearch = true -// searchMode = mode -// } + panelHeight = maximumHeight + self.stickerPane.collectionListPanelOffset = 0.0 transition.updateFrame(node: self.topPanel, frame: CGRect(origin: CGPoint(), size: CGSize(width: width, height: topInset + topPanelHeight))) @@ -1029,7 +1023,7 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode { let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition) - let listPosition = CGPoint(x: width / 2.0, y: (bottomPanelHeight - collectionListPanelOffset) / 2.0 + 5.0) + let listPosition = CGPoint(x: width / 2.0, y: (bottomPanelHeight - collectionListPanelOffset) / 2.0 + 15.0) self.stickerListView.bounds = CGRect(x: 0.0, y: 0.0, width: bottomPanelHeight + 31.0, height: width) transition.updatePosition(node: self.stickerListView, position: listPosition) diff --git a/submodules/TelegramUI/Sources/EditAccessoryPanelNode.swift b/submodules/TelegramUI/Sources/EditAccessoryPanelNode.swift index c163e938b1..ac42e4899d 100644 --- a/submodules/TelegramUI/Sources/EditAccessoryPanelNode.swift +++ b/submodules/TelegramUI/Sources/EditAccessoryPanelNode.swift @@ -324,7 +324,7 @@ final class EditAccessoryPanelNode: AccessoryPanelNode { return CGSize(width: constrainedSize.width, height: 45.0) } - override func updateState(size: CGSize, interfaceState: ChatPresentationInterfaceState) { + override func updateState(size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState) { let editMediaReference = interfaceState.editMessageState?.mediaReference var updatedEditMedia = false if let currentEditMediaReference = self.currentEditMediaReference, let editMediaReference = editMediaReference { @@ -342,15 +342,11 @@ final class EditAccessoryPanelNode: AccessoryPanelNode { } self.updateMessage(self.currentMessage) } - } - - override func layout() { - super.layout() - let bounds = self.bounds - let leftInset: CGFloat = 55.0 + let bounds = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: 45.0)) let textLineInset: CGFloat = 10.0 - let rightInset: CGFloat = 55.0 + let leftInset: CGFloat = 55.0 + inset + let rightInset: CGFloat = 55.0 + inset let textRightInset: CGFloat = 20.0 let indicatorSize = CGSize(width: 22.0, height: 22.0) @@ -358,7 +354,7 @@ final class EditAccessoryPanelNode: AccessoryPanelNode { self.statusNode.frame = CGRect(origin: CGPoint(x: 18.0, y: 15.0), size: indicatorSize).insetBy(dx: -2.0, dy: -2.0) let closeButtonSize = CGSize(width: 44.0, height: bounds.height) - let closeButtonFrame = CGRect(origin: CGPoint(x: bounds.width - closeButtonSize.width, y: 2.0), size: closeButtonSize) + let closeButtonFrame = CGRect(origin: CGPoint(x: bounds.width - closeButtonSize.width - inset, y: 2.0), size: closeButtonSize) self.closeButton.frame = closeButtonFrame self.actionArea.frame = CGRect(origin: CGPoint(x: leftInset, y: 2.0), size: CGSize(width: closeButtonFrame.minX - leftInset, height: bounds.height)) @@ -366,7 +362,7 @@ final class EditAccessoryPanelNode: AccessoryPanelNode { self.lineNode.frame = CGRect(origin: CGPoint(x: leftInset, y: 8.0), size: CGSize(width: 2.0, height: bounds.size.height - 10.0)) if let icon = self.iconNode.image { - self.iconNode.frame = CGRect(origin: CGPoint(x: 7.0, y: 10.0), size: icon.size) + self.iconNode.frame = CGRect(origin: CGPoint(x: 7.0 + inset, y: 10.0), size: icon.size) } var imageTextInset: CGFloat = 0.0 diff --git a/submodules/TelegramUI/Sources/ForwardAccessoryPanelNode.swift b/submodules/TelegramUI/Sources/ForwardAccessoryPanelNode.swift index 114d51c871..9e1ed10de3 100644 --- a/submodules/TelegramUI/Sources/ForwardAccessoryPanelNode.swift +++ b/submodules/TelegramUI/Sources/ForwardAccessoryPanelNode.swift @@ -99,7 +99,7 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode { var nameDisplayOrder: PresentationPersonNameOrder var forwardOptionsState: ChatInterfaceForwardOptionsState? - private var validLayout: (size: CGSize, interfaceState: ChatPresentationInterfaceState)? + private var validLayout: (size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState)? init(context: AccountContext, messageIds: [MessageId], theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, nameDisplayOrder: PresentationPersonNameOrder, forwardOptionsState: ChatInterfaceForwardOptionsState?) { self.context = context @@ -196,8 +196,8 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode { } strongSelf.actionArea.accessibilityLabel = "\(headerString). From: \(authors).\n\(text)" - if let (size, interfaceState) = strongSelf.validLayout { - strongSelf.updateState(size: size, interfaceState: interfaceState) + if let (size, inset, interfaceState) = strongSelf.validLayout { + strongSelf.updateState(size: size, inset: inset, interfaceState: interfaceState) } let _ = (ApplicationSpecificNotice.getChatForwardOptionsTip(accountManager: strongSelf.context.sharedContext.accountManager) @@ -206,7 +206,7 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode { Queue.mainQueue().after(3.0) { if let snapshotView = strongSelf.textNode.view.snapshotContentTree() { let text: String - if let (size, _) = strongSelf.validLayout, size.width > 320.0 { + if let (size, _, _) = strongSelf.validLayout, size.width > 320.0 { text = strongSelf.strings.Conversation_ForwardOptions_TapForOptions } else { text = strongSelf.strings.Conversation_ForwardOptions_TapForOptionsShort @@ -216,8 +216,8 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode { strongSelf.view.addSubview(snapshotView) - if let (size, interfaceState) = strongSelf.validLayout { - strongSelf.updateState(size: size, interfaceState: interfaceState) + if let (size, inset, interfaceState) = strongSelf.validLayout { + strongSelf.updateState(size: size, inset: inset, interfaceState: interfaceState) } strongSelf.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3) @@ -278,8 +278,8 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode { self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(15.0), textColor: self.theme.chat.inputPanel.secondaryTextColor) - if let (size, interfaceState) = self.validLayout { - self.updateState(size: size, interfaceState: interfaceState) + if let (size, inset, interfaceState) = self.validLayout { + self.updateState(size: size, inset: inset, interfaceState: interfaceState) } } } @@ -288,18 +288,17 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode { return CGSize(width: constrainedSize.width, height: 45.0) } - override func updateState(size: CGSize, interfaceState: ChatPresentationInterfaceState) { - self.validLayout = (size, interfaceState) + override func updateState(size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState) { + self.validLayout = (size, inset, interfaceState) let bounds = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: 45.0)) - let inset: CGFloat = 55.0 - let leftInset: CGFloat = inset - let rightInset: CGFloat = inset + let leftInset: CGFloat = 55.0 + inset + let rightInset: CGFloat = 55.0 + inset let textLineInset: CGFloat = 10.0 let textRightInset: CGFloat = 20.0 let closeButtonSize = CGSize(width: 44.0, height: bounds.height) - let closeButtonFrame = CGRect(origin: CGPoint(x: bounds.width - closeButtonSize.width, y: 2.0), size: closeButtonSize) + let closeButtonFrame = CGRect(origin: CGPoint(x: bounds.width - closeButtonSize.width - inset, y: 2.0), size: closeButtonSize) self.closeButton.frame = closeButtonFrame self.closeButton.isHidden = interfaceState.renderedPeer == nil @@ -308,7 +307,7 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode { self.lineNode.frame = CGRect(origin: CGPoint(x: leftInset, y: 8.0), size: CGSize(width: 2.0, height: bounds.size.height - 10.0)) if let icon = self.iconNode.image { - self.iconNode.frame = CGRect(origin: CGPoint(x: 7.0, y: 10.0), size: icon.size) + self.iconNode.frame = CGRect(origin: CGPoint(x: 7.0 + inset, y: 10.0), size: icon.size) } let titleSize = self.titleNode.updateLayout(CGSize(width: bounds.size.width - leftInset - textLineInset - rightInset - textRightInset, height: bounds.size.height)) @@ -337,7 +336,7 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode { let alertController = richTextAlertController(context: self.context, title: title, text: text, actions: [TextAlertAction(type: .genericAction, title: self.strings.Conversation_ForwardOptions_ShowOptions, action: { [weak self] in if let strongSelf = self { strongSelf.interfaceInteraction?.presentForwardOptions(strongSelf) - Queue.mainQueue().after(1.5) { + Queue.mainQueue().after(0.5) { strongSelf.updateThemeAndStrings(theme: strongSelf.theme, strings: strongSelf.strings, forwardOptionsState: strongSelf.forwardOptionsState, force: true) } diff --git a/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift b/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift index e5e58a077d..3fcf8a651a 100644 --- a/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift +++ b/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift @@ -454,7 +454,7 @@ final class PeerSelectionControllerNode: ASDisplayNode { if let forwardAccessoryPanelNode = self.forwardAccessoryPanelNode { let size = forwardAccessoryPanelNode.calculateSizeThatFits(CGSize(width: layout.size.width - layout.safeInsets.left - layout.safeInsets.right, height: layout.size.height)) - forwardAccessoryPanelNode.updateState(size: size, interfaceState: self.presentationInterfaceState) + forwardAccessoryPanelNode.updateState(size: size, inset: layout.safeInsets.left, interfaceState: self.presentationInterfaceState) forwardAccessoryPanelNode.updateThemeAndStrings(theme: self.presentationData.theme, strings: self.presentationData.strings, forwardOptionsState: self.presentationInterfaceState.interfaceState.forwardOptionsState) let panelFrame = CGRect(x: layout.safeInsets.left, y: layout.size.height - (textPanelHeight ?? 0.0) - size.height, width: size.width - layout.safeInsets.left - layout.safeInsets.right, height: size.height) diff --git a/submodules/TelegramUI/Sources/ReplyAccessoryPanelNode.swift b/submodules/TelegramUI/Sources/ReplyAccessoryPanelNode.swift index ddb7dca857..92f7ccd10b 100644 --- a/submodules/TelegramUI/Sources/ReplyAccessoryPanelNode.swift +++ b/submodules/TelegramUI/Sources/ReplyAccessoryPanelNode.swift @@ -244,9 +244,7 @@ final class ReplyAccessoryPanelNode: AccessoryPanelNode { return CGSize(width: constrainedSize.width, height: 45.0) } - override func layout() { - super.layout() - + override func updateState(size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState) { let bounds = self.bounds let leftInset: CGFloat = 55.0 let textLineInset: CGFloat = 10.0 @@ -254,7 +252,7 @@ final class ReplyAccessoryPanelNode: AccessoryPanelNode { let textRightInset: CGFloat = 20.0 let closeButtonSize = CGSize(width: 44.0, height: bounds.height) - let closeButtonFrame = CGRect(origin: CGPoint(x: bounds.width - closeButtonSize.width, y: 2.0), size: closeButtonSize) + let closeButtonFrame = CGRect(origin: CGPoint(x: bounds.width - closeButtonSize.width - inset, y: 2.0), size: closeButtonSize) self.closeButton.frame = closeButtonFrame self.actionArea.frame = CGRect(origin: CGPoint(x: leftInset, y: 2.0), size: CGSize(width: closeButtonFrame.minX - leftInset, height: bounds.height)) @@ -264,7 +262,7 @@ final class ReplyAccessoryPanelNode: AccessoryPanelNode { } if let icon = self.iconNode.image { - self.iconNode.frame = CGRect(origin: CGPoint(x: 7.0, y: 10.0), size: icon.size) + self.iconNode.frame = CGRect(origin: CGPoint(x: 7.0 + inset, y: 10.0), size: icon.size) } var imageTextInset: CGFloat = 0.0 diff --git a/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift b/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift index 27ac9eb311..bb861781c6 100644 --- a/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift +++ b/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift @@ -150,9 +150,7 @@ final class WebpagePreviewAccessoryPanelNode: AccessoryPanelNode { return CGSize(width: constrainedSize.width, height: 45.0) } - override func layout() { - super.layout() - + override func updateState(size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState) { let bounds = self.bounds let leftInset: CGFloat = 55.0 let textLineInset: CGFloat = 10.0 @@ -160,12 +158,12 @@ final class WebpagePreviewAccessoryPanelNode: AccessoryPanelNode { let textRightInset: CGFloat = 20.0 let closeButtonSize = CGSize(width: 44.0, height: bounds.height) - self.closeButton.frame = CGRect(origin: CGPoint(x: bounds.size.width - closeButtonSize.width, y: 2.0), size: closeButtonSize) + self.closeButton.frame = CGRect(origin: CGPoint(x: bounds.size.width - closeButtonSize.width - inset, y: 2.0), size: closeButtonSize) self.lineNode.frame = CGRect(origin: CGPoint(x: leftInset, y: 8.0), size: CGSize(width: 2.0, height: bounds.size.height - 10.0)) if let icon = self.iconNode.image { - self.iconNode.frame = CGRect(origin: CGPoint(x: 7.0, y: 10.0), size: icon.size) + self.iconNode.frame = CGRect(origin: CGPoint(x: 7.0 + inset, y: 10.0), size: icon.size) } let makeTitleLayout = TextNode.asyncLayout(self.titleNode) @@ -183,6 +181,7 @@ final class WebpagePreviewAccessoryPanelNode: AccessoryPanelNode { let _ = textApply() } + @objc func closePressed() { if let dismiss = self.dismiss { dismiss()