You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1008 B
43 lines
1008 B
//
|
|
// Podcast.swift
|
|
// PodcastsClone
|
|
//
|
|
// Created by etudiant on 2023-05-16.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
|
|
struct Podcast {
|
|
var id: UUID
|
|
var image: UIImage
|
|
var title: String
|
|
var by: String
|
|
private var _episodes: [Episode]
|
|
var rating: Double
|
|
var reviews: Int
|
|
var genre: String
|
|
|
|
init(
|
|
id: UUID, image: UIImage, title: String, by: String, episodes: [Episode], rating: Double, reviews: Int, genre: String) {
|
|
self.id = id
|
|
self.image = image
|
|
self.title = title
|
|
self.by = by
|
|
self._episodes = episodes
|
|
self.rating = rating
|
|
self.reviews = reviews
|
|
self.genre = genre
|
|
}
|
|
|
|
|
|
var episodes: [Episode] {
|
|
_episodes.sorted(by: { $0.publicationDate > $1.publicationDate })
|
|
}
|
|
|
|
var latestEpisodeDescription: String {
|
|
guard !episodes.isEmpty else { return "No episodes available" }
|
|
return episodes.first?.description ?? "No description available"
|
|
}
|
|
}
|