Skip to content

Commit 7e2a833

Browse files
committed
using SDWebImageSwiftUI for image download from url and display
1 parent 12c66af commit 7e2a833

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

firestore/FirestoreExample.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@
551551
"${BUILT_PRODUCTS_DIR}/gRPC-Core/grpc.framework",
552552
"${BUILT_PRODUCTS_DIR}/leveldb-library/leveldb.framework",
553553
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
554+
"${BUILT_PRODUCTS_DIR}/SDWebImageSwiftUI/SDWebImageSwiftUI.framework",
554555
);
555556
name = "[CP] Embed Pods Frameworks";
556557
outputPaths = (
@@ -571,6 +572,7 @@
571572
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpc.framework",
572573
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/leveldb.framework",
573574
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
575+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSwiftUI.framework",
574576
);
575577
runOnlyForDeploymentPostprocessing = 0;
576578
shellPath = /bin/sh;

firestore/FirestoreSwiftUIExample/Views/RestaurantItemView.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,38 @@
77
//
88

99
import SwiftUI
10+
import SDWebImageSwiftUI
1011

1112
struct RestaurantItemView: View {
1213
var restaurant: Restaurant
1314

1415
var body: some View {
1516
HStack {
16-
Image(systemName: "circle")
17+
WebImage(url: restaurant.photo)
18+
.resizable()
19+
.placeholder(Image(systemName: "photo"))
20+
.aspectRatio(1, contentMode: .fill)
21+
.frame(width: 100, height: 100, alignment: .leading)
1722
VStack(alignment: .leading) {
1823
Text(restaurant.name)
1924
Text("Star Placeholder")
2025
Spacer()
21-
Text("Type and location")
26+
HStack {
27+
Text(restaurant.category)
28+
Text("")
29+
Text(restaurant.city)
30+
}
2231
}
2332
Spacer()
2433
Text("$$$")
2534
}
26-
.padding([.leading, .bottom, .trailing])
35+
.padding([.bottom, .trailing])
2736
}
2837
}
2938

3039
struct RestaurantItemView_Previews: PreviewProvider {
3140
static var previews: some View {
32-
let data = Restaurant(id: .init(), name: "test123", category: "test123", city: "test123", price: 0, ratingCount: 0, averageRating: 0, photo: Restaurant.imageURL(forName: "test"))
41+
let data = Restaurant(id: .init(), name: "Pizza Place", category: "Pizza", city: "Austin", price: 0, ratingCount: 0, averageRating: 0, photo: Restaurant.imageURL(forName: "Place Place"))
3342
RestaurantItemView(restaurant: data)
3443
}
3544
}

firestore/Podfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
platform :ios, '10.0'
1+
platform :ios, '13.0'
22

33
target 'FirestoreExample' do
44
use_frameworks!
@@ -25,5 +25,5 @@ target 'FirestoreSwiftUIExample' do
2525
# pod 'FirebaseUI/Email'
2626
pod 'Firebase/Firestore'
2727
pod 'FirebaseFirestoreSwift', "~> 7.0-beta"
28-
pod 'SDWebImage'
28+
pod 'SDWebImageSwiftUI'
2929
end

firestore/Podfile.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ PODS:
340340
- SDWebImage (5.10.4):
341341
- SDWebImage/Core (= 5.10.4)
342342
- SDWebImage/Core (5.10.4)
343+
- SDWebImageSwiftUI (2.0.1):
344+
- SDWebImage (~> 5.10)
343345

344346
DEPENDENCIES:
345347
- Firebase/Analytics
@@ -349,6 +351,7 @@ DEPENDENCIES:
349351
- FirebaseUI/Auth
350352
- FirebaseUI/Email
351353
- SDWebImage
354+
- SDWebImageSwiftUI
352355

353356
SPEC REPOS:
354357
trunk:
@@ -373,6 +376,7 @@ SPEC REPOS:
373376
- nanopb
374377
- PromisesObjC
375378
- SDWebImage
379+
- SDWebImageSwiftUI
376380

377381
SPEC CHECKSUMS:
378382
abseil: 6c8eb7892aefa08d929b39f9bb108e5367e3228f
@@ -396,7 +400,8 @@ SPEC CHECKSUMS:
396400
nanopb: 59221d7f958fb711001e6a449489542d92ae113e
397401
PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97
398402
SDWebImage: c666b97e1fa9c64b4909816a903322018f0a9c84
403+
SDWebImageSwiftUI: ff3dc77f69330e6513c655bcb9b5080a033405a5
399404

400-
PODFILE CHECKSUM: c84c0ddc2710245ae619c050f9ab9128baca858a
405+
PODFILE CHECKSUM: a966f717dce1e9f228756a84905b47eb4d2009be
401406

402407
COCOAPODS: 1.10.1

0 commit comments

Comments
 (0)