10
10
import Combine
11
11
import SwiftUI
12
12
13
+ /// A custom Image view for remote images with support for a loading and error state.
13
14
public struct RemoteImage < ErrorView: View , ImageView: View , LoadingView: View , Service: RemoteImageService > : View {
14
15
private let type : RemoteImageType
15
16
private let errorView : ( Error ) -> ErrorView
@@ -33,14 +34,14 @@ public struct RemoteImage<ErrorView: View, ImageView: View, LoadingView: View, S
33
34
}
34
35
}
35
36
36
- /// <#Description#>
37
+ /// Initializes the view with the given values, especially with a custom `RemoteImageService`.
37
38
///
38
39
/// - Parameters:
39
- /// - type: <# type description#>
40
- /// - service: <#service description#>
41
- /// - errorView: <#errorView description#>
42
- /// - imageView: <#imageView description#>
43
- /// - loadingView: <#loadingView description#>
40
+ /// - type: Specifies the source type of the remote image. Choose between `.url` or `.phAsset`.
41
+ /// - service: An object conforming to the `RemoteImageService` protocol. Responsible for fetching the image and managing the state.
42
+ /// - errorView: A view builder used to create the view displayed in the error state.
43
+ /// - imageView: A view builder used to create the `Image` displayed in the image state.
44
+ /// - loadingView: A view builder used to create the view displayed in the loading state.
44
45
public init ( type: RemoteImageType , service: Service , @ViewBuilder errorView: @escaping ( Error ) -> ErrorView , @ViewBuilder imageView: @escaping ( Image ) -> ImageView , @ViewBuilder loadingView: @escaping ( ) -> LoadingView ) {
45
46
self . type = type
46
47
self . errorView = errorView
@@ -53,14 +54,14 @@ public struct RemoteImage<ErrorView: View, ImageView: View, LoadingView: View, S
53
54
}
54
55
55
56
extension RemoteImage where Service == DefaultRemoteImageService {
56
- /// <#Description#>
57
+ /// Initializes the view with the given values. Uses the built-in `DefaultRemoteImageService`.
57
58
///
58
59
/// - Parameters:
59
- /// - type: <# type description#>
60
- /// - remoteImageURLDataPublisher: <#remoteImageURLDataPublisher description#>
61
- /// - errorView: <#errorView description#>
62
- /// - imageView: <#imageView description#>
63
- /// - loadingView: <#loadingView description#>
60
+ /// - type: Specifies the source type of the remote image. Choose between `.url` or `.phAsset`.
61
+ /// - remoteImageURLDataPublisher: An object conforming to the `RemoteImageURLDataPublisher` protocol, by default `URLSession.shared` is used.
62
+ /// - errorView: A view builder used to create the view displayed in the error state.
63
+ /// - imageView: A view builder used to create the `Image` displayed in the image state.
64
+ /// - loadingView: A view builder used to create the view displayed in the loading state.
64
65
public init ( type: RemoteImageType , remoteImageURLDataPublisher: RemoteImageURLDataPublisher = URLSession . shared, @ViewBuilder errorView: @escaping ( Error ) -> ErrorView , @ViewBuilder imageView: @escaping ( Image ) -> ImageView , @ViewBuilder loadingView: @escaping ( ) -> LoadingView ) {
65
66
self . type = type
66
67
self . errorView = errorView
0 commit comments