Skip to content

[feat/#330] 회원 정보 업데이트 API 연동#331

Merged
SeungWon1125 merged 11 commits intodevelopfrom
feat/#330-profile-edit
Nov 13, 2025
Merged

[feat/#330] 회원 정보 업데이트 API 연동#331
SeungWon1125 merged 11 commits intodevelopfrom
feat/#330-profile-edit

Conversation

@SeungWon1125
Copy link
Copy Markdown
Collaborator

@SeungWon1125 SeungWon1125 commented Nov 12, 2025

📄 작업 내용

  • 회원 정보 업데이트 API 를 연동했어요
  • PR 길어질 거 같아서 프로필 사진 변경은 다음 이슈에서 진행하겠습니다
구현 내용 회원 정보 업데이트 변경사항 alert
iPhone 13 mini

💻 주요 코드 설명

NicknameTextField 초기값 추가

프로필 수정뷰에 들어갔을 때 NicknameTextField에 초기값으로 유저의 nickname이 보여야 해서
NicknameTextField 컴포넌트에 초기값을 설정할 수 있도록 수정했어요
기존 사용방식에 영향X

// NicknameTextField.swift
// MARK: - Properties
@State private var text: String // <- 변경 (초기값 "" 삭제)
...

// MARK: - Initializer
init(
    initialText: String = "", // <- 추가된 부분
    placeholder: String = "여기에 입력하세요.",
    state: NicknameTextFieldState,
    counterVisibility: CounterVisibility = .whenNotEmpty,
    onChange: ((String) -> Void)? = nil,
    onSubmit: ((String) -> Void)? = nil
) {
    self._text = State(initialValue: initialText) // <- 추가된 부분
    self.placeholder = placeholder
    self.state = state
    self.counterVisibility = counterVisibility
    self.onChange = onChange
    self.onSubmit = onSubmit
}

기존에는 @State private var text: String = "" 이렇게 State변수의 초기값이 ""로 고정이었습니다.
초기값을 추가하기 위해 init()함수에 initialText: String 인자값을 추가하여 초기값을 받아 @State변수를 초기화 하도록 수정했어요
디폴트값 ""으로 설정하여 기존에 사용하던 곳에서는 영향이 없게 했습니다.

NicknameTextField 키보드 내렸을 때 중복 검사

처음에는 .onTapGesture를 통해 키보드를 내렸을 때 닉네임 중복 검사 API를 호출하려 했지만
이렇게 되면 키보드를 올리지 않은 상태에서 화면을 탭했을 때도 닉네임 중복 검사 API가 호출되기 때문에
@FocusState를 사용하여 키보드 포커스가 풀리는 시점에 닉네임 중복 검사 API를 호출하도록 구현했어요

// MyPageEditView.swift

@FocusState private var isNicknameTextFieldFocused: Bool
...
NicknameTextField(...)
    .focused($isNicknameTextFieldFocused) // <- 포커스 바인딩
...
.onChange(of: isNicknameTextFieldFocused) { _, newValue in
    if !newValue {
        store.dispatch(.fetchUserNicknameCheck) // <- 포커스 상태가 false일 때 API 호출
    }
}

참고PR: [fix/#305] 장소 제보하기/등록하기 QA TextEditor 키보드 수정사항 반영

🔗 연결된 이슈

@SeungWon1125 SeungWon1125 requested a review from a team November 12, 2025 09:42
@SeungWon1125 SeungWon1125 self-assigned this Nov 12, 2025
@SeungWon1125 SeungWon1125 added 🦒 seungwon 승원이가함! 🛠️ feat 새로운 기능 구현 시 사용 labels Nov 12, 2025
@SeungWon1125 SeungWon1125 linked an issue Nov 12, 2025 that may be closed by this pull request
1 task
Copy link
Copy Markdown
Contributor

@pedro0527 pedro0527 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gooooood


var nicknameTextFieldState: NicknameTextFieldState = .editing
var isUserInformationChanged: Bool = false
var shouldGoBack: Bool = false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 왜 필요하져?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

17번줄만!!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

원래는 View에서 appCoordinator.goBack()을 호출하면 되지만,
여기서는 완료 버튼을 누름 -> 프로필 수정 API 호출 -> 성공 응답 받고 뒤로 가야하기 때문에 State에 상태를 추가했어요
성공 응답 ActionReducer에게 전달되었을 때 Reducer에서 이 shouldGoBacktrue로 토글시켜 View에서 onChange로 감시하다 true로 바뀌면 goBack()하게 구현했어요

Comment on lines +25 to +27
effect: MyPageEditEffect = MyPageEditEffect(
userService: UserService()
),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 처음보는 형태인데...? init을 사용한 이유가 있나용

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[feat/#318] 장소상세 동네 변경 Toast
관련 트러블 슈팅

위 PR과 트슈 보면 이해하기 쉽습니다!
약간 API를 호출하거나, 화면의 초기상태를 나타내는 데이터는 State에서 저장하기 보다 Store에서 init으로 주입받고 let으로 관리하여 수정이 불가하게 하는 것이 더 적합하다는 판단하여 위처럼 구현했어요

@SeungWon1125 SeungWon1125 merged commit d0df735 into develop Nov 13, 2025
@SeungWon1125 SeungWon1125 deleted the feat/#330-profile-edit branch November 13, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ feat 새로운 기능 구현 시 사용 🦒 seungwon 승원이가함!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 프로필 수정 구현

2 participants