Skip to content

Commit

Permalink
✨[feat]: 화면 전환 방식 변경 #13
Browse files Browse the repository at this point in the history
 * navigationstack 에서 코디네이터 로 변경
  • Loading branch information
Roy-wonji committed Oct 2, 2024
1 parent 2e65362 commit 7f7a06a
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 487 deletions.
93 changes: 51 additions & 42 deletions OPeace/Projects/App/OPeace.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public struct EditProfile {
var profileYear: Int = 0
let paddings: [CGFloat] = [47, 25, 32, 47, 24, 32]
@Presents var destination: Destination.State?
@Shared(.inMemory("isChangeProfile")) var isChangeProfile: Bool = false
@Shared(.inMemory("userInfoModel")) var userInfoModel: UserInfoModel? = .init()

public init() {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public struct EditProfileView: View {
year: store.profileYear ,
job: store.profileSelectedJob ?? "",
generation: store.editProfileGenerationText)))
store.isChangeProfile = true
store.userInfoModel?.isChangeProfile = true
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
backToHomeAction()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import KeychainAccess

import Utill
import DesignSystem
import Model
import Utills
import UseCase
import Networkings

import KakaoSDKAuth
import KakaoSDKUser
Expand Down Expand Up @@ -49,11 +47,7 @@ public struct Profile {
var questionId: Int = .zero

@Presents var destination: Destination.State?
@Shared(.inMemory("isLogOut")) var isLogOut: Bool = false
@Shared(.inMemory("isDeleteUser")) var isDeleteUser: Bool = false
@Shared(.inMemory("isChangeProfile")) var isChangeProfile: Bool = false
@Shared(.inMemory("isDeleteQuestion")) var isDeleteQuestion: Bool = false
@Shared(.inMemory("loginSocialType")) var loginSocialType: SocialType? = nil
@Shared(.inMemory("userInfoModel")) var userInfoModel: UserInfoModel? = .init()
@Shared(.appStorage("lastViewedPage")) var lastViewedPage: Int = .zero

public init() {}
Expand Down Expand Up @@ -134,16 +128,14 @@ public struct Profile {
return .none

case .scopeFetchUser:
state.isChangeProfile = false
return .run { @MainActor send in
send(.async(.fetchUser))
state.userInfoModel?.isChangeProfile = false
return .run { send in
await send(.async(.fetchUser))
}

case .destination(.presented(.setting(.test))):
case .destination(_):
return .none



case .view(let View):
switch View {

Expand Down Expand Up @@ -231,15 +223,15 @@ public struct Profile {
case .success(let resultData):
state.profileUserModel = resultData
state.profileGenerationYear = state.profileUserModel?.data?.year
state.isChangeProfile = false
state.userInfoModel?.isChangeProfile = false

case let .failure(error):
Log.network("프로필 오류", error.localizedDescription)
}
return .none

case .socilalLogOutUser:
nonisolated(unsafe) var loginSocialType = state.loginSocialType
nonisolated(unsafe) var socialType = UserDefaults.standard.string(forKey: "LoginSocialType") ?? ""
let socialType = UserDefaults.standard.string(forKey: "LoginSocialType") ?? ""
return .run { send in
switch socialType {
case "kakao":
Expand All @@ -257,15 +249,15 @@ public struct Profile {
case .success(let userData):
state.userLogoutModel = userData
Log.debug("유저 로그아웃 성공", userData)
state.isLogOut = true
state.destination = .home(.init(isLogOut: state.isLogOut, isDeleteUser: state.isDeleteUser, isChangeProfile: state.isChangeProfile, isDeleteQuestion: state.isDeleteQuestion))
state.userInfoModel?.isLogOut = true
state.destination = .home(.init(userInfoModel: state.userInfoModel))
case .failure(let error):
Log.debug("유저 로그아웃 에러", error.localizedDescription)
}
return .none

case .logoutUser:
nonisolated(unsafe) var loginSocialType = state.loginSocialType
nonisolated(unsafe) var userinfoModel = state.userInfoModel
return .run { send in
let userLogOutData = await Result {
try await authUseCase.logoutUser(refreshToken: "")
Expand All @@ -276,10 +268,11 @@ public struct Profile {
if let userLogOutData = userLogOutData {
await send(.async(.logoutUseResponse(.success(userLogOutData))))
UserDefaults.standard.removeObject(forKey: "ACCESS_TOKEN")
loginSocialType = nil
await send(.view(.closePopUp))
let loginSocialType = UserDefaults.standard.removeObject(forKey: "LoginSocialType")
await send(.view(.closePopUp))
userinfoModel?.isLogOut = true
try await self.clock.sleep(for: .seconds(0.4))
await send(.navigation(.presntLogout))
await send(.navigation(.presntLogout))
}

case .failure(let error):
Expand Down Expand Up @@ -338,7 +331,7 @@ public struct Profile {
switch result {
case .success(let deleteQuestionData):
state.deleteQuestionModel = deleteQuestionData
state.isDeleteQuestion = true
state.userInfoModel?.isDeleteQuestion = true

case .failure(let error):
Log.debug("질문 삭제 에러", error.localizedDescription)
Expand Down Expand Up @@ -416,5 +409,11 @@ public struct Profile {
return .none
}
}
.onChange(of: \.userInfoModel) { oldValue, newValue in
Reduce { state, action in
state.userInfoModel = newValue
return .none
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ public struct WithDraw {

@Presents var destination: Destination.State?

@Shared(.inMemory("isLogOut")) var isLogOut: Bool = false
@Shared(.inMemory("isDeleteUser")) var isDeleteUser: Bool = false
@Shared(.inMemory("loginSocialType")) var loginSocialType: SocialType? = nil
@Shared(.inMemory("userInfoModel")) var userInfoModel: UserInfoModel? = .init()

public init() {}
}

Expand Down Expand Up @@ -126,15 +125,14 @@ public struct WithDraw {
state.userDeleteModel = userDeleteData
UserDefaults.standard.removeObject(forKey: "REFRESH_TOKEN")
UserDefaults.standard.removeObject(forKey: "ACCESS_TOKEN")
state.isDeleteUser = true
state.destination = .home(.init(isLogOut: state.isLogOut, isDeleteUser: state.isDeleteUser))
state.userInfoModel?.isDeleteUser = true
state.destination = .home(.init(userInfoModel: state.userInfoModel))
case .failure(let error):
Log.debug("회원 탈퇴 에러", error.localizedDescription)
}
return .none

case .deletUserSocialType(let reason):
nonisolated(unsafe) var loginSocialType = state.loginSocialType
nonisolated(unsafe) var socialType = UserDefaults.standard.string(forKey: "LoginSocialType")
return .run { send in
switch socialType {
Expand Down
Loading

0 comments on commit 7f7a06a

Please sign in to comment.