Skip to content

Commit 4523b3d

Browse files
Fix icon alignments, clipping in sidebar (#53)
On macOS Tahoe, room icons don't quite behave as expected compared to older macOS releases. When no room icon can be loaded, the system icon is terribly misaligned as it is too small to fit the space it's given. When a room icon is found, it takes the full space, getting clipped in the process. I'm not entirely sure what the cause of the issue is, given that I haven't seen this behavior in other apps, but I suspect there's an issue with image sizing parameters internally. To work around this, I've made some minor modifications to the sidebar entry. First, system icons are now centered inside an invisible rounded rectangle to make sure it lines up correctly in the space given. Likewise, the image inside the label is given a frame, constraining its size to 22 points. To allow this to respect Dynamic Type features, this value is recorded as a ScaledMetric value, meaning it should adjust when the Dynamic Type rules are adjusted. Signed-off-by: Marquis Kurt <software@marquiskurt.net>
1 parent a79af5e commit 4523b3d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

MactrixLibrary/Sources/UI/Sidebar/RoomRow.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public struct RoomRow: View {
4343
@State private var joining: Bool = false
4444
@State private var error: Error? = nil
4545
@State private var isErrorVisible: Bool = false
46+
@ScaledMetric(relativeTo: .body) private var roomAvatarSize: CGFloat = 22.0
4647

4748
public init(title: String, avatarUrl: String?, roomInfo: RoomInfo?, imageLoader: ImageLoader?, joinRoom: (() async throws -> Void)?) {
4849
self.title = title
@@ -71,8 +72,13 @@ public struct RoomRow: View {
7172
},
7273
icon: {
7374
UI.AvatarImage(avatarUrl: avatarUrl, imageLoader: imageLoader) {
74-
Image(systemName: placeholderImageName)
75+
RoundedRectangle(cornerRadius: 4)
76+
.fill(.clear)
77+
.overlay {
78+
Image(systemName: placeholderImageName)
79+
}
7580
}
81+
.frame(width: roomAvatarSize, height: roomAvatarSize)
7682
.clipShape(RoundedRectangle(cornerRadius: 4))
7783
}
7884
)

0 commit comments

Comments
 (0)