// // PodcastDetailView.swift // PodcastsClone // // Created by etudiant on 2023-05-12. // import SwiftUI struct PodcastDetailView: View { let podcast: Podcast var body: some View { ScrollView { ZStack() { // TODO make this background the same as the dominant color of the podcast logo Color.theme.background.ignoresSafeArea(.all, edges: .all) VStack(alignment: .center) { // TODO make content of the VStack below switch to dark mode if the ZStack's background is dark, and vice versa VStack(alignment: .center) { Image(uiImage: podcast.image) .resizable() .scaledToFit() .cornerRadius(10) .shadow(color: Color.theme.shadow, radius: 10, x: 0, y: 10) .padding(.horizontal, 48) .padding(.vertical, 16) Text(podcast.title) .font(.title) .foregroundColor(Color.theme.primary) .multilineTextAlignment(.center) Text(podcast.by) .font(.headline) .foregroundColor(Color.theme.secondary) .multilineTextAlignment(.center) Button(action: {}) { HStack { Image(systemName: "play.fill") Text(Strings.latestEpisode) }} .foregroundColor(Color.theme.primary) .padding(.vertical) .padding(.horizontal, 64) .background(Color.theme.background) .clipShape(RoundedRectangle(cornerSize: CGSize(width: 12.0, height: 12.0))) // TODO replace '...' with Strings.readFurtherPrompt Text(podcast.latestEpisodeDescription) .lineLimit(3) .truncationMode(.tail) .padding() HStack() { Text("\(Image(systemName: "star.fill")) \(podcast.rating, specifier: "%.1f") (\(podcast.reviews)) \(Strings.classySeparator) \(podcast.genre)") .padding(.horizontal) Spacer() } } Divider() .foregroundColor(Color.theme.backgroundSecondary) ZStack() { Color.theme.background.ignoresSafeArea(.all, edges: .all) VStack(alignment: .leading) { Text("Episodes") .font(.title2) .fontWeight(.bold) .foregroundColor(Color.theme.primary) .padding() ForEach(podcast.episodes, id: \.id) { episode in EpisodeViewCell(episode: episode) } } } } } } } } struct PodcastDetailView_Previews: PreviewProvider { static var previews: some View { PodcastDetailView(podcast: Podcast( id: UUID(), image: UIImage(named: "podcast_logo_1")!, title: "Podcast Title 1", by: "Author 1", episodes: [ Episode( id: UUID(), publicationDate: Date.now.addingTimeInterval(-1000000), title: "A New Ipsum", description: "Stand in doorway, unwilling to chose whether to stay in or go out more napping, more napping all the napping is exhausting sleep i'm bored inside, let me out i'm lonely outside, let me in i can't make up my mind whether to go in or out, guess i'll just stand partway in and partway out, contemplating the universe for half an hour how dare you nudge me with your foot?!?! leap into the air in greatest offense!", duration: 3463 ), Episode( id: UUID(), publicationDate: Date.now, title: "Return of the Hooman", description: "Catch mouse and gave it as a present mewl for food at 4am drink water out of the faucet and have secret plans. Stretch chase dog then run away. Kitty. Mouse if it fits, i sits. Bite off human's toes. If human is on laptop sit on the keyboard.", duration: 4480 ), Episode( id: UUID(), publicationDate: Date.now.addingTimeInterval(-100000), title: "Cat Ipsum Strikes Back", description: "Chase after silly colored fish toys around the house i want to go outside let me go outside nevermind inside is better or get video posted to internet for chasing red dot eat owner's food wack the mini furry mouse so cat meoooow i iz master of hoomaan, not hoomaan master of i, oooh damn dat dog but stuff and things. Cats making all the muffins.", duration: 4028 ), ], rating: 4.2, reviews: 2139, genre: "Genre 1" )) } }