swiftui-view-refactor

Featured

Refactor SwiftUI views into smaller components with stable, explicit data flow.

Code & Development 49,938 stars 7238 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# SwiftUI View Refactor ## Overview Refactor SwiftUI views toward small, explicit, stable view types. Default to vanilla SwiftUI: local state in the view, shared dependencies in the environment, business logic in services/models, and view models only when the request or existing code clearly requires one. ## When to Use - When cleaning up a large SwiftUI view or splitting long `body` implementations. - When you need smaller subviews, explicit dependency injection, or better Observation usage. ## Core Guidelines ### 1) View ordering (top → bottom) - Enforce this ordering unless the existing file has a stronger local convention you must preserve. - Environment - `private`/`public` `let` - `@State` / other stored properties - computed `var` (non-view) - `init` - `body` - computed view builders / other view helpers - helper / async functions ### 2) Default to MV, not MVVM - Views should be lightweight state expressions and orchestration points, not containers for business logic. - Favor `@State`, `@Environment`, `@Query`, `.task`, `.task(id:)`, and `onChange` before reaching for a view model. - Inject services and shared models via `@Environment`; keep domain logic in services/models, not in the view body. - Do not introduce a view model just to mirror local view state or wrap environment dependencies. - If a screen is getting large, split the UI into subviews before inventing a new view model layer. ### 3) Strongly prefer dedicated subview types over computed `some View` ...

Details

Author
sickn33
Repository
sickn33/antigravity-awesome-skills
Created
10 months ago
Last Updated
today
Language
Python
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category