Skip to content

Commit

Permalink
Start annotating stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
piercifani committed Jun 17, 2024
1 parent 27d3c64 commit bf5e881
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 16 deletions.
14 changes: 9 additions & 5 deletions Sources/BSWInterfaceKit/Behaviour/MailComposerBehaviour.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import UIKit
import MessageUI

@MainActor
final public class MessageComposerBehavior: NSObject, MFMailComposeViewControllerDelegate, MFMessageComposeViewControllerDelegate {
public static let composer = MessageComposerBehavior()

Expand Down Expand Up @@ -40,13 +41,16 @@ final public class MessageComposerBehavior: NSObject, MFMailComposeViewControlle
return smsVC
}

public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil)
public nonisolated func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
MainActor.assumeIsolated {
controller.dismiss(animated: true, completion: nil)
}
}

public func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {

controller.dismiss(animated: true, completion: nil)
public nonisolated func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
MainActor.assumeIsolated {
controller.dismiss(animated: true, completion: nil)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import PhotosUI

public typealias MediaHandler = ((URL?) -> Void)

@MainActor
@available(tvOS, unavailable)
final public class MediaPickerBehavior: NSObject, UIDocumentPickerDelegate, PHPickerViewControllerDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import UIKit

@MainActor
final public class UpdatePageControlOnScrollBehavior: NSObject {

private weak var pageControl: UIPageControl?
Expand All @@ -30,7 +31,13 @@ final public class UpdatePageControlOnScrollBehavior: NSObject {
case horizontal, vertical
}

public func scrollViewDidScroll(_ scrollView: UIScrollView) {
nonisolated func scrollViewDidScroll(_ scrollView: UIScrollView) {
MainActor.assumeIsolated {
_scrollViewDidScroll(scrollView)
}
}

private func _scrollViewDidScroll(_ scrollView: UIScrollView) {
guard let pageControl = pageControl else { return }

let isScrollingHorizontal = scrollingDirection == .horizontal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import BSWFoundation

/// This `UICollectionViewDiffableDataSource` subclass adds a
/// simple way to handle Pull to Refresh and empty views.
open class CollectionViewDiffableDataSource<Section: Hashable, Item: Hashable>:
open class CollectionViewDiffableDataSource<Section: Hashable & Sendable, Item: Hashable & Sendable>:
UICollectionViewDiffableDataSource<Section, Item> {

/// This type describes what to do when the `dataSource` is empty.
@MainActor
public enum EmptyConfiguration {
/// Displays the given `UIView`
case view(UIView)
Expand Down Expand Up @@ -42,7 +43,9 @@ open class CollectionViewDiffableDataSource<Section: Hashable, Item: Hashable>:
guard let emptyView = emptyView else {
return
}
emptyView.removeFromSuperview()
MainActor.assumeIsolated {
emptyView.removeFromSuperview()
}
}

/// Specifies what to do when the `dataSource` is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
})
```
*/
open class PagingCollectionViewDiffableDataSource<Section: Hashable, Item: PagingCollectionViewItem>:
open class PagingCollectionViewDiffableDataSource<Section: Hashable & Sendable, Item: PagingCollectionViewItem>:
CollectionViewDiffableDataSource<Section, Item> {

private var offsetObserver: NSKeyValueObservation?
Expand All @@ -37,7 +37,7 @@ open class PagingCollectionViewDiffableDataSource<Section: Hashable, Item: Pagin
/// `PagingCollectionViewDiffableDataSource`
/// forcing that Item to accomodate a `loading` option,
/// which will be displayed during paging
public protocol PagingCollectionViewItem: Hashable {
public protocol PagingCollectionViewItem: Hashable & Sendable {
var isLoading: Bool { get }
static func loadingItem() -> Self
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import BSWFoundation

public extension UICollectionViewCell {

@MainActor
enum WiggleAppearance {
public static var Spacing: CGFloat = 7
public static var DeleteButtonImage: UIImage?
Expand All @@ -16,6 +17,7 @@ public extension UICollectionViewCell {
fileprivate static let DeleteButtonTag = 876
}

@MainActor
private enum AssociatedBlockHost {
static var handlerHost: UInt8 = 0
}
Expand Down
1 change: 1 addition & 0 deletions Sources/BSWInterfaceKit/Social/SocialAuthentication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public protocol SocialAuthenticationCredentials {
}

/// This class allows you to integrate with social networks to authenticate a user.
@MainActor
public class SocialAuthenticationManager: NSObject {

/// A shared manager.
Expand Down
4 changes: 4 additions & 0 deletions Sources/BSWInterfaceKit/SwiftUI/LibraryContent.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@

import SwiftUI

#warning("TODO")

Check warning on line 4 in Sources/BSWInterfaceKit/SwiftUI/LibraryContent.swift

View workflow job for this annotation

GitHub Actions / build

TODO
/*
struct BSWInterfaceKit_SwiftUILibrary: LibraryContentProvider {

public var views: [LibraryItem] {
return [
LibraryItem(PhotoView(photo: .emptyPhoto()), title: "Photo View", category: .other, matchingSignature: "photovie"),
LibraryItem(AsyncButton("", action: {}), title: "Async Button", category: .control, matchingSignature: "asyncbutton")
]
}
}
*/
6 changes: 3 additions & 3 deletions Sources/BSWInterfaceKit/SwiftUI/Views/AsyncButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct AsyncButton<Label: View>: View {
}
} else {
Task {
await performAction(forIOS16: true)
await performAction(forLegacyOS: true)
}
}
},
Expand All @@ -57,7 +57,7 @@ public struct AsyncButton<Label: View>: View {
}

@MainActor
private func performAction(forIOS16: Bool = false) async {
private func performAction(forLegacyOS: Bool = false) async {

#if canImport(UIKit)
var hudVC: UIViewController?
Expand All @@ -66,7 +66,7 @@ public struct AsyncButton<Label: View>: View {
}
#endif

if forIOS16 {
if forLegacyOS {
withAnimation {
self.state = .loading
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/BSWInterfaceKit/SwiftUI/Views/PhotoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import NukeUI
/// Displays a `Photo` in `SwiftUI`
public struct PhotoView: View {

@MainActor
public init(photo: Photo, configuration: PhotoView.Configuration = .init()) {

Check failure on line 12 in Sources/BSWInterfaceKit/SwiftUI/Views/PhotoView.swift

View workflow job for this annotation

GitHub Actions / build

call to main actor-isolated initializer 'init(placeholder:aspectRatio:contentMode:)' in a synchronous nonisolated context
self.photo = photo
self.configuration = configuration
Expand Down Expand Up @@ -81,6 +82,7 @@ public struct PhotoView: View {

extension PhotoView {

@MainActor
public struct Configuration {
let placeholder: Placeholder
let aspectRatio: CGFloat?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import UIKit

@MainActor
public enum TextFieldAlertController {

/// Creates an alert with a `UITextField` to capture user input.
Expand All @@ -25,7 +26,7 @@ public enum TextFieldAlertController {
placeholder: String? = nil,
initialValue: String? = nil,
textContentType: UITextContentType? = nil,
actionValidator: @escaping ((String) -> Bool) = { $0.count > 0 },
actionValidator: @escaping @Sendable ((String) -> Bool) = { $0.count > 0 },

Check failure on line 29 in Sources/BSWInterfaceKit/ViewControllers/TextFieldAlertController.swift

View workflow job for this annotation

GitHub Actions / build

@sendable attribute only applies to function types
onAction: @escaping (String?) -> (),
onCancelAction: (() -> ())? = nil) -> UIViewController {
let alertVC = UIAlertController(title: title, message: subtitle, preferredStyle: .alert)
Expand Down Expand Up @@ -56,8 +57,10 @@ public enum TextFieldAlertController {
$0.isSecureTextEntry = (textContentType == .password)
observation = NotificationCenter.default.addObserver(forName: UITextField.textDidChangeNotification, object: $0, queue: OperationQueue.main) { [weak action] (note) in
guard let t = note.object as? UITextField else { return }
textField = t
action?.isEnabled = actionValidator(t.text ?? "")
MainActor.assumeIsolated {
textField = t
action?.isEnabled = actionValidator(t.text ?? "")
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/BSWInterfaceKit/Views/ErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import BSWFoundation
open class ErrorView: UIStackView {

/// The configuration that will be used to generate an `ErrorView`
@MainActor
public struct Configuration {
public let title: NSAttributedString
public let message: NSAttributedString?
Expand Down Expand Up @@ -48,6 +49,7 @@ open class ErrorView: UIStackView {
}
}

@MainActor
public enum Appereance {
static public var Spacing: CGFloat = 10
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/BSWInterfaceKit/Views/RangeSlider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@ public class RangeSlider: UIControl, ViewModelConfigurable {
}

class RangeSliderThumbLayer: CALayer {

weak var rangeSlider: RangeSlider?
var highlighted: Bool = false {
didSet { setNeedsDisplay() }
}

@MainActor
override func draw(in ctx: CGContext) {
if let slider = rangeSlider {
let thumbFrame = bounds.insetBy(dx: 2.0, dy: 2.0)
Expand Down Expand Up @@ -273,6 +275,7 @@ public class RangeSlider: UIControl, ViewModelConfigurable {
weak var rangeSlider: RangeSlider?
private let heightTrackLine: CGFloat = 3

@MainActor
override func draw(in ctx: CGContext) {
if let slider = rangeSlider {
// Clip
Expand Down

0 comments on commit bf5e881

Please sign in to comment.