Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Improve Movies Page #455

Merged
merged 11 commits into from
Jul 21, 2022
18 changes: 18 additions & 0 deletions Campus-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
100803462764E2C50013ED0E /* ProfileToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 100803452764E2C50013ED0E /* ProfileToolbar.swift */; };
100803482764E37A0013ED0E /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 100803472764E37A0013ED0E /* ProfileView.swift */; };
1F33B2ED282B084100C898E4 /* MockGradesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F33B2EC282B084100C898E4 /* MockGradesViewModel.swift */; };
1F4C836228300306006971C0 /* MapViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4C836128300306006971C0 /* MapViewModel.swift */; };
1F4C836428300D25006971C0 /* MapViewModel+State.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4C836328300D25006971C0 /* MapViewModel+State.swift */; };
1F4C836728300E79006971C0 /* CafeteriasService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4C836628300E79006971C0 /* CafeteriasService.swift */; };
Expand All @@ -19,6 +20,10 @@
1F33B2ED282B084100C898E4 /* MockGradesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F33B2EC282B084100C898E4 /* MockGradesViewModel.swift */; };
1FBFA168285E5B2D00FC1515 /* PanelContentListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FBFA167285E5B2D00FC1515 /* PanelContentListView.swift */; };
226CB51E2798DF9C0043ABCA /* Snap in Frameworks */ = {isa = PBXBuildFile; productRef = 226CB51D2798DF9C0043ABCA /* Snap */; };
2F1B2B8528652FC90023BD9A /* MovieDetailsBasicInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F1B2B8428652FC90023BD9A /* MovieDetailsBasicInfoView.swift */; };
2F1B2B87286530120023BD9A /* MovieDetailsBasicInfoRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F1B2B86286530120023BD9A /* MovieDetailsBasicInfoRowView.swift */; };
2FCF38AD286C9B5600F10915 /* MovieDetailsDetailedInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FCF38AC286C9B5600F10915 /* MovieDetailsDetailedInfoView.swift */; };
2FCF38B1286C9B9200F10915 /* MovieDetailsDetailedInfoRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FCF38B0286C9B9200F10915 /* MovieDetailsDetailedInfoRowView.swift */; };
36108BB627A3046B007DC62D /* LectureDetailsViewModel+State.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36108B9E27A3046B007DC62D /* LectureDetailsViewModel+State.swift */; };
36108BB727A3046B007DC62D /* LectureDetailsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36108B9F27A3046B007DC62D /* LectureDetailsViewModel.swift */; };
36108BB827A3046B007DC62D /* LecturesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36108BA027A3046B007DC62D /* LecturesViewModel.swift */; };
Expand Down Expand Up @@ -220,6 +225,7 @@
/* Begin PBXFileReference section */
100803452764E2C50013ED0E /* ProfileToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileToolbar.swift; sourceTree = "<group>"; };
100803472764E37A0013ED0E /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
1F33B2EC282B084100C898E4 /* MockGradesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockGradesViewModel.swift; sourceTree = "<group>"; };
1F4C836128300306006971C0 /* MapViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapViewModel.swift; sourceTree = "<group>"; };
1F4C836328300D25006971C0 /* MapViewModel+State.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MapViewModel+State.swift"; sourceTree = "<group>"; };
1F4C836628300E79006971C0 /* CafeteriasService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CafeteriasService.swift; sourceTree = "<group>"; };
Expand All @@ -230,6 +236,10 @@
227FBB492762AC440062FEC3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
227FBB4A2762AC4C0062FEC3 /* Campus-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Campus-iOS.entitlements"; sourceTree = "<group>"; };
256D0D4227D77A9C00F5EC38 /* MapViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapViewModel.swift; sourceTree = "<group>"; };
2F1B2B8428652FC90023BD9A /* MovieDetailsBasicInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieDetailsBasicInfoView.swift; sourceTree = "<group>"; };
2F1B2B86286530120023BD9A /* MovieDetailsBasicInfoRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieDetailsBasicInfoRowView.swift; sourceTree = "<group>"; };
2FCF38AC286C9B5600F10915 /* MovieDetailsDetailedInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieDetailsDetailedInfoView.swift; sourceTree = "<group>"; };
2FCF38B0286C9B9200F10915 /* MovieDetailsDetailedInfoRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieDetailsDetailedInfoRowView.swift; sourceTree = "<group>"; };
36108B9E27A3046B007DC62D /* LectureDetailsViewModel+State.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "LectureDetailsViewModel+State.swift"; sourceTree = "<group>"; };
36108B9F27A3046B007DC62D /* LectureDetailsViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LectureDetailsViewModel.swift; sourceTree = "<group>"; };
36108BA027A3046B007DC62D /* LecturesViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LecturesViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -625,7 +635,11 @@
36108BF627A30516007DC62D /* MovieCard.swift */,
36108BF727A30516007DC62D /* MovieDetailedView.swift */,
36108BF827A30516007DC62D /* MovieDetailCellView.swift */,
2F1B2B8428652FC90023BD9A /* MovieDetailsBasicInfoView.swift */,
36108BF927A30516007DC62D /* MoviesView.swift */,
2F1B2B86286530120023BD9A /* MovieDetailsBasicInfoRowView.swift */,
2FCF38AC286C9B5600F10915 /* MovieDetailsDetailedInfoView.swift */,
2FCF38B0286C9B9200F10915 /* MovieDetailsDetailedInfoRowView.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -1443,6 +1457,7 @@
36BB6F6227AFCDFA00F224AB /* PersonSearchView.swift in Sources */,
97270F5A27AB2A4900BB25E4 /* Array+Rearrange.swift in Sources */,
3654F38428517260008AD5DC /* StudyRoomVIewModel.swift in Sources */,
2F1B2B87286530120023BD9A /* MovieDetailsBasicInfoRowView.swift in Sources */,
36BB6F6627AFD12B00F224AB /* PersonDetails.swift in Sources */,
36108BFD27A30517007DC62D /* MovieDetailedView.swift in Sources */,
3683C3182758117900082930 /* Model.swift in Sources */,
Expand All @@ -1467,6 +1482,7 @@
36108BC427A3046B007DC62D /* LectureDetailsDetailedInfoRowView.swift in Sources */,
36108C1C27A307FA007DC62D /* GradesView.swift in Sources */,
3654F365285168D2008AD5DC /* RoomImageMapping.swift in Sources */,
2FCF38B1286C9B9200F10915 /* MovieDetailsDetailedInfoRowView.swift in Sources */,
36AD5CFC27B974F100DAE143 /* ProfileMyTumSection.swift in Sources */,
36108BE227A304B5007DC62D /* MensaMenu.swift in Sources */,
36108BC027A3046B007DC62D /* LecturesView.swift in Sources */,
Expand Down Expand Up @@ -1558,6 +1574,7 @@
36108C1727A307F9007DC62D /* GradesViewModel+State.swift in Sources */,
36FF906F2773BE8100F4C785 /* AuthenticationHandler.swift in Sources */,
36108BFE27A30517007DC62D /* MovieDetailCellView.swift in Sources */,
2FCF38AD286C9B5600F10915 /* MovieDetailsDetailedInfoView.swift in Sources */,
36108BE527A304B5007DC62D /* MealPlanView.swift in Sources */,
36AF61EF27A2FD7800FEBD98 /* LoadingView.swift in Sources */,
36AF61D827A2FD7800FEBD98 /* EntityImporter.swift in Sources */,
Expand Down Expand Up @@ -1589,6 +1606,7 @@
36BB6F7327B1CD9200F224AB /* ProfileViewModel.swift in Sources */,
36BB6F6827AFD26500F224AB /* Organization.swift in Sources */,
3616C4DB27904BD3000A1BC9 /* NewsViewModel.swift in Sources */,
2F1B2B8528652FC90023BD9A /* MovieDetailsBasicInfoView.swift in Sources */,
3629BA2E27A1CEFA0036AC80 /* NewsCard.swift in Sources */,
100803482764E37A0013ED0E /* ProfileView.swift in Sources */,
36AD5CF627B8D97500DAE143 /* LectureDetailsEventInfoView.swift in Sources */,
Expand Down
17 changes: 17 additions & 0 deletions Campus-iOS/MoviesComponent/ViewModel/Movie.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,20 @@ struct Movie: Entity {
self.year = year
}
}
extension Movie: Identifiable {
static let dummyData: Movie = .init(
id: 123,
actors: "Morgan Freeman",
cover: URL(string:"https://www.google.com"),
created: Date.now,
date: Date.now,
director: "Frank Darapant",
genre: "Crime",
link: URL(string:"www.google.com"),
movieDescription: "Yes",
rating: "11/10",
runtime: "194",
title: "Shawshank Redemption",
year: "2020"
)
}
14 changes: 12 additions & 2 deletions Campus-iOS/MoviesComponent/ViewModel/MoviesViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ class MoviesViewModel: ObservableObject {
importer.performFetch(handler: { result in
switch result {
case .success(let incoming):
self.movies = incoming.sorted(by: {
// Remove all movies from list that are older than today
let relevantMovies = incoming.filter ({
if let date = $0.date {
return Date.now <= date
} else {
// If no date available keep movie just in case
return true;
}
})

self.movies = relevantMovies.sorted(by: {
guard let dateOne = $0.date, let dateTwo = $1.date else {
return false
}
return dateOne > dateTwo
return dateOne < dateTwo
})
case .failure(let error):
print(error)
Expand Down
6 changes: 4 additions & 2 deletions Campus-iOS/MoviesComponent/Views/MovieCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct MovieCard: View {
@State var movie: Movie

var body: some View {
VStack(alignment: .center, spacing: 0) {
VStack(alignment: .leading, spacing: 0) {

if let link = self.movie.cover {
AsyncImage(url: link) { image in
Expand Down Expand Up @@ -50,8 +50,10 @@ struct MovieCard: View {
Text(self.movie.title ?? "")
.fontWeight(Font.Weight.heavy)
.font(.subheadline).foregroundColor(.black)
.fixedSize(horizontal: false, vertical: true)
.lineLimit(2)
Text(self.movie.date ?? Date(), style: .date)
.font(Font.custom("HelveticaNeue-Bold", size: 11))
.font(Font.custom("HelveticaNeue-Bold", size: 12))
.foregroundColor(Color.gray)
}
.padding(12)
Expand Down
4 changes: 4 additions & 0 deletions Campus-iOS/MoviesComponent/Views/MovieDetailCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ struct MovieDetailCellView: View {
var body: some View {
HStack {
Text(property.key)
.font(.system(size: 18, weight: .semibold))
.foregroundColor(Color("tumBlue"))
.multilineTextAlignment(.leading)
.frame(maxWidth: .infinity, alignment: .leading)
Spacer().frame(width: 20)
VStack(alignment: .leading) {
ForEach(property.value, id: \.self) { propVal in
Text(propVal)
.font(.system(size: 16))
.multilineTextAlignment(.leading)
}
}.frame(maxWidth: .infinity, alignment: .leading)
Expand All @@ -33,3 +36,4 @@ struct MovieDetailCellView_Previews: PreviewProvider {
.previewLayout(.sizeThatFits)
}
}

Loading