Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: 프로필탭 & 로그인탭 네트워크 레이어 적용 #96

Open
wants to merge 55 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
ab7f8c4
Refactor : profile retrieval api
cyndii20 Sep 30, 2024
495dd3f
Refactor : pochak post retrieval api
cyndii20 Sep 30, 2024
db36d18
Refactor : profile update api
cyndii20 Sep 30, 2024
1f2ccab
Refactor : signout & logout api refactor
cyndii20 Sep 30, 2024
f45449e
Refactor : user block/unblock api
cyndii20 Sep 30, 2024
a03e7e3
Refactor : block user list api
cyndii20 Sep 30, 2024
bf72a54
Refactor : 프로필 API 네트워크 레이어 적용
cyndii20 Sep 30, 2024
487da12
Chore : 프로필 UI 파일 구조 변경
cyndii20 Sep 30, 2024
fa11e3c
Chore : 프로필 UI 폴더 구조 변경
cyndii20 Sep 30, 2024
1392608
Style : convention 따라 코드 포맷팅
cyndii20 Sep 30, 2024
f8660e9
Chore : 파일 이름 변경
cyndii20 Sep 30, 2024
9c7235f
Style : convention 따라 코드 포맷팅
cyndii20 Sep 30, 2024
d689da5
Chore : 파일 이름 변경
cyndii20 Sep 30, 2024
fcd4de3
Refactor : 핸들 중복 검사 api
cyndii20 Sep 30, 2024
3b7f802
Refactor : signup API
cyndii20 Sep 30, 2024
4f5bc26
Style : convention 따라 코드 포맷팅
cyndii20 Sep 30, 2024
7d13c6c
Fix : block api 수정
cyndii20 Oct 1, 2024
b95db28
Fix : update api 수정
cyndii20 Oct 6, 2024
a3a6468
Fix : 새로고침 액션 수정
cyndii20 Oct 6, 2024
d936886
Fix : 프로필 데이터 새로고침
cyndii20 Oct 6, 2024
ac2393f
Feat : scrollview 추가
cyndii20 Oct 14, 2024
c4f938e
Style : 코드 포맷팅
cyndii20 Oct 14, 2024
fb5ac92
Fix : fix profile scrollView
cyndii20 Nov 4, 2024
3356cd2
Fix : fix myprofile scrollview
cyndii20 Nov 4, 2024
77cab88
Fix : fix constraint of postList Tabman View
cyndii20 Nov 4, 2024
3c140e4
Fix : fix scrollview
cyndii20 Nov 4, 2024
7bdde8c
Fix : fix scrollview
cyndii20 Nov 4, 2024
14a80d5
Fix : fix UIScrollView
cyndii20 Nov 19, 2024
ef8250c
Fix : fix scroll view
cyndii20 Nov 25, 2024
d57d33d
Fix : add notification
cyndii20 Nov 25, 2024
07174b2
Fix : fix notification
cyndii20 Nov 25, 2024
88bed56
Fix : fix notification
cyndii20 Nov 25, 2024
d56cec7
Fix : fix variable
cyndii20 Nov 25, 2024
92d01f4
Fix : fix variables
cyndii20 Nov 25, 2024
1da7ffb
Chore : scrollview backup
cyndii20 Dec 1, 2024
d2035b7
Fix : divide functions in tabman
cyndii20 Dec 2, 2024
9633b66
Fix : 불필요한 notification 제거
cyndii20 Dec 2, 2024
8c296b2
Fix : 스크롤뷰 페이징 수정
cyndii20 Dec 2, 2024
d250790
Add : 프로필 데이터 관리 위한 singleton 파일 추가하여
cyndii20 Dec 2, 2024
a7d6319
Fix : 페이징 수정
cyndii20 Dec 2, 2024
df588a1
Fix : 내 프로필 스크롤 뷰 contraint 수정
cyndii20 Dec 2, 2024
b8ddc11
Fix : 내 프로필 탭 constraint 수정
cyndii20 Dec 9, 2024
231432f
Fix : 프로필 사진 높이 수정
cyndii20 Dec 9, 2024
4838cec
Fix : 프로필 사진 높이 수정
cyndii20 Dec 9, 2024
b8d3e60
Feat : 리프레시 토큰 휴요성 검사 추가
cyndii20 Dec 9, 2024
3e26e9e
Fix : 불필요한 print문 제거
cyndii20 Dec 9, 2024
2fb13a5
Fix : 차단한 프로필 조회 로직 수정
cyndii20 Dec 9, 2024
dfeb5a2
Fix : 차단 유저 프로필 조회 수정
cyndii20 Dec 9, 2024
4809ad4
Fix : 차단 유저 프로필 조회시 네트워크 에러 알림 수정
cyndii20 Dec 9, 2024
4da24f4
Fix : enum으로 수정
cyndii20 Dec 9, 2024
c9f8322
Refactor : 로그인, 회원가입 탭 리팩토링
cyndii20 Dec 9, 2024
83de866
Refactor : 프로필 탭, 네트워크 리팩토링
cyndii20 Dec 9, 2024
5461d12
Refactor : 프로필 탭 리팩토링
cyndii20 Dec 9, 2024
5f851b1
Merge branch 'develop' into refactor/76-profileTabNetworkRefactoring
cyndii20 Dec 9, 2024
4dce758
Fix : 프로필 탭 스크롤 뷰 높이 수정
cyndii20 Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
410 changes: 193 additions & 217 deletions pochak/pochak.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

