Image.swift 822 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // Image.swift
  3. // DashKitUI
  4. //
  5. // Created by Pete Schwamb on 2/7/20.
  6. // Copyright © 2020 LoopKit Authors. All rights reserved.
  7. //
  8. import SwiftUI
  9. private class LocalBundle {
  10. /// Returns the resource bundle associated with the current Swift module.
  11. static var main: Bundle = {
  12. if let mainResourceURL = Bundle.main.resourceURL,
  13. let bundle = Bundle(url: mainResourceURL.appendingPathComponent("LoopKitUI_LoopKitUI.bundle"))
  14. {
  15. return bundle
  16. }
  17. return Bundle(for: LocalBundle.self)
  18. }()
  19. }
  20. extension Image {
  21. init(frameworkImage name: String, decorative: Bool = false) {
  22. if decorative {
  23. self.init(decorative: name, bundle: LocalBundle.main)
  24. } else {
  25. self.init(name, bundle: LocalBundle.main)
  26. }
  27. }
  28. }