Show moderator icons in open groups

pull/347/head
Niels Andriesse 3 years ago
parent bc58dfd94e
commit b8f82c98eb

@ -5331,7 +5331,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 178; CURRENT_PROJECT_VERSION = 179;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = SUQ8J2PCT7; DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_SEARCH_PATHS = "$(inherited)";
@ -5400,7 +5400,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 178; CURRENT_PROJECT_VERSION = 179;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = SUQ8J2PCT7; DEVELOPMENT_TEAM = SUQ8J2PCT7;
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
@ -5461,7 +5461,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 178; CURRENT_PROJECT_VERSION = 179;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = SUQ8J2PCT7; DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_SEARCH_PATHS = "$(inherited)";
@ -5531,7 +5531,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 178; CURRENT_PROJECT_VERSION = 179;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = SUQ8J2PCT7; DEVELOPMENT_TEAM = SUQ8J2PCT7;
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
@ -6416,7 +6416,7 @@
CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 178; CURRENT_PROJECT_VERSION = 179;
DEVELOPMENT_TEAM = SUQ8J2PCT7; DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -6484,7 +6484,7 @@
CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 178; CURRENT_PROJECT_VERSION = 179;
DEVELOPMENT_TEAM = SUQ8J2PCT7; DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",

@ -1,14 +1,13 @@
// TODO // TODO
// Tapping replies // Tapping replies
// Moderator icons // Disappearing messages timer
// Brendan no likey buttons above text field
// Slight paging glitch // Slight paging glitch
// Image detail VC transition glitch // Image detail VC transition glitch
// Photo rounding // Photo rounding
// Disappearing messages timer
// Scroll button behind mentions view // Scroll button behind mentions view
// Remaining search glitchiness // Remaining search glitchiness
// Brendan no likey buttons above text field
final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversationSettingsViewDelegate, ConversationSearchControllerDelegate, UITableViewDataSource, UITableViewDelegate { final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversationSettingsViewDelegate, ConversationSearchControllerDelegate, UITableViewDataSource, UITableViewDelegate {
let thread: TSThread let thread: TSThread

@ -89,10 +89,7 @@ private extension MentionSelectionView {
// MARK: Components // MARK: Components
private lazy var profilePictureView = ProfilePictureView() private lazy var profilePictureView = ProfilePictureView()
private lazy var moderatorIconImageView: UIImageView = { private lazy var moderatorIconImageView = UIImageView(image: #imageLiteral(resourceName: "Crown"))
let result = UIImageView(image: #imageLiteral(resourceName: "Crown"))
return result
}()
private lazy var displayNameLabel: UILabel = { private lazy var displayNameLabel: UILabel = {
let result = UILabel() let result = UILabel()

@ -59,6 +59,8 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewV2Delegate {
return result return result
}() }()
private lazy var moderatorIconImageView = UIImageView(image: #imageLiteral(resourceName: "Crown"))
lazy var bubbleView: UIView = { lazy var bubbleView: UIView = {
let result = UIView() let result = UIView()
result.layer.cornerRadius = VisibleMessageCell.smallCornerRadius result.layer.cornerRadius = VisibleMessageCell.smallCornerRadius
@ -151,6 +153,12 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewV2Delegate {
profilePictureViewLeftConstraint.isActive = true profilePictureViewLeftConstraint.isActive = true
profilePictureViewWidthConstraint.isActive = true profilePictureViewWidthConstraint.isActive = true
profilePictureView.pin(.bottom, to: .bottom, of: self, withInset: -1) profilePictureView.pin(.bottom, to: .bottom, of: self, withInset: -1)
// Moderator icon image view
moderatorIconImageView.set(.width, to: 20)
moderatorIconImageView.set(.height, to: 20)
addSubview(moderatorIconImageView)
moderatorIconImageView.pin(.trailing, to: .trailing, of: profilePictureView, withInset: 1)
moderatorIconImageView.pin(.bottom, to: .bottom, of: profilePictureView, withInset: 4.5)
// Bubble view // Bubble view
addSubview(bubbleView) addSubview(bubbleView)
bubbleViewLeftConstraint1.isActive = true bubbleViewLeftConstraint1.isActive = true
@ -202,6 +210,13 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewV2Delegate {
if let senderSessionID = senderSessionID { if let senderSessionID = senderSessionID {
profilePictureView.update(for: senderSessionID) profilePictureView.update(for: senderSessionID)
} }
if let thread = thread as? TSGroupThread, thread.isOpenGroup,
let openGroup = Storage.shared.getOpenGroup(for: thread.uniqueId!), let senderSessionID = senderSessionID {
let isUserModerator = OpenGroupAPI.isUserModerator(senderSessionID, for: openGroup.channel, on: openGroup.server)
moderatorIconImageView.isHidden = !isUserModerator || profilePictureView.isHidden
} else {
moderatorIconImageView.isHidden = true
}
// Bubble view // Bubble view
bubbleViewLeftConstraint1.isActive = (direction == .incoming) bubbleViewLeftConstraint1.isActive = (direction == .incoming)
bubbleViewLeftConstraint1.constant = isGroupThread ? VisibleMessageCell.groupThreadHSpacing : VisibleMessageCell.contactThreadHSpacing bubbleViewLeftConstraint1.constant = isGroupThread ? VisibleMessageCell.groupThreadHSpacing : VisibleMessageCell.contactThreadHSpacing
@ -542,8 +557,7 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewV2Delegate {
.foregroundColor : textColor, .foregroundColor : textColor,
.font : UIFont.systemFont(ofSize: getFontSize(for: viewItem)) .font : UIFont.systemFont(ofSize: getFontSize(for: viewItem))
] ]
var attributedText = NSMutableAttributedString(attributedString: MentionUtilities.highlightMentions(in: message.body ?? "", isOutgoingMessage: isOutgoing, threadID: viewItem.interaction.uniqueThreadId, attributes: attributes)) let attributedText = NSMutableAttributedString(attributedString: MentionUtilities.highlightMentions(in: message.body ?? "", isOutgoingMessage: isOutgoing, threadID: viewItem.interaction.uniqueThreadId, attributes: attributes))
if let searchText = searchText, searchText.count >= ConversationSearchController.kMinimumSearchTextLength { if let searchText = searchText, searchText.count >= ConversationSearchController.kMinimumSearchTextLength {
let normalizedSearchText = FullTextSearchFinder.normalize(text: searchText) let normalizedSearchText = FullTextSearchFinder.normalize(text: searchText)
do { do {
@ -555,7 +569,7 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewV2Delegate {
attributedText.addAttribute(.foregroundColor, value: UIColor.black, range: match.range) attributedText.addAttribute(.foregroundColor, value: UIColor.black, range: match.range)
} }
} catch { } catch {
// Do nothing
} }
} }
result.attributedText = attributedText result.attributedText = attributedText

@ -1,7 +1,7 @@
{ {
"images" : [ "images" : [
{ {
"filename" : "Crown.pdf", "filename" : "crown.pdf",
"idiom" : "universal" "idiom" : "universal"
} }
], ],

Loading…
Cancel
Save