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

Commit

Permalink
Improve Movies Page (#455) (#465)
Browse files Browse the repository at this point in the history
* Improve Movies Page (#455)

* Updated movies page

* cleanup of my local movies page

* NavigationTitle logic on MovieDetailView

* removed NavigationTitle
instead create offset of back button to background

* Fixed date issue

* Changed movie title icon. Removed location info. Added sheet view for movies.

* Add manual dismiss button and bar to hint swipe down gesture.

* Fix dismiss button

* improved Movie Overview Card Design

* Add space at bottom of MovieDetailedView

Co-authored-by: August Wittgenstein <august.wittgenstein@tum.de>

* Movie Card View: conform to darkmode

Co-authored-by: Atharva Mathapati <92479959+Atharva-Mathapati@users.noreply.github.com>
  • Loading branch information
AW-tum and Atharva-Mathapati authored Jul 22, 2022
1 parent b2568f8 commit 4725d98
Show file tree
Hide file tree
Showing 11 changed files with 396 additions and 69 deletions.
16 changes: 16 additions & 0 deletions Campus-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
1FAF9F0C284D2ABC000ABE93 /* MapScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FAF9F0B284D2ABC000ABE93 /* MapScreenView.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 */; };
226CB51E2798DF9C0043ABCA /* Snap in Frameworks */ = {isa = PBXBuildFile; productRef = 226CB51D2798DF9C0043ABCA /* Snap */; settings = {ATTRIBUTES = (Required, ); }; };
36108BB627A3046B007DC62D /* LectureDetailsViewModel+State.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36108B9E27A3046B007DC62D /* LectureDetailsViewModel+State.swift */; };
36108BB727A3046B007DC62D /* LectureDetailsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36108B9F27A3046B007DC62D /* LectureDetailsViewModel.swift */; };
Expand Down Expand Up @@ -242,6 +246,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 @@ -645,7 +653,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 @@ -1491,6 +1503,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 @@ -1516,6 +1529,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 @@ -1607,6 +1621,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 @@ -1638,6 +1653,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
9 changes: 6 additions & 3 deletions Campus-iOS/MoviesComponent/Views/MovieCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import SwiftUI
struct MovieCard: View {

@State var movie: Movie
@Environment(\.colorScheme) var colorScheme

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 @@ -49,9 +50,11 @@ struct MovieCard: View {
VStack(alignment: .leading, spacing: 6) {
Text(self.movie.title ?? "")
.fontWeight(Font.Weight.heavy)
.font(.subheadline).foregroundColor(.black)
.font(.subheadline).foregroundColor(colorScheme == .dark ? .init(UIColor.white) : .init(UIColor.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)
}
}

161 changes: 101 additions & 60 deletions Campus-iOS/MoviesComponent/Views/MovieDetailedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,79 +11,120 @@ import UIKit
struct MovieDetailedView: View {

@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>

@Environment(\.colorScheme) var colorScheme

var movie: Movie

var body: some View {
ZStack {
VStack {
Color.gray.opacity(0.4).ignoresSafeArea()
Color.white.ignoresSafeArea()
}

VStack(alignment: .center) {
if let link = self.movie.cover {
AsyncImage(url: link) { image in
switch image {
case .empty:
ProgressView()
case .success(let image):
image
.resizable()
.scaledToFit()
.frame(height: 225, alignment: .top)
case .failure:
ScrollView {
ZStack {
GeometryReader { geometry in
if let link = self.movie.cover {
AsyncImage(url: link) { image in
switch image {
case .empty:
ProgressView()
.frame(width: geometry.size.width, height: geometry.size.height)


case .success(let image):
if geometry.frame(in: .global).minY <= 0 {
image
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: geometry.size.width, height: geometry.size.height)
.offset(y: geometry.frame(in: .global).minY/9)
.clipped()
} else {
image
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: geometry.size.width, height: geometry.size.height + geometry.frame(in: .global).minY)
.clipped()
.offset(y: -geometry.frame(in: .global).minY)
}
case .failure:
Image("movie")
.resizable()
.frame(minWidth: nil, idealWidth: nil, maxWidth: UIScreen.main.bounds.width, minHeight: nil, idealHeight: nil, maxHeight: UIScreen.main.bounds.height, alignment: .center)
.clipped()
@unknown default:
// Since the AsyncImagePhase enum isn't frozen,
// we need to add this currently unused fallback
// to handle any new cases that might be added
// in the future:
EmptyView()
}
}
} else {
Image("movie")
.resizable()
.frame(minWidth: nil, idealWidth: nil, maxWidth: UIScreen.main.bounds.width, minHeight: nil, idealHeight: nil, maxHeight: UIScreen.main.bounds.height, alignment: .center)
.clipped()
@unknown default:
// Since the AsyncImagePhase enum isn't frozen,
// we need to add this currently unused fallback
// to handle any new cases that might be added
// in the future:
EmptyView()
.scaledToFit()
.frame(height: 120, alignment: .top)
}
}.frame(height: 550)
.edgesIgnoringSafeArea(.bottom)
.navigationBarBackButtonHidden(true)

VStack {
HStack {
Spacer()
Button(action: { self.presentationMode.wrappedValue.dismiss() }) { ZStack {
Circle()
.frame(width: 30,height:30)
.foregroundColor(colorScheme == .dark ? .init(UIColor.darkGray) : .init(UIColor.white))
.shadow(color: Color.black.opacity(0.2), radius: 2)

Image(systemName: "xmark")
.font(.system(size: 15, weight: .bold, design: .rounded))
.foregroundColor(Color.blue)
}
.padding(8)
.contentShape(Circle())
}
}
.padding(.top, 5)
Spacer()
}

} else {
Image("movie")
.resizable()
.scaledToFit()
.frame(height: 120, alignment: .top)
}
details().cornerRadius(20)
}.edgesIgnoringSafeArea(.bottom)
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading: Button(action: { self.presentationMode.wrappedValue.dismiss() }) {
HStack(alignment: .top) {
Image(systemName: "chevron.backward")
Text("Back").foregroundColor(.blue)
}.foregroundColor(.blue)
})
}

// VStack(alignment: .center) {
// }.edgesIgnoringSafeArea(.bottom)
// .navigationBarBackButtonHidden(true)
// .navigationBarItems(leading: Button(action: { self.presentationMode.wrappedValue.dismiss() }) {
// HStack(alignment: .top) {
// Image(systemName: "chevron.backward")
// Text("Back").foregroundColor(.blue)
// }.foregroundColor(.blue)
// })

VStack(alignment: .leading, spacing: 20) {
MovieDetailsBasicInfoView(movieDetails: movie)
}.frame(
maxWidth: .infinity,
alignment: .topLeading
)
.padding(.horizontal)

VStack(alignment: .leading, spacing: 20) {
MovieDetailsDetailedInfoView(movieDetails: movie)
}.frame(
maxWidth: .infinity,
alignment: .topLeading
)
.padding()

}.edgesIgnoringSafeArea(.top)
}

// TODO: remove when ready OR update accordingly
func details() -> some View {
List {
MovieDetailCellView(property: ("Title", [self.movie.title ?? ""]))

Group {
MovieDetailCellView(property: ("Genre", [self.movie.genre ?? ""]))
MovieDetailCellView(property: ("Rating", [self.movie.rating ?? ""]))
MovieDetailCellView(property: ("Date", [(self.movie.date?.formatted()) ?? ""]))
MovieDetailCellView(property: ("Duration", [self.movie.runtime ?? ""]))
}

Group {
MovieDetailCellView(property: ("Description", [self.movie.movieDescription ?? ""]))
VStack(alignment: .leading, spacing: 20) {
MovieDetailsBasicInfoView(movieDetails: movie)
}

Group {
MovieDetailCellView(property: ("Director", [self.movie.director ?? ""]))
MovieDetailCellView(property: ("Actors", [self.movie.actors ?? ""]))
MovieDetailCellView(property: ("Created", [self.movie.created?.formatted() ?? ""]))
MovieDetailCellView(property: ("Year", [self.movie.year ?? ""]))
VStack(alignment: .leading, spacing: 20) {
MovieDetailsDetailedInfoView(movieDetails: movie)
}

HStack {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// MovieDetaislBasicInfoRowView.swift
// Campus-iOS
//
// Created by Atharva Mathapati on 23.06.22.
//

import SwiftUI

struct MovieDetailsBasicInfoRowView: View {
var iconName: String
var text: String

var body: some View {
HStack(alignment: .center, spacing: 12) {
Image(systemName: iconName)
.imageScale(.medium)
.frame(width: 25, height: 25, alignment: .center)
Text(text)
.font(.system(size: 16))
}
}
}

struct MovieDetaislBasicInfoRowView_Previews: PreviewProvider {
static var previews: some View {
MovieDetailsBasicInfoRowView(
iconName: "number",
text: "test"
)
}
}

Loading

0 comments on commit 4725d98

Please sign in to comment.