From 83ae6c5c63118e2ccb2a80abdc79bdc3a957295c Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Mon, 6 Mar 2023 23:08:14 +0900 Subject: [PATCH] =?UTF-8?q?feat=20::=20new=20Notice=20=EC=9E=88=EC=9D=84?= =?UTF-8?q?=20=EB=95=8C=20=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Features/HomeFeature/Sources/HomeView.swift | 10 ++++++++-- .../Features/HomeFeature/Sources/HomeViewModel.swift | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/HomeView.swift b/Projects/Features/HomeFeature/Sources/HomeView.swift index af4c3d57..1721fc1c 100644 --- a/Projects/Features/HomeFeature/Sources/HomeView.swift +++ b/Projects/Features/HomeFeature/Sources/HomeView.swift @@ -44,14 +44,20 @@ struct HomeView: View { } label: { NoticeView() } + .offset(x: viewModel.isExistNewNotice ? 0 : 50) + .opacity(viewModel.isExistNewNotice ? 1 : 0) + .animation( + .easeInOut(duration: 1), + value: viewModel.isExistNewNotice + ) } Text("오늘의 급식") .dmsFont(.title(.title1), color: .GrayScale.gray7) - .padding(.top, viewModel.isExistNewNotice ? 16 : 46) + .padding(.top, viewModel.isExistNewNotice ? 10 : 46) selectDateView() - .padding(.top, 24) + .padding(.top, 15) MealCarouselView( meal: viewModel.selectedDateMeal, diff --git a/Projects/Features/HomeFeature/Sources/HomeViewModel.swift b/Projects/Features/HomeFeature/Sources/HomeViewModel.swift index 4a9bbd89..63a6c45d 100644 --- a/Projects/Features/HomeFeature/Sources/HomeViewModel.swift +++ b/Projects/Features/HomeFeature/Sources/HomeViewModel.swift @@ -4,10 +4,11 @@ import DomainModule import ErrorModule import Foundation import Utility +import SwiftUI final class HomeViewModel: BaseViewModel { @Published var selectedDate = Date() - @Published var isExistNewNotice = true + @Published var isExistNewNotice = false @Published var meals: [String: MealEntity] = [:] @Published var prevMonth = Date().month var selectedDateString: String { @@ -36,7 +37,11 @@ final class HomeViewModel: BaseViewModel { func onAppear() { addCancellable(fetchWhetherNewNoticeUseCase.execute()) { [weak self] isExistNewNotice in - self?.isExistNewNotice = isExistNewNotice + DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { + withAnimation { + self?.isExistNewNotice = isExistNewNotice + } + } } }