mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-06-28 21:06:25 +02:00
Add Async image loading
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
See LICENSE folder for this sample’s licensing information.
|
||||
|
||||
Abstract:
|
||||
A view showing a list of landmarks.
|
||||
*/
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct LandmarkList: View {
|
||||
@EnvironmentObject private var userData: UserData
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
Toggle(isOn: $userData.showFavoritesOnly) {
|
||||
Text("Show Favorites Only")
|
||||
}
|
||||
|
||||
ForEach(userData.landmarks) { landmark in
|
||||
if !self.userData.showFavoritesOnly || landmark.isFavorite {
|
||||
NavigationButton(
|
||||
destination: LandmarkDetail(landmark: landmark)) {
|
||||
LandmarkRow(landmark: landmark)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationBarTitle(Text("Landmarks"), displayMode: .large)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct LandmarksList_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in
|
||||
LandmarkList()
|
||||
.previewDevice(PreviewDevice(rawValue: deviceName))
|
||||
.previewDisplayName(deviceName)
|
||||
}
|
||||
.environmentObject(UserData())
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user