-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from crelies/dev
4.0.0
- Loading branch information
Showing
22 changed files
with
155 additions
and
170 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
Sources/RemoteImage/private/Protocols/RemoteImageServiceProtocol.swift
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
Sources/RemoteImage/private/Protocols/RemoteImageURLDataPublisher.swift
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
Sources/RemoteImage/private/Services/DefaultRemoteImageServiceDependencies.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// DefaultRemoteImageServiceDependencies.swift | ||
// RemoteImage | ||
// | ||
// Created by Christian Elies on 29.10.19. | ||
// | ||
|
||
import Foundation | ||
|
||
protocol DefaultRemoteImageServiceDependenciesProtocol: PhotoKitServiceProvider, RemoteImageURLDataPublisherProvider { | ||
|
||
} | ||
|
||
struct DefaultRemoteImageServiceDependencies: DefaultRemoteImageServiceDependenciesProtocol { | ||
let photoKitService: PhotoKitServiceProtocol | ||
let remoteImageURLDataPublisher: RemoteImageURLDataPublisher | ||
|
||
init(remoteImageURLDataPublisher: RemoteImageURLDataPublisher) { | ||
photoKitService = PhotoKitService() | ||
self.remoteImageURLDataPublisher = remoteImageURLDataPublisher | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
Sources/RemoteImage/private/Services/RemoteImageServiceDependencies.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// RemoteImageState.swift | ||
// RemoteImage | ||
// | ||
// Created by Christian Elies on 11.08.19. | ||
// Copyright © 2019 Christian Elies. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum RemoteImageState: Hashable { | ||
case error(_ error: NSError) | ||
case image(_ image: UniversalImage) | ||
case loading | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Sources/RemoteImage/public/Protocols/RemoteImageService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// RemoteImageService.swift | ||
// RemoteImage | ||
// | ||
// Created by Christian Elies on 15.12.19. | ||
// | ||
|
||
import Combine | ||
|
||
public typealias RemoteImageCacheKeyProvider = (RemoteImageType) -> AnyObject | ||
|
||
/// Represents the service associated with a `RemoteImage` view. Responsible for fetching the image and managing the state. | ||
public protocol RemoteImageService where Self: ObservableObject { | ||
/// The cache for the images fetched by any instance of `RemoteImageService`. | ||
static var cache: RemoteImageCache { get set } | ||
/// Provides a key for a given `RemoteImageType` used for storing an image in the cache. | ||
static var cacheKeyProvider: RemoteImageCacheKeyProvider { get set } | ||
|
||
/// The current state of the image fetching process - `loading`, `error` or `image (success)`. | ||
var state: RemoteImageState { get set } | ||
|
||
/// Fetches the image with the given type. | ||
/// | ||
/// - Parameter type: Specifies the source type of the remote image. Choose between `.url` or `.phAsset`. | ||
func fetchImage(ofType type: RemoteImageType) | ||
} |
13 changes: 13 additions & 0 deletions
13
Sources/RemoteImage/public/Protocols/RemoteImageURLDataPublisher.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// RemoteImageURLDataPublisher.swift | ||
// RemoteImage | ||
// | ||
// Created by Christian Elies on 15.12.19. | ||
// | ||
|
||
import Combine | ||
import Foundation | ||
|
||
public protocol RemoteImageURLDataPublisher { | ||
func dataPublisher(for url: URL) -> AnyPublisher<(data: Data, response: URLResponse), URLError> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Sources/RemoteImage/public/Services/DefaultRemoteImageServiceFactory.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// DefaultRemoteImageServiceFactory.swift | ||
// RemoteImage | ||
// | ||
// Created by Christian Elies on 29.10.19. | ||
// | ||
|
||
import Foundation | ||
|
||
public final class DefaultRemoteImageServiceFactory { | ||
public static func makeDefaultRemoteImageService(remoteImageURLDataPublisher: RemoteImageURLDataPublisher = URLSession.shared) -> DefaultRemoteImageService { | ||
let dependencies = DefaultRemoteImageServiceDependencies(remoteImageURLDataPublisher: remoteImageURLDataPublisher) | ||
return DefaultRemoteImageService(dependencies: dependencies) | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
Sources/RemoteImage/public/Services/RemoteImageServiceFactory.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.