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

Feat [#360] 3차 스프린트 건의사항 반영 #361

Merged
merged 3 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion YELLO-iOS/YELLO-iOS/Global/Literals/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ enum StringLiterals {
}

enum Notification {
static let doNotSeeAgainLabel = "다시 보지 않기"
static let doNotSeeAgainLabel = "오늘 하루 보지 않기"
static let close = "닫기"
}

Expand Down
64 changes: 32 additions & 32 deletions YELLO-iOS/YELLO-iOS/Presentation/Around/View/AroundView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,7 @@ final class AroundView: BaseView {
var scrollCount = 0
var isUserSenderVote = false {
didSet {
if isUserSenderVote {
filterButtonLabel.text = StringLiterals.Around.myYello
filterButtonStackView.spacing = 0
filterButtonStackView.snp.updateConstraints {
$0.leading.equalToSuperview().inset(8.adjustedWidth)
}
aroundEmptyView.emptyDescriptionLabel.setTextWithLineHeight(
text: StringLiterals.Recommending.Empty.timeLineMyTitle,
lineHeight: 24)
} else {
filterButtonLabel.text = StringLiterals.Around.allYello
filterButtonStackView.spacing = 6.adjustedWidth
filterButtonStackView.snp.updateConstraints {
$0.leading.equalToSuperview().inset(20.adjustedWidth)
}
aroundEmptyView.emptyDescriptionLabel.setTextWithLineHeight(
text: StringLiterals.Recommending.Empty.timeLineAllTitle,
lineHeight: 24)
}

self.aroundPage = -1
self.aroundCount = -1
self.isFinishPaging = false
self.fetchingMore = false
self.aroundTableView.reloadData()
self.aroundModelDummy = []
self.around()
self.updateView()
updateAroundView()
}
}

Expand Down Expand Up @@ -221,10 +194,6 @@ final class AroundView: BaseView {
}
}

private func setAroundViewMode() {

}

// MARK: Custom Function
/// 친구가 없을 때 초대 뷰를 띄우는 로직
func updateView() {
Expand All @@ -236,6 +205,37 @@ final class AroundView: BaseView {
}
}

private func updateAroundView() {
if isUserSenderVote {
filterButtonLabel.text = StringLiterals.Around.myYello
filterButtonStackView.spacing = 0
filterButtonStackView.snp.updateConstraints {
$0.leading.equalToSuperview().inset(8.adjustedWidth)
}
aroundEmptyView.emptyDescriptionLabel.setTextWithLineHeight(
text: StringLiterals.Recommending.Empty.timeLineMyTitle,
lineHeight: 24)
} else {
filterButtonLabel.text = StringLiterals.Around.allYello
filterButtonStackView.spacing = 6.adjustedWidth
filterButtonStackView.snp.updateConstraints {
$0.leading.equalToSuperview().inset(20.adjustedWidth)
}
aroundEmptyView.emptyDescriptionLabel.setTextWithLineHeight(
text: StringLiterals.Recommending.Empty.timeLineAllTitle,
lineHeight: 24)
}

self.aroundPage = -1
self.aroundCount = -1
self.isFinishPaging = false
self.fetchingMore = false
self.aroundTableView.reloadData()
self.aroundModelDummy = []
self.around()
self.updateView()
}

// MARK: Objc Function
@objc func refreshTable(refresh: UIRefreshControl) {
self.isRefreshing = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,19 @@ extension NotificationView {
isTapped.toggle()
doNotSeeAgainButton.setImage(UIImage(imageLiteralResourceName: isTapped ? "btnCheckBox" : "btnNotCheckBox"), for: .normal)
UserDefaults.standard.set(isTapped, forKey: "isTapped")
if isTapped {
UserDefaults.standard.set(Date(), forKey: "tapDate")
}
}

@objc
private func doNotSeeLabelTapped() {
isTapped.toggle()
doNotSeeAgainButton.setImage(UIImage(imageLiteralResourceName: isTapped ? "btnCheckBox" : "btnNotCheckBox"), for: .normal)
UserDefaults.standard.set(isTapped, forKey: "isTapped")
if isTapped {
UserDefaults.standard.set(Date(), forKey: "tapDate")
}
}

@objc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ extension YELLOTabBarController {
case .success(let data):
guard let data = data.data else { return }
if data.isAvailable && self.notificationReadCount == 0 {
// 다시 보지 않기 버튼을 안눌렀거나 이전 공지와 현재 공지의 title이 다른 경우에만 표시
if !UserDefaults.standard.bool(forKey: "isTapped") || UserDefaults.standard.string(forKey: "notificationTitle") != data.title {
// 다시 보지 않기 버튼을 안눌렀거나 하루가 지났거나 이전 공지와 현재 공지의 title이 다른 경우에만 표시
if !UserDefaults.standard.bool(forKey: "isTapped") ||
self.hasDayPassed(from: UserDefaults.standard.object(forKey: "tapDate") as? Date ?? Date()) ||
UserDefaults.standard.string(forKey: "notificationTitle") != data.title {
self.userNotificationView.frame = self.view.bounds
self.userNotificationView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.userNotificationView.notificationImageView.kfSetImage(url: data.imageUrl)
Expand All @@ -273,6 +275,17 @@ extension YELLOTabBarController {
purchaseSubscribeNeed()
}

// 하루 지났는지 확인하는 함수
func hasDayPassed(from date: Date) -> Bool {
let calendar = Calendar.current
let currentDate = Date()

let startOfToday = calendar.startOfDay(for: currentDate)
let startOfTappedDate = calendar.startOfDay(for: date)

return calendar.dateComponents([.day], from: startOfTappedDate, to: startOfToday).day ?? 0 > 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기서 혹시 0>0은 bool 값으로 보내주는 건가요?
혹시 그냥 false로 설정하지 않은 이유가 있을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(day ?? 0 ) > 0 으로 봐주시면 될 것 같습니다 !!

}

/// 구독 연장 여부 서버통신
func purchaseSubscribeNeed() {
NetworkService.shared.purchaseService.purchaseSubscibeNeed { result in
Expand Down