Created
December 30, 2020 02:25
-
-
Save jodyabney/5c540433d79129d9e9f4e0f6a37df3cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // PhotoGridCell.swift | |
| // MediumArticleFlickrApp | |
| // | |
| // Created by Jody Abney on 12/6/20. | |
| // | |
| import KingfisherSwiftUI | |
| import SwiftUI | |
| struct PhotoGridCell: View { | |
| @ObservedObject var viewModel: ViewModel | |
| let photo: Photo | |
| @State var isActive = false | |
| var body: some View { | |
| ZStack { | |
| // Show a progress view until the photo overlays it | |
| ProgressView() | |
| // Display the photo | |
| CellPhotoView(photo: photo) | |
| // set up for tap navigation | |
| .onTapGesture { | |
| self.isActive.toggle() | |
| } | |
| .background(NavigationLink( | |
| destination: PhotoScreen(viewModel: viewModel, | |
| isFavorite: viewModel.isFavorite(photo: photo), | |
| photo: photo), | |
| isActive: $isActive) { EmptyView() } | |
| ) | |
| } | |
| .padding() | |
| } | |
| } | |
| struct PhotoGridCell_Previews: PreviewProvider { | |
| static var previews: some View { | |
| PhotoGridCell(viewModel: ViewModel(), photo: Photo.default) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment