Image.swift 840 B

123456789101112131415161718192021222324252627282930
  1. import Foundation
  2. /// A view that displays an image.
  3. public struct Image: Sendable {
  4. /// Whether the image is resizable.
  5. private var isResizable = false
  6. /// Creates an image view.
  7. ///
  8. /// `png`, `jpg`, and `webp` are supported.
  9. ///
  10. /// - Parameters:
  11. /// - url: The URL of the file to display.
  12. /// - useFileExtension: If `true`, the file extension is used to determine
  13. /// the file type, otherwise the first few ('magic') bytes of the file
  14. /// are used.
  15. public init(_ url: URL, useFileExtension: Bool = true) {}
  16. /// Makes the image resize to fit the available space.
  17. public func resizable() -> Self {
  18. var image = self
  19. image.isResizable = true
  20. return image
  21. }
  22. }
  23. extension Image: View {
  24. public var body: some View { return EmptyView() }
  25. }