59 changes: 53 additions & 6 deletions pochak/pochak/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import FirebaseCore

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
sleep(2)
Expand Down Expand Up @@ -64,22 +64,69 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
removeKeychainAtFirstLaunch()
return true
}

private func removeKeychainAtFirstLaunch() {
guard UserDefaults.isFirstLaunch() else {
return
}
do {
try KeychainManager.delete(account: "accessToken")
try KeychainManager.delete(account: "refreshToken")
} catch {
print(error)
}
}

// 리프레시 토큰 유효성 검사
func applicationDidBecomeActive(_ application: UIApplication) {
handleRefreshToken()
}

private func handleRefreshToken() {
if !isRefreshTokenValid() {
print("Refresh Token 만료됨.. 재로그인 필요")
AuthenticationService.logOut { data, failed in
guard let data = data else {
return
}
let message = data.message
print(message)
}
deleteUserData()
moveToMainPage()
}
}

private func isRefreshTokenValid() -> Bool {
guard let issuedAt = UserDefaultsManager.getData(type: Date.self, forKey: .refreshTokenIssuedAt) else {
return false // 발급 시점을 알 수 없으면 토큰이 유효하지 않음
}
let validityPeriod: TimeInterval = 30 * 24 * 60 * 60 // 1달(30일)을 초 단위로
let expirationDate = issuedAt.addingTimeInterval(validityPeriod)

// 첫 실행이라면 keyChain 정보를 삭제
return Date() < expirationDate // 현재 시간과 만료 시간을 비교
}

private func deleteUserData() {
do {
// Keychain 삭제
try KeychainManager.delete(account: "accessToken")
try KeychainManager.delete(account: "refreshToken")

// UserDefaults 삭제
UserDefaultsManager.UserDefaultsKeys.allCases.forEach { key in
UserDefaultsManager.removeData(key: key)
}
} catch {
print(error)
}
}

// MARK: UISceneSession Lifecycle

private func moveToMainPage() {
let mainVCBundle = UIStoryboard.init(name: "Login", bundle: nil)
guard let mainVC = mainVCBundle.instantiateViewController(withIdentifier: "NavigationVC") as? NavigationController else { return }
(UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.changeRootViewController(mainVC, animated: false)
}

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
Expand All @@ -93,7 +140,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}

// Google 로그인
// Google 로그인 등록
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
return GIDSignIn.sharedInstance.handle(url)
}
Expand Down
13 changes: 13 additions & 0 deletions pochak/pochak/Global/Extensions/Notification+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Notification.swift
// pochak
//
// Created by Seo Cindy on 12/2/24.
//

import Foundation

extension Notification.Name {
static let didUpdateTotalHeight = Notification.Name("didUpdateTotalHeight")
static let didHitBottom = Notification.Name("didHitBottom")
}
25 changes: 25 additions & 0 deletions pochak/pochak/Global/Types/HandleDuplicationType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// HandleDuplicationType.swift
// pochak
//
// Created by Seo Cindy on 12/9/24.
//

import Foundation

