Skip to content

Commit

Permalink
refactor : 파일 분리, 메소드 이름 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
eeeesong committed May 7, 2021
1 parent dc51e18 commit 7c185b1
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 37 deletions.
50 changes: 45 additions & 5 deletions iOS/baseball-game/baseball-game.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
E4FE76F8264407E600151B35 /* TeamScoreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4FE76F7264407E600151B35 /* TeamScoreView.swift */; };
E4FE76FA2644108900151B35 /* PitcherInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4FE76F92644108900151B35 /* PitcherInfoView.swift */; };
E4FE76FC2644136600151B35 /* BatterInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4FE76FB2644136600151B35 /* BatterInfoView.swift */; };
E4FE77062644DCBC00151B35 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4FE77052644DCBC00151B35 /* Team.swift */; };
E4FE77082644DCC500151B35 /* GameInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4FE77072644DCC500151B35 /* GameInfo.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -62,6 +64,8 @@
E4FE76F7264407E600151B35 /* TeamScoreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeamScoreView.swift; sourceTree = "<group>"; };
E4FE76F92644108900151B35 /* PitcherInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PitcherInfoView.swift; sourceTree = "<group>"; };
E4FE76FB2644136600151B35 /* BatterInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatterInfoView.swift; sourceTree = "<group>"; };
E4FE77052644DCBC00151B35 /* Team.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Team.swift; sourceTree = "<group>"; };
E4FE77072644DCC500151B35 /* GameInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameInfo.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -88,10 +92,9 @@
children = (
AEFE32D92643971B0077AA5F /* LoginViewController.swift */,
AE7A1541263FE4DE005EBAB9 /* SelectionViewController.swift */,
AE5C79B6264138E70075EBC3 /* SelectViewModel.swift */,
AE5C79AD2640E8710075EBC3 /* GameCell.swift */,
AE5C79AE2640E8710075EBC3 /* GameCell.xib */,
AE5C79B1264127300075EBC3 /* Game.swift */,
E4FE77012644DC4200151B35 /* View */,
E4FE77022644DC4B00151B35 /* Model */,
E4FE77032644DC7700151B35 /* ViewModel */,
);
path = Selection;
sourceTree = "<group>";
Expand Down Expand Up @@ -140,9 +143,9 @@
isa = PBXGroup;
children = (
E4AA6886263FDDA500139BD6 /* GamePlayViewController.swift */,
E4FE76EA2643BDA800151B35 /* GamePlayViewModel.swift */,
E4FE76F6264407BA00151B35 /* View */,
E4FE76E92643B67000151B35 /* Model */,
E4FE77042644DC9E00151B35 /* ViewModel */,
E4FE76E82643B60B00151B35 /* SelectPitcher */,
);
path = GamePlay;
Expand Down Expand Up @@ -180,6 +183,41 @@
path = View;
sourceTree = "<group>";
};
E4FE77012644DC4200151B35 /* View */ = {
isa = PBXGroup;
children = (
AE5C79AD2640E8710075EBC3 /* GameCell.swift */,
AE5C79AE2640E8710075EBC3 /* GameCell.xib */,
);
path = View;
sourceTree = "<group>";
};
E4FE77022644DC4B00151B35 /* Model */ = {
isa = PBXGroup;
children = (
AE5C79B1264127300075EBC3 /* Game.swift */,
E4FE77052644DCBC00151B35 /* Team.swift */,
E4FE77072644DCC500151B35 /* GameInfo.swift */,
);
path = Model;
sourceTree = "<group>";
};
E4FE77032644DC7700151B35 /* ViewModel */ = {
isa = PBXGroup;
children = (
AE5C79B6264138E70075EBC3 /* SelectViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
};
E4FE77042644DC9E00151B35 /* ViewModel */ = {
isa = PBXGroup;
children = (
E4FE76EA2643BDA800151B35 /* GamePlayViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -260,6 +298,7 @@
E4FE76DF26438ABC00151B35 /* PitchListTableViewCell.swift in Sources */,
E4FE76D82641242400151B35 /* SelectPitcherViewController.swift in Sources */,
AEFE32DA2643971B0077AA5F /* LoginViewController.swift in Sources */,
E4FE77062644DCBC00151B35 /* Team.swift in Sources */,
AE5C79AF2640E8710075EBC3 /* GameCell.swift in Sources */,
E4FE76ED2643DA3400151B35 /* Turn.swift in Sources */,
AE5C79B2264127300075EBC3 /* Game.swift in Sources */,
Expand All @@ -271,6 +310,7 @@
AE5C79B426412B830075EBC3 /* Network.swift in Sources */,
E4FE76EF2643DA4600151B35 /* Player.swift in Sources */,
E4FE76F12643DA5600151B35 /* Pitch.swift in Sources */,
E4FE77082644DCC500151B35 /* GameInfo.swift in Sources */,
E4AA6885263FDDA500139BD6 /* SceneDelegate.swift in Sources */,
E4FE76F32643DA7300151B35 /* GameManagable.swift in Sources */,
);
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GamePlayViewController: UIViewController {
private var gamePlayViewModel: GamePlayViewModel!
private var dataSource: UITableViewDiffableDataSource<Int, Pitch>!

private let isUserHomeSide = true // 게임 선택 시 값을 지정해줄 수 있도록 한다 (prepare segue?)
private let isUserHomeSide = true
private var cancelBag = Set<AnyCancellable>()

override func viewDidLoad() {
Expand Down Expand Up @@ -61,7 +61,7 @@ class GamePlayViewController: UIViewController {
.receive(on: DispatchQueue.main)
.sink { error in
guard let error = error else { return }
print(error) //사용자에게 에러 표시!
print(error) ///사용자에게 에러 표시하는 부분 미구현
}.store(in: &cancelBag)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GamePlayViewModel {
}

func requestGame() {
NetworkManager.request(type: GameManager.self, url: EndPoint.url(path: "/1/attack")!)
NetworkManager.get(type: GameManager.self, url: EndPoint.url(path: "/1/attack")!)
.sink { error in
self.error = error as? Error
} receiveValue: { data in
Expand Down
4 changes: 2 additions & 2 deletions iOS/baseball-game/baseball-game/Network/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum EndPoint {

class NetworkManager {

static func request<T: Decodable>(type: T.Type, url: URL) -> AnyPublisher<T, Error> {
static func get<T: Decodable>(type: T.Type, url: URL) -> AnyPublisher<T, Error> {

return URLSession.shared.dataTaskPublisher(for: url)
.tryMap { element -> Data in
Expand All @@ -54,7 +54,7 @@ class NetworkManager {
return Just(data)
.encode(encoder: JSONEncoder())
.mapError { error -> Error in
print(error)
print(error) ///사용자에게 에러 표시하는 부분 미구현
return error
}
.map { data -> URLRequest in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,3 @@ struct Game: Codable, Hashable {
var home: Team = Team()
var away: Team = Team()
}

struct Team: Codable, Hashable {
var team: String = ""
var status: String = ""
}

struct GameInfo: Codable {
var userID: String = ""
var gameID: Int = 0
var team: String = ""
}
14 changes: 14 additions & 0 deletions iOS/baseball-game/baseball-game/Selection/Model/GameInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// GameInfo.swift
// baseball-game
//
// Created by Song on 2021/05/07.
//

import Foundation

struct GameInfo: Codable {
var userID: String = ""
var gameID: Int = 0
var team: String = ""
}
13 changes: 13 additions & 0 deletions iOS/baseball-game/baseball-game/Selection/Model/Team.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Team.swift
// baseball-game
//
// Created by Song on 2021/05/07.
//

import Foundation

struct Team: Codable, Hashable {
var team: String = ""
var status: String = ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,7 @@ class SelectionViewController: UIViewController {
self.configureDataSource()
self.createSnapshot()
}

//임시
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

let gamePlayStoryboard = UIStoryboard.init(name: GamePlayViewController.ViewID.storyboard, bundle: nil)

guard let nextVC = gamePlayStoryboard.instantiateViewController(identifier: GamePlayViewController.ViewID.controller) as? GamePlayViewController else { return }

nextVC.modalPresentationStyle = .fullScreen
present(nextVC, animated: true, completion: nil)
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ class SelectViewModel {
}

//MARK: GET

func request() {
NetworkManager.request(type: [Game].self, url: EndPoint.url(path: "")!)
NetworkManager.get(type: [Game].self, url: EndPoint.url(path: "")!)
.receive(on: DispatchQueue.main)
.sink { error in
print(error)
print(error) ///사용자에게 에러 표시하는 부분 미구현
} receiveValue: { games in
self.fetch(data: games)
}
Expand All @@ -47,9 +46,9 @@ class SelectViewModel {
NetworkManager.post(url: EndPoint.url(path: "")!, data: gameInfo)
.receive(on: DispatchQueue.main)
.sink { error in
print(error)
print(error) ///사용자에게 에러 표시하는 부분 미구현
} receiveValue: { _ in
print("success")
print("success") ///서버 POST 기능 미구현
}
.store(in: &cancellable)
}
Expand Down

0 comments on commit 7c185b1

Please sign in to comment.