Parcourir la source

Update sample app for loading more images

onevcat il y a 6 ans
Parent
commit
c3d671b680

+ 9 - 8
Demo/Demo/Kingfisher-Demo/ViewControllers/SwiftUIScreens/SwiftUIList.swift

@@ -30,23 +30,24 @@ import SwiftUI
 @available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
 struct SwiftUIList : View {
 
-    let index = Array(repeating: 1...10, count: 10).flatMap { $0 }
+    let index = 1 ..< 700
 
     var body: some View {
         List(index) { i in
             HStack(alignment: .center) {
                 Spacer()
-                KFImage(url: URL(string: "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/Loading/kingfisher-\(i).jpg")!)
+                KFImage(url: URL(string: "https://github.com/onevcat/Flower-Data-Set/raw/master/rose/rose-\(i).jpg")!)
                     .resizable()
                     .onSuccess { r in
                         print("suc: \(i) - \(r.cacheType)")
-                }
-                .onFailure { e in
-                    print("err: \(i)")
-                }
-                .placeholder(image: Image(systemName: "arrow.2.circlepath.circle"))
-                    .frame(width: 300, height: 300)
+                    }
+                    .onFailure { e in
+                        print("err: \(i)")
+                    }
+                    .placeholder(image: Image(systemName: "arrow.2.circlepath.circle"))
+                    .aspectRatio(contentMode: .fit)
                     .cornerRadius(20)
+                    .frame(width: 300, height: 300)
                 Spacer()
             }.padding(.vertical, 12)
         }.navigationBarTitle(Text("SwiftUI List"))

+ 1 - 0
Sources/SwiftUI/KFImage.swift

@@ -57,6 +57,7 @@ public struct KFImage: View {
         return configs
             .reduce(image) { current, config in config(current) }
             .onAppear { [unowned binder] in
+                print("Start!! \(binder.url)")
                 binder.start()
             }
     }