enum MemberCode: String {
case success = "MEMBER2001" // 중복 검사 성공
case duplicationError = "MEMBER4002" // 중복된 아이디
case unknown // 알 수 없는 코드

init(rawValue: String) {
switch rawValue {
case "MEMBER2001":
self = .success
case "MEMBER4002":
self = .duplicationError
default:
self = .unknown
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// CheckDuplicateHandleAPI.swift
// pochak
//
// Created by Seo Cindy on 10/1/24.
//

import Foundation
import Alamofire

enum CheckDuplicateHandleAPI {
case checkDuplicateHandle(CheckDuplicateHandleRequest)
}

extension CheckDuplicateHandleAPI: BaseAPI {

typealias Response = CheckDuplicateHandleResponse

var method: HTTPMethod {
switch self {
case .checkDuplicateHandle: return .get
}
}

var path: String {
switch self {
case .checkDuplicateHandle: return "/v2/members/duplicate"
}
}

var parameters: RequestParams? {
switch self {
case .checkDuplicateHandle(let request): return .query(request)
}
}
}
30 changes: 30 additions & 0 deletions pochak/pochak/Network/APIs/Authentication/LogOutAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// LogOutAPI.swift
// pochak
//
// Created by Seo Cindy on 9/30/24.
//

import Foundation
import Alamofire

enum LogOutAPI {
case logOut
}

extension LogOutAPI: BaseAPI {

typealias Response = LogOutResponse

var method: HTTPMethod {
switch self {
case .logOut: return .get
}
}

var path: String {
switch self {
case .logOut: return "/v2/logout"
}
}
}
30 changes: 30 additions & 0 deletions pochak/pochak/Network/APIs/Authentication/SignOutAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// SignOutAPI.swift
// pochak
//
// Created by Seo Cindy on 9/30/24.
//

import Foundation
import Alamofire

enum SignOutAPI {
case signOut
}

extension SignOutAPI: BaseAPI {

typealias Response = SignOutResponse

var method: HTTPMethod {
switch self {
case .signOut: return .delete
}
}

var path: String {
switch self {
case .signOut: return "/v2/signout"
}
}
}
36 changes: 36 additions & 0 deletions pochak/pochak/Network/APIs/Authentication/SignUpAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// SignUpAPI.swift
// pochak
//
// Created by Seo Cindy on 10/1/24.
//

import Foundation
import Alamofire

enum SignUpAPI {
case signUp(SignUpRequest)
}

extension SignUpAPI: BaseAPI {

typealias Response = SignUpResponse

var method: HTTPMethod {
switch self {
case .signUp: return .post
}
}

var path: String {
switch self {
case .signUp: return "/v2/signup"
}
}

var parameters: RequestParams? {
switch self {
case .signUp(let request): return .query(request)
}
}
}
37 changes: 37 additions & 0 deletions pochak/pochak/Network/APIs/Profile/PochakPostRetrievalAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// PochakPostRetrievalAPI.swift
// pochak
//
// Created by Seo Cindy on 9/30/24.
//

import Foundation
import Alamofire

enum PochakPostRetrievalAPI {
case getPochakPost(handle: String, request: ProfileRetrievalRequest)
}

extension PochakPostRetrievalAPI: BaseAPI {

typealias Response = PochakPostRetrievalResponse

var method: HTTPMethod {
switch self {
case .getPochakPost: return .get
}
}

var path: String {
switch self {
case .getPochakPost(let handle, _): return "/v2/members/\(handle)/upload"
}
}

var parameters: RequestParams? {
switch self {
case .getPochakPost(_, let request): return .query(request)
}
}
}

37 changes: 37 additions & 0 deletions pochak/pochak/Network/APIs/Profile/ProfileRetrievalAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// ProfileRetrievalAPI.swift
// pochak
//
// Created by Seo Cindy on 9/30/24.
//

import Foundation
import Alamofire

enum ProfileRetrievalAPI {
case getProfile(handle: String, request: ProfileRetrievalRequest)
}

extension ProfileRetrievalAPI: BaseAPI {

typealias Response = ProfileRetrievalResponse

var method: HTTPMethod {
switch self {
case .getProfile: return .get
}
}

var path: String {
switch self {
case .getProfile(let handle, _): return "/v2/members/\(handle)"
}
}

var parameters: RequestParams? {
switch self {
case .getProfile(_, let request): return .query(request)
}
}
}

37 changes: 37 additions & 0 deletions pochak/pochak/Network/APIs/Profile/ProfileUpdateAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// ProfileUpdateAPI.swift
// pochak
//
// Created by Seo Cindy on 9/30/24.
//

import Foundation
import Alamofire


enum ProfileUpdateAPI {
case updateProfile(handle: String, request: ProfileUpdateRequest)
}

extension ProfileUpdateAPI: BaseAPI {

typealias Response = ProfileUpdateResponse

var method: HTTPMethod {
switch self {
case .updateProfile: return .put
}
}

var path: String {
switch self {
case .updateProfile(let handle, _): return "/v2/members/\(handle)"
}
}

var parameters: RequestParams? {
switch self {
case .updateProfile(_, let request): return .query(request)
}
}
}
Loading