Skip to content

Commit

Permalink
Swift 6 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii authored Oct 17, 2024
1 parent f41ce26 commit 1ec4fcd
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 37 deletions.
46 changes: 23 additions & 23 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
// swift-tools-version:5.5
// swift-tools-version:6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Descriptors",
platforms: [.iOS(.v10)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Descriptors",
targets: ["Descriptors"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Descriptors",
dependencies: []),
.testTarget(
name: "DescriptorsTests",
dependencies: ["Descriptors"]),
]
name: "Descriptors",
platforms: [.iOS(.v10)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Descriptors",
targets: ["Descriptors"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Descriptors",
dependencies: []),
.testTarget(
name: "DescriptorsTests",
dependencies: ["Descriptors"]),
]
)
14 changes: 8 additions & 6 deletions Sources/Descriptors/HapticsDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,23 @@

import UIKit

public struct HapticsDescriptor {
public struct HapticsDescriptor: Sendable {

public enum Event: Equatable {
public enum Event: Equatable, Sendable {
case onTouchDownInside
case onTouchUpInside
case onLongPress
}

private let _onReceiveEvent: (Event) -> Void
private let _onReceiveEvent: @MainActor (Event) -> Void

public init(
onReceiveEvent: @escaping (Event) -> Void
onReceiveEvent: @escaping @MainActor (Event) -> Void
) {
self._onReceiveEvent = onReceiveEvent
}

@MainActor
public func send(event: Event) {
_onReceiveEvent(event)
}
Expand All @@ -49,9 +50,10 @@ extension HapticsDescriptor {
delay: DispatchTimeInterval = .seconds(0)
) -> Self {

let feedbackGenerator = UIImpactFeedbackGenerator(style: style)

return self.init { event in

let feedbackGenerator = UIImpactFeedbackGenerator(style: style)

if case .onTouchUpInside = event {
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
feedbackGenerator.impactOccurred()
Expand Down
8 changes: 4 additions & 4 deletions Sources/Descriptors/HighlightAnimationDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import UIKit

public struct HighlightAnimationDescriptor {
public struct HighlightAnimationDescriptor: Sendable {

public final class Context {

Expand All @@ -43,16 +43,16 @@ public struct HighlightAnimationDescriptor {
}
}

private let _prepare: (Context) -> Void
private let _prepare: @MainActor (Context) -> Void

public init(
prepare: @escaping (Context) -> Void
prepare: @escaping @MainActor (Context) -> Void
) {
self._prepare = prepare
}

@MainActor
public func prepare() -> Context {
assert(Thread.isMainThread)
let context = Context()
_prepare(context)
return context
Expand Down
6 changes: 3 additions & 3 deletions Sources/Descriptors/LinearGradientDescriptor.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit

public struct GradientColor: Hashable {
public struct GradientColor: Hashable, Sendable {

public let color: UIColor
public let location: CGFloat
Expand All @@ -14,7 +14,7 @@ public struct GradientColor: Hashable {
}
}

public struct GradientSource: Hashable {
public struct GradientSource: Hashable, Sendable {

public let colors: [GradientColor]
public let identifier: String
Expand All @@ -26,7 +26,7 @@ public struct GradientSource: Hashable {

}

public struct LinearGradientDescriptor: Equatable {
public struct LinearGradientDescriptor: Equatable, Sendable {

// MARK: - Properties

Expand Down
2 changes: 1 addition & 1 deletion Sources/Descriptors/LinearGradientDrawer.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import UIKit

public struct LinearGradientDrawer {
public struct LinearGradientDrawer: Sendable {

// MARK: - Properties

Expand Down

0 comments on commit 1ec4fcd

Please sign in to comment.