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

[IDLE-180] 센터프로필 조회및 수정 API 연동 #22

Merged
merged 3 commits into from
Jul 22, 2024

Conversation

J0onYEong
Copy link
Contributor

@J0onYEong J0onYEong commented Jul 22, 2024

변경된 부분

  • 프로필 수정 API를 연동하여 프로필 수정이 가능합니다.
  • 이미지 처리방식 변경(png(pixel base) -> SVG)

프로필 수정가능

프로필은 총 3가지 요소를 수정할 수 있습니다.

  • 연락처
  • 센터 소개말
  • 센터 이미지

DefaultCenterProfileUseCase의 updateProfile함수를 통해 변경을 희망하는 요소들을 옵셔널로 전달받습니다.
이미지 업로드와 텍스트 업로드에 대한 처리가 독립적으로 동작하며, nil값을 전달받을 경우 해당하는 API를 요청하지 않습니다.

독립적으로 동작하지만 하나의 스트림을 통해서 발생하는 에러를 처리하기 위해 RxSwift의 zip오퍼레이터를 사용하였습니다.

let task = Observable
    .zip(
        updateTextResult.asObservable(),
        updateImageResult.asObservable()
    )
    .map { _ in () }
    .asSingle()

updateTextResult, updateImageResult옵저버블은 각각 변경사항이 없는 경우 Void인스턴스를 명시적으로 방출하도록 설계하였습니다.

스크린샷 2024-07-22 오후 1 04 05

SVG형식의 이미지파일은 픽셀기반이 아닌 수학적 벡터를 사용하여 이미지를 랜더링한다. 따라서 Single scale모드로 사용해도 이미지의 해상도가 저하되지 않는다는 장점이 있다.
해당 방식을 적용한 이유는 화면 scale에(1x, 2x, 3x) 따라 이미지를 각각 할당해야하는 작업이 필요하지 않다는 것에서도 의의가 있다고 판단하여 사용하였다.

UIImage는 랜더링 모드를 사용할 수 있다. 랜더링모드가 template일 경우 UIImageView의 tintColor프로퍼티로 전달한 색상값이 이미지 랜더링에 적용된다.
이미지가 단조로운 경우 여러 이미지를 사용할 필요없이 해당 방식을 사용하여 하나의 이미지를 범용적으로 쓸 수 있다는 장점이 있다.
@J0onYEong J0onYEong requested a review from monibu1548 July 22, 2024 04:05
@J0onYEong J0onYEong merged commit 96d7cde into develop Jul 22, 2024
1 check passed
@J0onYEong J0onYEong deleted the feature/center_profile branch July 22, 2024 04:07
Comment on lines +12 to +20
let centerName: String?
let officeNumber: String?
let roadNameAddress: String?
let lotNumberAddress: String?
let detailedAddress: String?
let longitude: String?
let latitude: String?
let introduce: String?
let profileImageUrl: String?
Copy link
Collaborator

Choose a reason for hiding this comment

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

@J0onYEong 이 값들이 모두 정말로 Optional인가요~~~?
적어도 몇개는 required로 갖고 있어야 할 값들로 보입니다. 파싱 오류 방지를 위해서 무조건 Optional로 가는건 좋지 않습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵! 저렇게 처리하고 랩핑을 벗길때 기본값을 고민했어야 했는데.. 앞으로는 요구사항을 좀더 명확히 인지해 보겠습니다!

Comment on lines +53 to +64
.catch { error in
if let httpExp = error as? HTTPResponseException {
let newError = HTTPResponseException(
status: httpExp.status,
rawCode: "Err-001",
timeStamp: httpExp.timeStamp
)

return .error(newError)
}
return .error(error)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

앞으로 이 코드가 굉장히 반복될텐데 이 부분을 코드 복붙 말고 깔끔하게 처리할 수 있는 방법이 무엇이 있는지 고민해보시면 좋을 것 같습니다 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵! 명확하게 에러처리가 되어 있지 않은 부분들을 일관성 있게 처리할 수 있는 방법을 생각해봐야겠습니다. 말씀대로 코드가 지저분해질 것 같습니다.

@@ -48,6 +43,11 @@ public class IconStateButton: UIImageView {
private func setAppearance() {

self.contentMode = .scaleAspectFit

// 이미지를 템플릿 모드로 변경
let templateImage = self.representImage.withRenderingMode(.alwaysTemplate)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍
한가지 더 추가하자면 template으로만 사용되는 asset의 경우엔 asset 설정에서 RenderAs값을 template로 설정해두면 코드레벨에서 매번 renderMode를 바꿔주지 않아도 됩니다.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵~! 팁 감사합니다!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants