Skip to content

Commit

Permalink
Keep going
Browse files Browse the repository at this point in the history
  • Loading branch information
piercifani committed Jun 17, 2024
1 parent 1c4322f commit 84cd7cd
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Sources/BSWInterfaceKit/Cells/PhotoCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import UIKit

/// This View displays `Photo`s in a `UIScrollView` using `UIContentConfiguration` and `UIContentView`
public enum PhotoCollectionViewCell {
struct Configuration: UIContentConfiguration, Hashable {
struct Configuration: UIContentConfiguration, Hashable, Sendable {

let photo: Photo
let imageContentMode: UIView.ContentMode
let zoomEnabled: Bool

var state: UICellConfigurationState?
nonisolated(unsafe) var state: UICellConfigurationState?

Check warning on line 17 in Sources/BSWInterfaceKit/Cells/PhotoCollectionViewCell.swift

View workflow job for this annotation

GitHub Actions / build

'nonisolated' is redundant on struct's stored properties; this is an error in Swift 6

Check warning on line 17 in Sources/BSWInterfaceKit/Cells/PhotoCollectionViewCell.swift

View workflow job for this annotation

GitHub Actions / build

stored property 'state' of 'Sendable'-conforming struct 'Configuration' has non-sendable type 'UICellConfigurationState?'

func makeContentView() -> UIView & UIContentView {
View(configuration: self)
Expand Down
15 changes: 7 additions & 8 deletions Sources/BSWInterfaceKit/Model/Photo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import Nuke
/// This represents an image to be displayed in the app.
///
/// Please do not use this to represent Symbols, but rather large Bitmaps.
public struct Photo {
public struct Photo: Sendable {


/// The source of the Photo.
public enum Kind {
public enum Kind: Sendable {
/// The Photo is in a remote URL and there's an Optional `PlaceholderImage` to be shown while the Photo is loading.
case url(Foundation.URL, placeholderImage: PlaceholderImage?)

Expand Down Expand Up @@ -73,12 +73,11 @@ public struct Photo {
}
}

@MainActor
public enum RandomColorFactory {
public enum RandomColorFactory: @unchecked Sendable {

public static var isOn: Bool = true
public static nonisolated(unsafe) var isOn: Bool = true
#if canImport(UIKit)
public static var defaultColor = UIColor(r: 255, g: 149, b: 0)
public static nonisolated(unsafe) var defaultColor = UIColor(r: 255, g: 149, b: 0)

/// Generates a random pastel color
/// - Returns: a UIColor
Expand Down Expand Up @@ -142,7 +141,7 @@ public extension Photo {
}

public extension Photo {
struct PlaceholderImage {
struct PlaceholderImage: Sendable {
public let image: PlatformImage
public let preferredContentMode: PlatformContentMode
public init(image: PlatformImage, preferredContentMode: PlatformContentMode) {
Expand All @@ -162,7 +161,7 @@ extension Photo {
}
}

extension CGSize: Hashable { // For some reason `CGSize` isn't `Hashable`
extension CGSize: @retroactive Hashable { // For some reason `CGSize` isn't `Hashable`

Check failure on line 164 in Sources/BSWInterfaceKit/Model/Photo.swift

View workflow job for this annotation

GitHub Actions / build

unknown attribute 'retroactive'

Check failure on line 164 in Sources/BSWInterfaceKit/Model/Photo.swift

View workflow job for this annotation

GitHub Actions / build

inheritance from non-protocol type 'any Hashable'
public func hash(into hasher: inout Hasher) {
hasher.combine(width)
hasher.combine(height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import UIKit

class PresentAlertOperation: Operation {
class PresentAlertOperation: Operation, @unchecked Sendable {

let title: String?
let message: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extension SocialAuthenticationManager {
return allScopes
}

public struct Scope: OptionSet, CustomDebugStringConvertible {
public struct Scope: OptionSet, CustomDebugStringConvertible, Sendable {
public let rawValue: Int

public init(rawValue: Int) {
Expand Down
1 change: 1 addition & 0 deletions Sources/BSWInterfaceKit/Stylesheet/TextStyler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import BSWFoundation
/// This class allows you generate `NSAttributedString`s that respect the user's [Dynamic Type](https://developer.apple.com/documentation/uikit/uifont/scaling_fonts_automatically/) setting.
///
/// More info on how the fonts scale [here] (https://gist.github.com/zacwest/916d31da5d03405809c4)
@MainActor
open class TextStyler {

/// Shared `TextStyler` that uses the system font.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import SwiftUI

@MainActor
open class InfiniteScrollingDataSource<ListItem: Identifiable>: ObservableObject {
open class InfiniteScrollingDataSource<ListItem: Identifiable & Sendable>: ObservableObject {

@Published public private(set) var items = [ListItem]()
@Published public private(set) var state: State
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

private struct CGSizeKey: PreferenceKey {
static var defaultValue = CGSize.zero
nonisolated(unsafe) static var defaultValue = CGSize.zero
static func reduce (value: inout CGSize, nextValue: () -> CGSize) {
value = nextValue()
}
Expand Down
7 changes: 3 additions & 4 deletions Sources/BSWInterfaceKit/SwiftUI/Views/PhotoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct PhotoView: View {

@ViewBuilder
private var placeholder: some View {
configuration.placeholder
configuration.placeholder.body()
}

@ViewBuilder
Expand Down Expand Up @@ -83,14 +83,13 @@ extension PhotoView {
let aspectRatio: CGFloat?
let contentMode: ContentMode

@MainActor
public init(placeholder: Placeholder = .init(shape: .rectangle), aspectRatio: CGFloat? = nil, contentMode: ContentMode = .fit) {
self.placeholder = placeholder
self.aspectRatio = aspectRatio
self.contentMode = contentMode
}

public struct Placeholder: View {
public struct Placeholder {

public init(shape: PhotoView.Configuration.Placeholder.Shape, color: Color = Color(RandomColorFactory.defaultColor)) {
self.shape = shape
Expand All @@ -104,7 +103,7 @@ extension PhotoView {
case circle, rectangle
}

public var body: some View {
func body() -> some View {
Group {
switch self.shape {
case .circle:
Expand Down
4 changes: 2 additions & 2 deletions Sources/BSWInterfaceKit/Views/PhotoGalleryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public protocol PhotoGalleryViewDelegate: AnyObject {
@objc(BSWPhotoGalleryView)
final public class PhotoGalleryView: UIView {

enum Section: Hashable {
enum Section: Hashable, Sendable {
case main
}

enum Item: Hashable {
enum Item: Hashable, Sendable {
case photo(PhotoCollectionViewCell.Configuration)
}

Expand Down

0 comments on commit 84cd7cd

Please sign in to comment.