Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

swiftui-ui-patterns

/swiftui-ui-patterns

Podpowiada wzorce budowy widoków SwiftUI na przykładach: architekturę zakładek TabView, składanie ekranów i gotowe komponenty.

Repozytorium
stacc ↗
Licencja
MIT
Ostatnia zmiana repozytorium
21.09.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
27
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 21.09.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Podpowiada wzorce budowy widoków SwiftUI na przykładach: architekturę zakładek TabView, składanie ekranów i gotowe komponenty.

Oryginalny opis (EN)

Best practices and example-driven guidance for building SwiftUI views and components. Use when creating or refactoring SwiftUI UI, designing tab architecture with TabView, composing screens, or needing component-specific patterns and examples.

Jak działa

  1. Quick start
  2. General rules to follow
  3. Workflow for a new SwiftUI view
  4. Component references
  5. Sheet patterns
  6. Adding a new component reference
Sekcje z nagłówków SKILL.md, w oryginale · 92 linii, 459 słów
Podgląd SKILL.md
---
name: swiftui-ui-patterns
description: Best practices and example-driven guidance for building SwiftUI views and components. Use when creating or refactoring SwiftUI UI, designing tab architecture with TabView, composing screens, or needing component-specific patterns and examples.
license: MIT
origin_url: https://github.com/Dimillian/Skills
---

# SwiftUI UI Patterns

## Quick start

Choose a track based on your goal:

### Existing project

- Identify the feature or screen and the primary interaction model (list, detail, editor, settings, tabbed).
- Find a nearby example in the repo with `rg "TabView\("` or similar, then read the closest SwiftUI view.
- Apply local conventions: prefer SwiftUI-native state, keep state local when possible, and use environment injection for shared dependencies.
- Choose the relevant component reference from `references/components-index.md` and follow its guidance.
- Build the view with small, focused subviews and SwiftUI-native data flow.

### New project scaffolding

- Start with `references/app-scaffolding-wiring.md` to wire TabView + NavigationStack + sheets.
- Add a minimal `AppTab` and `RouterPath` based on the provided skeletons.
- Choose the next component reference based on the UI you need first (TabView, NavigationStack, Sheets).
- Expand the route and sheet enums as new screens are added.

## General rules to follow

- Use modern SwiftUI state (`@State`, `@Binding`, `@Observable`, `@Environment`) and avoid unnecessary view models.
- Prefer composition; keep views small and focused.
- Use async/await with `.task` and explicit loading/error states.
- Maintain existing legacy patterns only when editing legacy files.
- Follow the project's formatter and style guide.
- **Sheets**: Prefer `.sheet(item:)` over `.sheet(isPresented:)` when state represents a selected model. Avoid `if let` inside a sheet body. Sheets should own their actions and call `dismiss()` internally instead of forwarding `onCancel`/`onConfirm` closures.

## Workflow for a new SwiftUI view

1. Define the view's state and its ownership location.
2. Identify dependencies to inject via `@Environment`.
3. Sketch the view hierarchy and extract repeated parts into subviews.
4. Implement async loading with `.task` and explicit state enum if needed.
5. Add accessibility labels or identifiers when the UI is interactive.
6. Validate with a build and update usage callsites if needed.

## Component references

Use `references/components-index.md` as the entry point. Each component reference should include:
- Intent and best-fit scenarios.
- Minimal usage pattern with local conventions.
- Pitfalls and performance notes.
- Paths to existing examples in the current repo.

## Sheet patterns

### Item-driven sheet (preferred)

```swift
@State private var selectedItem: Item?

.sheet(item: $selectedItem) { item in
    EditItemSheet(item: item)
}
```

### Sheet owns its actions

```swift
struct EditItemSheet: View {
    @Environment(\.dismiss) private var dismiss
    @Environment(Store.self) private var store

    let item: Item
    @State private var isSaving = false

    var body: some View {
        VStack {
            Button(isSaving ? "Saving…" : "Save") {
                Task { await save() }
            }
        }
    }

    private func save() async {
        isSaving = true
        await store.save(item)
        dismiss()
    }
}
```

## Adding a new component reference

- Create `references/<component>.md`.
- Keep it short and actionable; link to concrete files in the current repo.
- Update `references/components-index.md` with the new entry.
Pliki w paczce (27)
  • SKILL.md 4 KB
  • references/app-wiring.md 6 KB
  • references/components-index.md 4 KB
  • references/controls.md 2 KB
  • references/deeplinks.md 2 KB
  • references/focus.md 2 KB
  • references/form.md 3 KB
  • references/grids.md 2 KB
  • references/haptics.md 2 KB
  • references/input-toolbar.md 1 KB
  • references/lightweight-clients.md 2 KB
  • references/list.md 3 KB
  • references/loading-placeholders.md 1 KB
  • references/macos-settings.md 2 KB
  • references/matched-transitions.md 2 KB
  • references/media.md 2 KB
  • references/menu-bar.md 2 KB
  • references/navigationstack.md 4 KB
  • references/overlay.md 1 KB
  • references/scrollview.md 2 KB
  • references/searchable.md 2 KB
  • references/sheets.md 3 KB
  • references/split-views.md 2 KB
  • references/tabview.md 3 KB
  • references/theming.md 2 KB
  • references/title-menus.md 2 KB
  • references/top-bar.md 1 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · heyAyushh/stacc100MIT
TerminalSkills/skills100Apache-2.0
velimirmueller/ai-development-skills100MIT
heyAyushh/stacc100MIT

Identyczna treść występuje jeszcze w 4 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.

Migawka bazy z 13.11.2026 · wersja paczki c56617150e50 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100guide-swiftui-ui-patterns
    Podaje wzorce budowania widoków SwiftUI: nawigację, modyfikatory, układy ze stosów i siatek, TabView oraz zarządzanie stanem.
  • 100swiftui-patterns
    Podpowiada wzorce architektury SwiftUI: stan przez Observable, kompozycję widoków, nawigację i wydajność renderowania w iOS i macOS.
  • 100swiftui-patterns
    Opisuje wzorce architektury SwiftUI: stan z @Observable, kompozycja widoków, nawigacja i optymalizacja wydajności renderowania w aplikacjach iOS i macOS.
  • 100local-swiftui-ui-patterns-298fc724
    Buduje i refaktoryzuje interfejs SwiftUI wzorcami komponentów: nawigacja, stan, układy i kompozycja ekranów.
  • 100navigation-patterns
    Opisuje wzorce architektury nawigacji w SwiftUI, takie jak NavigationStack, NavigationSplitView, TabView, nawigacja programowa i własne przejścia, przy budowie i przeglądzie przepływu aplikacji.
  • 96swiftui-patterns
    Podpowiada wzorce architektury SwiftUI: zarządzanie stanem przez @Observable, nawigację i wydajność widoków.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.