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

#134 [fix] 스낵바 띄우기 및 위치 조정 #137

Merged
merged 23 commits into from
Feb 2, 2024

Conversation

pump9918
Copy link
Collaborator

@pump9918 pump9918 commented Jan 25, 2024

📑 Work Description

  • dimen 이용한 dp값 -> px 조정
  • 프래그먼트 bottom 기준 스낵바 위치 조정
  • margin값으로 스낵바 가로 크기 조정
  • 스낵바 지속시간 1초(1000)
  • companion으로 HappyMyRoutineFragment 진입상황별 조건부 스낵바

🛠️ Issue

📷 Screenshot

Screen_Recording_20240202_123931_Softie.mp4

💬 To Reviewers

  • 가능하면 sharedPreference를 안쓰려고 했으나 visiblility로 두 뷰를 1개로 합쳐놓은 HappyRoutineFragment 특성상 고유 키를 이용해 구분하지 않으면 스낵바를 한번만 띄우기 어려웠습니다ㅜ (ActivityResultLauncher를 사용하려 했으나 제 위치로 스낵바를 적용하지 못하고 터지는 이슈가 있어서 사용하지 않았슴다.

  • (수정) sharedPreference 대신 companion으로 진입상황을 구분하여 스낵바를 띄웠습니다.

  • (수정의 수정) companion 대신 registerForActivityResult의 상태코드로 스낵바를 띄웠습니다

Copy link
Member

@minemi00 minemi00 left a comment

Choose a reason for hiding this comment

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

스낵바 때문에 sharedpreference 사용하느라 고생많으셨슴다..!!

Comment on lines 4 to 7
<dimen name="snackbar_delete_margin_bottom">47dp</dimen>
<dimen name="snackbar_add_margin_bottom">147dp</dimen>
<dimen name="snackbar_margin_start">12dp</dimen>
<dimen name="snackbar_margin_end">12dp</dimen>
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
Collaborator Author

Choose a reason for hiding this comment

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

참 알다가도 모르겠는 dimen...

@pump9918 pump9918 self-assigned this Jan 26, 2024
@pump9918 pump9918 added UI ui 관련 작업 호연🐻‍❄️ 호연이가 작업함! fix Fix(디자인 등) labels Jan 26, 2024
@pump9918 pump9918 changed the title [fix] 스낵바 띄우기 및 위치 조정 #134 [fix] 스낵바 띄우기 및 위치 조정 Jan 28, 2024
Copy link
Contributor

@stellar-halo stellar-halo 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 44 to 49
val sharedPreferences =
requireActivity().getSharedPreferences("HappyFirstAdd", MODE_PRIVATE)
if (sharedPreferences.getBoolean("isFirstAdded", false)) {
customHappyRoutineAddSnackBar()
sharedPreferences.edit().remove("isFirstAdded").apply()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

local에 계속 가지고 있어야 하는 값 + 자주 변경되지 않는 값인지 충분히 고민하고 써야 하는 값입니다!
해당 처리는 서버가 주는 값으로 충분히 처리할 수 있다고 판단이 됩니다.

참고: 이 클래스는 강력한 일관성을 보장합니다. 앱 속도를 저하시킬 수 있는 비용이 많이 드는 작업을 사용하고 있습니다. 자주 변경되는 속성이나 손실이 허용될 수 있는 속성은 다른 메커니즘을 사용해야 합니다.

해당 인용은 안드로이드 공식 문서에서 가져온 글입니다.
https://developer.android.com/reference/android/content/SharedPreferences
보통의 경우에는, 로그인 여부, 사용자의 아이디, 비밀번호 정도의 고정되고 서버만으로 처리하기 어려운 경우에 사용하고 해당처럼 자주 바뀌는 값은 사용하지 않습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

피드백 감사합니다! POST 요청시 서버에서 받는 routineId값을 최대한 활용하는 방안으로 리팩토링해보겠습니다 👍

Comment on lines 57 to 64
customSnackbar.setDuration(1000)
customSnackbar.setMargin(
resources.getDimensionPixelSize(R.dimen.snackbar_margin_start),
0,
resources.getDimensionPixelSize(R.dimen.snackbar_margin_end),
resources.getDimensionPixelSize(R.dimen.snackbar_add_margin_bottom)
)
customSnackbar.show()
Copy link
Contributor

Choose a reason for hiding this comment

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

고정 dp는 좋지 않습니다. 최대한 피해야 하는 방식이고 어쩔 수 없을 때 최후의 방식으로 써야되는 것입니다!
현재 custom snackbar에 anchor view가 써있고, 그 속성을 이용해 위치를 조정하는 것이 가장 베스트인 것 같습니다.
(현재 상황에서 적용이 안되지만, 왜 그런지 같이 알아내보는 것이 좋아보입니다)

Copy link
Collaborator Author

@pump9918 pump9918 Jan 28, 2024

Choose a reason for hiding this comment

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

Screenshot_20240128_164503_Softie

스낵바 역시 xml처럼 dp로 위치를 조정해야한다는 생각에 다소 미흡했던 것 같네요ㅜ 최대한 버튼 위에 anchor를 거는 방식을 써보겠습니다.

다만, 위 "삭제하기" 요청 이후 나타나는 스낵바는 특정 버튼이 아닌 프래그먼트 자체에 앵커를 거는데 고정dp로 특별한 조치를 하지 않으면 위처럼 바텀네비를 가리는 형태로 나타납니다. 여기서 Figma를 최대한 반영하기 위해선 dp를 사용하는 것이 불가피하다고 생각하는데 다른 추천 방식이 있을까요?

Copy link
Contributor

Choose a reason for hiding this comment

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

흠 제대로 작동만 된다면, 프래그먼트 bottom이 activity의 바텀 네비의 위이니 가리지 않을 것 같습니다!
제가 이전에 시도해봤을 때 anchor view 자체가 적용이 안되는 것 같더라고요. 아마 지금도 그래서 프래그먼트로 걸어줘도 안걸리는 듯 싶습니다. custom snackbar 쪽을 좀 더 자세하게 살펴보는 것이 필요해 보여요

Copy link
Contributor

Choose a reason for hiding this comment

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

@minemi00 의 최근 PR에 스낵바 위치 조정한 코드가 있습니다! 참고해보셔도 좋을 것 같아요!
#143 입니다.

Copy link
Member

@emjayMJkim emjayMJkim left a comment

Choose a reason for hiding this comment

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

리드님이 다 말해주셔서.. 수고하셨습니다!!

@pump9918 pump9918 requested a review from stellar-halo February 2, 2024 04:14
Copy link
Contributor

@stellar-halo stellar-halo left a comment

Choose a reason for hiding this comment

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

반영이 깔끔하게 됐네요! 고생하셨습니다. 다만, companion object로 선언할 때에는 변수가 아닌 상수일 경우입니다.

@@ -192,4 +190,8 @@ class HappyDetailActivity :
outRect.right = margin
}
}

