1 import ABI49_0_0ExpoModulesCore 2 3 /** 4 Describes how the image should be resized to fit its container. 5 - Note: It mirrors the CSS [`object-fit`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) property. 6 */ 7 enum ContentFit: String, Enumerable { 8 /** 9 The image is scaled to maintain its aspect ratio while fitting within the container's box. 10 The entire image is made to fill the box, while preserving its aspect ratio, 11 so the image will be "letterboxed" if its aspect ratio does not match the aspect ratio of the box. 12 */ 13 case contain 14 15 /** 16 The image is sized to maintain its aspect ratio while filling the element's entire content box. 17 If the image's aspect ratio does not match the aspect ratio of its box, then the object will be clipped to fit. 18 */ 19 case cover 20 21 /** 22 The image is sized to fill the element's content box. The entire object will completely fill the box. 23 If the image's aspect ratio does not match the aspect ratio of its box, then the image will be stretched to fit. 24 */ 25 case fill 26 27 /** 28 The image is not resized and is centered by default. 29 When specified, the exact position can be controlled with `ContentPosition`. 30 */ 31 case none 32 33 /** 34 The image is sized as if `none` or `contain` were specified, 35 whichever would result in a smaller concrete image size. 36 */ 37 case scaleDown = "scale-down" 38 39 /** 40 `ContentFit` cases can be directly translated to the native `UIView.ContentMode` 41 except `scaleDown` that needs to be handled differently at the later step of rendering. 42 */ toContentModenull43 func toContentMode() -> UIView.ContentMode { 44 switch self { 45 case .contain: 46 return .scaleAspectFit 47 case .cover: 48 return .scaleAspectFill 49 case .fill: 50 return .scaleToFill 51 case .none, .scaleDown: 52 return .center 53 } 54 } 55 } 56