Repository navigation
refactor(api): trim over-engineered scaling, fast-path, and SwiftUI surface - #7
Merged
Merged
Conversation
Remove .fastW/.fastH/.fastSp from CLAUDE.md Public Contract & Module Map and from README; strike the resolved Known Issues (data race, rotation) and correct the Sendable note. Ignore graphify-out/ and .superpowers/.
The per-value fast variants only skipped one isFinite guard while still paying a per-value atomic snapshot load (~1.1x, not a real speedup). The capture-once FastScale/withFastScale path is unchanged; the Debug benchmark is repointed to FastScale.width and the dead/flaky fast tests removed.
Dicky019
force-pushed
the
refactor/remove-fast-scaling-variants
branch
from
June 21, 2026 10:24
e97c3d9 to
4d027b2
Compare
…urface Collapse the duplicated/speculative API down to the cross-platform scaling primitives and the minimum SwiftUI/UIKit ergonomics that carry real logic. Scaling: - Numeric+Scaling: 4 copy-paste extensions → 2 generics (BinaryInteger, BinaryFloatingPoint), now covering Int64/UInt uniformly. - FastScale delegates to the internal ScaleFactorCache core instead of re-implementing the capture. - Consolidate batch scaling onto BatchScaler (add scale/points/rects); drop the redundant ScreenUtil.batch* methods. Debug: - ScreenUtilDebug struct+singleton → caseless enum of static methods; drop validateScaling, generateTestReport, and free-function wrappers. SwiftUI: - Remove Font.scaledSystem/scaledCustom, @ScaledValue/@ScreenPercentage, and the responsiveFrame/responsivePadding/responsiveCornerRadius view modifiers — all thin sugar over the .w/.h/.sp/.r primitives applied inside native modifiers. Keep EnvironmentValues.screenUtil (renamed file Environment+ScreenUtil.swift). Also: fix responsivePadding(.all) consumers via native per-axis scaling, UIView constraint helpers disable the autoresizing mask and batch-activate, and update tests, examples, and docs. Build clean under -strict-concurrency=complete; 105 tests, 0 failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes redundant and speculative public API across the scaling, fast-path, debug, and SwiftUI layers, reducing ScreenUtil to its cross-platform scaling primitives plus the platform ergonomics that carry real logic. Driven by a multi-lens audit (over-engineering, clean-code, SOLID, Swift-concurrency, SwiftUI/UIKit). Net −733 lines (253 insertions, 986 deletions) across 24 files, with no behavior change to the surviving API.
What changed
Scaling
Numeric+Scaling: 4 copy-pasteInt/Float/Double/CGFloatextensions → 2 generics (BinaryInteger,BinaryFloatingPoint) — also coversInt64/UIntuniformly, closing the silent-scale-to-zero gap..fastW/.fastH/.fastSpnumeric variants (~1.1× over.w/.h/.sp, not the documented speedup). The real hot-loop path —FastScale/withFastScale— is unchanged.FastScalenow delegates to the internalScaleFactorCachecore instead of re-implementing the capture.BatchScaler(addedscale/points/rects); dropped the redundant, driftedScreenUtil.batch*methods.Debug
ScreenUtilDebugstruct+singleton → caselessenumof static methods; droppedvalidateScaling,generateTestReport, and the free-function wrappers.SwiftUI
Font.scaledSystem/scaledCustom,@ScaledValue/@ScreenPercentage, and theresponsiveFrame/responsivePadding/responsiveCornerRadiusview modifiers — all thin sugar over the.w/.h/.sp/.rprimitives applied inside native modifiers. KeptEnvironmentValues.screenUtil(file renamed toEnvironment+ScreenUtil.swift).Bug fixes (included)
responsivePadding(.all)scaled every edge by height only — fixed to scale each axis by its own factor (now applied at consumer call sites).Docs / examples / tests
Updated to the new surface; stale
CLAUDE.md"Known Issues" (data race, stale-on-rotation — both already fixed in source) struck.Migration
100.fastW/.fastH/.fastSp100.w/.h/.sp(orFastScalein a hot loop)ScreenUtil.shared.batchWidths(xs)ScreenUtil.shared.batchScaler.widths(xs).font(.scaledSystem(size: 16)).font(.system(size: 16.sp))@ScaledValue(.width) var w = 100let w = 100.w.responsiveFrame(width: 200, height: 50).frame(width: 200.w, height: 50.h)ScreenUtilDebug.shared.printCurrentConfiguration()ScreenUtilDebug.printCurrentConfiguration()Verification
swift buildclean under-strict-concurrency=complete, no new warnings.swift test: 105 tests, 0 failures (down from 116 — removed tests covered deleted API; no behavioral coverage lost).Commits
refactor(api): trim over-engineered scaling and SwiftUI convenience surfacerefactor(scaling): remove .fastW/.fastH/.fastSp numeric variantsdocs(scaling): drop removed .fast* numeric API from docs