@octopus-community/react-native 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/OctopusUIManager.swift +31 -6
- package/package.json +1 -1
|
@@ -89,18 +89,43 @@ class OctopusUIManager {
|
|
|
89
89
|
}.resume()
|
|
90
90
|
} else {
|
|
91
91
|
// Local file path (from Image.resolveAssetSource)
|
|
92
|
-
if let image =
|
|
92
|
+
if let image = loadImageFromLocalPath(uri) {
|
|
93
93
|
completion(image)
|
|
94
94
|
} else {
|
|
95
|
-
|
|
96
|
-
let filename = (uri as NSString).lastPathComponent
|
|
97
|
-
let nameWithoutExtension = (filename as NSString).deletingPathExtension
|
|
98
|
-
let image = UIImage(named: nameWithoutExtension)
|
|
99
|
-
completion(image)
|
|
95
|
+
completion(nil)
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
98
|
}
|
|
103
99
|
|
|
100
|
+
private func loadImageFromLocalPath(_ path: String) -> UIImage? {
|
|
101
|
+
// Handle absolute file URLs (file://) first
|
|
102
|
+
if path.hasPrefix("file://"), let url = URL(string: path),
|
|
103
|
+
let image = UIImage(contentsOfFile: url.path) {
|
|
104
|
+
return image
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Try raw absolute path next
|
|
108
|
+
if path.hasPrefix("/"), FileManager.default.fileExists(atPath: path),
|
|
109
|
+
let image = UIImage(contentsOfFile: path) {
|
|
110
|
+
return image
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// For React Native bundled assets the path is relative (e.g. assets/assets/logo.png)
|
|
114
|
+
let nsPath = path as NSString
|
|
115
|
+
let directory = nsPath.deletingLastPathComponent
|
|
116
|
+
let filename = nsPath.lastPathComponent
|
|
117
|
+
let nameWithoutExtension = (filename as NSString).deletingPathExtension
|
|
118
|
+
let fileExtension = (filename as NSString).pathExtension
|
|
119
|
+
|
|
120
|
+
if let bundlePath = Bundle.main.path(forResource: nameWithoutExtension, ofType: fileExtension.isEmpty ? nil : fileExtension, inDirectory: directory.isEmpty ? nil : directory) ,
|
|
121
|
+
let image = UIImage(contentsOfFile: bundlePath) {
|
|
122
|
+
return image
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Final fallback: let UIKit try to resolve it by name (works for assets catalog entries)
|
|
126
|
+
return UIImage(named: nameWithoutExtension)
|
|
127
|
+
}
|
|
128
|
+
|
|
104
129
|
func closeUI() throws {
|
|
105
130
|
guard let presentedVC = presentedViewController else {
|
|
106
131
|
throw NSError(domain: "CLOSE_UI_ERROR", code: 0, userInfo: [NSLocalizedDescriptionKey: "No UI is currently presented"])
|