Skip to content

Commit

Permalink
Code review - refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
plajdo committed Jul 3, 2024
1 parent a398115 commit 10e6e5d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/GRAsyncImage/GRAsyncImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct GRAsyncImage<FailurePlaceholder: View, LoadingPlaceholder: View>:
var url: URL?
var failurePlaceholder: FailurePlaceholder
var loadingPlaceholder: LoadingPlaceholder
var reloadingIsAllowed: Bool
var allowsReloading: Bool
var onLoading: VoidClosure?
var onSuccess: VoidClosure?
var onFailure: VoidClosure?
Expand All @@ -28,7 +28,7 @@ public struct GRAsyncImage<FailurePlaceholder: View, LoadingPlaceholder: View>:
url: URL?,
@ViewBuilder failurePlaceholder: () -> FailurePlaceholder = { Image(systemName: "arrow.clockwise") },
@ViewBuilder loadingPlaceholder: () -> LoadingPlaceholder = { ProgressView().progressViewStyle(.circular) },
reloadingIsAllowed: Bool = true,
allowsReloading: Bool = true,
onLoading: VoidClosure? = nil,
onSuccess: VoidClosure? = nil,
onFailure: VoidClosure? = nil
Expand All @@ -38,7 +38,7 @@ public struct GRAsyncImage<FailurePlaceholder: View, LoadingPlaceholder: View>:
self.url = url
self.failurePlaceholder = failurePlaceholder()
self.loadingPlaceholder = loadingPlaceholder()
self.reloadingIsAllowed = reloadingIsAllowed
self.allowsReloading = allowsReloading
self.onLoading = onLoading
self.onSuccess = onSuccess
self.onFailure = onFailure
Expand All @@ -61,7 +61,7 @@ public struct GRAsyncImage<FailurePlaceholder: View, LoadingPlaceholder: View>:
}

case .failure:
if let url, reloadingIsAllowed {
if let url, allowsReloading {
Button(action: { loadImage(url: url) }, label: { failurePlaceholder })
} else {
failurePlaceholder
Expand Down

0 comments on commit 10e6e5d

Please sign in to comment.