1010import Combine
1111import SwiftUI
1212
13+ /// A custom Image view for remote images with support for a loading and error state.
1314public struct RemoteImage < ErrorView: View , ImageView: View , LoadingView: View , Service: RemoteImageService > : View {
1415 private let type : RemoteImageType
1516 private let errorView : ( Error ) -> ErrorView
@@ -33,14 +34,14 @@ public struct RemoteImage<ErrorView: View, ImageView: View, LoadingView: View, S
3334 }
3435 }
3536
36- /// <#Description#>
37+ /// Initializes the view with the given values, especially with a custom `RemoteImageService`.
3738 ///
3839 /// - 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.
4445 public init ( type: RemoteImageType , service: Service , @ViewBuilder errorView: @escaping ( Error ) -> ErrorView , @ViewBuilder imageView: @escaping ( Image ) -> ImageView , @ViewBuilder loadingView: @escaping ( ) -> LoadingView ) {
4546 self . type = type
4647 self . errorView = errorView
@@ -53,14 +54,14 @@ public struct RemoteImage<ErrorView: View, ImageView: View, LoadingView: View, S
5354}
5455
5556extension RemoteImage where Service == DefaultRemoteImageService {
56- /// <#Description#>
57+ /// Initializes the view with the given values. Uses the built-in `DefaultRemoteImageService`.
5758 ///
5859 /// - 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.
6465 public init ( type: RemoteImageType , remoteImageURLDataPublisher: RemoteImageURLDataPublisher = URLSession . shared, @ViewBuilder errorView: @escaping ( Error ) -> ErrorView , @ViewBuilder imageView: @escaping ( Image ) -> ImageView , @ViewBuilder loadingView: @escaping ( ) -> LoadingView ) {
6566 self . type = type
6667 self . errorView = errorView
0 commit comments