@@ -27,14 +27,6 @@ public struct ImageViewerRemote: View {
27
27
28
28
loader = ImageLoader ( url: imageURL)
29
29
}
30
-
31
- func getURLRequest( url: String ) -> URLRequest {
32
- let url = URL ( string: url) !
33
- var request = URLRequest ( url: url)
34
- request. httpMethod = " GET "
35
-
36
- return request;
37
- }
38
30
39
31
@ViewBuilder
40
32
public var body : some View {
@@ -60,7 +52,7 @@ public struct ImageViewerRemote: View {
60
52
VStack {
61
53
ZStack {
62
54
if ( self . disableCache == nil || self . disableCache == false ) {
63
- URLImage ( url: URL ( string: self . imageURL) !, content: { image in
55
+ URLImage ( url: URL ( string: self . imageURL) ?? URL ( string : " https://via.placeholder.com/150.png " ) !, content: { image in
64
56
image
65
57
. resizable ( )
66
58
. aspectRatio ( self . aspectRatio? . wrappedValue, contentMode: . fit)
@@ -311,7 +303,7 @@ class ImageLoader: ObservableObject {
311
303
private var cancellable : AnyCancellable ?
312
304
313
305
func getURLRequest( url: String ) -> URLRequest {
314
- let url = URL ( string: url) !
306
+ let url = URL ( string: url) ?? URL ( string : " https://via.placeholder.com/150.png " ) !
315
307
var request = URLRequest ( url: url)
316
308
request. httpMethod = " GET "
317
309
@@ -321,7 +313,9 @@ class ImageLoader: ObservableObject {
321
313
init ( url: Binding < String > ) {
322
314
self . url = url
323
315
324
- load ( )
316
+ if ( url. wrappedValue. count > 0 ) {
317
+ load ( )
318
+ }
325
319
}
326
320
327
321
deinit {
0 commit comments