Skip to content

Commit

Permalink
Merge pull request #159 from tukcomCD2024/Feat/#156_ios_modifydebatel…
Browse files Browse the repository at this point in the history
…ogic

Feat/#156 ios modifydebatelogic
  • Loading branch information
yeahzxnn authored Jun 20, 2024
2 parents ec8031e + 0f82def commit 7681269
Show file tree
Hide file tree
Showing 50 changed files with 1,807 additions and 468 deletions.
Binary file modified iOS/RollTheDice/.DS_Store
Binary file not shown.
198 changes: 167 additions & 31 deletions iOS/RollTheDice/RollTheDice.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions iOS/RollTheDice/RollTheDice/RollTheDiceApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct RollTheDiceApp: App {
var signUpViewModel = SignUpViewModel()

var newsListViewModel = NewsListViewModel()
@StateObject var bookmarkListViewModel = BookmarkListViewModel()
var bookmarkListViewModel = BookmarksListViewModel()

init() {
KakaoSDK.initSDK(appKey: "ff09b3d83873ed4e320f0d6bc90759d6")
Expand All @@ -46,7 +46,7 @@ struct RollTheDiceApp: App {
// 각 뷰마다 .navigationBarBackButtonHidden() 설정하기!
switch pathType {
case .chatView(isAiMode: true) :
GPTChatView()
GPTChatView(topic: "토픽", roomId: 74)
.navigationBarBackButtonHidden()

case .chatView(isAiMode: false):
Expand All @@ -66,6 +66,8 @@ struct RollTheDiceApp: App {
DebateSummaryView()
case .webView(let url):
WebView(urlToLoad: url)
case .createdebateroom:
GPTChatView(topic: "", roomId: 74)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class APIHeaderManager {
static let shared = APIHeaderManager()

let contentType: String = "application/json"
let scoopHost: String = "ec2-13-124-191-244.ap-northeast-2.compute.amazonaws.com:8080"
// let scoopHost: String = "ec2-13-124-191-244.ap-northeast-2.compute.amazonaws.com:8080"
let scoopHost: String = "roll-the-dice.store:8080"
}


// http://ec2-13-124-191-244.ap-northeast-2.compute.amazonaws.com:8080/swagger-ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
import Foundation

enum ScoopAPI {
static let baseURL = "http://ec2-13-124-191-244.ap-northeast-2.compute.amazonaws.com:8080"
// static let baseURL = "http://ec2-13-124-191-244.ap-northeast-2.compute.amazonaws.com:8080"
static let baseURL = "http://roll-the-dice.store:8080"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// ScoopAPIBookmark.swift
// RollTheDice
//
// Created by Subeen on 6/14/24.
//

import Foundation

public enum ScoopAPIBookmarks {
public static let bookmarks = String("/bookmarks")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// ScoopAPILogin.swift
// RollTheDice
//
// Created by Subeen on 6/18/24.
//

import Foundation

public enum ScoopAPILogin {
public static let login = String("/login")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// BookmarksService.swift
// RollTheDice
//
// Created by Subeen on 6/14/24.
//

import Foundation
import Moya

enum BookmarksService {
case bookmarksIsChecked(newsId: Int, accessToken: String) ///뉴스 북마크 여부 조회
case saveBookmarks(newsId: Int, accessToken: String) ///북마크 저장
case deleteBookmarks(newsId: Int, accessToken: String) ///북마크 삭제
case allBookmarks(page: Int, size: Int, accessToken: String) ///북마크 전체 조회/
}

extension BookmarksService: BaseTargetType {

var baseURL: URL {
return URL(string: ScoopAPI.baseURL)!
}

var path: String {
switch self {
case .bookmarksIsChecked(let newsId, _),
.saveBookmarks(let newsId, _),
.deleteBookmarks(let newsId, _)
:
return "\(ScoopAPIBookmarks.bookmarks)/\(newsId)"

case .allBookmarks:
return ScoopAPIBookmarks.bookmarks
}
}

var method: Moya.Method {
switch self {
case .bookmarksIsChecked:
return .get
case .saveBookmarks:
return .post
case .deleteBookmarks:
return .delete
case .allBookmarks:
return .get
}
}

var task: Moya.Task {
switch self {
case .bookmarksIsChecked(let newsId, _),
.saveBookmarks(let newsId, _),
.deleteBookmarks(let newsId, _):
let parameters : [String : Any] = [:]
return .requestParameters(parameters: parameters, encoding: URLEncoding.default)

case .allBookmarks(let page, let size, _):
let parameters : [String : Any] = [
"page" : page,
"size" : size,
]
return .requestParameters(parameters: parameters,
encoding: URLEncoding.queryString)
}
}

var headers: [String : String]? {
let accessToken: String
switch self {
case .bookmarksIsChecked(_, let accessToken),
.saveBookmarks(_, let accessToken),
.deleteBookmarks(_, let accessToken),
.allBookmarks(_, _, let accessToken):
return [
"Authorization": "Bearer \(accessToken)",
"X-Content-Type_Options" : "nosniff"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// AuthAPI.swift
// RollTheDice
//
// Created by 신예진 on 5/31/24.
//

import Foundation
import Moya

enum LoginService {
case login(request: AuthRequestModel)
}

//struct LoginService {
// static let provider = MoyaProvider<AuthTarget>()
//}

extension LoginService: BaseTargetType {

var baseURL: URL {
return URL(string: ScoopAPI.baseURL)!
}

var path: String {
switch self {
case .login:
return ScoopAPILogin.login
}
}

var method: Moya.Method {
switch self {
case .login:
return .post
}
}

var task: Moya.Task {
switch self {
case .login(let request):
// let parameters : [String : Any] = [
// "token" : token,
// "socialType" : socialType,
// ]
// return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
return .requestJSONEncodable(request)
}
}

var headers: [String: String]? {
return [
"X-Content-Type_Options" : "nosniff"
]
}
}
3 changes: 3 additions & 0 deletions iOS/RollTheDice/RollTheDice/Source/Model/Path/PathType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ enum PathType: Hashable {
case mypageView // 마이페이지뷰

case webView(url: String)

case createdebateroom //토론방 생성

}
23 changes: 23 additions & 0 deletions iOS/RollTheDice/RollTheDice/Source/View/Authentication/Auth.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Auth.swift
// RollTheDice
//
// Created by Subeen on 6/18/24.
//

import Foundation

struct AuthModel: Codable {
let accessToken: String?
let refreshToken: String?

// enum CodingKeys: String, CodingKey {
// case Authorization
// case AuthorizationRefresh = "Authorization-refresh"
// }
}

struct AuthRequestModel: Codable {
let token: String?
let socialType: String?
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -122,45 +122,8 @@ struct AuthenticatedView: View {
.frame(height: 50)
}

// Button {
// if (UserApi.isKakaoTalkLoginAvailable()) {
// UserApi.shared.loginWithKakaoTalk {(oauthToken, error) in
// print(oauthToken)
// print(error)
// }
// } else {
// UserApi.shared.loginWithKakaoAccount {(oauthToken, error) in
// print(oauthToken)
// print(error)
// }
// }
//
// } label: {
// Image(.kakaoSignInBtn01)
// .resizable()
// .aspectRatio(contentMode: .fit)
// .frame(height: 50)
// }
Button {
if UserApi.isKakaoTalkLoginAvailable() {
UserApi.shared.loginWithKakaoTalk { (oauthToken, error) in
if let error = error {
print("Kakao Login Error: \(error)")
} else if let oauthToken = oauthToken {
print("Kakao Login Success: \(oauthToken)")
TokenManager.shared.accessToken = oauthToken.accessToken
authViewModel.authenticationState = .completedSignUp }
}
} else {
UserApi.shared.loginWithKakaoAccount { (oauthToken, error) in
if let error = error {
print("Kakao Login Error: \(error)")
} else if let oauthToken = oauthToken {
print("Kakao Login Success: \(oauthToken)")
TokenManager.shared.accessToken = oauthToken.accessToken
authViewModel.authenticationState = .completedSignUp }
}
}
authViewModel.loginWithKakao()
} label: {
Image(.kakaoSignInBtn01)
.resizable()
Expand Down
Loading

0 comments on commit 7681269

Please sign in to comment.