diff --git a/LibSession-Util b/LibSession-Util index 3ad592079..dfcd3ae00 160000 --- a/LibSession-Util +++ b/LibSession-Util @@ -1 +1 @@ -Subproject commit 3ad5920794d6c84d7ebd44936a23627f574fdc73 +Subproject commit dfcd3ae009dd68b8ca9f32a8b1fe5da46b793c99 diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 66d1f1c90..15e458a71 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -8042,7 +8042,7 @@ CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 458; + CURRENT_PROJECT_VERSION = 459; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -8120,7 +8120,7 @@ CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Distribution"; - CURRENT_PROJECT_VERSION = 458; + CURRENT_PROJECT_VERSION = 459; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; diff --git a/Session/Conversations/Message Cells/Content Views/QuoteView.swift b/Session/Conversations/Message Cells/Content Views/QuoteView.swift index 76de4d401..6f3dcc265 100644 --- a/Session/Conversations/Message Cells/Content Views/QuoteView.swift +++ b/Session/Conversations/Message Cells/Content Views/QuoteView.swift @@ -193,7 +193,13 @@ final class QuoteView: UIView { currentUserPublicKey: currentUserPublicKey, currentUserBlinded15PublicKey: currentUserBlinded15PublicKey, currentUserBlinded25PublicKey: currentUserBlinded25PublicKey, - isOutgoingMessage: (direction == .outgoing), + location: { + switch (mode, direction) { + case (.draft, _): return .quoteDraft + case (_, .outgoing): return .outgoingQuote + case (_, .incoming): return .incomingQuote + } + }(), textColor: textColor, theme: theme, primaryColor: primaryColor, diff --git a/Session/Conversations/Message Cells/Content Views/SwiftUI/QuoteView_SwiftUI.swift b/Session/Conversations/Message Cells/Content Views/SwiftUI/QuoteView_SwiftUI.swift index ad4b66171..1bd63fc68 100644 --- a/Session/Conversations/Message Cells/Content Views/SwiftUI/QuoteView_SwiftUI.swift +++ b/Session/Conversations/Message Cells/Content Views/SwiftUI/QuoteView_SwiftUI.swift @@ -162,7 +162,13 @@ struct QuoteView_SwiftUI: View { currentUserPublicKey: info.currentUserPublicKey, currentUserBlinded15PublicKey: info.currentUserBlinded15PublicKey, currentUserBlinded25PublicKey: info.currentUserBlinded25PublicKey, - isOutgoingMessage: (info.direction == .outgoing), + location: { + switch (info.mode, info.direction) { + case (.draft, _): return .quoteDraft + case (_, .outgoing): return .outgoingQuote + case (_, .incoming): return .incomingQuote + } + }(), textColor: textColor, theme: ThemeManager.currentTheme, primaryColor: ThemeManager.primaryColor, diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index fa44fcead..8ac8a1bc5 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -1120,7 +1120,7 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate { currentUserPublicKey: cellViewModel.currentUserPublicKey, currentUserBlinded15PublicKey: cellViewModel.currentUserBlinded15PublicKey, currentUserBlinded25PublicKey: cellViewModel.currentUserBlinded25PublicKey, - isOutgoingMessage: isOutgoing, + location: (isOutgoing ? .outgoingMessage : .incomingMessage), textColor: actualTextColor, theme: theme, primaryColor: primaryColor, diff --git a/Session/Utilities/MentionUtilities.swift b/Session/Utilities/MentionUtilities.swift index bff0eb9b3..166157c58 100644 --- a/Session/Utilities/MentionUtilities.swift +++ b/Session/Utilities/MentionUtilities.swift @@ -6,6 +6,15 @@ import SessionUIKit import SessionMessagingKit public enum MentionUtilities { + public enum MentionLocation { + case incomingMessage + case outgoingMessage + case incomingQuote + case outgoingQuote + case quoteDraft + case styleFree + } + public static func highlightMentionsNoAttributes( in string: String, threadVariant: SessionThread.Variant, @@ -20,7 +29,7 @@ public enum MentionUtilities { currentUserPublicKey: currentUserPublicKey, currentUserBlinded15PublicKey: currentUserBlinded15PublicKey, currentUserBlinded25PublicKey: currentUserBlinded25PublicKey, - isOutgoingMessage: false, + location: .styleFree, textColor: .black, theme: .classicDark, primaryColor: Theme.PrimaryColor.green, @@ -34,7 +43,7 @@ public enum MentionUtilities { currentUserPublicKey: String?, currentUserBlinded15PublicKey: String?, currentUserBlinded25PublicKey: String?, - isOutgoingMessage: Bool, + location: MentionLocation, textColor: UIColor, theme: Theme, primaryColor: Theme.PrimaryColor, @@ -93,27 +102,36 @@ public enum MentionUtilities { mentions.forEach { mention in result.addAttribute(.font, value: UIFont.boldSystemFont(ofSize: Values.smallFontSize), range: mention.range) - if mention.isCurrentUser { + if mention.isCurrentUser && location == .incomingMessage { // Note: The designs don't match with the dynamic sizing so these values need to be calculated // to maintain a "rounded rect" effect rather than a "pill" effect result.addAttribute(.currentUserMentionBackgroundCornerRadius, value: (8 * sizeDiff), range: mention.range) result.addAttribute(.currentUserMentionBackgroundPadding, value: (3 * sizeDiff), range: mention.range) result.addAttribute(.currentUserMentionBackgroundColor, value: primaryColor.color, range: mention.range) - result.addAttribute( - .foregroundColor, - value: UIColor.black, // Note: This text should always be black - range: mention.range - ) } - else { - result.addAttribute( - .foregroundColor, - value: (isOutgoingMessage || theme.interfaceStyle == .light ? - textColor : - primaryColor.color - ), - range: mention.range - ) + + switch (location, mention.isCurrentUser, theme.interfaceStyle) { + // 1 - Incoming messages where the mention is for the current user + case (.incomingMessage, true, .dark): result.addAttribute(.foregroundColor, value: UIColor.black, range: mention.range) + case (.incomingMessage, true, _): result.addAttribute(.foregroundColor, value: textColor, range: mention.range) + + // 2 - Incoming messages where the mention is for another user + case (.incomingMessage, false, .dark): result.addAttribute(.foregroundColor, value: primaryColor.color, range: mention.range) + case (.incomingMessage, false, _): result.addAttribute(.foregroundColor, value: textColor, range: mention.range) + + // 3 - Outgoing messages + case (.outgoingMessage, _, .dark): result.addAttribute(.foregroundColor, value: UIColor.black, range: mention.range) + case (.outgoingMessage, _, _): result.addAttribute(.foregroundColor, value: textColor, range: mention.range) + + // 4 - Mentions in quotes + case (.outgoingQuote, _, .dark): result.addAttribute(.foregroundColor, value: UIColor.black, range: mention.range) + case (.outgoingQuote, _, _): result.addAttribute(.foregroundColor, value: textColor, range: mention.range) + case (.incomingQuote, _, .dark): result.addAttribute(.foregroundColor, value: primaryColor.color, range: mention.range) + case (.incomingQuote, _, _): result.addAttribute(.foregroundColor, value: textColor, range: mention.range) + + // 5 - Mentions in quote drafts + case (.quoteDraft, _, _), (.styleFree, _, _): + result.addAttribute(.foregroundColor, value: textColor, range: mention.range) } }