Updated mention styling and added back path "recovery" logic

pull/986/head
Morgan Pretty 10 months ago
parent e2fc0a5b51
commit 3dada9e58a

@ -1 +1 @@
Subproject commit 3ad5920794d6c84d7ebd44936a23627f574fdc73
Subproject commit dfcd3ae009dd68b8ca9f32a8b1fe5da46b793c99

@ -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;

@ -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,

@ -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,

@ -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,

@ -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)
}
}

Loading…
Cancel
Save