companion object {
var HappyFirstAdd: Boolean = false
Copy link
Contributor

Choose a reason for hiding this comment

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

변수가 아닌 상수로 선언해주세요!
false값을 가진 상수 하나, true값을 가진 상수 하나 총 2개를 선언하여
각각의 상수일 때로 분기처리 하시면 될 듯 합니다.

Copy link
Collaborator Author

@pump9918 pump9918 Feb 2, 2024

Choose a reason for hiding this comment

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

각각을 상수로 처리할 경우 로직이 완전히 틀려질 것 같은데, 현재로는 다른 해결책을 떠올리기 어려웠습니다..
피드백 해주신대로 companion object에 변수를 넣지 않기 위해 전역변수를 object로 util에 생성하는 방향으로 bool 체크를 하였습니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

변수명을 잘 짓자
코드 실행 위치 헷갈리지 말자
구글에는 언제나 답이 있다

반드시 기억하겠습니다... @stellar-halo 감사합니다ㅜㅜ

Copy link
Contributor

@stellar-halo stellar-halo left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 상세한 부분만 수정해주시면 될 것 같아요!

@@ -50,10 +68,10 @@ class HappyMyRoutineFragment :
}
}

private fun setMyCardEnter() {
private fun setNewCardEnter() {
Copy link
Contributor

Choose a reason for hiding this comment

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

startHappyAddListActivity처럼 명시적으로 해주세요! 아니면 setImageHappy~ClickListener로 변경해도 좋아보입니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

변수는 소중하니까...

binding.ivHappyRoutineEmptyCard.setOnClickListener {
val intent = Intent(requireContext(), HappyAddListActivity::class.java)
startActivity(intent)
val intent = Intent(context, HappyAddListActivity::class.java)
Copy link
Contributor

Choose a reason for hiding this comment

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

context말고 requireContext로 바꿔주세요!
https://4z7l.github.io/2020/11/22/android-getcontext-requirecontext.html
차이점입니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

null을 쉽게 간과하고 사용했는데 그 차이 잘 알고 갑니다..!

…nackbar

# Conflicts:
#	app/src/main/java/com/sopetit/softie/ui/happyroutine/detail/HappyDetailActivity.kt
#	app/src/main/java/com/sopetit/softie/ui/happyroutine/list/HappyAddListActivity.kt
#	app/src/main/res/layout/item_happy_add_detail_card.xml
@pump9918 pump9918 merged commit 93b5ccb into develop Feb 2, 2024
1 check passed
@pump9918 pump9918 deleted the feature/#134-fix-snackbar branch February 2, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fix(디자인 등) UI ui 관련 작업 호연🐻‍❄️ 호연이가 작업함!
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[fix] 스낵바 띄우기 및 위치 조정
4 participants