Skip to content

Commit

Permalink
Display user id
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyu committed Oct 8, 2022
1 parent 01553eb commit af46a64
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 70 deletions.
26 changes: 21 additions & 5 deletions Mixin/UserInterface/Controllers/Common/Views/PeerInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ class PeerInfoView: UIView, XibDesignable {
}

func render(result: SearchResult) {
var identityNumber: String?
var specializedCategory: MessageSearchResult.SpecializedCategory?
switch result {
case let result as UserSearchResult:
let user = result.user
avatarImageView.setImage(with: user.avatarUrl, userId: user.userId, name: user.fullName)
identityNumber = user.identityNumber
case let result as ConversationSearchResult:
let conversation = result.conversation
if conversation.isGroup() {
Expand All @@ -62,13 +64,15 @@ class PeerInfoView: UIView, XibDesignable {
case .group(let conversation):
avatarImageView.setGroupImage(with: conversation.iconUrl)
case .user(let user):
identityNumber = user.identityNumber
avatarImageView.setImage(with: user.avatarUrl, userId: user.userId, name: user.fullName)
}
case let result as CircleMemberSearchResult:
let member = result.member
if member.category == ConversationCategory.GROUP.rawValue {
avatarImageView.setGroupImage(with: member.iconUrl)
} else {
identityNumber = member.identityNumber
avatarImageView.setImage(with: member.iconUrl, userId: member.userId ?? "", name: member.name)
}
case let result as PhoneContactSearchResult:
Expand All @@ -94,6 +98,9 @@ class PeerInfoView: UIView, XibDesignable {
if let description = result.description {
descriptionLabel.attributedText = description
descriptionLabel.isHidden = false
} else if let identityNumber {
descriptionLabel.isHidden = false
descriptionLabel.text = identityNumber
} else {
descriptionLabel.isHidden = true
}
Expand All @@ -106,7 +113,8 @@ class PeerInfoView: UIView, XibDesignable {
badgeImageView.isHidden = badgeImageView.image == nil
superscriptLabel.text = nil
prefixIconImageView.isHidden = true
descriptionLabel.isHidden = true
descriptionLabel.isHidden = false
descriptionLabel.text = user.identityNumber
}

func render(user: User, userBiographyAsSubtitle: Bool) {
Expand All @@ -116,43 +124,51 @@ class PeerInfoView: UIView, XibDesignable {
badgeImageView.isHidden = badgeImageView.image == nil
superscriptLabel.text = nil
prefixIconImageView.isHidden = true
descriptionLabel.isHidden = false
if userBiographyAsSubtitle {
descriptionLabel.isHidden = false
descriptionLabel.text = user.biography
} else {
descriptionLabel.isHidden = true
descriptionLabel.text = user.identityNumber
}
}

func render(receiver: MessageReceiver) {
switch receiver.item {
case let .group(conversation):
descriptionLabel.isHidden = true
avatarImageView.setGroupImage(with: conversation.iconUrl)
case let .user(user):
descriptionLabel.isHidden = false
descriptionLabel.text = user.identityNumber
avatarImageView.setImage(with: user.avatarUrl, userId: user.userId, name: user.fullName)
}
titleLabel.text = receiver.name
badgeImageView.image = receiver.badgeImage
badgeImageView.isHidden = badgeImageView.image == nil
superscriptLabel.text = nil
prefixIconImageView.isHidden = true
descriptionLabel.isHidden = true
}

func render(member: CircleMember) {
if member.category == ConversationCategory.GROUP.rawValue {
avatarImageView.setGroupImage(with: member.iconUrl)
descriptionLabel.isHidden = true
} else {
avatarImageView.setImage(with: member.iconUrl,
userId: member.userId ?? "",
name: member.name)
if let identityNumber = member.identityNumber {
descriptionLabel.text = identityNumber
descriptionLabel.isHidden = false
} else {
descriptionLabel.isHidden = true
}
}
titleLabel.text = member.name
badgeImageView.image = member.badgeImage
badgeImageView.isHidden = badgeImageView.image == nil
superscriptLabel.text = nil
prefixIconImageView.isHidden = true
descriptionLabel.isHidden = true
}

func render(phoneContact: PhoneContact) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension BlockedUsersViewController: UITableViewDelegate, UITableViewDataSource

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellReuseId) as! BlockUserCell
cell.render(user: users[indexPath.row])
cell.infoView.render(user: users[indexPath.row])
return cell
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ import MixinServices

class BlockUserCell: ModernSelectedBackgroundCell {

@IBOutlet weak var avatarImageView: AvatarImageView!
@IBOutlet weak var nameLabel: UILabel!

func render(user: UserItem) {
avatarImageView.setImage(with: user)
nameLabel.text = user.fullName
}
@IBOutlet weak var infoView: PeerInfoView!

}
Loading

0 comments on commit af46a64

Please sign in to comment.