diff --git a/Application/Resources/Assets.xcassets/Image/Icon/ThumbDownNoti.imageset/Contents.json b/Application/Resources/Assets.xcassets/Image/Icon/ThumbDownNoti.imageset/Contents.json new file mode 100644 index 00000000..1425c9b5 --- /dev/null +++ b/Application/Resources/Assets.xcassets/Image/Icon/ThumbDownNoti.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "ThumbDown.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Application/Resources/Assets.xcassets/Image/Icon/ThumbDownNoti.imageset/ThumbDown.svg b/Application/Resources/Assets.xcassets/Image/Icon/ThumbDownNoti.imageset/ThumbDown.svg new file mode 100644 index 00000000..be82a042 --- /dev/null +++ b/Application/Resources/Assets.xcassets/Image/Icon/ThumbDownNoti.imageset/ThumbDown.svg @@ -0,0 +1,3 @@ + + + diff --git a/Application/Resources/Assets.xcassets/Image/Icon/ThumbUp.imageset/Contents.json b/Application/Resources/Assets.xcassets/Image/Icon/ThumbUp.imageset/Contents.json index 5656a3d7..4ae5ec00 100644 --- a/Application/Resources/Assets.xcassets/Image/Icon/ThumbUp.imageset/Contents.json +++ b/Application/Resources/Assets.xcassets/Image/Icon/ThumbUp.imageset/Contents.json @@ -8,5 +8,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Application/Resources/Assets.xcassets/Image/Icon/ThumbUpNoti.imageset/Contents.json b/Application/Resources/Assets.xcassets/Image/Icon/ThumbUpNoti.imageset/Contents.json new file mode 100644 index 00000000..55e6ab19 --- /dev/null +++ b/Application/Resources/Assets.xcassets/Image/Icon/ThumbUpNoti.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "ThumbUpNoti.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Application/Resources/Assets.xcassets/Image/Icon/ThumbUpNoti.imageset/ThumbUpNoti.svg b/Application/Resources/Assets.xcassets/Image/Icon/ThumbUpNoti.imageset/ThumbUpNoti.svg new file mode 100644 index 00000000..6bf27429 --- /dev/null +++ b/Application/Resources/Assets.xcassets/Image/Icon/ThumbUpNoti.imageset/ThumbUpNoti.svg @@ -0,0 +1,3 @@ + + + diff --git a/Application/Sources/ResoucesCode/Image.swift b/Application/Sources/ResoucesCode/Image.swift index 712cd56a..a9e0c183 100644 --- a/Application/Sources/ResoucesCode/Image.swift +++ b/Application/Sources/ResoucesCode/Image.swift @@ -21,6 +21,8 @@ extension Image { static let home = Image("Home") static let settingIcon = Image("Setting") static let thumbUpIcon = Image("ThumbUp") + static let thumbUpNotiIcon = Image("ThumbUpNoti") + static let thumbDownNotiIcon = Image("ThumbDownNoti") static let userIcon = Image("User") static let viewMoreIcon = Image("ViewMore") static let warningTriangleIcon = Image("WarningTriangle") diff --git a/Application/Sources/Scene/Home/HomeView.swift b/Application/Sources/Scene/Home/HomeView.swift index 05f7e30a..dd57e6df 100644 --- a/Application/Sources/Scene/Home/HomeView.swift +++ b/Application/Sources/Scene/Home/HomeView.swift @@ -65,14 +65,14 @@ struct HomeView: View, XNavigationAndTabContent { .sdText(type: .heading6, textColor: .GrayScale.gray900) .padding(.leading, 5) } -// ToolbarItemGroup(placement: .navigationBarTrailing) { -// Button { -// self.xquareRouter.navigateTo(.notification) -// } label: { -// Image.bell -// .frame(width: 24, height: 24) -// } -// } + ToolbarItemGroup(placement: .navigationBarTrailing) { + Button { + self.xquareRouter.navigateTo(.notification) + } label: { + Image.bell + .frame(width: 24, height: 24) + } + } } .sdOkayAlert(isPresented: $viewModel.isPresentErrorAlert, sdAlert: { SDOkayAlert(title: "교실로 이동할 수 없습니다.", message: "관리에게 문의해주세요!") diff --git a/Application/Sources/Scene/Notification/Cell/NotificationListCell.swift b/Application/Sources/Scene/Notification/Cell/NotificationListCell.swift index 1f48f74b..6f4e4d42 100644 --- a/Application/Sources/Scene/Notification/Cell/NotificationListCell.swift +++ b/Application/Sources/Scene/Notification/Cell/NotificationListCell.swift @@ -5,31 +5,29 @@ import SemicolonDesign import XDateUtil struct NotificationListCell: View { + @EnvironmentObject var xquareRouter: XquareRouter let entity: NotificationEntity var body: some View { HStack(alignment: .top, spacing: 0) { - topicToImage(topic: entity.topic) .frame(width: 24, height: 24) .padding(.trailing, 4) .foregroundColor(entity.isRead ? .GrayScale.gray700 : .Primary.purple400) - VStack(alignment: .leading, spacing: 0) { - + VStack(alignment: .leading, spacing: 4) { HStack(spacing: 4) { - Text(entity.categoryName) + Text(entity.title) .sdText(type: .caption) Spacer() - Text(getTimeForSend(date: entity.sendAt)) .sdText(type: .caption) } Text(entity.content) .sdText(type: .body3, textColor: .GrayScale.gray900) } - .padding(.top, 2) + .padding(.top, 3) } .padding(16) @@ -45,20 +43,26 @@ struct NotificationListCell: View { return "\((Int(today.toString(format: "dd")) ?? 0) - (Int(date.toString(format: "dd")) ?? 0))일 전" } else if Int(today.toString(format: "HH")) ?? 0 > Int(date.toString(format: "HH")) ?? 0 { return "\((Int(today.toString(format: "HH")) ?? 0) - (Int(date.toString(format: "HH")) ?? 0))시간 전" - } else { + } else if Int(today.toString(format: "mm")) ?? 0 > Int(date.toString(format: "mm")) ?? 0 { return "\((Int(today.toString(format: "mm")) ?? 0) - (Int(date.toString(format: "mm")) ?? 0))분 전" + } else { + return "방금 전" } } + // swiftlint:disable line_length private func topicToImage(topic: NotificationTopic) -> Image { switch topic { - case .feed: - return .feed - case .application: - return .application - case .schedule: - return .calendar - default: - return Image.entire + case .applicationWeekendMeal, .applicationStay, .applicationMoveClassRoom, .applicationPicnic, .applicationPicnicPass, .applicationWeekendPicnic, .applicationWeekendPicnicReservation: + return Image.application + case .allGoodPoint: + return Image.thumbUpNotiIcon + case .allBadPoint, .allPenaltyLevel: + return Image.thumbDownNotiIcon + case .scheduleLocal, .scheduleSocial: + return Image.calendar + case .feedNotice, .feedComment, .feedLike: + return Image.feed } } + // swiftlint:enable line_length } diff --git a/Application/Sources/Scene/Notification/NotificationViewModel.swift b/Application/Sources/Scene/Notification/NotificationViewModel.swift index a993b8b6..1777543c 100644 --- a/Application/Sources/Scene/Notification/NotificationViewModel.swift +++ b/Application/Sources/Scene/Notification/NotificationViewModel.swift @@ -16,7 +16,7 @@ class NotificationViewModel: ObservableObject { func fetchNotification() { self.fetchPostedNotificationListUseCase.excute() .subscribe(onNext: { - self.notifications = $0 + self.notifications = $0.sorted(by: { $0.sendAt > $1.sendAt }) }) .disposed(by: disposeBag) } diff --git a/Services/NotificationService/Sources/Data/Remote/Response/NotificationResponse.swift b/Services/NotificationService/Sources/Data/Remote/Response/NotificationResponse.swift index 4ff12859..8d5c82d7 100644 --- a/Services/NotificationService/Sources/Data/Remote/Response/NotificationResponse.swift +++ b/Services/NotificationService/Sources/Data/Remote/Response/NotificationResponse.swift @@ -10,8 +10,6 @@ struct NotificationResponse: Decodable { case sendAt = "sent_at" case isRead = "is_read" case userId = "user_id" - case destination - case categoryName = "category_name" case topic } let id: String @@ -20,8 +18,6 @@ struct NotificationResponse: Decodable { let sendAt: String let isRead: Bool let userId: String - let destination: String - let categoryName: String let topic: String } @@ -34,9 +30,7 @@ extension NotificationResponse { sendAt: sendAt.toDate(format: .fullDateWithTime), isRead: isRead, userId: userId, - destination: destination, - categoryName: categoryName, - topic: .init(rawValue: topic) ?? .all + topic: .init(rawValue: topic) ?? .allGoodPoint ) } } diff --git a/Services/NotificationService/Sources/Domain/Entity/NotificationEntity.swift b/Services/NotificationService/Sources/Domain/Entity/NotificationEntity.swift index c9d3ecce..f8f677bf 100644 --- a/Services/NotificationService/Sources/Domain/Entity/NotificationEntity.swift +++ b/Services/NotificationService/Sources/Domain/Entity/NotificationEntity.swift @@ -7,7 +7,5 @@ public struct NotificationEntity: Equatable { public let sendAt: Date public let isRead: Bool public let userId: String - public let destination: String - public let categoryName: String public let topic: NotificationTopic } diff --git a/Services/NotificationService/Sources/Domain/Enum/NotificationTopic.swift b/Services/NotificationService/Sources/Domain/Enum/NotificationTopic.swift index 9a66e88c..2cfe4904 100644 --- a/Services/NotificationService/Sources/Domain/Enum/NotificationTopic.swift +++ b/Services/NotificationService/Sources/Domain/Enum/NotificationTopic.swift @@ -1,8 +1,19 @@ import Foundation public enum NotificationTopic: String { - case feed = "FEED" - case application = "APPLICATION" - case schedule = "SCHEDULE" - case all = "ALL" + case applicationWeekendMeal = "APPLICATION_WEEKEND_MEAL" + case applicationStay = "APPLICATION_STAY" + case applicationMoveClassRoom = "APPLICATION_MOVE_CLASSROOM" + case applicationPicnic = "APPLICATION_PICNIC" + case applicationPicnicPass = "APPLICATION_PICNIC_PASS" + case applicationWeekendPicnic = "APPLICATION_WEEKEND_PICNIC" + case applicationWeekendPicnicReservation = "APPLICATION_WEEKEND_PICNIC_RESERVATION" + case allBadPoint = "ALL_BAD_POINT" + case allGoodPoint = "ALL_GOOD_POINT" + case allPenaltyLevel = "ALL_PENALTY_LEVEL" + case scheduleLocal = "SCHEDULE_LOCAL" + case scheduleSocial = "SCHEDULE_SOCIAL" + case feedNotice = "FEED_NOTICE" + case feedComment = "FEED_COMMENT" + case feedLike = "FEED_LIKE" }