Skip to content

Commit

Permalink
feat :: new Notice 있을 때 애니메이션
Browse files Browse the repository at this point in the history
  • Loading branch information
HongSJae committed Mar 6, 2023
1 parent 4c7be36 commit 83ae6c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Projects/Features/HomeFeature/Sources/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions Projects/Features/HomeFeature/Sources/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
}
}

Expand Down

0 comments on commit 83ae6c5

Please sign in to comment.