Skip to content

Commit

Permalink
Merge branch 'develop' into feature/my-page-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
radiantchoi authored Dec 1, 2022
2 parents 3623d2d + 4cbc493 commit c03d2fd
Show file tree
Hide file tree
Showing 19 changed files with 433 additions and 47 deletions.
40 changes: 40 additions & 0 deletions Segno/Segno.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
66A8CF6D29379A9900C17F84 /* UserDetailEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66A8CF6C29379A9900C17F84 /* UserDetailEndpoint.swift */; };
66F0D7EE2925FF8B0074872E /* DiaryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66F0D7ED2925FF8B0074872E /* DiaryCell.swift */; };
66F0D7F729260BA20074872E /* GoogleSignIn in Frameworks */ = {isa = PBXBuildFile; productRef = 66F0D7F629260BA20074872E /* GoogleSignIn */; };
791529D82932F364005A8DDB /* DiaryEditUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 791529D72932F364005A8DDB /* DiaryEditUseCase.swift */; };
791529DC29332CF2005A8DDB /* ImageDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 791529DB29332CF2005A8DDB /* ImageDTO.swift */; };
791529DE29333D40005A8DDB /* ImageEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 791529DD29333D40005A8DDB /* ImageEndpoint.swift */; };
791529E0293344E9005A8DDB /* DiaryPostEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 791529DF293344E8005A8DDB /* DiaryPostEndpoint.swift */; };
791837FA292225C600BC6992 /* Cafe24Shiningstar.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 791837F7292225BF00BC6992 /* Cafe24Shiningstar.ttf */; };
791837FB292225C800BC6992 /* Cafe24Ssurround.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 791837F9292225BF00BC6992 /* Cafe24Ssurround.ttf */; };
791837FC292225CB00BC6992 /* Cafe24SsurroundAir.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 791837F8292225BF00BC6992 /* Cafe24SsurroundAir.ttf */; };
Expand All @@ -62,6 +66,8 @@
7940FB2F292E063100276EFC /* DiaryDetailDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7940FB2E292E063100276EFC /* DiaryDetailDTO.swift */; };
7940FB31292E065100276EFC /* DiaryDetailEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7940FB30292E065100276EFC /* DiaryDetailEndpoint.swift */; };
7940FB33292E065F00276EFC /* DiaryDetailUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7940FB32292E065F00276EFC /* DiaryDetailUseCase.swift */; };
9825F41B29377875005F2163 /* ChangeUserNameUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9825F41A29377875005F2163 /* ChangeUserNameUseCase.swift */; };
9825F41D29377ACF005F2163 /* SettingsRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9825F41C29377ACF005F2163 /* SettingsRepository.swift */; };
982A2A472924AE74006F6ACD /* UserDefaultsKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 982A2A462924AE74006F6ACD /* UserDefaultsKey.swift */; };
982A3699292C905300FDC6CF /* DiaryDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 982A3698292C905300FDC6CF /* DiaryDetailViewController.swift */; };
982B3B7F292E68FB0077A44B /* DiaryDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 982B3B7E292E68FB0077A44B /* DiaryDetailViewModel.swift */; };
Expand All @@ -75,6 +81,8 @@
988414D72923304F007C9132 /* KeychainError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988414D62923304F007C9132 /* KeychainError.swift */; };
988414D929235345007C9132 /* DiaryCollectionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988414D829235345007C9132 /* DiaryCollectionViewModel.swift */; };
988414DB2923606B007C9132 /* DiaryListUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988414DA2923606B007C9132 /* DiaryListUseCase.swift */; };
9894EAF529373385005F2B15 /* SettingsUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9894EAF429373385005F2B15 /* SettingsUseCase.swift */; };
9894EAF829375281005F2B15 /* DarkMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9894EAF729375281005F2B15 /* DarkMode.swift */; };
98B5263E292CA46C00446413 /* TagView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B5263D292CA46C00446413 /* TagView.swift */; };
98B52640292CB92900446413 /* MusicContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B5263F292CB92900446413 /* MusicContentView.swift */; };
98BEE36E2934907700B20143 /* LoginError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BEE36D2934907700B20143 /* LoginError.swift */; };
Expand Down Expand Up @@ -129,6 +137,10 @@
66A8CF6C29379A9900C17F84 /* UserDetailEndpoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDetailEndpoint.swift; sourceTree = "<group>"; };
66F0D7ED2925FF8B0074872E /* DiaryCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryCell.swift; sourceTree = "<group>"; };
66F0D7EF292605AE0074872E /* Segno.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Segno.entitlements; sourceTree = "<group>"; };
791529D72932F364005A8DDB /* DiaryEditUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryEditUseCase.swift; sourceTree = "<group>"; };
791529DB29332CF2005A8DDB /* ImageDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageDTO.swift; sourceTree = "<group>"; };
791529DD29333D40005A8DDB /* ImageEndpoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageEndpoint.swift; sourceTree = "<group>"; };
791529DF293344E8005A8DDB /* DiaryPostEndpoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryPostEndpoint.swift; sourceTree = "<group>"; };
791837F7292225BF00BC6992 /* Cafe24Shiningstar.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Cafe24Shiningstar.ttf; sourceTree = "<group>"; };
791837F8292225BF00BC6992 /* Cafe24SsurroundAir.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Cafe24SsurroundAir.ttf; sourceTree = "<group>"; };
791837F9292225BF00BC6992 /* Cafe24Ssurround.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Cafe24Ssurround.ttf; sourceTree = "<group>"; };
Expand All @@ -138,6 +150,8 @@
7940FB2E292E063100276EFC /* DiaryDetailDTO.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryDetailDTO.swift; sourceTree = "<group>"; };
7940FB30292E065100276EFC /* DiaryDetailEndpoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryDetailEndpoint.swift; sourceTree = "<group>"; };
7940FB32292E065F00276EFC /* DiaryDetailUseCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryDetailUseCase.swift; sourceTree = "<group>"; };
9825F41A29377875005F2163 /* ChangeUserNameUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeUserNameUseCase.swift; sourceTree = "<group>"; };
9825F41C29377ACF005F2163 /* SettingsRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRepository.swift; sourceTree = "<group>"; };
982A2A462924AE74006F6ACD /* UserDefaultsKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsKey.swift; sourceTree = "<group>"; };
982A3698292C905300FDC6CF /* DiaryDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryDetailViewController.swift; sourceTree = "<group>"; };
982B3B7E292E68FB0077A44B /* DiaryDetailViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryDetailViewModel.swift; sourceTree = "<group>"; };
Expand All @@ -151,6 +165,8 @@
988414D62923304F007C9132 /* KeychainError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainError.swift; sourceTree = "<group>"; };
988414D829235345007C9132 /* DiaryCollectionViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryCollectionViewModel.swift; sourceTree = "<group>"; };
988414DA2923606B007C9132 /* DiaryListUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListUseCase.swift; sourceTree = "<group>"; };
9894EAF429373385005F2B15 /* SettingsUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsUseCase.swift; sourceTree = "<group>"; };
9894EAF729375281005F2B15 /* DarkMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DarkMode.swift; sourceTree = "<group>"; };
98B5263D292CA46C00446413 /* TagView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagView.swift; sourceTree = "<group>"; };
98B5263F292CB92900446413 /* MusicContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicContentView.swift; sourceTree = "<group>"; };
98BEE36D2934907700B20143 /* LoginError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginError.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -235,6 +251,7 @@
4F317792291BEB5E0019BDFC /* Presentation */ = {
isa = PBXGroup;
children = (
9894EAF629375272005F2B15 /* Utility */,
4F31779C291BEE900019BDFC /* Coordinator */,
4F31779B291BEE890019BDFC /* View */,
4F31779A291BEE810019BDFC /* ViewController */,
Expand Down Expand Up @@ -293,6 +310,9 @@
7940FB32292E065F00276EFC /* DiaryDetailUseCase.swift */,
988414DA2923606B007C9132 /* DiaryListUseCase.swift */,
66A8CF682937945300C17F84 /* UserDetailUseCase.swift */,
791529D72932F364005A8DDB /* DiaryEditUseCase.swift */,
9894EAF429373385005F2B15 /* SettingsUseCase.swift */,
9825F41A29377875005F2163 /* ChangeUserNameUseCase.swift */,
);
path = UseCase;
sourceTree = "<group>";
Expand Down Expand Up @@ -371,6 +391,7 @@
982A2A462924AE74006F6ACD /* UserDefaultsKey.swift */,
4F4E0D3D2924B925005ABA8F /* LoginRepository.swift */,
66A8CF642937934A00C17F84 /* MyPageRepository.swift */,
9825F41C29377ACF005F2163 /* SettingsRepository.swift */,
);
path = Repository;
sourceTree = "<group>";
Expand All @@ -391,6 +412,7 @@
7940FB2E292E063100276EFC /* DiaryDetailDTO.swift */,
4F4E0D7A29252526005ABA8F /* TokenDTO.swift */,
66A8CF6A2937947A00C17F84 /* UserDetailDTO.swift */,
791529DB29332CF2005A8DDB /* ImageDTO.swift */,
);
path = DTO;
sourceTree = "<group>";
Expand All @@ -400,8 +422,10 @@
children = (
4FA3242A2923646F00DB04D5 /* DiaryListItemEndpoint.swift */,
7940FB30292E065100276EFC /* DiaryDetailEndpoint.swift */,
791529DF293344E8005A8DDB /* DiaryPostEndpoint.swift */,
4F4E0D7529252236005ABA8F /* LoginEndpoint.swift */,
66A8CF6C29379A9900C17F84 /* UserDetailEndpoint.swift */,
791529DD29333D40005A8DDB /* ImageEndpoint.swift */,
);
path = Endpoints;
sourceTree = "<group>";
Expand Down Expand Up @@ -433,6 +457,14 @@
path = Font;
sourceTree = "<group>";
};
9894EAF629375272005F2B15 /* Utility */ = {
isa = PBXGroup;
children = (
9894EAF729375281005F2B15 /* DarkMode.swift */,
);
path = Utility;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -521,14 +553,17 @@
buildActionMask = 2147483647;
files = (
98F5AD2A292DDDEB00E53E25 /* LocationContentView.swift in Sources */,
791529DE29333D40005A8DDB /* ImageEndpoint.swift in Sources */,
4F4E0D3E2924B925005ABA8F /* LoginRepository.swift in Sources */,
4F9A00212922338E007D9057 /* AppDelegate.swift in Sources */,
983AE9D82935CEE2006547BD /* SettingsViewModel.swift in Sources */,
9825F41D29377ACF005F2163 /* SettingsRepository.swift in Sources */,
66F0D7EE2925FF8B0074872E /* DiaryCell.swift in Sources */,
4F9A00202922337F007D9057 /* LoginViewController.swift in Sources */,
982A2A472924AE74006F6ACD /* UserDefaultsKey.swift in Sources */,
66A8CF6B2937947A00C17F84 /* UserDetailDTO.swift in Sources */,
4F9A001B292227D7007D9057 /* NetworkManager.swift in Sources */,
9894EAF529373385005F2B15 /* SettingsUseCase.swift in Sources */,
9841D6172925FACC00318EA9 /* LoginUseCase.swift in Sources */,
66A8CF6D29379A9900C17F84 /* UserDetailEndpoint.swift in Sources */,
4FEBFAAD291CF62E00E78139 /* DiaryDetail.swift in Sources */,
Expand All @@ -544,6 +579,7 @@
666E6F81291CF49E00CECD4B /* LoginCoordinator.swift in Sources */,
7940FB31292E065100276EFC /* DiaryDetailEndpoint.swift in Sources */,
666E6F85291CF4AD00CECD4B /* MyPageCoordinator.swift in Sources */,
9894EAF829375281005F2B15 /* DarkMode.swift in Sources */,
983AE9D22934F041006547BD /* NicknameCell.swift in Sources */,
983AE9D4293513AD006547BD /* SettingsCellModel.swift in Sources */,
4F4E0D79292522B7005ABA8F /* BaseURL.swift in Sources */,
Expand All @@ -555,11 +591,13 @@
66A8CF672937937300C17F84 /* UserDetailItem.swift in Sources */,
666E6F7D291CF45600CECD4B /* Coordinator.swift in Sources */,
982A3699292C905300FDC6CF /* DiaryDetailViewController.swift in Sources */,
9825F41B29377875005F2163 /* ChangeUserNameUseCase.swift in Sources */,
666E6F8C291CFAC200CECD4B /* DiaryCollectionViewController.swift in Sources */,
666E6F8A291CF82700CECD4B /* TabBarPageCase.swift in Sources */,
66A8CF652937934A00C17F84 /* MyPageRepository.swift in Sources */,
79183800292225DC00BC6992 /* UIFont+.swift in Sources */,
666E6F83291CF4A600CECD4B /* TabBarCoordinator.swift in Sources */,
791529E0293344E9005A8DDB /* DiaryPostEndpoint.swift in Sources */,
4F9A001D29222B1B007D9057 /* Endpoint.swift in Sources */,
4F9A001F29222C97007D9057 /* NetworkError.swift in Sources */,
98FDF8A1292F56580083FA05 /* Location.swift in Sources */,
Expand All @@ -573,12 +611,14 @@
4FA3242B2923646F00DB04D5 /* DiaryListItemEndpoint.swift in Sources */,
791837FF292225DC00BC6992 /* UIColor+.swift in Sources */,
666E6F7F291CF46800CECD4B /* AppCoordinator.swift in Sources */,
791529DC29332CF2005A8DDB /* ImageDTO.swift in Sources */,
9841D61B2926131200318EA9 /* LoginViewModel.swift in Sources */,
988414D72923304F007C9132 /* KeychainError.swift in Sources */,
98BEE36E2934907700B20143 /* LoginError.swift in Sources */,
98B5263E292CA46C00446413 /* TagView.swift in Sources */,
7940FB2F292E063100276EFC /* DiaryDetailDTO.swift in Sources */,
4F4E0D7629252236005ABA8F /* LoginEndpoint.swift in Sources */,
791529D82932F364005A8DDB /* DiaryEditUseCase.swift in Sources */,
4FA324262923600C00DB04D5 /* DiaryListDTO.swift in Sources */,
666E6F87291CF4B400CECD4B /* DiaryCoordinator.swift in Sources */,
4F31777F291BE4710019BDFC /* SceneDelegate.swift in Sources */,
Expand Down
8 changes: 7 additions & 1 deletion Segno/Segno/Data/Network/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum HTTPMethod: String {
enum HTTPRequestParameter {
case queries(Queries)
case body(Body)
case data(Data)
}

// MARK: Endpoint 본체
Expand All @@ -35,7 +36,12 @@ protocol Endpoint {

extension Endpoint {
var headers: Headers {
return ["Content-Type": "application/json"]
switch self.parameters {
case .data(_):
return ["Content-Type": "multipart/form-data; boundary=SEGNO"]
default:
return ["Content-Type": "application/json"]
}
}

func toURLRequest() throws -> URLRequest {
Expand Down
31 changes: 31 additions & 0 deletions Segno/Segno/Data/Network/Endpoints/DiaryPostEndpoint.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// DiaryPostEndpoint.swift
// Segno
//
// Created by TaehoYoo on 2022/11/27.
//

import Foundation

enum DiaryPostEndpoint: Endpoint {
case item(DiaryDetail)

var baseURL: URL? {
return URL(string: BaseURL.urlString)
}

var httpMethod: HTTPMethod {
return .GET
}

var path: String {
return "diary"
}

var parameters: HTTPRequestParameter? {
switch self {
case .item(let diary):
return HTTPRequestParameter.body(diary)
}
}
}
31 changes: 31 additions & 0 deletions Segno/Segno/Data/Network/Endpoints/ImageEndpoint.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// ImageEndpoint.swift
// Segno
//
// Created by TaehoYoo on 2022/11/27.
//

import Foundation

enum ImageEndpoint: Endpoint {
case item(Data)

var baseURL: URL? {
return URL(string: BaseURL.urlString)
}

var httpMethod: HTTPMethod {
return .POST
}

var path: String {
return "image"
}

var parameters: HTTPRequestParameter? {
switch self {
case .item(let image):
return HTTPRequestParameter.data(image)
}
}
}
43 changes: 38 additions & 5 deletions Segno/Segno/Data/Network/NetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ struct NetworkManager {
return Disposables.create()
}
}

return call(request)
switch endpoint.parameters {
case .data(let data):
return call(request, type: .uploadTask, data: buildDataBody(data))
default:
return call(request)
}
}

private func call(_ request: URLRequest) -> Single<Data> {
return Single.create { observer -> Disposable in
let task = URLSession.shared.dataTask(with: request) { data, response, error in
private func call(_ request: URLRequest, type: SessionType = .dataTask, data: Data? = nil) -> Single<Data> {
Single.create { observer -> Disposable in
let completeHandler: (Data?, URLResponse?, Error?) -> Void = { data, response, error in
if error != nil {
observer(.failure(NetworkError.unknownNetworkError))
return
Expand All @@ -53,8 +57,37 @@ struct NetworkManager {
}
}

let task = {
switch type {
case .dataTask:
return URLSession.shared.dataTask(with: request, completionHandler: completeHandler)
case .uploadTask:
return URLSession.shared.uploadTask(with: request, from: data, completionHandler: completeHandler)
}
}()

task.resume()
return Disposables.create()
}
}

func buildDataBody(_ data: Data) -> Data? {
let boundary = "SEGNO"
let headerLines = [
"--\(boundary)",
"Content-Disposition: form-data; name=\"image\"; filename=\"testImage\"",
"Content-Type: image/png",
"\r\n"
]
var body = headerLines.joined(separator: "\r\n").data(using: .utf8)!
body.append(contentsOf: data)
body.append(contentsOf: "\r\n--\(boundary)--".data(using: .utf8)!)

return body
}

enum SessionType {
case dataTask
case uploadTask
}
}
10 changes: 10 additions & 0 deletions Segno/Segno/Data/Repository/DTO/ImageDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// ImageDTO.swift
// Segno
//
// Created by TaehoYoo on 2022/11/27.
//

struct ImageDTO: Decodable {
let filename: String?
}
Loading

0 comments on commit c03d2fd

Please sign in to comment.