Skip to content

Commit

Permalink
Updated front-end elements and stylings & Enhanced mobile app
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangsonww committed Dec 23, 2023
1 parent 4fbd774 commit 9834c9d
Show file tree
Hide file tree
Showing 43 changed files with 2,506 additions and 136 deletions.
121 changes: 121 additions & 0 deletions MovieVerse-Mobile/app/ios/AboutViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import UIKit

// MARK: - Data Model
struct AboutSection {
let title: String
let description: String
}

class AboutViewController: UIViewController {

// Data
private let sections: [AboutSection] = [
AboutSection(title: "Welcome to The MovieVerse",
description: "Your ultimate destination for exploring the magic of movies. Here, you can discover, engage, and immerse yourself in the world of film."),
AboutSection(title: "Core Features",
description: "Explore movies by genre, director, language, and era. Enjoy interactive movie details, high-quality trailers, and a community-driven recommendation system."),
AboutSection(title: "Our Vision",
description: "We aim to create a haven for cinephiles, where discovery of movies is an adventure. It's a vibrant community for sharing cinematic experiences and insights."),
AboutSection(title: "Join The Journey",
description: "We're constantly innovating to bring you new and exciting features. Your engagement and feedback are invaluable to us.")
]

// UI Components
private lazy var tableView: UITableView = {
let table = UITableView()
table.delegate = self
table.dataSource = self
table.register(AboutSectionCell.self, forCellReuseIdentifier: AboutSectionCell.identifier)
return table
}()

// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}

// MARK: - Setup
private func setupUI() {
view.addSubview(tableView)
tableView.frame = view.bounds
title = "About The MovieVerse"
}
}

// MARK: - UITableView DataSource & Delegate
extension AboutViewController: UITableViewDataSource, UITableViewDelegate {

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return sections.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: AboutSectionCell.identifier, for: indexPath) as? AboutSectionCell else {
return UITableViewCell()
}
let section = sections[indexPath.row]
cell.configure(with: section)
return cell
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
}

// MARK: - Custom TableViewCell
class AboutSectionCell: UITableViewCell {

static let identifier = "AboutSectionCell"

private let titleLabel: UILabel = {
let label = UILabel()
label.font = UIFont.boldSystemFont(ofSize: 18)
label.numberOfLines = 0
return label
}()

private let descriptionLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 16)
label.numberOfLines = 0
label.textColor = .darkGray
return label
}()

// Initialization
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.addSubview(titleLabel)
contentView.addSubview(descriptionLabel)
applyConstraints()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// Configure Cell
func configure(with section: AboutSection) {
titleLabel.text = section.title
descriptionLabel.text = section.description
}

// Constraints
private func applyConstraints() {
titleLabel.translatesAutoresizingMaskIntoConstraints = false
descriptionLabel.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 10),
titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 10),
titleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -10),

descriptionLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 5),
descriptionLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 10),
descriptionLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -10),
descriptionLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -10)
])
}
}
96 changes: 96 additions & 0 deletions MovieVerse-Mobile/app/ios/ActorDetailsViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import UIKit

// MARK: - Actor Data Model
struct Actor {
let id: Int
let name: String
let bio: String
let birthDate: String
let filmography: [String]
}

class ActorDetailsViewController: UIViewController {

var actor: Actor? // Actor data passed from the previous screen

// UI Components
private let nameLabel: UILabel = {
let label = UILabel()
label.font = UIFont.boldSystemFont(ofSize: 24)
label.textAlignment = .center
return label
}()

private let bioLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 16)
label.numberOfLines = 0
label.textAlignment = .left
return label
}()

private let tableView: UITableView = {
let table = UITableView()
table.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
return table
}()

// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
configureTableView()
loadActorDetails()
}

// MARK: - Setup
private func setupUI() {
view.backgroundColor = .white
view.addSubview(nameLabel)
view.addSubview(bioLabel)
view.addSubview(tableView)
layoutUI()
}

private func configureTableView() {
tableView.dataSource = self
tableView.delegate = self
}

