Skip to content

Commit

Permalink
πŸ”€ :: (#475) notification κ΅¬ν˜„
Browse files Browse the repository at this point in the history
  • Loading branch information
juyeong525 authored May 7, 2023
2 parents 324c64d + d64c557 commit 1f1efe5
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "ThumbDown.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "ThumbUpNoti.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Application/Sources/ResoucesCode/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 8 additions & 8 deletions Application/Sources/Scene/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: "κ΄€λ¦¬μ—κ²Œ λ¬Έμ˜ν•΄μ£Όμ„Έμš”!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand All @@ -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
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 1f1efe5

Please sign in to comment.