Skip to content

Instantly share code, notes, and snippets.

@jodyabney
Created December 30, 2020 02:25
Show Gist options
  • Select an option

  • Save jodyabney/5c540433d79129d9e9f4e0f6a37df3cc to your computer and use it in GitHub Desktop.

Select an option

Save jodyabney/5c540433d79129d9e9f4e0f6a37df3cc to your computer and use it in GitHub Desktop.
//
// 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