private func layoutUI() {
nameLabel.translatesAutoresizingMaskIntoConstraints = false
bioLabel.translatesAutoresizingMaskIntoConstraints = false
tableView.translatesAutoresizingMaskIntoConstraints = false
dobLabel.translatesAutoresizingMaskIntoConstraints = false
ageLabel.translatesAutoresizingMaskIntoConstraints = false
filmographyLabel.translatesAutoresizingMaskIntoConstraints = false
heightLabel.translatesAutoresizingMaskIntoConstraints = false
}

private func loadActorDetails() {
guard let actor = actor else { return }
nameLabel.text = actor.name
bioLabel.text = "Biography: \(actor.bio)"

tableView.reloadData()
}
}

// MARK: - UITableViewDataSource, UITableViewDelegate
extension ActorDetailsViewController: UITableViewDataSource, UITableViewDelegate {

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return actor?.filmography.count ?? 0
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = actor?.filmography[indexPath.row]
return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
tableView.reloadData()
}
}
106 changes: 106 additions & 0 deletions MovieVerse-Mobile/app/ios/DirectorDetailsViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import UIKit

// MARK: - Director Data Model
struct Director {
let id: Int
let name: String
let bio: String
let birthDate: String
let filmography: [String]
}

class DirectorDetailsViewController: UIViewController {

var directorId: Int? // Director ID passed from the previous screen

// UI Components
private let nameLabel: UILabel = {
let label = UILabel()
label.font = UIFont.boldSystemFont(ofSize: 24)
label.textAlignment = .center
return label
}()

private let bioTextView: UITextView = {
let textView = UITextView()
textView.font = UIFont.systemFont(ofSize: 16)
textView.isEditable = false
return textView
}()

private let tableView: UITableView = {
let table = UITableView()
table.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
return table
}()

// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
configureTableView()
loadDirectorDetails()
}

// MARK: - Setup
private func setupUI() {
view.backgroundColor = .white
view.addSubview(nameLabel)
view.addSubview(bioTextView)
view.addSubview(tableView)
layoutUI()
}

private func configureTableView() {
tableView.dataSource = self
tableView.delegate = self
}

private func layoutUI() {
// Constraints setup for nameLabel, bioTextView, and tableView
}

private func loadDirectorDetails() {
guard let directorId = directorId else { return }
fetchDirectorDetails(directorId: directorId)
}

private func fetchDirectorDetails(directorId: Int) {}
let sampleDirector = Director(id: directorId, name: "Christopher Nolan", bio: "An acclaimed British-American film director...", birthDate: "1970-07-30", filmography: ["Inception", "The Dark Knight", "Interstellar"])

nameLabel.text = sampleDirector.name
bioTextView.text = "Bio: \(sampleDirector.bio)\n\nBorn: \(sampleDirector.birthDate)"

apiClient.fetchDirectorFilmography(directorId: directorId) { result in
switch result {
case .success(let movies):
director.filmography = movies.map { $0.title }
case .failure(let error):
print(error.localizedDescription)
}
}

resultsLabel.text = "Filmography"

tableView.reloadData()
}
}

// MARK: - UITableViewDataSource, UITableViewDelegate
extension DirectorDetailsViewController: UITableViewDataSource, UITableViewDelegate {

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3 // Sample data
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = ["Inception", "The Dark Knight", "Interstellar"][indexPath.row]
return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
movieDetails(movie: ["Inception", "The Dark Knight", "Interstellar"][indexPath.row])
}
}
2 changes: 1 addition & 1 deletion MovieVerse-Mobile/app/ios/MovieDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,4 @@ struct MoviesViewController: UIViewController, UITableViewDelegate, UITableViewD
movieDetailViewController.movie = movie
}
}
}
}
2 changes: 1 addition & 1 deletion MovieVerse-Mobile/app/ios/MovieDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct MoviePosterImage: View {
}.resume()
}

private func fetchImageData() {
private func fetchImageData2() {
URLSession.shared.dataTaskPublisher(for: url)
.map { $0.data }
.replaceError(with: nil)
Expand Down
Loading

0 comments on commit 9834c9d

Please sign in to comment.