Skip to content

Conversation

@taipaise
Copy link
Collaborator

🌁 Background

📱 Screenshot

  • iPhone SE3
se3.mov
  • iPhone 13 mini
13.mini.mov
  • iPhone 16 Pro
16pro.mov

👩‍💻 Contents

  • 사진 추가 기능 완성

✅ Testing

  • WhiteboardViewController를 생성하고, toolBar에서 사진 버튼을 누르면 테스트 할 수 있습니다.
  • 생성된 사진 오브젝트는 현재 보고 있는 화면의 중앙에 생성됩니다.

📝 Review Note

사진 오브젝트 뷰 생성하기

  • 사진 오브젝트를 생성하는 생성자는 아래와 같습니다.
init(photoObject: PhotoObject) {
        self.objectId = photoObject.id
        var width = photoObject.size.width
        var height = photoObject.size.height
        let scaleFactor: CGFloat = width >= height ? 200 / width : 200 / height
        width *= scaleFactor
        height *= scaleFactor

        let imageViewFrame = CGRect(
            x: photoObject.position.x - width / 2,
            y: photoObject.position.y - height / 2,
            width: width,
            height: height)
        super.init(frame: imageViewFrame)

        configureAttribute()
        configureLayout()
        configureImage(with: photoObject)
    }
  • 냅다 실제 사진을 화이트보드에 추가해버리면, 가로 세로 크기가 너무 커지는 문제가 있었습니다.
  • 따라서 처음 생성되는 사진의 크기를 200*200으로 제한하였습니다.
  • 가로, 세로 중 더 긴 쪽을 200으로 설정하였습니다. 남은 한 쪽은 비율에 맞게 길이를 재조정하도록 했습니다. (scaleFactor 를 설정하여 조절)
  • 다른 WhiteObjectView의 서브클래스들은 super.init(whiteboardObject: WhiteboardObject) 을 통해 초기화합니다. 다만 사진 오브젝트 엔티티가 가지고 있는 size는 실제 사진의 가로, 세로 길이이기 때문에 해당 생성자로 생성이 불가능했습니다. 따라서 WhiteboardObject에 아래 생성자를 추가하고, 해당 생성자를 이용해 초기화하도록 구현했습니다.
override init(frame: CGRect) {
        super.init(frame: frame)
}

📣 Related Issue

Copy link
Collaborator

@choijungp choijungp left a comment

Choose a reason for hiding this comment

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

초스피드 띵똥 ! 이번 PR도 잘봤습니다 !!!
궁금한 것이 있는데요 ~ PHPicker에서 사진 1장 선택할 때에도 완료 버튼을 만들 수 있는지 궁금합니다 ~~

Comment on lines 59 to 61
private func convertSize(photoSize: CGSize) -> CGSize {
return .init()
}
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
Collaborator Author

Choose a reason for hiding this comment

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

헉 사용하지 않는 메서드라 삭제해야합니다.!.! 날카로운 조이~

@taipaise
Copy link
Collaborator Author

taipaise commented Nov 19, 2024

@choijungp

PHPicker에서 사진 1장 선택할 때에도 완료 버튼을 만들 수 있는지 궁금합니다 ~~
사진 앨범에서 완료 버튼을 말하는게 맞으시다면, PHPickerConfiguration의 설정으로 가능하지 않을까 합니다!! 해보겠습니다!

Copy link
Collaborator

@ekrud99 ekrud99 left a comment

Choose a reason for hiding this comment

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

고생했어유
어프루브~

}

private func configureAttribute() {
imageView.contentMode = .scaleAspectFit
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
Collaborator Author

Choose a reason for hiding this comment

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

죠습니다 🦈🦈🦈🦈🦈

Copy link
Member

@eemdeeks eemdeeks left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다!!

역시 속도가 장난 아니시군요..

Comment on lines +92 to +98
guard let tool else { return }
switch tool {
case .photo:
self?.presentImagePicker()
default:
break
}
Copy link
Member

Choose a reason for hiding this comment

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

이부분에서 하는 것과, selectedToolDelegate에서 해주는 것 중 어떤 것이 더 괜찮을까요??

해당 부분 말고 여기서 해주신 이유가 궁금합니다!!

Copy link
Collaborator Author

@taipaise taipaise Nov 19, 2024

Choose a reason for hiding this comment

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

데이터의 흐름에 따라 처리하는게 적절하지 않을까 하여 위와 같이 처리했습니다. 제가 생각한 흐름은 다음과 같습니다!

Toobar에서 사용자의 action ->
delegate를 통해 VC에 알려줌 ->
VC가 ViewModel에게 선택한 tool을 알려줌 ->
ViewModel이 Usecase를 통해 선택한 tool에 대해 적절한 처리 ->
처리 결과를 VC에 알려줌 ->
VC는 받은 정보 (어떤 tool인지)에 따라 적절한 처리

Comment on lines +27 to +31
private var visibleCenterPoint: CGPoint {
let centerX = scrollView.contentOffset.x + (scrollView.bounds.width / 2)
let centerY = scrollView.contentOffset.y + (scrollView.bounds.height / 2)
return CGPoint(x: centerX, y: centerY)
}
Copy link
Member

Choose a reason for hiding this comment

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

화면 중앙을 알기 위해 연산 프로퍼티로 선언 해 주신 것이 인상깊습니다.

@taipaise taipaise merged commit c680dfa into develop Nov 19, 2024
2 checks passed
@taipaise taipaise deleted the feature/photoObject branch November 19, 2024 08:51
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.

[Feature] 화이트보드에 사진 추가 기능 구현

5 participants