BrazilStateFlags

1.0.0

Bandeiras dos estados brasileiros para SwiftUI. Flags of all 26 Brazilian states, the Federal District and Brazil as SwiftUI vectors. No assets, no dependencies, sharp at any size. iOS, macOS, tvOS, watchOS, visionOS.
Adrianogba/brazil-state-flags-swift

What's New

1.0.0

2026-09-02T13:05:54Z

First release.

Flags of the 26 Brazilian states, the Federal District and Brazil, in four styles: full, rounded, squareRounded and circle. 124 drawings in total, for iOS, macOS, tvOS, watchOS and visionOS.

  • No assets and no dependencies. Every flag is vector data compiled into Swift.
  • Each flag is a lazy static let, so the linker strips the ones an app never names.
  • UF code shorthands (FlagsCircle.sp) alongside full names.
  • Runtime lookup by UF, documented as reaching every flag in a style.
  • Rendering verified by generating contact sheets with ImageRenderer on a Mac and comparing against the Flutter and Compose output.

Instalação / Install

In Xcode: File → Add Package Dependencies, then paste this repository's URL.

.package(url: "https://github.com/Adrianogba/brazil-state-flags-swift.git", from: "1.0.0")

Artwork from icones-bandeiras-br-uf by Pierre Lapalu, CC0 1.0.

Also available for Flutter and Compose Multiplatform.

BrazilStateFlags

Bandeiras dos 26 estados brasileiros, do Distrito Federal e do Brasil.
Nítidas em qualquer tamanho, em Swift puro, para SwiftUI.

Swift platforms license

Português · English

Todas as bandeiras no estilo circle

Também existe para outras plataformas: Flutter · Compose Multiplatform

O que você recebe

  • 28 bandeiras em 4 estilos: full (3:2), rounded (3:2 com cantos arredondados), squareRounded e circle.
  • Zero assets e zero dependências. Cada bandeira é vetor compilado em Swift, sem nada em Assets.xcassets.
  • Nada é construído de forma ansiosa. Cada bandeira é um static let preguiçoso, então o linker descarta as que o app nunca cita.
  • Nítidas em qualquer tamanho, de 16 pt a tela cheia.
  • iOS, macOS, tvOS, watchOS e visionOS.

Instalação

No Xcode: File → Add Package Dependencies e cole a URL do repositório.

Ou no Package.swift:

dependencies: [
    .package(
        url: "https://github.com/Adrianogba/brazil-state-flags-swift.git",
        from: "1.0.0"
    )
]

Uso

import BrazilStateFlags
import SwiftUI

// Escolha o estilo, depois o estado.
BrazilStateFlagView(FlagsCircle.saoPaulo)
    .frame(width: 48, height: 48)

BrazilStateFlagView(FlagsFull.rioDeJaneiro)
    .frame(width: 120)

// Siglas de UF funcionam como atalho.
BrazilStateFlagView(FlagsCircle.sp)
    .frame(width: 24, height: 24)

As quatro coleções são FlagsFull, FlagsRounded, FlagsSquareRounded e FlagsCircle.

Tamanho

A view respeita a proporção da arte, então a bandeira nunca é esticada. Basta dar um frame:

BrazilStateFlagView(FlagsFull.parana).frame(width: 150)   // vira 150 x 100
BrazilStateFlagView(FlagsCircle.parana).frame(width: 64)  // vira 64 x 64

Busca por UF

Formulários de endereço precisam escolher a bandeira a partir de uma string:

if let bandeira = flagForUF("sp", style: .circle) {
    BrazilStateFlagView(bandeira).frame(width: 32, height: 32)
}

// Montando um seletor:
List(BrazilState.all) { estado in
    HStack {
        BrazilStateFlagView(estado.flag(.circle)).frame(width: 28, height: 28)
        Text("\(estado.uf)  \(estado.name)")
    }
}

flagForUF alcança todas as bandeiras do estilo pedido, então o linker não consegue remover nenhuma. Se você só precisa de duas ou três bandeiras fixas, cite as propriedades diretamente.

