From 200c9135fe7388a273efdb112a7cea9fc06a70e7 Mon Sep 17 00:00:00 2001 From: AakifNadeem Date: Wed, 27 Sep 2023 15:54:54 +0500 Subject: [PATCH] remove constants --- MovieApp/MovieApp.xcodeproj/project.pbxproj | 12 +++++--- MovieApp/MovieApp/Constant.swift | 30 ------------------- .../MovieApp/Domain/Model/GenreModel.swift | 30 +++++++++++++++++++ MovieApp/MovieApp/Extensions.swift | 6 ++++ .../ChartView/View/ChartTableViewCell.swift | 2 +- .../ChartView/View/ChartViewController.swift | 6 ++-- .../View/CreditTableViewDescriptionCell.swift | 2 +- .../View/CreditViewController.swift | 8 ++--- .../View/DetailViewController.swift | 2 +- .../View/DiscoverCollectionHeaderView.swift | 4 +-- .../View/DiscoverViewController.swift | 4 +-- .../Presentation/MainTabBarController.swift | 2 +- 12 files changed, 59 insertions(+), 49 deletions(-) create mode 100644 MovieApp/MovieApp/Domain/Model/GenreModel.swift diff --git a/MovieApp/MovieApp.xcodeproj/project.pbxproj b/MovieApp/MovieApp.xcodeproj/project.pbxproj index 6cb403b..1e1f9ed 100644 --- a/MovieApp/MovieApp.xcodeproj/project.pbxproj +++ b/MovieApp/MovieApp.xcodeproj/project.pbxproj @@ -39,7 +39,8 @@ 7DDE9C2D2787D6EE00938996 /* MainTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DDE9C2C2787D6EE00938996 /* MainTabBarController.swift */; }; 7DDE9C302787E0C700938996 /* ChartViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DDE9C2F2787E0C700938996 /* ChartViewController.swift */; }; 7DDE9C322788045B00938996 /* ChartTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DDE9C312788045B00938996 /* ChartTableViewCell.swift */; }; - 7DE8154327910DDC00726799 /* Keys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DE8154227910DDC00726799 /* Keys.swift */; }; + 9440E7322AC440A1000CE141 /* GenreModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9440E7312AC440A1000CE141 /* GenreModel.swift */; }; + 9440E7342AC44102000CE141 /* Keys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9440E7332AC44102000CE141 /* Keys.swift */; }; 9F38C115EB6AF0EEE6B8E0C5 /* Pods_MovieApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1333EC5F83FAB13E0CD0D899 /* Pods_MovieApp.framework */; }; /* End PBXBuildFile section */ @@ -80,7 +81,8 @@ 7DDE9C2C2787D6EE00938996 /* MainTabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTabBarController.swift; sourceTree = ""; }; 7DDE9C2F2787E0C700938996 /* ChartViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartViewController.swift; sourceTree = ""; }; 7DDE9C312788045B00938996 /* ChartTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartTableViewCell.swift; sourceTree = ""; }; - 7DE8154227910DDC00726799 /* Keys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keys.swift; sourceTree = ""; }; + 9440E7312AC440A1000CE141 /* GenreModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenreModel.swift; sourceTree = ""; }; + 9440E7332AC44102000CE141 /* Keys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keys.swift; sourceTree = ""; }; FDA2E981A792A2B7397508AB /* Pods-MovieApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MovieApp.release.xcconfig"; path = "Target Support Files/Pods-MovieApp/Pods-MovieApp.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -213,7 +215,7 @@ isa = PBXGroup; children = ( 7D37AD9F278D5C97004BBFF9 /* APIService.swift */, - 7DE8154227910DDC00726799 /* Keys.swift */, + 9440E7332AC44102000CE141 /* Keys.swift */, ); path = Service; sourceTree = ""; @@ -224,6 +226,7 @@ 7D37ADA1278D5CE7004BBFF9 /* MovieList.swift */, 7D9D9F49278E928C0098FEA3 /* MovieFront.swift */, 7D202FAD27B262A6008F8051 /* MovieDetail.swift */, + 9440E7312AC440A1000CE141 /* GenreModel.swift */, ); path = Model; sourceTree = ""; @@ -468,16 +471,17 @@ 7D40A08127BCC91E002C21FE /* DescriptionView.swift in Sources */, 7D2DD62527855A30000EBDE0 /* DiscoverCollectionHeaderView.swift in Sources */, 7D37ADA2278D5CE7004BBFF9 /* MovieList.swift in Sources */, + 9440E7342AC44102000CE141 /* Keys.swift in Sources */, 7DDE9C2D2787D6EE00938996 /* MainTabBarController.swift in Sources */, 7D40A07F27BCC33D002C21FE /* IconLabel.swift in Sources */, 7D88534027BA1E7500CC915E /* DetailViewController.swift in Sources */, 7DDE9C302787E0C700938996 /* ChartViewController.swift in Sources */, + 9440E7322AC440A1000CE141 /* GenreModel.swift in Sources */, 7D0408B72A94815200402458 /* Cache.swift in Sources */, 7D9D9F4A278E928C0098FEA3 /* MovieFront.swift in Sources */, 7D7A7D3A2A7E744100E7879A /* ImageCacheManager.swift in Sources */, 7D85FCB42AB9B77800570222 /* UIImageViewExtension.swift in Sources */, 7D947CA9278C03E00031C7C9 /* CreditViewController.swift in Sources */, - 7DE8154327910DDC00726799 /* Keys.swift in Sources */, 7D90EC1B27D5EC160099B485 /* CreditHeaderView.swift in Sources */, 7DC7D34727913C89005C3D9C /* DiscoverViewModel.swift in Sources */, 7D15F0DA27D726E50029C40F /* CreditFootherView.swift in Sources */, diff --git a/MovieApp/MovieApp/Constant.swift b/MovieApp/MovieApp/Constant.swift index 3188f1c..7e1f179 100644 --- a/MovieApp/MovieApp/Constant.swift +++ b/MovieApp/MovieApp/Constant.swift @@ -7,13 +7,6 @@ import Foundation - -struct Colors { - static let background = "BgColor" - static let light_background = "LightBgColor" - static let placeholder = "PlaceholderTextColor" -} - struct identifiers { static let discover_collection_cell = "DiscoverCollectionCell" static let discover_collection_header = "DiscoverCollectionHeader" @@ -26,26 +19,3 @@ struct identifiers { static let detail_trailer_collection_Cell = "DetailTrailerCollectionCell" static let detail_cast_collection_Cell = "DetailCastCollectionCell" } - - -let genreCode = [ - 28 : "Action", - 12 : "Adventure", - 16 : "Animation", - 35 : "Comedy", - 80 : "Crime", - 99 : "Documentary", - 18 : "Drama", - 10751 : "Family", - 14 : "Fantasy", - 36 : "History", - 27 : "Horror", - 10402 : "Music", - 9648 : "Mystery", - 10749 : "Romance", - 878 : "Science Fiction", - 10770 : "TV Movie", - 53 : "Thriller", - 10752 : "War", - 37 : "Western" -] diff --git a/MovieApp/MovieApp/Domain/Model/GenreModel.swift b/MovieApp/MovieApp/Domain/Model/GenreModel.swift new file mode 100644 index 0000000..8b41793 --- /dev/null +++ b/MovieApp/MovieApp/Domain/Model/GenreModel.swift @@ -0,0 +1,30 @@ +// +// GenreModel.swift +// MovieApp +// +// Created by Aakif Nadeem on 27/09/2023. +// + +import Foundation + +let genreCode = [ + 28 : "Action", + 12 : "Adventure", + 16 : "Animation", + 35 : "Comedy", + 80 : "Crime", + 99 : "Documentary", + 18 : "Drama", + 10751 : "Family", + 14 : "Fantasy", + 36 : "History", + 27 : "Horror", + 10402 : "Music", + 9648 : "Mystery", + 10749 : "Romance", + 878 : "Science Fiction", + 10770 : "TV Movie", + 53 : "Thriller", + 10752 : "War", + 37 : "Western" +] diff --git a/MovieApp/MovieApp/Extensions.swift b/MovieApp/MovieApp/Extensions.swift index a50a0a3..877dc2f 100644 --- a/MovieApp/MovieApp/Extensions.swift +++ b/MovieApp/MovieApp/Extensions.swift @@ -22,3 +22,9 @@ extension UIImage { } } + +extension UIColor { + static let background = "BgColor" + static let light_background = "LightBgColor" + static let placeholder = "PlaceholderTextColor" +} diff --git a/MovieApp/MovieApp/Presentation/ChartView/View/ChartTableViewCell.swift b/MovieApp/MovieApp/Presentation/ChartView/View/ChartTableViewCell.swift index 7d66432..0cdb090 100644 --- a/MovieApp/MovieApp/Presentation/ChartView/View/ChartTableViewCell.swift +++ b/MovieApp/MovieApp/Presentation/ChartView/View/ChartTableViewCell.swift @@ -98,7 +98,7 @@ class ChartTableViewCell: UITableViewCell { $0.spacing = 5 } - self.backgroundColor = UIColor(named: Colors.background) + self.backgroundColor = UIColor(named: UIColor.background) self.selectionStyle = .none //MARK: Set Constraints diff --git a/MovieApp/MovieApp/Presentation/ChartView/View/ChartViewController.swift b/MovieApp/MovieApp/Presentation/ChartView/View/ChartViewController.swift index 20b36aa..0e5f31b 100644 --- a/MovieApp/MovieApp/Presentation/ChartView/View/ChartViewController.swift +++ b/MovieApp/MovieApp/Presentation/ChartView/View/ChartViewController.swift @@ -14,7 +14,7 @@ class ChartViewController: UIViewController { // MARK: - UI Components lazy var tableView = UITableView().then { - $0.backgroundColor = UIColor(named: Colors.background) + $0.backgroundColor = UIColor(named: UIColor.background) $0.allowsSelection = true $0.register(ChartTableViewCell.self, forCellReuseIdentifier: identifiers.chart_table_cell) @@ -26,7 +26,7 @@ class ChartViewController: UIViewController { lazy var navigationAppearance = UINavigationBarAppearance().then { $0.titleTextAttributes = [.foregroundColor: UIColor.white] $0.largeTitleTextAttributes = [.foregroundColor: UIColor.white] - $0.backgroundColor = UIColor(named: Colors.background) + $0.backgroundColor = UIColor(named: UIColor.background) } // MARK: - Instances @@ -52,7 +52,7 @@ class ChartViewController: UIViewController { private func setUpView() { - self.view.backgroundColor = UIColor(named: Colors.background) + self.view.backgroundColor = UIColor(named: UIColor.background) self.view.addSubview(tableView) self.tableView.dataSource = self self.tableView.delegate = self diff --git a/MovieApp/MovieApp/Presentation/CreditView/View/CreditTableViewDescriptionCell.swift b/MovieApp/MovieApp/Presentation/CreditView/View/CreditTableViewDescriptionCell.swift index 86e7177..20b524c 100644 --- a/MovieApp/MovieApp/Presentation/CreditView/View/CreditTableViewDescriptionCell.swift +++ b/MovieApp/MovieApp/Presentation/CreditView/View/CreditTableViewDescriptionCell.swift @@ -37,7 +37,7 @@ class CreditTableViewDescriptionCell: UITableViewCell { private func setupView() { self.addSubview(descriptionView) - descriptionView.backgroundColor = UIColor(named: Colors.background) + descriptionView.backgroundColor = UIColor(named: UIColor.background) descriptionView.snp.makeConstraints { $0.edges.equalToSuperview() } } diff --git a/MovieApp/MovieApp/Presentation/CreditView/View/CreditViewController.swift b/MovieApp/MovieApp/Presentation/CreditView/View/CreditViewController.swift index e27c4ad..0951320 100644 --- a/MovieApp/MovieApp/Presentation/CreditView/View/CreditViewController.swift +++ b/MovieApp/MovieApp/Presentation/CreditView/View/CreditViewController.swift @@ -17,11 +17,11 @@ class CreditViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - self.view.backgroundColor = UIColor(named: Colors.background) + self.view.backgroundColor = UIColor(named: UIColor.background) tableView = UITableView(frame: self.view.frame, style: .insetGrouped) - tableView.backgroundColor = UIColor(named: Colors.background) - tableView.separatorColor = UIColor(named: Colors.background) + tableView.backgroundColor = UIColor(named: UIColor.background) + tableView.separatorColor = UIColor(named: UIColor.background) tableView.register(UITableViewCell.self, forCellReuseIdentifier: identifiers.credit_table_cell) tableView.bounces = false @@ -60,7 +60,7 @@ extension CreditViewController: UITableViewDataSource { if indexPath.section == 0 { let cell = tableView.dequeueReusableCell(withIdentifier: identifiers.credit_table_cell, for: indexPath) as UITableViewCell - cell.backgroundColor = UIColor(named: Colors.light_background) + cell.backgroundColor = UIColor(named: UIColor.light_background) cell.textLabel?.textColor = .white let data = ExternalLink.data[indexPath.row] diff --git a/MovieApp/MovieApp/Presentation/DetailView/View/DetailViewController.swift b/MovieApp/MovieApp/Presentation/DetailView/View/DetailViewController.swift index 95d6611..c3e5635 100644 --- a/MovieApp/MovieApp/Presentation/DetailView/View/DetailViewController.swift +++ b/MovieApp/MovieApp/Presentation/DetailView/View/DetailViewController.swift @@ -124,7 +124,7 @@ class DetailViewController: UIViewController { private func setUpView() { self.navigationController?.setNavigationBarHidden(true, animated: false) - self.view.backgroundColor = UIColor(named: Colors.background) + self.view.backgroundColor = UIColor(named: UIColor.background) scrollView.contentInsetAdjustmentBehavior = .never scrollView.bounces = false } diff --git a/MovieApp/MovieApp/Presentation/DiscoverView/View/DiscoverCollectionHeaderView.swift b/MovieApp/MovieApp/Presentation/DiscoverView/View/DiscoverCollectionHeaderView.swift index 4745187..cb656b3 100644 --- a/MovieApp/MovieApp/Presentation/DiscoverView/View/DiscoverCollectionHeaderView.swift +++ b/MovieApp/MovieApp/Presentation/DiscoverView/View/DiscoverCollectionHeaderView.swift @@ -26,10 +26,10 @@ class DiscoverCollectionHeaderView: UICollectionReusableView { lazy var searchField = PaddingTextField().then { $0.layer.cornerRadius = 20 - $0.backgroundColor = UIColor(named: Colors.light_background) + $0.backgroundColor = UIColor(named: UIColor.light_background) $0.textColor = .white - let placeholderColor = UIColor(named: Colors.placeholder) ?? UIColor.lightGray + let placeholderColor = UIColor(named: UIColor.placeholder) ?? UIColor.lightGray $0.attributedPlaceholder = NSAttributedString( string: "Search...", attributes: [NSAttributedString.Key.foregroundColor: placeholderColor] diff --git a/MovieApp/MovieApp/Presentation/DiscoverView/View/DiscoverViewController.swift b/MovieApp/MovieApp/Presentation/DiscoverView/View/DiscoverViewController.swift index 47af56d..6d1b640 100644 --- a/MovieApp/MovieApp/Presentation/DiscoverView/View/DiscoverViewController.swift +++ b/MovieApp/MovieApp/Presentation/DiscoverView/View/DiscoverViewController.swift @@ -28,7 +28,7 @@ class DiscoverViewController: UIViewController { var collectionView = UICollectionView(frame: self.view.frame, collectionViewLayout: flowLayout) collectionView.register(DiscoverCollectionViewCell.self, forCellWithReuseIdentifier: identifiers.discover_collection_cell) collectionView.register(DiscoverCollectionHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: identifiers.discover_collection_header) - collectionView.backgroundColor = UIColor(named: Colors.background) + collectionView.backgroundColor = UIColor(named: UIColor.background) return collectionView }() @@ -45,7 +45,7 @@ class DiscoverViewController: UIViewController { private func setUpView() { self.title = "Discover" - self.view.backgroundColor = UIColor(named: Colors.background) + self.view.backgroundColor = UIColor(named: UIColor.background) self.dismissKeyboard() collectionView.dataSource = self diff --git a/MovieApp/MovieApp/Presentation/MainTabBarController.swift b/MovieApp/MovieApp/Presentation/MainTabBarController.swift index 7ead52b..ce1d9d5 100644 --- a/MovieApp/MovieApp/Presentation/MainTabBarController.swift +++ b/MovieApp/MovieApp/Presentation/MainTabBarController.swift @@ -11,7 +11,7 @@ class MainTabBarController: UITabBarController, UITabBarControllerDelegate { let appearance = UITabBarAppearance().then { $0.configureWithOpaqueBackground() - $0.backgroundColor = UIColor(named: Colors.light_background) + $0.backgroundColor = UIColor(named: UIColor.light_background) } override func viewDidLoad() {