Skip to content

Commit

Permalink
Change delegate calls to return sharable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ste Prescott committed Jun 14, 2020
1 parent 51c7f2c commit 932006e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Sources/Share/Share.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ extension Share {

extension Share.Service {
public enum Status {
case willShare([Any], via: Share.Service)
case didShare([Any], via: Share.Service)
case error(Share.Service.Status.Error, sharing:[Any])
case willShare(Sharable, via: Share.Service)
case didShare(Sharable, via: Share.Service)
case error(Share.Service.Status.Error, sharing: Sharable)
}
}

Expand Down
14 changes: 7 additions & 7 deletions Sources/Share/Sheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension Share {
guard service == nil
else { return }

serviceDelegate?.didChange(status: .error(.cancelled(service), sharing: sharable.shareItems))
serviceDelegate?.didChange(status: .error(.cancelled(service), sharing: sharable))
}

public func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, delegateFor sharingService: NSSharingService) -> NSSharingServiceDelegate? {
Expand All @@ -29,15 +29,15 @@ extension Share {
// MARK:- NSSharingServiceDelegate

public func sharingService(_ sharingService: NSSharingService, willShareItems items: [Any]) {
serviceDelegate?.didChange(status: .willShare(items, via: sharingService))
serviceDelegate?.didChange(status: .willShare(sharable, via: sharingService))
}

public func sharingService(_ sharingService: NSSharingService, didShareItems items: [Any]) {
serviceDelegate?.didChange(status: .didShare(items, via: sharingService))
serviceDelegate?.didChange(status: .didShare(sharable, via: sharingService))
}

public func sharingService(_ sharingService: NSSharingService, didFailToShareItems items: [Any], error: Error) {
serviceDelegate?.didChange(status: .error(.other(error, with: sharingService), sharing: items))
serviceDelegate?.didChange(status: .error(.other(error, with: sharingService), sharing: sharable))
}
}
}
Expand Down Expand Up @@ -66,9 +66,9 @@ extension Share {
}

if !completed {
self.report(.willShare(sharable.shareItems, via: service))
self.report(.willShare(sharable, via: service))
} else {
self.report(.didShare(sharable.shareItems, via: service))
self.report(.didShare(sharable, via: service))
}
}
}
Expand All @@ -78,7 +78,7 @@ extension Share {
}

private func report(error: Share.Service.Status.Error) {
serviceDelegate?.didChange(status: .error(error, sharing: sharable.shareItems))
serviceDelegate?.didChange(status: .error(error, sharing: sharable))
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions Tests/ShareTests/ShareTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import XCTest
@testable import Share

final class ShareTests: XCTestCase {
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
XCTAssertEqual(Share().text, "Hello, World!")
}
func testExample() { }

static var allTests = [
("testExample", testExample),
Expand Down

0 comments on commit 932006e

Please sign in to comment.