Skip to content

paritytech/polkadot-app-design-system-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polkadot App Design System — iOS

SwiftUI / UIKit design tokens for the Polkadot App: colors, typography, spacings, radii. Generated from polkadot-app-design-system — do not edit files under Sources/DesignSystem/Generated/ by hand; they're regenerated on every release.

Consuming via Swift Package Manager

In Package.swift:

.package(
    url: "https://github.com/novasamatech/polkadot-app-design-system-ios",
    from: "0.0.1"
)

…then add "DesignSystem" to your target's dependencies. Or use Xcode's File → Add Package Dependencies… with the same URL.

Tags are published as X.Y.Z (no v prefix). See the Releases page.

What's in the package

Sources/DesignSystem/
├── Theme/                  Theme protocol + CommonTheme base
├── ThemeManager/           Singleton that resolves and persists the active theme
├── Typography/             TypographyFamily protocol + style composition (.emphasized, .mono)
├── TypographyManager/      Singleton that resolves and persists the active typography family
├── Tokens/                 UIColor.app(_:), UIFont.app(_:) resolvers
├── Traits/                 DSThemeTrait, DSTypographyTrait + UIView typography binding
├── SwiftUI/                .typography(_:) view modifier with reactive trait binding
├── Extensions/             UIColor(rgbHex:), UIColor(rgbaHex:)
└── Generated/              Style Dictionary output — do not hand-edit
    ├── colors/             ThemeColorsProtocol, UIColor+Tokens, Color+Tokens, per-theme classes
    ├── typography/         Typescale, font family/weight enums, UIFont+Tokens, per-family classes
    ├── radii/              DSRadii (zero, tiny, …, full)
    └── spacings/           DSSpacings (zero, tiny, …, extraLargeIncreased)

Setup at app launch

In your scene delegate's scene(_:willConnectTo:options:):

import DesignSystem

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) {
    guard let windowScene = scene as? UIWindowScene else { return }

    ThemeManager.shared.setup(scene: windowScene)
    TypographyManager.shared.setup(scene: windowScene)

    // your usual scene setup…
}

setup(scene:) (a) captures the scene for future trait broadcasts, (b) applies the persisted theme/typography selection as a trait override before any view renders.

Using tokens

SwiftUI colors (reactive — driven by UIColor(dynamicProvider:)):

Text("Hello").foregroundStyle(.fgPrimary)

SwiftUI typography (reactive — driven by environment-bridged trait):

Text("Hello").typography(.bodyMedium)

UIKit colors (reactive — dynamic UIColor):

label.textColor = .fgPrimary

UIKit fonts (snapshot — UIFont can't be dynamic; bind explicitly if you need live updates):

label.font = .bodyMedium
label.bindAppTypography { $0.font = .bodyMedium }

Radii and spacings (static values):

RoundedRectangle(cornerRadius: DSRadii.medium)
VStack(spacing: DSSpacings.large) {  }

Updating tokens

Tokens are edited in the upstream polkadot-app-design-system repo. The generator regenerates the Swift output into Sources/DesignSystem/Generated/ — those files are checked in here but driven by the upstream source.

About

SwiftUI / UIKit design tokens for the Polkadot App. Generated from polkadot-app-design-system.

Resources

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages