Skip to content

Commit

Permalink
GamesVC collection view is done
Browse files Browse the repository at this point in the history
  • Loading branch information
aligunes195 committed May 9, 2021
1 parent 138b147 commit 7825d0b
Show file tree
Hide file tree
Showing 21 changed files with 436 additions and 24 deletions.
40 changes: 38 additions & 2 deletions games.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
objects = {

/* Begin PBXBuildFile section */
8811FE7C26485CF900E78864 /* GameCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8811FE7B26485CF900E78864 /* GameCell.swift */; };
8811FE7F26485D0500E78864 /* GamePresentation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8811FE7E26485D0500E78864 /* GamePresentation.swift */; };
8811FE8526487D6C00E78864 /* Games.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8811FE8426487D6C00E78864 /* Games.storyboard */; };
8811FE882648882A00E78864 /* UIStoryboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8811FE872648882900E78864 /* UIStoryboard.swift */; };
8811FE8B264888AD00E78864 /* StoryboardName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8811FE8A264888AD00E78864 /* StoryboardName.swift */; };
8811FE8F26488E3400E78864 /* SearchListResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8811FE8E26488E3400E78864 /* SearchListResponseDTO.swift */; };
8811FE92264894F500E78864 /* SearchResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8811FE91264894F500E78864 /* SearchResponseDTO.swift */; };
8811FE952648955D00E78864 /* GenreResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8811FE942648955D00E78864 /* GenreResponseDTO.swift */; };
885314E424791CD50054F839 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 885314E324791CD50054F839 /* Assets.xcassets */; };
8894A170248314A40009F8A6 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8894A16F248314A40009F8A6 /* App.swift */; };
8894A173248318ED0009F8A6 /* RouterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8894A172248318ED0009F8A6 /* RouterProtocol.swift */; };
Expand Down Expand Up @@ -47,6 +55,15 @@
/* Begin PBXFileReference section */
21F39E2EE8617D42975A0C21 /* Pods-games.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-games.release.xcconfig"; path = "Target Support Files/Pods-games/Pods-games.release.xcconfig"; sourceTree = "<group>"; };
7B508184064393999C6F3BD7 /* libPods-games.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-games.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8811FE7B26485CF900E78864 /* GameCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameCell.swift; sourceTree = "<group>"; };
8811FE7E26485D0500E78864 /* GamePresentation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GamePresentation.swift; sourceTree = "<group>"; };
8811FE81264870EA00E78864 /* games.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = games.entitlements; sourceTree = "<group>"; };
8811FE8426487D6C00E78864 /* Games.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Games.storyboard; sourceTree = "<group>"; };
8811FE872648882900E78864 /* UIStoryboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIStoryboard.swift; sourceTree = "<group>"; };
8811FE8A264888AD00E78864 /* StoryboardName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryboardName.swift; sourceTree = "<group>"; };
8811FE8E26488E3400E78864 /* SearchListResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchListResponseDTO.swift; sourceTree = "<group>"; };
8811FE91264894F500E78864 /* SearchResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResponseDTO.swift; sourceTree = "<group>"; };
8811FE942648955D00E78864 /* GenreResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenreResponseDTO.swift; sourceTree = "<group>"; };
885314D724791CCF0054F839 /* games.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = games.app; sourceTree = BUILT_PRODUCTS_DIR; };
885314E324791CD50054F839 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
885314E824791CD50054F839 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -137,6 +154,7 @@
885314D924791CCF0054F839 /* games */ = {
isa = PBXGroup;
children = (
8811FE81264870EA00E78864 /* games.entitlements */,
8894A16C248312E40009F8A6 /* App */,
8894A17D24832DC20009F8A6 /* Component */,
8894A191248336D30009F8A6 /* Extension */,
Expand Down Expand Up @@ -221,6 +239,7 @@
8894A17D24832DC20009F8A6 /* Component */ = {
isa = PBXGroup;
children = (
8811FE8A264888AD00E78864 /* StoryboardName.swift */,
8894A17E24832DD30009F8A6 /* Navigation */,
);
path = Component;
Expand All @@ -242,17 +261,21 @@
8894A1A0248457560009F8A6 /* GamesContract.swift */,
8894A18F2483328B0009F8A6 /* GamesVC.swift */,
8894A1A2248457640009F8A6 /* GamesVM.swift */,
8811FE7B26485CF900E78864 /* GameCell.swift */,
8811FE7E26485D0500E78864 /* GamePresentation.swift */,
8811FE8426487D6C00E78864 /* Games.storyboard */,
);
path = Games;
sourceTree = "<group>";
};
8894A191248336D30009F8A6 /* Extension */ = {
isa = PBXGroup;
children = (
8894A192248336E80009F8A6 /* String.swift */,
88961E5226480220008FA7ED /* Data.swift */,
88961E5526480A9F008FA7ED /* Print.swift */,
88961E5826480F08008FA7ED /* Encodable.swift */,
88961E5526480A9F008FA7ED /* Print.swift */,
8894A192248336E80009F8A6 /* String.swift */,
8811FE872648882900E78864 /* UIStoryboard.swift */,
);
path = Extension;
sourceTree = "<group>";
Expand Down Expand Up @@ -281,6 +304,9 @@
children = (
88961E5C26482034008FA7ED /* SearchRequestDTO.swift */,
88961E5F264836B4008FA7ED /* DetailRequestDTO.swift */,
8811FE8E26488E3400E78864 /* SearchListResponseDTO.swift */,
8811FE91264894F500E78864 /* SearchResponseDTO.swift */,
8811FE942648955D00E78864 /* GenreResponseDTO.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -364,6 +390,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8811FE8526487D6C00E78864 /* Games.storyboard in Resources */,
8894A19D24833F5B0009F8A6 /* LaunchScreen.storyboard in Resources */,
8894A1962483385F0009F8A6 /* Localizable.strings in Resources */,
885314E424791CD50054F839 /* Assets.xcassets in Resources */,
Expand Down Expand Up @@ -404,18 +431,23 @@
files = (
88961E3C2647F9D6008FA7ED /* NetworkManager.swift in Sources */,
88B697702647DADF00E36A1F /* FavouritesVM.swift in Sources */,
8811FE952648955D00E78864 /* GenreResponseDTO.swift in Sources */,
8894A173248318ED0009F8A6 /* RouterProtocol.swift in Sources */,
8811FE7C26485CF900E78864 /* GameCell.swift in Sources */,
8894A19B24833E720009F8A6 /* MainContainer.swift in Sources */,
88961E5926480F08008FA7ED /* Encodable.swift in Sources */,
88B6974C2647B69D00E36A1F /* AppDelegate.swift in Sources */,
8894A1A3248457640009F8A6 /* GamesVM.swift in Sources */,
8894A1902483328B0009F8A6 /* GamesVC.swift in Sources */,
88B48598249571C8002D8DD8 /* NavigatingRouterProtocol.swift in Sources */,
8811FE92264894F500E78864 /* SearchResponseDTO.swift in Sources */,
8894A19F248457410009F8A6 /* GamesBuilder.swift in Sources */,
8894A18024832DF90009F8A6 /* MainTabBarController.swift in Sources */,
8811FE882648882A00E78864 /* UIStoryboard.swift in Sources */,
88B697732647DAEF00E36A1F /* FavouritesContract.swift in Sources */,
8894A186248331120009F8A6 /* GamesRouter.swift in Sources */,
8894A184248330F80009F8A6 /* FavouritesRouter.swift in Sources */,
8811FE8B264888AD00E78864 /* StoryboardName.swift in Sources */,
8894A193248336E80009F8A6 /* String.swift in Sources */,
8894A1A5248C2F8F0009F8A6 /* ContainerProtocol.swift in Sources */,
8894A1A1248457560009F8A6 /* GamesContract.swift in Sources */,
Expand All @@ -428,6 +460,8 @@
88961E492647FFDA008FA7ED /* NetworkService.swift in Sources */,
88961E5626480A9F008FA7ED /* Print.swift in Sources */,
88961E60264836B4008FA7ED /* DetailRequestDTO.swift in Sources */,
8811FE7F26485D0500E78864 /* GamePresentation.swift in Sources */,
8811FE8F26488E3400E78864 /* SearchListResponseDTO.swift in Sources */,
88961E5D26482034008FA7ED /* SearchRequestDTO.swift in Sources */,
8894A1762483199E0009F8A6 /* MainRouter.swift in Sources */,
8894A170248314A40009F8A6 /* App.swift in Sources */,
Expand Down Expand Up @@ -574,6 +608,7 @@
baseConfigurationReference = B5F154B7502FE26A75EA5066 /* Pods-games.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = games/games.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = CX3V6YWNLY;
INFOPLIST_FILE = games/Info.plist;
Expand All @@ -594,6 +629,7 @@
baseConfigurationReference = 21F39E2EE8617D42975A0C21 /* Pods-games.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = games/games.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = CX3V6YWNLY;
INFOPLIST_FILE = games/Info.plist;
Expand Down
2 changes: 1 addition & 1 deletion games/App/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class App {
}

func start() {
self.window.rootViewController = self.router.rootVC
self.router.start()
self.window.makeKeyAndVisible()
}
}
30 changes: 30 additions & 0 deletions games/App/AppConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,34 @@ final class AppConfiguration {

let baseUrl = "https://api.rawg.io"
let apiKey = "5f3f08b28e8745b599aed7512634c491"

var bundleIdentifier: String {
guard let id = Bundle.main.bundleIdentifier else {
fatalError("Bundle Identifier not found")
}
return id
}

var appGroupContainerURL: URL {
guard let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.alig.games") else {
fatalError("App Group Container URL not found")
}
return url
}

var cachedImagesURL: URL {
let url = appGroupContainerURL.appendingPathComponent("cachedImages")

try? FileManager.default.createDirectory(at: url, withIntermediateDirectories: true, attributes: nil)

return url
}

var cachedThumbnailsURL: URL {
let url = appGroupContainerURL.appendingPathComponent("cachedThumbnails")

try? FileManager.default.createDirectory(at: url, withIntermediateDirectories: true, attributes: nil)

return url
}
}
2 changes: 2 additions & 0 deletions games/App/Protocol/RouterProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ import UIKit

protocol RouterProtocol: class {
var rootVC: UIViewController { get }

func start()
}
10 changes: 7 additions & 3 deletions games/App/Router/FavouritesRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
import UIKit

final class FavouritesRouter: NavigatingRouterProtocol {
let rootVC: UIViewController
let navController: UINavigationController

lazy var rootVC: UIViewController = FavouritesBuilder.build()

init() {
rootVC = FavouritesBuilder.build()
navController = UINavigationController(rootViewController: rootVC)
navController = UINavigationController()
navController.view.backgroundColor = .white
navController.tabBarItem = UITabBarItem(title: String.localized("FAVOURITES_TITLE"),
image: UIImage(named: "favourite-icon"),
selectedImage: UIImage(named: "favourite-icon"))
navController.navigationBar.prefersLargeTitles = true
}

func start() {
navController.setViewControllers([rootVC], animated: false)
}
}
17 changes: 14 additions & 3 deletions games/App/Router/GamesRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,27 @@
import UIKit

final class GamesRouter: NavigatingRouterProtocol {
let rootVC: UIViewController
let navController: UINavigationController

lazy var rootVC: UIViewController = GamesBuilder.build()

init() {
rootVC = GamesBuilder.build()
navController = UINavigationController(rootViewController: rootVC)
navController = UINavigationController()
navController.view.backgroundColor = .white
navController.tabBarItem = UITabBarItem(title: String.localized("GAMES_TITLE"),
image: UIImage(named: "game-console-icon"),
selectedImage: UIImage(named: "game-console-icon"))
navController.navigationBar.prefersLargeTitles = true
}

func start() {
(rootVC as! GamesVC).routerDelegate = self
navController.setViewControllers([rootVC], animated: false)
}
}

extension GamesRouter: GamesNavigationDelegate {
func showDetail(with id: Int) {

}
}
21 changes: 13 additions & 8 deletions games/App/Router/MainRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
import UIKit

final class MainRouter: RouterProtocol {
let rootVC: UIViewController
lazy var rootVC: UIViewController = {
let tabBarController = MainTabBarController()
tabBarController.viewControllers = childRouters
.sorted(by: { $0.key.rawValue < $1.key.rawValue })
.map { $0.value.navController }
tabBarController.changeScene(.games)
return tabBarController
}()

private let childRouters: [MainScene: NavigatingRouterProtocol]

Expand All @@ -18,12 +25,10 @@ final class MainRouter: RouterProtocol {
.games : GamesRouter(),
.favourites : FavouritesRouter()
]

let tabBarController = MainTabBarController()
tabBarController.viewControllers = childRouters
.sorted(by: { $0.key.rawValue < $1.key.rawValue })
.map { $0.value.navController }
tabBarController.changeScene(.games)
rootVC = tabBarController
}

func start() {
childRouters.values.forEach { $0.start() }
app.window.rootViewController = self.rootVC
}
}
13 changes: 13 additions & 0 deletions games/Component/StoryboardName.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// StoryboardName.swift
// games
//
// Created by ali güneş on 10.05.2021.
// Copyright © 2021 ali güneş. All rights reserved.
//

import Foundation

enum StoryboardName: String {
case games = "Games"
}
21 changes: 21 additions & 0 deletions games/Extension/UIStoryboard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// UIStoryboard.swift
// games
//
// Created by ali güneş on 10.05.2021.
// Copyright © 2021 ali güneş. All rights reserved.
//

import UIKit

extension UIStoryboard {
static func load(_ name: StoryboardName, identifier: String? = nil) -> UIViewController {
let sb = UIStoryboard(name: name.rawValue, bundle: nil)

if let identifier = identifier {
return sb.instantiateViewController(withIdentifier: identifier)
} else {
return sb.instantiateInitialViewController()!
}
}
}
2 changes: 1 addition & 1 deletion games/Manager/NetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Alamofire

final class NetworkManager {
private let networkQueue = DispatchQueue(label: "asdasf", attributes: .concurrent)
private let networkQueue = DispatchQueue(label: "\(AppConfiguration.shared.bundleIdentifier).network.manager.queue", attributes: .concurrent)

@discardableResult
func request(_ service: NetworkService, completion: ((NetworkResult<Data>) -> Void)?) -> DataRequest? {
Expand Down
14 changes: 14 additions & 0 deletions games/Network/Model/GenreResponseDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// GenreResponseDTO.swift
// games
//
// Created by ali güneş on 10.05.2021.
// Copyright © 2021 ali güneş. All rights reserved.
//

import Foundation

struct GenreResponseDTO: Decodable {
let id: Int
let name: String
}
13 changes: 13 additions & 0 deletions games/Network/Model/SearchListResponseDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// SearchListResponseDTO.swift
// games
//
// Created by ali güneş on 10.05.2021.
// Copyright © 2021 ali güneş. All rights reserved.
//

import Foundation

struct SearchListResponseDTO: Decodable {
let results: [SearchResponseDTO]
}
17 changes: 17 additions & 0 deletions games/Network/Model/SearchResponseDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// SearchResponseDTO.swift
// games
//
// Created by ali güneş on 10.05.2021.
// Copyright © 2021 ali güneş. All rights reserved.
//

import Foundation

struct SearchResponseDTO: Decodable {
let id: Int
let name: String
let metacritic: Int?
let background_image: String
let genres: [GenreResponseDTO]
}
Loading

0 comments on commit 7825d0b

Please sign in to comment.