Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add concurrency annotations #848

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:
branches: [ main ]

env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.0.app/Contents/Developer

jobs:
build:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-docc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
workflow_dispatch:

env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.0.app/Contents/Developer

jobs:
documentation:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Generate DocC
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/regenerate_snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ on:
required: true

env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.0.app/Contents/Developer

jobs:
generate_snapshots:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion Automation/update_country_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

source_template = source_header + '''public extension CountryFlag {{

enum CountryCode: String, CaseIterable {{
enum CountryCode: String, CaseIterable, Sendable {{
{cases}
}}
}}
Expand Down
6 changes: 3 additions & 3 deletions Automation/update_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

source_template = source_header + '''public extension Icon {{

enum Symbol: CaseIterable, Equatable {{
enum Symbol: CaseIterable, Equatable, Sendable {{
{cases}

public var value: String {{
Expand Down Expand Up @@ -97,8 +97,8 @@ def iconsFolderPath():

swift_icon_key = dots_to_camel_case(swift_icon_name)
case_lines.append(f" /// Orbit `{swift_icon_name}` icon symbol.\n case {swift_icon_key}")
value_lines.append(f" case .{swift_icon_key}: return \"{swift_value}\"")
value_lines.append(f" case .{swift_icon_key}: \"{swift_value}\"")

updated_file_content = source_template.format(cases = '\n'.join(case_lines), values = '\n'.join(value_lines))

with open(icons_swift_path, "w+") as source_file:
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Components/BadgeList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public extension BadgeList where Icon == Orbit.Icon, Label == Text {
// MARK: - Types

/// A type of Orbit ``BadgeList``.
public enum BadgeListType: Equatable, Hashable {
public enum BadgeListType: Equatable, Hashable, Sendable {
case neutral
case status(_ status: Status?)
// FIXME: Remove and use override modifiers
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Components/ButtonLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public extension ButtonLink where Label == Text, LeadingIcon == Orbit.Icon, Trai
// MARK: - Types

/// A predefined type of Orbit ``ButtonLink``.
public enum ButtonLinkType: Equatable {
public enum ButtonLinkType: Equatable, Sendable {
case primary
case critical
case status(_ status: Status?)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Components/Checkbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public extension Checkbox where Title == Text, Description == Text {
// MARK: - Types

/// A state of Orbit ``Checkbox``.
public enum CheckboxState {
public enum CheckboxState: Sendable {
case normal
case error
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Orbit/Components/ChoiceTile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,14 @@ public extension ChoiceTile where Badge == Orbit.Badge<EmptyView, Text, EmptyVie
// MARK: - Types

/// Indicator used for Orbit ``ChoiceTile``.
public enum ChoiceTileIndicator {
public enum ChoiceTileIndicator: Sendable {
case radio
case checkbox
case `switch`
}

/// Alignment variant of Orbit ``ChoiceTile``.
public enum ChoiceTileAlignment {
public enum ChoiceTileAlignment: Sendable {
case `default`
case center
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Components/Heading.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public extension Heading {
public extension Heading {

/// Orbit ``Heading`` style that represents the default size and color of a title.
enum Style: Equatable {
enum Style: Equatable, Sendable {
/// 28 pts.
case title1
/// 22 pts.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Components/HorizontalScroll.swift
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public struct HorizontalScroll<Content: View>: View {
// MARK: - Types

/// Width for all items used in Orbit ``HorizontalScroll``.
public enum HorizontalScrollItemWidth {
public enum HorizontalScrollItemWidth: Sendable {
/// Width ratio calculated from the available container width.
case ratio(CGFloat = 0.48, maxWidth: CGFloat? = Layout.readableMaxWidth - 270)
/// Custom fixed width.
Expand Down
4 changes: 2 additions & 2 deletions Sources/Orbit/Components/Icon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public extension Icon {
public extension Icon {

/// Preferred Orbit ``Icon`` size in both dimensions. The actual size may differ based on icon content.
enum Size: Equatable {
enum Size: Equatable, Sendable {
/// Size 16.
case small
/// Size 20.
Expand Down Expand Up @@ -210,7 +210,7 @@ public extension Icon {
// MARK: - Private
private extension Icon {

enum Content {
enum Content: Sendable {
case symbol(Symbol)
case sfSymbol(String)

Expand Down
4 changes: 2 additions & 2 deletions Sources/Orbit/Components/ListChoice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ public extension ListChoice where Title == Text, Description == Text, Header ==
// MARK: - Types

/// Disclosure used in Orbit ``ListChoice``.
public enum ListChoiceDisclosure: Equatable {
public enum ListChoiceDisclosure: Equatable, Sendable {

/// Orbit ``ListChoiceDisclosure`` button type.
public enum ButtonType {
public enum ButtonType: Sendable {
case add
case remove
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Components/Radio.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public extension Radio where Title == Text, Description == Text {
// MARK: - Types

/// A state of Orbit ``Radio``.
public enum RadioState {
public enum RadioState: Sendable {
case normal
case error
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Orbit/Components/Skeleton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public struct Skeleton: View {
extension Skeleton {

/// Orbit ``Skeleton`` shape and size preset.
public enum Preset {
public enum Atomic {
public enum Preset: Sendable {

public enum Atomic: Sendable {
case circle
case rectangle
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/Orbit/Components/Tile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ public extension Tile where Title == Heading, Description == Text, Icon == Orbit

// MARK: - Types

public enum TileDisclosure: Equatable {
// FIXME: remove @unchecked if `LocalizedStringKey` becomes `Sendable`
public enum TileDisclosure: Equatable, @unchecked Sendable {
/// Icon with optional color override.
case icon(Icon.Symbol, alignment: VerticalAlignment = .center)
/// ButtonLink indicator.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Foundation/Borders/BorderRadius.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CoreGraphics
/// Orbit predefined border radiuses.
///
/// - Note: [Orbit.kiwi documentation](https://orbit.kiwi/foundation/border-radiuses/)
public enum BorderRadius {
public enum BorderRadius: Sendable {
/// 2 pts border radius.
public static let xxSmall: CGFloat = 2
/// 3 pts border radius.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Foundation/Borders/BorderWidth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import CoreGraphics
import UIKit

/// Predefiend Orbit border widths.
public enum BorderWidth {
public enum BorderWidth: Sendable {
/// 1 pixel border width.
public static let hairline: CGFloat = 1.0 / UIScreen.main.scale
/// 0.5 pt border width.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Foundation/Colors/Gradients.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

/// Predefined Orbit gradient styles.
public enum Gradient {
public enum Gradient: Sendable {

case bundleBasic
case bundleMedium
Expand Down
5 changes: 4 additions & 1 deletion Sources/Orbit/Foundation/CountryFlags/CountryFlags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Generated by 'Automation/update_country_flags.py'
public extension CountryFlag {

enum CountryCode: String, CaseIterable {
enum CountryCode: String, CaseIterable, Sendable {

/// Country code for Andorra
case ad
Expand Down Expand Up @@ -633,6 +633,7 @@ public extension CountryFlag {
/// Country code for Suriname
case sr

/// Country code for South Sudan
case ss

/// Country code for São Tomé and Príncipe
Expand All @@ -641,6 +642,7 @@ public extension CountryFlag {
/// Country code for El Salvador
case sv

/// Country code for Saint Martin
case sx

/// Country code for Syria
Expand Down Expand Up @@ -743,6 +745,7 @@ public extension CountryFlag {
/// Country code for Samoa
case ws

/// Country code for Kosovo
case xk

/// Country code for Yemen
Expand Down
4 changes: 2 additions & 2 deletions Sources/Orbit/Foundation/Elevations/Elevation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI
/// Predefined Orbit elevation that brings content closer to user.
///
/// Elevation levels with higher numbers are usually visually closer to the user.
public enum Elevation {
public enum Elevation: Sendable {
case level1
case level2
case level3
Expand All @@ -12,7 +12,7 @@ public enum Elevation {
}

/// A shape to use as a surface on which Orbit `elevation` is applied.
public enum ElevationShape {
public enum ElevationShape: Sendable {
/// Elevation effect shape is based on provided content.
///
/// To improve performance, the elevation can be applied on multiple views at once
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Foundation/Icons/Icons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Generated by 'Automation/update_icons.py'
public extension Icon {

enum Symbol: CaseIterable, Equatable {
enum Symbol: CaseIterable, Equatable, Sendable {
/// Orbit `accommodation` icon symbol.
case accommodation
/// Orbit `accountCircle` icon symbol.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Foundation/Spacing/Spacing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI
/// Predefined Orbit spacing to help making interface clear and easy to scan.
///
/// - Note: [Orbit.kiwi documentation](https://orbit.kiwi/foundation/spacing/)
public enum Spacing: CGFloat {
public enum Spacing: CGFloat, Sendable {
/// 2 pts.
case xxxSmall = 2
/// 4 pts.
Expand Down
4 changes: 2 additions & 2 deletions Sources/Orbit/Foundation/Typography/Font.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public extension Font {
static var fontSizeToLineHeightRatio: CGFloat = 1.3333

/// Default Orbit fonts used for rendering text.
static var orbitFonts: [Font.Weight: URL?] = [
@MainActor static var orbitFonts: [Font.Weight: URL?] = [
.ultraLight: Bundle.orbit.url(forResource: "Circular20-Book", withExtension: "otf"),
.thin: Bundle.orbit.url(forResource: "Circular20-Book", withExtension: "otf"),
.light: Bundle.orbit.url(forResource: "Circular20-Book", withExtension: "otf"),
Expand Down Expand Up @@ -44,7 +44,7 @@ public extension Font {
}

/// Registers Orbit fonts set in the `Font.orbitFonts` property for use in all Orbit text components.
static func registerOrbitFonts() {
@MainActor static func registerOrbitFonts() {
var registeredFonts: [URL: CGFont] = [:]

for case let (weight, url?) in orbitFonts {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Orbit/Support/BindingSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public enum OptionalBindingSource<Value> {
case state(Value)
}

extension OptionalBindingSource: Sendable where Value: Sendable {}

/// A view that provides either a binding to its content or an internal state, based on provided ``OptionalBindingSource`` value.
///
/// The binding can either be supplied, in which case it is used directly,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Support/Components/TabStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI
/// Orbit ``Tabs`` style applied to the active tab.
///
/// To apply a style, use the `activeTabStyle()` modifier.
public enum TabStyle: Equatable {
public enum TabStyle: Equatable, Sendable {
case `default`
case underlined(Color)
case underlinedGradient(Orbit.Gradient)
Expand Down
Loading
Loading