Skip to content

Commit 3ffb37d

Browse files
committed
fix issues with maximum size
1 parent d5f8854 commit 3ffb37d

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

Sources/ArcGISToolkit/Components/FeatureTemplatePicker/FeatureTemplatePicker.swift

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,27 +143,35 @@ private struct FeatureTemplateView: View {
143143
let info: FeatureTemplateInfo
144144
@Binding var selection: FeatureTemplateInfo?
145145

146+
// The maximum size of the image when the font is body.
147+
@ScaledMetric(relativeTo: .body) var maxImageSize = 44
148+
146149
var body: some View {
147150
HStack {
148151
Label {
149152
Text(info.template.name)
150153
.lineLimit(1)
151154
} icon: {
152155
if let image = info.image {
153-
if image.size.width > 50 || image.size.height > 50 {
154-
// Limit icon to 50x50.
155-
Image(uiImage: image)
156-
.resizable()
157-
.aspectRatio(contentMode: .fit)
158-
} else {
159-
// But don't restrict how small the icon can be.
160-
Image(uiImage: image)
161-
}
156+
Image(uiImage: image)
157+
.resizable()
158+
.scaledToFit()
159+
.containerRelativeFrame(.horizontal) { size, axis in
160+
let maxSize = maxImageSize
161+
if image.size.width > maxSize {
162+
// Limit icon to max size.
163+
return maxSize
164+
} else {
165+
// But don't restrict how small the icon can be.
166+
return image.size.width
167+
}
168+
}
162169
} else {
163170
Image(systemName: "minus")
164171
.foregroundStyle(.secondary)
165172
}
166173
}
174+
.font(.body)
167175
Spacer()
168176
if info == selection {
169177
Image(systemName: "checkmark")

0 commit comments

Comments
 (0)