Variantes

Três estados têm dois desenhos no conjunto original. Eles não seguem um eixo único de "detalhado" e "simples", então cada um é exposto pelo que realmente é:

As três variantes

Padrão Alternativa Diferença
paraiba paraibaSimplified a simplificada não traz a palavra NEGO
ceara cearaSimplified a simplificada não traz o brasão
espiritoSanto espiritoSantoSimplified a padrão traz o lema TRABALHA E CONFIA

Acessibilidade

BrazilStateFlagView(
    FlagsCircle.bahia,
    accessibilityLabel: "Bandeira da Bahia"
)

Sem accessibilityLabel a bandeira é marcada como decorativa, que costuma ser o certo quando já existe um texto ao lado.

Requisitos

Requisito Mínimo
Swift 5.9
iOS 15
macOS 12
tvOS 15
watchOS 8
visionOS 1

Créditos

A arte vem de icones-bandeiras-br-uf, de Pierre Lapalu, publicada sob CC0 1.0. Os SVGs são convertidos em Swift por tool/generate_swift.dart, incluído no repositório.


English

Flags of the 26 Brazilian states, the Federal District and Brazil. Sharp at any size, in pure Swift, for SwiftUI.

Also available for other platforms: Flutter · Compose Multiplatform

What you get

  • 28 flags in 4 styles: full (3:2), rounded (3:2 with rounded corners), squareRounded and circle.
  • Zero assets and zero dependencies. Each flag is vector data compiled into Swift, with nothing in Assets.xcassets.
  • Nothing is built eagerly. Each flag is a lazy static let, so the linker strips the ones an app never names.
  • Sharp at any size, from 16 pt to full screen.
  • iOS, macOS, tvOS, watchOS and visionOS.

Install

In Xcode: File → Add Package Dependencies, then paste the repository URL.

Or in Package.swift:

dependencies: [
    .package(
        url: "https://github.com/Adrianogba/brazil-state-flags-swift.git",
        from: "1.0.0"
    )
]

Usage

import BrazilStateFlags
import SwiftUI

BrazilStateFlagView(FlagsCircle.saoPaulo)
    .frame(width: 48, height: 48)

BrazilStateFlagView(FlagsFull.rioDeJaneiro)
    .frame(width: 120)

BrazilStateFlagView(FlagsCircle.sp)
    .frame(width: 24, height: 24)

The four collections are FlagsFull, FlagsRounded, FlagsSquareRounded and FlagsCircle.

Sizing

The view keeps the artwork's aspect ratio, so the flag is never stretched. Just give it a frame.

Lookup by UF

if let flag = flagForUF("sp", style: .circle) {
    BrazilStateFlagView(flag).frame(width: 32, height: 32)
}

List(BrazilState.all) { state in
    HStack {
        BrazilStateFlagView(state.flag(.circle)).frame(width: 28, height: 28)
        Text("\(state.uf)  \(state.name)")
    }
}

flagForUF reaches every flag in the requested style, so the linker cannot drop any of them. If you only need a couple of fixed flags, name the properties directly.

Variants

Three states ship two drawings in the source set. They do not follow a single "detailed versus simple" axis, so each is exposed for what it actually is:

Default Alternative Difference
paraiba paraibaSimplified the simplified one drops the word NEGO
ceara cearaSimplified the simplified one drops the coat of arms
espiritoSanto espiritoSantoSimplified the default carries the TRABALHA E CONFIA motto

Accessibility

BrazilStateFlagView(
    FlagsCircle.bahia,
    accessibilityLabel: "Bandeira da Bahia"
)

With no accessibilityLabel the flag is marked decorative, which is usually right when a label already sits next to it.

Credits

Artwork from icones-bandeiras-br-uf by Pierre Lapalu, released under CC0 1.0. The SVGs are converted to Swift by tool/generate_swift.dart, included in the repository.

License

MIT. See LICENSE.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Sep 06 2026 11:16:01 GMT-0900 (Hawaii-Aleutian Daylight Time)