Skip to content

Commit

Permalink
Feat:#138-MainView Foreground 진입 Refresh 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
VronzeWook committed Jan 15, 2025
1 parent 25b9945 commit f3c168a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Spha/Spha/Views/Home/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import SwiftUI

struct MainView: View {
@EnvironmentObject var router: RouterManager
@Environment(\.scenePhase) private var scenePhase

@StateObject private var viewModel = MainViewModel(HealthKitManager(), MindfulSessionManager())

@State private var introOpacity = 0.0
Expand Down Expand Up @@ -124,7 +126,7 @@ struct MainView: View {
.frame(width: 90, height: 90)
.foregroundStyle(.gray)
}
.padding(.top, 40)
.padding(.top, 48)
}
}
.refreshable {
Expand Down Expand Up @@ -156,6 +158,11 @@ struct MainView: View {
.onChange(of: self.isFirstLaunch) { oldValue, newValue in
viewModel.updateTodayRecord()
}
.onChange(of: scenePhase) { _, newPhase in // 추가: 앱 상태 변화 감지
if newPhase == .active { // 포그라운드로 복귀 시
viewModel.updateTodayRecord()
}
}
}

private func triggerRefresh() {
Expand Down

0 comments on commit f3c168a

Please sign in to comment.