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

[ADD] CommonToolbarLayout(BaseToolbar) 추가 #317

Merged
merged 18 commits into from
Feb 14, 2024

Conversation

dongx0915
Copy link
Member

📌 개요

✨ 작업 내용

  • 사용 설명서(?)
  • CommonToolbarLayout 추가
  • 아이콘 타입, 텍스트 타입, 팝업 메뉴 타입 포함

✨ PR 포인트

  • 동적으로 뷰를 추가하는 작업이라 크래시, 파편화, 뷰 사이즈, 디자인 시안과 다른 점 등 많은 테스트 부탁 드립니다~!

📸 스크린샷/동영상

@dongx0915 dongx0915 added ADD ➕ feat 이외의 부수적인 코드, 파일, 라이브러리 추가 동현 🐨 동현 담당 labels Jan 20, 2024
@dongx0915 dongx0915 self-assigned this Jan 20, 2024
Copy link
Contributor

@unam98 unam98 left a comment

Choose a reason for hiding this comment

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

오호 친절한 사용 설명서까지~ 수고 많으셨습니다 :) 👍

@Retention(AnnotationRetention.SOURCE)
annotation class Direction

companion object {
Copy link
Contributor

Choose a reason for hiding this comment

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

타 파일과의 통일성을 위해 companion object는 파일 하단으로 배치해주시면 더 좋을 것 같습니다 :)

import com.runnect.runnect.util.custom.popup.RunnectPopupMenu
import com.runnect.runnect.util.extension.dpToPx

sealed class ToolbarMenu(
Copy link
Contributor

Choose a reason for hiding this comment

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

sealed class로 만드신 의도가 있나요?

Copy link
Member Author

Choose a reason for hiding this comment

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

@unam98 답변이 늦었네요

처음 구현할 때는 when 구문에서 ToolbarMenu 타입에 따라 뷰를 생성해주고 있었습니다.

BaseToolbarMenu로 추상화하면서 아래와 같이 createMenu 하나로 처리가 가능해져 when 구문은 삭제 되었으나, 굳이 sealed class까지 제거할 필요는 없다고 판단되어 유지 했습니다~!

    private fun addMenuView(context: Context?, parent: LinearLayout, toolbarMenu: ToolbarMenu) {
        context ?: return

        val menuView: View = toolbarMenu.createMenu(context)
        parent.addView(menuView)
    }

Copy link
Member

@leeeha leeeha left a comment

Choose a reason for hiding this comment

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

앞으로 툴바 사용할 일 있을 때 적극 이용해봐야겠네요! 새로운 거 많이 배워갑니다! 👍

interface CommonToolbarLayout {

@IntDef(LEFT, RIGHT)
@Retention(AnnotationRetention.SOURCE)
Copy link
Member

Choose a reason for hiding this comment

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

@IntDef, @Retention 어노테이션에 대해 배워갑니다!

private fun getColor(context: Context, @ColorRes colorResId: Int): Int {
return ContextCompat.getColor(context, colorResId)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

이런 식으로도 인터페이스를 활용할 수 있군요..!! 🫢 동현님 코드를 보다 보면 확실히 실무에서 배우는 게 훨씬 많은 거 같다는 생각이 자주 듭니다 ㅎㅎ

Copy link
Member Author

Choose a reason for hiding this comment

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

@leeeha
이게 좋은 방법인진 모르겠지만 최대한 코드 정리 해봤습니다..!
유동적인 레이아웃을 공통으로 이용할 수 있는 좋은 방법이 있으면 공유 부탁드려요~!

*/
fun setToolBarTitleFont(@FontRes fontResId: Int) {
with(toolbarBinding) {
val context = toolbar.context ?: return
Copy link
Member

Choose a reason for hiding this comment

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

플랫폼 타입에 대한 널처리도 항상 꼼꼼하게 챙기시는 모습이 인상적입니다! 평소에 개발하면서 간과했던 부분인데 덕분에 배워갑니다!

@dongx0915 dongx0915 merged commit 66bcfba into develop Feb 14, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADD ➕ feat 이외의 부수적인 코드, 파일, 라이브러리 추가 동현 🐨 동현 담당
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ADD] CommonToolbarLayout(BaseToolbar) 추가
3 participants