Skip to content

Commit

Permalink
Updated package for strict concurrency checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjavora committed Oct 31, 2024
1 parent d31b665 commit a1f34c2
Show file tree
Hide file tree
Showing 40 changed files with 112 additions and 110 deletions.
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
40 changes: 18 additions & 22 deletions Sources/Orbit/Support/Components/TimelineItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ public extension TimelineItem where Label == Heading, Sublabel == Text, Descript
// MARK: - Types

/// Orbit ``TimelineItem`` type.
public enum TimelineItemType: Equatable {
public enum TimelineItemType: Equatable, Sendable {

/// Orbit ``TimelineItemType`` status.
public enum Status {
public enum Status: Sendable {
case success
case warning
case critical
Expand All @@ -139,32 +139,30 @@ public enum TimelineItemType: Equatable {

public var icon: Icon.Symbol? {
switch self {
case .past: return .checkCircle
case .present(.critical): return .closeCircle
case .present(.warning): return .alertCircle
case .present(.success): return .checkCircle
case .present: return nil
case .future: return nil
case .past: .checkCircle
case .present(.critical): .closeCircle
case .present(.warning): .alertCircle
case .present(.success): .checkCircle
case .present: nil
case .future: nil
}
}

public var color: Color {
switch self {
case .past: return Orbit.Status.success.color
case .present(.critical): return Orbit.Status.critical.color
case .present(.warning): return Orbit.Status.warning.color
case .present(.success): return Orbit.Status.success.color
case .present: return Orbit.Status.success.color
case .future: return .cloudNormalHover
case .past: Orbit.Status.success.color
case .present(.critical): Orbit.Status.critical.color
case .present(.warning): Orbit.Status.warning.color
case .present(.success): Orbit.Status.success.color
case .present: Orbit.Status.success.color
case .future: .cloudNormalHover
}
}

public var isCurrentStep: Bool {
switch self {
case .present:
return true
case .past, .future:
return false
case .present: true
case .past, .future: false
}
}

Expand All @@ -174,10 +172,8 @@ public enum TimelineItemType: Equatable {

public var isLineDashed: Bool {
switch self {
case .future:
return true
case .past, .present:
return false
case .future: true
case .past, .present: false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

/// Stores background shapes used for Orbit components that render their own background, such as `Card` or `Tile`.
public struct BackgroundShape {
public struct BackgroundShape: Sendable {

public let inactive: any ShapeStyle
public let active: any ShapeStyle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

/// Orbit button priority.
public enum ButtonPriority {
public enum ButtonPriority: Sendable {
case primary
case secondary
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Support/Environment Keys/ButtonSizeKey.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

/// Orbit size used for various button components.
public enum ButtonSize {
public enum ButtonSize: Sendable {
case regular
case compact
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Orbit/Support/Environment Keys/IdealSizeKey.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

/// The expanding behaviour of compatible Orbit components in a view relative to their ideal size for each axis.
public struct IdealSizeValue {
public struct IdealSizeValue: Sendable {
public var horizontal: Bool?
public var vertical: Bool?
}
Expand Down
Loading

0 comments on commit a1f34c2

Please sign in to comment.