[FEAT/#364] 공고 상세 뷰 / 카카오톡 공유하기#373
Conversation
boiledeggg
left a comment
There was a problem hiding this comment.
너무 고생하셨어요👍 카카오 로직 관련해서 제 생각을 조금 달아봤는데 보시고 의견 남겨주세용~
| painter = painterResource(id = R.drawable.ic_back), | ||
| contentDescription = stringResource(id = R.string.ic_back), | ||
| modifier = Modifier | ||
| modifier = modifier |
There was a problem hiding this comment.
파라미터로 받는 modifier는 CenterAlignedTopAppBar의 수정자로 사용하는게 적합하다고 생각해요!
이렇게 내부 컴포넌트의 수정자로 사용하게 되면 외부에서 이 탑바를 호출하여 사용할 때 수정자로 인한 혼란이 생길 것 같네요,,
There was a problem hiding this comment.
아공 맨날 요부분 실수하네여 ㅠ 섬세킹!!! 따봉석준!!!
| private fun shareToKakaoTalk(context: Context, internInfo: InternInfo) { | ||
| val templateId = 118600L | ||
|
|
||
| val templateArgs = mapOf( | ||
| "COMPANY_IMG" to internInfo.companyImage, | ||
| "TITLE" to internInfo.title, | ||
| "DEADLINE" to internInfo.deadline, | ||
| "START_DATE" to internInfo.startYearMonth, | ||
| "PERIOD" to internInfo.workingPeriod, | ||
| "REGI_WEB_DOMAIN" to internInfo.url, | ||
| "A_E" to internInfo.url, | ||
| "I_E" to internInfo.url | ||
| ) | ||
|
|
||
| if (ShareClient.instance.isKakaoTalkSharingAvailable(context)) { | ||
| ShareClient.instance.shareCustom( | ||
| context, | ||
| templateId, | ||
| templateArgs | ||
| ) { sharingResult, error -> | ||
| if (error != null) { | ||
| Timber.e("카카오톡 공유 실패: ${error.message}") | ||
| } else if (sharingResult != null) { | ||
| context.startActivity(sharingResult.intent) | ||
| } | ||
| } | ||
| } else { | ||
| val sharerUrl = WebSharerClient.instance.makeCustomUrl(templateId, templateArgs) | ||
| try { | ||
| KakaoCustomTabsClient.openWithDefault(context, sharerUrl) | ||
| } catch (e: Exception) { | ||
| Timber.e("웹 공유 실패: ${e.message}") | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
개인적으로 카카오 관련 로직은 따로 designsystem/util에 클래스로 만들거나, 카카오 모듈 또는 써드파티 라이브러리를 위한 모듈을 만들어서 관리하면 좋을 것 같아요!
InternViewModel에서 templateArgs을 만들어서 카카오 공유하기 Util 클래스의 함수를 호출하는 식으로 풀면 될 것 같고, Context는 ApplicationContext를 힐트로 주입받는 식으로 해결할 수 있을 것 같네요!
이렇게 하면 이 로직을 뷰모델에서 관리할 수 있지 않을까 추측해봅니다😄
There was a problem hiding this comment.
좋은 의견인 것 같아요!🚀
카카오 관련 클래스를 하나 만들면 제가 카카오 로그인에 사용했던 부분들도 그 쪽으로 옮길 수 있을 것 같네용
There was a problem hiding this comment.
헉 ㅠ 동의합니다
이렇게 리팩토링하니 로직 분리가 되어서 훨씬 깔끔하고 유지보수하기 좋아졌네요
아직 이 코드에 딥링크 적용하기엔 너무 복잡한 것 같아서 임시방편으로 공유 되는 것까지 확인했습니다! 감사해용오 ㅜㅜ!!!!
| data class Toast(@StringRes val message: Int) : | ||
| InternSideEffect() | ||
|
|
||
| data class ShareKakaoTalk(val internInfo: InternInfo) : InternSideEffect() |
There was a problem hiding this comment.
위처럼 바꾸면 ShareKakaoTalk SideEffect도 불필요해지겠네요!
| fun shareWithKakaoTalk( | ||
| internInfo: InternInfo | ||
| ) { | ||
| viewModelScope.launch { | ||
| _sideEffect.emit(InternSideEffect.ShareKakaoTalk(internInfo)) | ||
| } | ||
| } |
There was a problem hiding this comment.
여기에서 바로 카카오 공유하기를 실행시키는 그런 그림?
| navController.popBackStack() | ||
| }, | ||
| actions = listOf( | ||
| {}, |
There was a problem hiding this comment.
요기 빈 람다 없어도 되는거면 지우는게 좋을 것 같아요!
There was a problem hiding this comment.
생각해보니 탑바 액션 리스트에서 이제 drop 1을 할 필요가 없는데 나이스캐치네요 ㅠㅠ 싹다 리팩토링ㅎ ㅐ주었습니다
| .noRippleClickable { | ||
| onClickShareButton() | ||
| } |
There was a problem hiding this comment.
onClick 함수가 2번 적용되는 것 같아요! Icon 내부에서 클릭 이벤트를 지정해준다면 IconButton을 사용하지 않아도 괜찮지 않을까 싶네요😊
| .noRippleClickable { | |
| onClickShareButton() | |
| } | |
| .noRippleClickable(onClick = onClickShareButton) |
그리고 람다를 새로 생성하면 객체가 하나 추가되는거라 미세하게나마 성능에 영향을 줄 수 있을 것 같아요! onClickShareButton만 실행하는 것이라면 함수 그대로 바로 넘겨주는 것은 어떨까요?
There was a problem hiding this comment.
가독성이 훨씬 좋아졌읍니다 최고 ㅠㅠ!
| private fun shareToKakaoTalk(context: Context, internInfo: InternInfo) { | ||
| val templateId = 118600L | ||
|
|
||
| val templateArgs = mapOf( | ||
| "COMPANY_IMG" to internInfo.companyImage, | ||
| "TITLE" to internInfo.title, | ||
| "DEADLINE" to internInfo.deadline, | ||
| "START_DATE" to internInfo.startYearMonth, | ||
| "PERIOD" to internInfo.workingPeriod, | ||
| "REGI_WEB_DOMAIN" to internInfo.url, | ||
| "A_E" to internInfo.url, | ||
| "I_E" to internInfo.url | ||
| ) | ||
|
|
||
| if (ShareClient.instance.isKakaoTalkSharingAvailable(context)) { | ||
| ShareClient.instance.shareCustom( | ||
| context, | ||
| templateId, | ||
| templateArgs | ||
| ) { sharingResult, error -> | ||
| if (error != null) { | ||
| Timber.e("카카오톡 공유 실패: ${error.message}") | ||
| } else if (sharingResult != null) { | ||
| context.startActivity(sharingResult.intent) | ||
| } | ||
| } | ||
| } else { | ||
| val sharerUrl = WebSharerClient.instance.makeCustomUrl(templateId, templateArgs) | ||
| try { | ||
| KakaoCustomTabsClient.openWithDefault(context, sharerUrl) | ||
| } catch (e: Exception) { | ||
| Timber.e("웹 공유 실패: ${e.message}") | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
좋은 의견인 것 같아요!🚀
카카오 관련 클래스를 하나 만들면 제가 카카오 로그인에 사용했던 부분들도 그 쪽으로 옮길 수 있을 것 같네용
# Conflicts: # feature/intern/src/main/java/com/terning/feature/intern/InternRoute.kt # feature/intern/src/main/java/com/terning/feature/intern/InternViewModel.kt # feature/intern/src/main/java/com/terning/feature/intern/InternViewSideEffect.kt
boiledeggg
left a comment
There was a problem hiding this comment.
너무 고생많으셨습니다!! 마지막 딥링크까지 화이팅💪
| dependencies { | ||
| // domain | ||
| implementation(projects.domain.intern) | ||
| implementation(libs.kakao.share) |
There was a problem hiding this comment.
카카오 util 클래스를 만들었으니 이 의존성은 없어도 되지 않나요??
| class KakaoUtil @Inject constructor( | ||
| @ApplicationContext private val context: Context | ||
| ) { | ||
| private val templateId = 118600L |
There was a problem hiding this comment.
이 templateId는 무슨 기준으로 넣는건가요?? 단순 궁금증ㅎ
There was a problem hiding this comment.
카카오 공유하기 메시지를 커스텀으로 만들때 식별하는 ID인데 일단 임의로 넣어둔 값이고 지금은 의미가 없어서 ㅜㅜ 다음 feature에서 유동적으로 수정하려고 합니당!
leeeyubin
left a comment
There was a problem hiding this comment.
확인했습니다! 만약에 저도 로그인 로직 구현을 위해 이 KakaoUtil 클래스를 사용한다면 따로 인터페이스를 만들어서 역할을 분리할 수 있게 만들어야겠네요!
⛳️ Work Description
📸 Screenshot
364.webm
📢 To Reviewers