Skip to content

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
juicyfru1t committed Sep 30, 2024
1 parent 260c050 commit 9d5731c
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Nivelir.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Pod::Spec.new do |spec|
spec.author = { "Almaz Ibragimov" => "[email protected]" }
spec.source = { :git => "https://github.com/hhru/Nivelir.git", :tag => "#{spec.version}" }

spec.swift_version = '5.7'
spec.swift_version = '6.0'
spec.requires_arc = true
spec.source_files = 'Sources/**/*.swift'

Expand Down
12 changes: 6 additions & 6 deletions Nivelir.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3456,7 +3456,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "ru.hh.Nivelir.Tests-iOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.7;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -3475,7 +3475,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "ru.hh.Nivelir.Tests-iOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.7;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down Expand Up @@ -3507,7 +3507,7 @@
SKIP_INSTALL = YES;
SKIP_SWIFTLINT = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.7;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 3;
};
name = Debug;
Expand Down Expand Up @@ -3538,7 +3538,7 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SKIP_SWIFTLINT = YES;
SWIFT_VERSION = 5.7;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 3;
};
name = Release;
Expand All @@ -3558,7 +3558,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "ru.hh.Nivelir.Tests-tvOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_VERSION = 5.7;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 3;
};
name = Debug;
Expand All @@ -3578,7 +3578,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "ru.hh.Nivelir.Tests-tvOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_VERSION = 5.7;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 3;
};
name = Release;
Expand Down
1 change: 0 additions & 1 deletion Sources/Addons/Safari/SafariManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import Foundation
import SafariServices

@MainActor
internal final class SafariManager:
NSObject,
SFSafariViewControllerDelegate {
Expand Down
5 changes: 3 additions & 2 deletions Sources/Addons/Sharing/Activity/SharingActivity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import UIKit

public struct SharingActivity {

private typealias Body = @MainActor (_ navigator: ScreenNavigator) -> UIActivity
private typealias Body = (_ navigator: ScreenNavigator) -> UIActivity

private let body: Body

private init(body: @escaping Body) {
self.body = body
}

@MainActor
internal func activity(navigator: ScreenNavigator) -> UIActivity {
body(navigator)
}
Expand All @@ -25,6 +24,7 @@ extension SharingActivity {
}
}

@MainActor
public static func custom<Value: SharingVisualActivity>(_ value: Value) -> Self {
Self { navigator in
SharingActivityManager(
Expand All @@ -34,6 +34,7 @@ extension SharingActivity {
}
}

@MainActor
public static func custom<Value: SharingSilentActivity>(_ value: Value) -> Self {
Self { navigator in
SharingActivityManager(
Expand Down
52 changes: 33 additions & 19 deletions Sources/Addons/Sharing/Activity/SharingActivityManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import UIKit

@MainActor
internal final class SharingActivityManager<Activity: SharingCustomActivity>: UIActivity {
internal final class SharingActivityManager<Activity: SharingCustomActivity>: UIActivity, Sendable {

internal override class var activityCategory: UIActivity.Category {
Activity.category
Expand All @@ -14,28 +14,34 @@ internal final class SharingActivityManager<Activity: SharingCustomActivity>: UI
internal let activity: Activity

internal override var activityType: UIActivity.ActivityType? {
activity.type
MainActor.assumeIsolated {
activity.type
}
}

internal override var activityTitle: String? {
activity.title
MainActor.assumeIsolated {
activity.title
}
}

internal override var activityImage: UIImage? {
activity.image
MainActor.assumeIsolated {
activity.image
}
}

internal override var activityViewController: UIViewController? {
guard let activity = activity as? SharingVisualActivity else {
return nil
}
MainActor.assumeIsolated {
guard let activity = activity as? SharingVisualActivity else {
return nil
}

let screen = activity.prepare(for: items) { [weak self] completed in
self?.activityDidFinish(completed)
}
let screen = activity.prepare(for: items) { [weak self] completed in
self?.activityDidFinish(completed)
}

return MainActor.assumeIsolated { [navigator] in
screen.build(navigator: navigator)
return screen.build(navigator: navigator)
}
}

Expand All @@ -48,20 +54,28 @@ internal final class SharingActivityManager<Activity: SharingCustomActivity>: UI
}

internal override func canPerform(withActivityItems activityItems: [Any]) -> Bool {
activity.isApplicable(for: activityItems.map(SharingItem.init(activityItem:)))
let activityItems = activityItems.map(SharingItem.init(activityItem:))
return MainActor.assumeIsolated {
activity.isApplicable(for: activityItems)
}
}

internal override func prepare(withActivityItems activityItems: [Any]) {
items = activityItems.map(SharingItem.init(activityItem:))
let activityItems = activityItems.map(SharingItem.init(activityItem:))
MainActor.assumeIsolated {
items = activityItems
}
}

internal override func perform() {
guard let activity = activity as? SharingSilentActivity else {
return activityDidFinish(false)
}
MainActor.assumeIsolated {
guard let activity = activity as? SharingSilentActivity else {
return activityDidFinish(false)
}

activity.perform(for: items, navigator: navigator) { [weak self] completed in
self?.activityDidFinish(completed)
activity.perform(for: items, navigator: navigator) { [weak self] completed in
self?.activityDidFinish(completed)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#if canImport(UIKit) && os(iOS)
import UIKit

@MainActor
public protocol SharingCustomActivity {

static var category: SharingActivityCategory { get }
Expand Down
4 changes: 2 additions & 2 deletions Sources/Addons/Sharing/Activity/SharingSilentActivity.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#if canImport(UIKit) && os(iOS)
import UIKit

@MainActor
public protocol SharingSilentActivity: SharingCustomActivity {
public protocol SharingSilentActivity: SharingCustomActivity, Sendable {

@MainActor
func perform(
for items: [SharingItem],
navigator: ScreenNavigator,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Addons/Sharing/Item/SharingItem.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#if canImport(UIKit) && os(iOS)
import UIKit

public enum SharingItem: CustomStringConvertible {
public enum SharingItem: CustomStringConvertible, @unchecked Sendable {

case regular(Any)
case custom(SharingCustomItem)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Screen/ScreenKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Foundation
///
/// - SeeAlso: `Screen`.
/// - SeeAlso: `ScreenKeyedContainer`.
public struct ScreenKey: Hashable, CustomStringConvertible, Sendable {
public struct ScreenKey: Hashable, CustomStringConvertible {

/// Screen name.
public let name: String
Expand Down

0 comments on commit 9d5731c

Please sign in to comment.