mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 04:36:58 +02:00
Merge branch 'develop' into 'feature/5410_federation_us15_room_settings'
# Conflicts: # bwi/Federation/MXRoom+Federation.swift
This commit is contained in:
@@ -112,27 +112,14 @@ class RoomInfoBasicView: UIView {
|
||||
if BWIBuildSettings.shared.isFederationEnabled && viewData.isFederated {
|
||||
// add imageview for the pill if it doesn't exist
|
||||
if pillImageView == nil {
|
||||
// because of svg we use fixed values here for the raw image size
|
||||
let pillImageWidth: CGFloat = 23.0
|
||||
let pillImageHeight: CGFloat = 18.0
|
||||
let pillBorderSize: CGFloat = 3.0
|
||||
|
||||
// compensation for the bottom gap in the asset
|
||||
let verticalShift: CGFloat = 2.5
|
||||
|
||||
let avatarSize = avatarImageView.frame.size.height
|
||||
let pillHeight: CGFloat = avatarSize * 0.34 // 34% relative size by design rule
|
||||
let pillWidth: CGFloat = pillHeight / pillImageHeight * pillImageWidth
|
||||
let scaledBorderSize: CGFloat = pillBorderSize * pillHeight / pillImageHeight
|
||||
let frame = CGRect(x: avatarImageView.frame.origin.x + avatarSize - pillWidth + scaledBorderSize, y: verticalShift + avatarImageView.frame.origin.y + avatarSize - pillHeight, width: pillWidth, height: pillHeight)
|
||||
let imageView = UIImageView(frame: frame)
|
||||
let imageView = FederationIconHelper.shared.getFederatedIconImageView(avatarFrame: avatarImageView.frame)
|
||||
pillImageView = imageView
|
||||
pillImageView?.contentMode = .scaleAspectFit
|
||||
avatarContainerView.addSubview(imageView)
|
||||
}
|
||||
|
||||
pillImageView?.image = federationBadgeImage()
|
||||
roomNameLabel.attributedText = roomNameWithFederationPill(roomDisplayName: viewData.roomDisplayName, font: roomNameLabel.font)
|
||||
pillImageView?.image = FederationIconHelper.shared.federationBadgeImage()
|
||||
roomNameLabel.attributedText = FederationIconHelper.shared.roomNameWithFederationPill(roomDisplayName: viewData.roomDisplayName, font: roomNameLabel.font)
|
||||
} else {
|
||||
roomNameLabel.text = viewData.roomDisplayName
|
||||
pillImageView?.image = nil
|
||||
@@ -163,46 +150,7 @@ class RoomInfoBasicView: UIView {
|
||||
updateRoomNameLabelPosition()
|
||||
updateBadgeImageViewPosition(isPresenceDisplayed: viewData.directUserPresence != .unknown)
|
||||
}
|
||||
|
||||
// bwi: 5216 - federation
|
||||
private func federationBadgeImage() -> UIImage {
|
||||
if ThemeService.shared().isCurrentThemeDark() {
|
||||
return Asset.Images.roomFederatedBumIconDark.image
|
||||
} else {
|
||||
return Asset.Images.roomFederatedBumIconLight.image
|
||||
}
|
||||
}
|
||||
|
||||
// bwi: 5216 - federation
|
||||
private func roomNameWithFederationPill(roomDisplayName: String?, font: UIFont) -> NSAttributedString? {
|
||||
guard let roomDisplayName = roomDisplayName else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let attributedString = NSMutableAttributedString(string: roomDisplayName + " ")
|
||||
|
||||
// get the correct asset for the current theme and language
|
||||
let image: UIImage
|
||||
if Locale.current.languageCode == "de" {
|
||||
image = ThemeService.shared().isCurrentThemeDark() ? Asset.Images.federationPillDeBumDark.image : Asset.Images.federationPillDeBumLight.image
|
||||
} else {
|
||||
image = ThemeService.shared().isCurrentThemeDark() ? Asset.Images.federationPillEnBumDark.image : Asset.Images.federationPillEnBumLight.image
|
||||
}
|
||||
|
||||
// append the pill to the room name
|
||||
if image.size.width > 0.0 && image.size.height > 0.0 {
|
||||
let aspectRatio = image.size.width / image.size.height
|
||||
let pillHeight: CGFloat = 20.0
|
||||
let offset = 0.5 * (font.capHeight - pillHeight)
|
||||
|
||||
let attachment = NSTextAttachment()
|
||||
attachment.image = image
|
||||
attachment.bounds = CGRect(x: 0, y: offset, width: pillHeight * aspectRatio, height: pillHeight)
|
||||
attributedString.append(NSAttributedString(attachment: attachment))
|
||||
}
|
||||
|
||||
return attributedString
|
||||
}
|
||||
|
||||
|
||||
// bwi
|
||||
private func updateRoomNameLabelPosition() {
|
||||
|
||||
Reference in New Issue
Block a user