File tree Expand file tree Collapse file tree
Sources/ArcGISToolkit/Components/FeatureTemplatePicker Expand file tree Collapse file tree Original file line number Diff line number Diff 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 " )
You can’t perform that action at this time.
0 commit comments