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

snack bar 알림 추가 #75

Merged
merged 20 commits into from
Feb 16, 2024
Merged

snack bar 알림 추가 #75

merged 20 commits into from
Feb 16, 2024

Conversation

sangohkim
Copy link
Collaborator

@sangohkim sangohkim commented Feb 6, 2024

변경된 부분

  1. 자신의 게시글 좋아요, 싫어요를 누를 때
  2. 자신의 댓글 좋아요, 싫어요 누를 때
  3. 첨부파일 다운로드에 성공, 실패했을 때
  4. PostViewPage에서 '공유' 버튼을 누를 때
  5. ProfileEditPage에서 프로필 수정에 실패했을 때(닉네임 변경 기간 문제 또는 인터넷)
  6. 인터넷 문제 등으로 차단에 실패했을 때
  7. PostViewPage launchInBrowser에서 브라우저로 URL 열기에 실패했을 때
  8. 게시글을 신고했을 때

논의해볼 부분

  • '담아두기'에 스낵바 알림까지 필요할까

자신의 좋아요, 싫어요의 경우에 누르는 경우 불가능하다는 스낵바 알림 추가
자신의 댓글에 대한 좋아요, 싫어요 클릭 시에 알림을 보내주는 스낵바 구현
@sangohkim sangohkim requested a review from skykhs3 February 6, 2024 14:41
@sangohkim sangohkim self-assigned this Feb 6, 2024
프로필 업데이트에 실패했을 때 스낵바 메시지를 보여주도록 함.
차단에 실패했을 때 스낵바 메시지로 알림이 가도록 하였고 _showAraSnackBar 함수를 _showInfoBySnackBar로 수정하여 리팩토링을 진행함.
launchInBrowser가 실패했을 때 스낵바가 두 번 사용되어 하나를 제거함.
information.svg + 텍스트 형태의 동일한 스낵바가 자주 사용되어 snackbar_noti.dart에 함수화함
@sangohkim sangohkim marked this pull request as ready for review February 16, 2024 08:30
Comment on lines +2 to +22
{
"filename" : "40.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"filename" : "60.png",
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"filename" : "29.png",
"idiom" : "iphone",
"scale" : "1x",
"size" : "29x29"
},
{
"filename" : "58.png",
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

@sangohkim sangohkim Feb 16, 2024

Choose a reason for hiding this comment

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

엇 이건 제가 의도적으로 변경한 부분이 아니고 자동으로 정렬된 것 같습니다. 내용을 보니 단순 정렬로 보이네요.

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

const Duration _araSnackBarDisplayDuration = Duration(seconds: 4);
const Duration _araSnackBarDisplayDuration = Duration(seconds: 3);
Copy link
Collaborator

Choose a reason for hiding this comment

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

시간 2.5초 정도로 좀 더 줄여도 될것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

2.5초로 줄였습니다

/// showSnackBar 함수가 자주 쓰여서 함수로 분리함.
void _showAraSnackBar() {
/// information.svg를 사용하는 SnackBar가 자주 쓰여서 함수화함.
void _showInfoBySnackBar(String infoText) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

buildAraSnack과의 관련성을 주석으로 더 적어주시면 좋을 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

주석 추가하였습니다.

@skykhs3
Copy link
Collaborator

skykhs3 commented Feb 16, 2024

좋아요 버튼을 계속 눌렀을 때 노티가 큐처럼 쌓여 계속 떠 있는 문제가 발생합니다.
아래 챗 지피티 검색 내용 첨부합니다.

RPReplay_Final1708090790.MP4

Flutter에서 현재 떠있는 SnackBar를 프로그래밍 방식으로 제거하려면, ScaffoldMessenger를 사용해야 합니다. ScaffoldMessenger는 SnackBar를 포함한 여러 Scaffold 관련 메시지를 관리하는 데 사용됩니다. 특히, 현재 표시되고 있는 SnackBar를 숨기기 위해서는 ScaffoldMessenger의 hideCurrentSnackBar 메서드를 호출하면 됩니다.

다음은 현재 떠있는 SnackBar를 꺼지게 하는 방법을 보여주는 예시 코드입니다:

dart

void hideCurrentSnackBar(BuildContext context) {
  ScaffoldMessenger.of(context).hideCurrentSnackBar();
}

이 함수를 호출할 때는 현재 BuildContext를 인자로 제공해야 합니다. 예를 들어, 버튼을 눌렀을 때 현재 표시되고 있는 SnackBar를 제거하고 싶다면, 다음과 같이 버튼의 onPressed 콜백 안에서 이 함수를 호출할 수 있습니다:

dart

ElevatedButton(
  onPressed: () => hideCurrentSnackBar(context),
  child: Text('Hide SnackBar'),
)

이 방법을 사용하면 현재 표시되고 있는 SnackBar가 있을 경우, 그 SnackBar가 즉시 사라집니다. 만약 표시되고 있는 SnackBar가 없다면, hideCurrentSnackBar 메서드 호출은 아무런 효과가 없습니다.


제가 생각하는 방안은 _buildAraSnackBar 을 사용하는 부분도 showInfoBySnackBar처럼 어떤 함수 안에 넣어,
함수 상단부에 ScaffoldMessenger.of(context).hideCurrentSnackBar();를 넣으면 될 것 같습니다.
showInfoBySnackBar 에도 적용이 되어야합니다.

@sangohkim
Copy link
Collaborator Author

기존에 존재하던 스낵바를 제거하고 새로운 스낵바를 보여주는 함수를 구현하여 스낵바가 쌓이는 문제 해결했습니다. 다른 리뷰도 반영하였습니다.

Simulator.Screen.Recording.-.iPhone.15.-.2024-02-16.at.23.19.22.mp4

@sangohkim sangohkim requested a review from skykhs3 February 16, 2024 14:21
Comment on lines 85 to 95
ScaffoldMessenger.of(context).hideCurrentSnackBar();
return ScaffoldMessenger.of(context).showSnackBar(araSnackBar);
}

/// information.svg와 함께 동일한 위젯 구성을 가진 SnackBar가 자주 사용되어
/// infoText만 전달하면 반복적으로 생성이 가능하도록 함수화함.
void showInfoBySnackBar(BuildContext context, String infoText) {
// 이전에 존재하던 스낵바 제거
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(buildAraSnackBar(context,
Copy link
Collaborator

@skykhs3 skykhs3 Feb 16, 2024

Choose a reason for hiding this comment

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

같은 형식의 함수임에도 hideOldsAndShowAraSnackBar은 리턴값이 있는 이유가 무엇인가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ScaffoldMessenger.of(context).showSnackBar 대신 사용하는 함수로 만든거라 같은 리턴 타입을 지정했습니다. showInfoSnackBar와 리턴타입을 하나로 통일하는것이 좋을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

리턴값 제거했습니다

@sangohkim sangohkim requested a review from skykhs3 February 16, 2024 15:08
@sangohkim sangohkim merged commit 3d5ecce into dev Feb 16, 2024
2 checks passed
@skykhs3 skykhs3 deleted the feature/apply-snack-bar branch February 16, 2024 19:33
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