-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Search View (with new episode cell for search)
- Search working! - Seasons Watched
- Loading branch information
Showing
11 changed files
with
267 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// FavoriteCell.swift | ||
// BBTGuide | ||
// | ||
// Created by Jesus Sanz on 7/1/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct FavoriteCell: View { | ||
@ObservedObject var detailVM:DetailViewModel | ||
|
||
@Environment(\.colorScheme) var colorScheme | ||
var fillColor: Color { | ||
if colorScheme == .dark { | ||
return Color.black | ||
} else { | ||
return Color.white | ||
} | ||
} | ||
|
||
var body: some View { | ||
HStack { | ||
ZStack(alignment: .bottom) { | ||
Image(detailVM.episode.image) | ||
.resizable() | ||
.scaledToFit() | ||
HStack (){ | ||
Text("Season \(detailVM.episode.season) - Episode \(detailVM.episode.number)") | ||
.bold() | ||
Spacer() | ||
HStack { | ||
RatingViewCell(rating: detailVM.score) | ||
if (detailVM.watched) { | ||
Image(systemName: "eye.circle.fill") | ||
} | ||
} | ||
.bold() | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.padding(10) | ||
.background { | ||
Rectangle() | ||
.fill(fillColor.opacity(0.9)) | ||
} | ||
} | ||
.cornerRadius(10) | ||
} | ||
} | ||
} | ||
|
||
struct FavoriteCell_Previews: PreviewProvider { | ||
static var previews: some View { | ||
FavoriteCell(detailVM: DetailViewModel(episode: .episodeTest)) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// SearchEpisodeCell.swift | ||
// BBTGuide | ||
// | ||
// Created by Jesus Sanz on 7/1/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SearchEpisodeCell: View { | ||
@ObservedObject var detailVM:DetailViewModel | ||
|
||
var body: some View { | ||
HStack { | ||
VStack(alignment: .leading) { | ||
HStack { | ||
Text(detailVM.episode.name) | ||
.font(.headline) | ||
} | ||
Text("Season: \(detailVM.episode.season) - Episode \(detailVM.episode.number)") | ||
.font(.caption) | ||
.padding(.bottom, 10) | ||
Text(detailVM.episode.summary) | ||
.lineLimit(3) | ||
.font(.caption) | ||
.padding(.bottom, 10) | ||
HStack { | ||
VStack (alignment: .leading) { | ||
Text("Runtime: \(detailVM.episode.runtime)") | ||
Text("Air date: \(detailVM.episode.airdate)") | ||
} | ||
.font(.caption) | ||
Spacer() | ||
RatingViewCell(rating: detailVM.score) | ||
Spacer() | ||
if (detailVM.watched) { | ||
Image(systemName: "eye.circle.fill") | ||
} | ||
if (detailVM.favorite) { | ||
Image(systemName: "star.circle.fill") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct SearchEpisodeCell_Previews: PreviewProvider { | ||
static var previews: some View { | ||
SearchEpisodeCell(detailVM: DetailViewModel(episode: .episodeTest)) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// SearchVIew.swift | ||
// BBTGuide | ||
// | ||
// Created by Jesus Sanz on 7/1/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SearchView: View { | ||
@EnvironmentObject var episodesVM:EpisodesViewModel | ||
@State var path = NavigationPath() | ||
|
||
var body: some View { | ||
NavigationStack(path: $path) { | ||
if episodesVM.search.isEmpty { | ||
Text("Search for an Episode.") | ||
.bold() | ||
} else { | ||
List { | ||
ForEach(episodesVM.searchSection, id:\.self) { episode in | ||
NavigationLink(value: episode) { | ||
SearchEpisodeCell(detailVM: DetailViewModel(episode: episode)) | ||
} | ||
} | ||
} | ||
.listStyle(.sidebar) | ||
.navigationDestination(for: Episode.self) { episode in | ||
EpisodeDetailView(detailVM: DetailViewModel(episode: episode)) | ||
} | ||
.navigationTitle("Search") | ||
} | ||
} | ||
.searchable(text: $episodesVM.search) | ||
} | ||
} | ||
|
||
struct SearchView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
SearchView() | ||
.environmentObject(EpisodesViewModel()) | ||
} | ||
} |
Oops, something went wrong.