File tree 1 file changed +17
-9
lines changed
Sources/ArcGISToolkit/Components/FeatureTemplatePicker
1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -143,27 +143,35 @@ private struct FeatureTemplateView: View {
143
143
let info : FeatureTemplateInfo
144
144
@Binding var selection : FeatureTemplateInfo ?
145
145
146
+ // The maximum size of the image when the font is body.
147
+ @ScaledMetric ( relativeTo: . body) var maxImageSize = 44
148
+
146
149
var body : some View {
147
150
HStack {
148
151
Label {
149
152
Text ( info. template. name)
150
153
. lineLimit ( 1 )
151
154
} icon: {
152
155
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
+ }
162
169
} else {
163
170
Image ( systemName: " minus " )
164
171
. foregroundStyle ( . secondary)
165
172
}
166
173
}
174
+ . font ( . body)
167
175
Spacer ( )
168
176
if info == selection {
169
177
Image ( systemName: " checkmark " )
You can’t perform that action at this time.
0 commit comments