Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-09-25 17:02:36 +03:00
parent 7c77d5ebcd
commit c849e63392
14 changed files with 86 additions and 25 deletions

View File

@ -774,7 +774,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
return
}
if case let .peer(_, peer, _, _, _, _, _, _, promoInfo, _, _, _) = item.content {
if promoInfo == nil, let mainPeer = peer.chatMainPeer {
if promoInfo == nil, let mainPeer = peer.peer {
item.interaction.togglePeerSelected(mainPeer)
}
}

View File

@ -100,7 +100,15 @@ public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder:
textIsReady = true
}
case .generic:
break
var messageTypes = Set<MessageGroupType>()
for message in messages {
messageTypes.insert(singleMessageType(message: message))
}
if messageTypes.count == 2 && messageTypes.contains(.photos) && messageTypes.contains(.videos) {
if !messageText.isEmpty {
textIsReady = true
}
}
}
}

View File

@ -6,9 +6,11 @@ import CoreText
private let defaultFont = UIFont.systemFont(ofSize: 15.0)
private final class TextNodeStrikethrough {
let range: NSRange
let frame: CGRect
init(frame: CGRect) {
init(range: NSRange, frame: CGRect) {
self.range = range
self.frame = frame
}
}
@ -990,7 +992,7 @@ public class TextNode: ASDisplayNode {
let lowerX = floor(CTLineGetOffsetForStringIndex(coreTextLine, range.location, nil))
let upperX = ceil(CTLineGetOffsetForStringIndex(coreTextLine, range.location + range.length, nil))
let x = lowerX < upperX ? lowerX : upperX
strikethroughs.append(TextNodeStrikethrough(frame: CGRect(x: x, y: 0.0, width: abs(upperX - lowerX), height: fontLineHeight)))
strikethroughs.append(TextNodeStrikethrough(range: range, frame: CGRect(x: x, y: 0.0, width: abs(upperX - lowerX), height: fontLineHeight)))
} else if let paragraphStyle = attributes[NSAttributedString.Key.paragraphStyle] as? NSParagraphStyle {
headIndent = paragraphStyle.headIndent
@ -1042,7 +1044,7 @@ public class TextNode: ASDisplayNode {
let lowerX = floor(CTLineGetOffsetForStringIndex(coreTextLine, range.location, nil))
let upperX = ceil(CTLineGetOffsetForStringIndex(coreTextLine, range.location + range.length, nil))
let x = lowerX < upperX ? lowerX : upperX
strikethroughs.append(TextNodeStrikethrough(frame: CGRect(x: x, y: 0.0, width: abs(upperX - lowerX), height: fontLineHeight)))
strikethroughs.append(TextNodeStrikethrough(range: range, frame: CGRect(x: x, y: 0.0, width: abs(upperX - lowerX), height: fontLineHeight)))
} else if let paragraphStyle = attributes[NSAttributedString.Key.paragraphStyle] as? NSParagraphStyle {
headIndent = paragraphStyle.headIndent
}
@ -1190,6 +1192,15 @@ public class TextNode: ASDisplayNode {
if !line.strikethroughs.isEmpty {
for strikethrough in line.strikethroughs {
var textColor: UIColor?
layout.attributedString?.enumerateAttributes(in: NSMakeRange(line.range.location, line.range.length), options: []) { attributes, range, _ in
if range == strikethrough.range, let color = attributes[NSAttributedString.Key.foregroundColor] as? UIColor {
textColor = color
}
}
if let textColor = textColor {
context.setFillColor(textColor.cgColor)
}
let frame = strikethrough.frame.offsetBy(dx: lineFrame.minX, dy: lineFrame.minY)
context.fill(CGRect(x: frame.minX, y: frame.minY - 5.0, width: frame.width, height: 1.0))
}

View File

@ -899,6 +899,8 @@ public final class ListMessageFileItemNode: ListMessageNode {
if isVoice {
iconStatusBackgroundColor = item.presentationData.theme.theme.list.itemAccentColor
iconStatusForegroundColor = item.presentationData.theme.theme.list.itemCheckColors.foregroundColor
} else if isAudio {
iconStatusForegroundColor = item.presentationData.theme.theme.list.itemCheckColors.foregroundColor
}
if !isAudio && !isInstantVideo {
@ -929,6 +931,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
}
self.iconStatusNode.backgroundNodeColor = iconStatusBackgroundColor
self.iconStatusNode.foregroundNodeColor = iconStatusForegroundColor
self.iconStatusNode.overlayForegroundNodeColor = .white
self.iconStatusNode.transitionToState(iconStatusState)
}

View File

@ -151,10 +151,10 @@ private enum ChannelDiscussionGroupSetupControllerEntry: ItemListNodeEntry {
let text: String
if let peer = peer as? TelegramChannel, let addressName = peer.addressName, !addressName.isEmpty {
text = "@\(addressName)"
} else if let peer = peer as? TelegramChannel, case .group = peer.info {
text = strings.Channel_DiscussionGroup_PrivateGroup
} else {
} else if let peer = peer as? TelegramChannel, case .broadcast = peer.info {
text = strings.Channel_DiscussionGroup_PrivateChannel
} else {
text = strings.Channel_DiscussionGroup_PrivateGroup
}
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: nameOrder, context: arguments.context, peer: peer, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .text(text, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
arguments.selectGroup(peer.id)

View File

@ -280,6 +280,9 @@ public final class PhoneInputNode: ASDisplayNode, UITextFieldDelegate {
if !realRegionPrefix.hasPrefix("+") {
realRegionPrefix = "+" + realRegionPrefix
}
if !text.hasPrefix("+") {
text = "+" + text
}
numberText = cleanPrefix(String(text[realRegionPrefix.endIndex...]))
} else {
realRegionPrefix = text

View File

@ -436,7 +436,7 @@ final class ThemeAccentColorController: ViewController {
if case let .colors(initialThemeReference, true) = strongSelf.mode {
let themeSpecificAccentColor = settings.themeSpecificAccentColors[themeReference.index]
var customAccentColor: UIColor?
if let color = themeSpecificAccentColor?.color {
if let color = themeSpecificAccentColor?.color, color != .clear {
accentColor = color
customAccentColor = accentColor
} else if case let .cloud(cloudTheme) = initialThemeReference, let settings = cloudTheme.theme.settings {

View File

@ -5024,12 +5024,12 @@ public final class VoiceChatController: ViewController {
displayPanelVideos = self.displayPanelVideos
}
let isLivestream: Bool
if let channel = self.peer as? TelegramChannel, case .broadcast = channel.info {
isLivestream = true
} else {
isLivestream = false
}
// let isLivestream: Bool
// if let channel = self.peer as? TelegramChannel, case .broadcast = channel.info {
// isLivestream = true
// } else {
// isLivestream = false
// }
let canManageCall = self.callState?.canManageCall ?? false

View File

@ -7,7 +7,9 @@ private final class LinkHelperClass: NSObject {
}
public func canSendMessagesToPeer(_ peer: Peer) -> Bool {
if peer is TelegramUser || peer is TelegramGroup {
if let peer = peer as? TelegramUser, peer.username == "replies" {
return false
} else if peer is TelegramUser || peer is TelegramGroup {
return !peer.isDeleted
} else if let peer = peer as? TelegramSecretChat {
return peer.embeddedState == .active

View File

@ -59,6 +59,11 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
} else {
bubbleColors = [accentColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98).rgb, accentColor.rgb]
}
} else {
let accentColor = accentColor ?? UIColor(rgb: 0xffffff)
if accentColor.rgb == 0xffffff {
monochrome = true
}
}
var badgeFillColor: UIColor?

View File

@ -47,6 +47,10 @@ public func makePresentationTheme(cloudTheme: TelegramTheme) -> PresentationThem
}
public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, extendingThemeReference: PresentationThemeReference? = nil, accentColor: UIColor? = nil, outgoingAccentColor: UIColor? = nil, backgroundColors: [UInt32] = [], bubbleColors: [UInt32] = [], animateBubbleColors: Bool? = nil, wallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil, serviceBackgroundColor: UIColor? = nil, preview: Bool = false) -> PresentationTheme? {
var accentColor = accentColor
if accentColor == .clear {
accentColor = nil
}
let theme: PresentationTheme
switch themeReference {
case let .builtin(reference):

View File

@ -281,12 +281,20 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
string = strings.Conversation_AutoremoveTimerSetUser(authorString, timeValue).string
}
} else if let _ = messagePeer as? TelegramGroup {
string = strings.Conversation_AutoremoveTimerSetGroup(timeValue).string
} else if let channel = messagePeer as? TelegramChannel {
if case .group = channel.info {
string = strings.Conversation_AutoremoveTimerSetGroup(timeValue).string
if message.author?.id == accountPeerId {
string = strings.Conversation_AutoremoveTimerSetUserYou(timeValue).string
} else {
string = strings.Conversation_AutoremoveTimerSetChannel(timeValue).string
string = strings.Conversation_AutoremoveTimerSetGroup(timeValue).string
}
} else if let channel = messagePeer as? TelegramChannel {
if message.author?.id == accountPeerId {
string = strings.Conversation_AutoremoveTimerSetUserYou(timeValue).string
} else {
if case .group = channel.info {
string = strings.Conversation_AutoremoveTimerSetGroup(timeValue).string
} else {
string = strings.Conversation_AutoremoveTimerSetChannel(timeValue).string
}
}
} else {
if message.author?.id == accountPeerId {

View File

@ -797,6 +797,10 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
isMediaEnabled = false
}
}
var isRecording = false
if let _ = interfaceState.inputTextPanelState.mediaRecordingState {
isRecording = true
}
var isScheduledMessages = false
if case .scheduledMessages = interfaceState.subject {
@ -811,7 +815,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
}
}
transition.updateAlpha(layer: self.attachmentButton.layer, alpha: isMediaEnabled ? 1.0 : 0.4)
self.attachmentButton.isEnabled = isMediaEnabled
self.attachmentButton.isEnabled = isMediaEnabled && !isRecording
self.attachmentButton.accessibilityTraits = (!isSlowmodeActive || isMediaEnabled) ? [.button] : [.button, .notEnabled]
self.attachmentButtonDisabledNode.isHidden = !isSlowmodeActive || isMediaEnabled
@ -840,6 +844,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
if self.theme == nil || !self.theme!.chat.inputPanel.inputTextColor.isEqual(interfaceState.theme.chat.inputPanel.inputTextColor) {
let textColor = interfaceState.theme.chat.inputPanel.inputTextColor
let tintColor = interfaceState.theme.list.itemAccentColor
let baseFontSize = max(minInputFontSize, interfaceState.fontSize.baseDisplaySize)
if let textInputNode = self.textInputNode {

View File

@ -2009,13 +2009,25 @@ final class PeerInfoHeaderNode: ASDisplayNode {
}
if let peer = peer {
var title: String
if peer.id == self.context.account.peerId && !self.isSettings {
titleString = NSAttributedString(string: presentationData.strings.Conversation_SavedMessages, font: Font.semibold(24.0), textColor: presentationData.theme.list.itemPrimaryTextColor)
title = presentationData.strings.Conversation_SavedMessages
} else if peer.id == self.context.account.peerId && !self.isSettings {
titleString = NSAttributedString(string: presentationData.strings.DialogList_Replies, font: Font.semibold(24.0), textColor: presentationData.theme.list.itemPrimaryTextColor)
title = presentationData.strings.DialogList_Replies
} else {
titleString = NSAttributedString(string: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), font: Font.semibold(24.0), textColor: presentationData.theme.list.itemPrimaryTextColor)
title = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
}
title = title.replacingOccurrences(of: "\u{1160}", with: "").replacingOccurrences(of: "\u{3164}", with: "")
if title.isEmpty {
if let peer = peer as? TelegramUser, let phone = peer.phone {
title = formatPhoneNumber(phone)
} else if let addressName = peer.addressName {
title = "@\(addressName)"
} else {
title = " "
}
}
titleString = NSAttributedString(string: title, font: Font.semibold(24.0), textColor: presentationData.theme.list.itemPrimaryTextColor)
if self.isSettings, let user = peer as? TelegramUser {
let formattedPhone = formatPhoneNumber(user.phone ?? "")