-
Notifications
You must be signed in to change notification settings - Fork 61
Optimize OPENSWIFTUI_LINK_COREUI check #812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,8 +76,8 @@ package enum NamedImage { | |
| self.idiom = idiom | ||
| } | ||
|
|
||
| #if OPENSWIFTUI_LINK_COREUI | ||
| fileprivate func loadVectorInfo(from catalog: CUICatalog, idiom: Int) -> VectorInfo? { | ||
| #if OPENSWIFTUI_LINK_COREUI | ||
| let matchType: CatalogAssetMatchType = .cuiIdiom(idiom) | ||
| let glyph: CUINamedVectorGlyph? = catalog.findAsset( | ||
| key: catalogKey, | ||
|
|
@@ -136,6 +136,9 @@ package enum NamedImage { | |
| layoutMetrics: metrics, | ||
| catalog: catalog | ||
| ) | ||
| #else | ||
| _openSwiftUIPlatformUnimplementedFailure() | ||
| #endif | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Severity: medium 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| /// Computes a scale factor for symbol images based on the glyph's | ||
|
|
@@ -148,6 +151,7 @@ package enum NamedImage { | |
| /// 4. Computes a reference circle.fill diameter for the current weight/pointSize | ||
| /// 5. Returns the ratio clamped to the allowed range | ||
| private func symbolSizeScale(for glyph: CUINamedVectorGlyph) -> CGFloat { | ||
| #if OPENSWIFTUI_LINK_COREUI | ||
| let range = imageScale.allowedScaleRange | ||
| guard range.lowerBound < range.upperBound else { | ||
| return range.lowerBound | ||
|
|
@@ -213,23 +217,22 @@ package enum NamedImage { | |
|
|
||
| let ratio = referenceRadius / actualRadius | ||
| return min(range.upperBound, max(range.lowerBound, ratio)) | ||
| #else | ||
| _openSwiftUIPlatformUnimplementedFailure() | ||
| #endif | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
|
|
||
| // MARK: - VectorInfo | ||
|
|
||
| fileprivate struct VectorInfo { | ||
| #if OPENSWIFTUI_LINK_COREUI | ||
| var glyph: CUINamedVectorGlyph | ||
|
|
||
| var flipsRightToLeft: Bool | ||
|
|
||
| var layoutMetrics: Image.LayoutMetrics | ||
|
|
||
| weak var catalog: CUICatalog? | ||
| #endif | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -315,8 +318,8 @@ package enum NamedImage { | |
| } | ||
| } | ||
|
|
||
| #if OPENSWIFTUI_LINK_COREUI | ||
| func loadBitmapInfo(location: Image.Location, idiom: Int, subtype: Int) -> BitmapInfo? { | ||
| #if OPENSWIFTUI_LINK_COREUI | ||
| // Resolve catalog from location | ||
| guard case .bundle(let bundle) = location, | ||
| let (catalog, _) = NamedImage.sharedCache[bundle] else { | ||
|
|
@@ -425,8 +428,11 @@ package enum NamedImage { | |
| renderingMode: renderingMode, | ||
| resizingInfo: resizingInfo | ||
| ) | ||
| #else | ||
| _openSwiftUIPlatformUnimplementedWarning() | ||
| return nil | ||
| #endif | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| // MARK: - NamedImage.BitmapInfo | ||
|
|
@@ -514,10 +520,10 @@ package enum NamedImage { | |
|
|
||
| // MARK: Cache subscripts | ||
|
|
||
| #if OPENSWIFTUI_LINK_COREUI | ||
| // Looks up cached VectorInfo for key; if not found or catalog changed, | ||
| // calls loadVectorInfo and caches the result. | ||
| fileprivate subscript(key: VectorKey, catalog: CUICatalog) -> VectorInfo? { | ||
| #if OPENSWIFTUI_LINK_COREUI | ||
| let cached = data.vectors[key] | ||
| if let cached { | ||
| if let cachedCatalog = cached.catalog, cachedCatalog == catalog { | ||
|
|
@@ -529,8 +535,11 @@ package enum NamedImage { | |
| } | ||
| data.vectors[key] = info | ||
| return info | ||
| #else | ||
| _openSwiftUIPlatformUnimplementedWarning() | ||
| return nil | ||
| #endif | ||
| } | ||
| #endif | ||
|
|
||
| // Looks up cached BitmapInfo for key; if not found, | ||
| // calls loadBitmapInfo and caches the result. | ||
|
|
@@ -550,10 +559,10 @@ package enum NamedImage { | |
| #endif | ||
| } | ||
|
|
||
| #if OPENSWIFTUI_LINK_COREUI | ||
| // Resolves a CUICatalog for the given bundle. | ||
| // First tries defaultUICatalog; falls back to Assets.car with weak caching. | ||
| package subscript(bundle: Bundle) -> (CUICatalog, retain: Bool)? { | ||
| #if OPENSWIFTUI_LINK_COREUI | ||
| if let catalog = CUICatalog.defaultUICatalog(for: bundle) { | ||
| return (catalog, retain: false) | ||
| } | ||
|
|
@@ -570,10 +579,12 @@ package enum NamedImage { | |
| } | ||
| data.catalogs[url] = WeakCatalog(catalog: catalog) | ||
| return (catalog, retain: true) | ||
| #else | ||
| _openSwiftUIPlatformUnimplementedWarning() | ||
| return nil | ||
| #endif | ||
| } | ||
|
|
||
| #endif | ||
|
|
||
| package func decode(_ key: Key) throws -> DecodedInfo { | ||
| switch key { | ||
| case .bitmap(let bitmapKey): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With
#if OPENSWIFTUI_LINK_COREUImoved inside the body, this file still references CoreUI types (e.g.,CUICatalog,CUINamedVectorGlyph) in signatures/fields (loadVectorInfo,VectorInfo, cache subscripts), so non-CoreUI builds may still need those symbols available. Can you confirm this won’t break configurations where CoreUI isn’t importable/linkable?Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.