summaryrefslogtreecommitdiff
path: root/macos/Sources/Features/Update/UpdatePill.swift
diff options
context:
space:
mode:
Diffstat (limited to 'macos/Sources/Features/Update/UpdatePill.swift')
-rw-r--r--macos/Sources/Features/Update/UpdatePill.swift13
1 files changed, 12 insertions, 1 deletions
diff --git a/macos/Sources/Features/Update/UpdatePill.swift b/macos/Sources/Features/Update/UpdatePill.swift
index 1dc29e250..b975e81c9 100644
--- a/macos/Sources/Features/Update/UpdatePill.swift
+++ b/macos/Sources/Features/Update/UpdatePill.swift
@@ -8,6 +8,9 @@ struct UpdatePill: View {
/// Whether the update popover is currently visible
@State private var showPopover = false
+ /// The font used for the pill text
+ private let textFont = NSFont.systemFont(ofSize: 11, weight: .medium)
+
var body: some View {
if !model.state.isIdle {
pillButton
@@ -43,8 +46,9 @@ struct UpdatePill: View {
.frame(width: 14, height: 14)
Text(model.text)
- .font(.system(size: 11, weight: .medium))
+ .font(Font(textFont))
.lineLimit(1)
+ .frame(width: textWidth)
}
.padding(.horizontal, 8)
.padding(.vertical, 4)
@@ -58,4 +62,11 @@ struct UpdatePill: View {
.buttonStyle(.plain)
.help(model.text)
}
+
+ /// Calculated width for the text to prevent resizing during progress updates
+ private var textWidth: CGFloat? {
+ let attributes: [NSAttributedString.Key: Any] = [.font: textFont]
+ let size = (model.maxWidthText as NSString).size(withAttributes: attributes)
+ return size.width
+ }
}