feat: 상단에 최근 공지사항 표시
This commit is contained in:
@@ -97,6 +97,10 @@ struct MyPageView: View {
|
|||||||
CategoryButtonsView(
|
CategoryButtonsView(
|
||||||
isShowAuthView: $viewModel.isShowAuthView,
|
isShowAuthView: $viewModel.isShowAuthView,
|
||||||
isAuthenticated: viewModel.isAuth,
|
isAuthenticated: viewModel.isAuth,
|
||||||
|
showMessage: {
|
||||||
|
viewModel.errorMessage = $0
|
||||||
|
viewModel.isShowPopup = true
|
||||||
|
},
|
||||||
refresh: {
|
refresh: {
|
||||||
viewModel.getMypage()
|
viewModel.getMypage()
|
||||||
}
|
}
|
||||||
@@ -126,6 +130,7 @@ struct MyPageView: View {
|
|||||||
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||||
viewModel.getMypage()
|
viewModel.getMypage()
|
||||||
}
|
}
|
||||||
|
viewModel.getLatestNotice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,7 +177,7 @@ struct MyPageHeaderView: View {
|
|||||||
if isShowButton {
|
if isShowButton {
|
||||||
HStack(spacing: 24) {
|
HStack(spacing: 24) {
|
||||||
// Settings Icon
|
// Settings Icon
|
||||||
Image(systemName: "ic_settings")
|
Image("ic_settings")
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
.frame(width: 24, height: 24)
|
.frame(width: 24, height: 24)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
@@ -183,7 +188,6 @@ struct MyPageHeaderView: View {
|
|||||||
}
|
}
|
||||||
.padding(.horizontal, 24)
|
.padding(.horizontal, 24)
|
||||||
.padding(.vertical, 20)
|
.padding(.vertical, 20)
|
||||||
.background(Color.black)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,22 +363,30 @@ struct CategoryButtonsView: View {
|
|||||||
@Binding var isShowAuthView: Bool
|
@Binding var isShowAuthView: Bool
|
||||||
|
|
||||||
let isAuthenticated: Bool
|
let isAuthenticated: Bool
|
||||||
|
let showMessage: (String) -> Void
|
||||||
let refresh: () -> Void
|
let refresh: () -> Void
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 3), spacing: 14) {
|
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 4), spacing: 16) {
|
||||||
CategoryButtonItem(icon: "ic_my_storage", title: "보관함") {
|
CategoryButtonItem(icon: "ic_my_storage", title: "보관함") {
|
||||||
AppState.shared.setAppStep(step: .myBox(currentTab: .orderlist))
|
AppState.shared.setAppStep(step: .myBox(currentTab: .orderlist))
|
||||||
}
|
}
|
||||||
|
|
||||||
CategoryButtonItem(icon: "ic_my_block", title: "차단목록") {
|
CategoryButtonItem(icon: "ic_my_block", title: "차단목록") {
|
||||||
AppState.shared.setAppStep(step: .blockList)
|
AppState.shared.setAppStep(step: .blockList)
|
||||||
}
|
}
|
||||||
if isAuthenticated {
|
|
||||||
CategoryButtonItem(
|
CategoryButtonItem(
|
||||||
icon: "ic_my_coupon",
|
icon: "ic_my_coupon",
|
||||||
title: "쿠폰등록"
|
title: "쿠폰등록"
|
||||||
) {
|
) {
|
||||||
|
if isAuthenticated {
|
||||||
AppState.shared.setAppStep(step: .canCoupon(refresh: refresh))
|
AppState.shared.setAppStep(step: .canCoupon(refresh: refresh))
|
||||||
|
} else {
|
||||||
|
showMessage("본인인증 후 등록합니다.")
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||||
|
isShowAuthView = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,11 +402,11 @@ struct CategoryButtonsView: View {
|
|||||||
AppState.shared.setAppStep(step: .serviceCenter)
|
AppState.shared.setAppStep(step: .serviceCenter)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isAuthenticated {
|
CategoryButtonItem(
|
||||||
CategoryButtonItem(
|
icon: "ic_my_auth",
|
||||||
icon: "ic_my_auth",
|
title: isAuthenticated ? "인증완료" : "본인인증"
|
||||||
title: "본인인증"
|
) {
|
||||||
) {
|
if !isAuthenticated {
|
||||||
isShowAuthView = true
|
isShowAuthView = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,4 +125,30 @@ final class MyPageViewModel: ObservableObject {
|
|||||||
isShowPopup = true
|
isShowPopup = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getLatestNotice() {
|
||||||
|
noticeRepository.getLatestNotice()
|
||||||
|
.sink { result in
|
||||||
|
switch result {
|
||||||
|
case .finished:
|
||||||
|
DEBUG_LOG("finish")
|
||||||
|
case .failure(let error):
|
||||||
|
ERROR_LOG(error.localizedDescription)
|
||||||
|
}
|
||||||
|
} receiveValue: {[unowned self] response in
|
||||||
|
self.isLoading = false
|
||||||
|
let responseData = response.data
|
||||||
|
|
||||||
|
do {
|
||||||
|
let jsonDecoder = JSONDecoder()
|
||||||
|
let decoded = try jsonDecoder.decode(ApiResponse<NoticeItem>.self, from: responseData)
|
||||||
|
|
||||||
|
if let data = decoded.data, decoded.success {
|
||||||
|
self.latestNotice = data
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.store(in: &subscription)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import Moya
|
|||||||
|
|
||||||
enum NoticeApi {
|
enum NoticeApi {
|
||||||
case getNotices
|
case getNotices
|
||||||
|
case getLatestNotice
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NoticeApi: TargetType {
|
extension NoticeApi: TargetType {
|
||||||
@@ -21,6 +22,9 @@ extension NoticeApi: TargetType {
|
|||||||
switch self {
|
switch self {
|
||||||
case .getNotices:
|
case .getNotices:
|
||||||
return "/notice"
|
return "/notice"
|
||||||
|
|
||||||
|
case .getLatestNotice:
|
||||||
|
return "/notice/latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +37,9 @@ extension NoticeApi: TargetType {
|
|||||||
case .getNotices:
|
case .getNotices:
|
||||||
let parameters = ["timezone": TimeZone.current.identifier] as [String: Any]
|
let parameters = ["timezone": TimeZone.current.identifier] as [String: Any]
|
||||||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
||||||
|
|
||||||
|
case .getLatestNotice:
|
||||||
|
return .requestPlain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,5 +17,9 @@ final class NoticeRepository {
|
|||||||
func getNotices() -> AnyPublisher<Response, MoyaError> {
|
func getNotices() -> AnyPublisher<Response, MoyaError> {
|
||||||
return api.requestPublisher(.getNotices)
|
return api.requestPublisher(.getNotices)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getLatestNotice() -> AnyPublisher<Response, MoyaError> {
|
||||||
|
return api.requestPublisher(.getLatestNotice)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user