feat(home): 홈 탭 지연 로딩 및 상태 유지 구현
This commit is contained in:
@@ -40,24 +40,31 @@ struct HomeView: View {
|
||||
@State private var pendingExternalNavigationAction: (() -> Void)? = nil
|
||||
@State private var pendingExternalNavigationCancelAction: (() -> Void)? = nil
|
||||
@State private var payload = Payload()
|
||||
@State private var loadedTabs: Set<HomeViewModel.CurrentTab> = [AppState.shared.startTab]
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
ZStack(alignment: .bottom) {
|
||||
VStack(spacing: 0) {
|
||||
ZStack {
|
||||
homeTabView
|
||||
.frame(width: viewModel.currentTab == .home ? proxy.size.width : 0)
|
||||
.opacity(viewModel.currentTab == .home ? 1.0 : 0.01)
|
||||
|
||||
liveView
|
||||
.frame(width: viewModel.currentTab == .live ? proxy.size.width : 0)
|
||||
.opacity(viewModel.currentTab == .live ? 1.0 : 0.01)
|
||||
|
||||
chatTabView
|
||||
.frame(width: viewModel.currentTab == .chat ? proxy.size.width : 0)
|
||||
.opacity(viewModel.currentTab == .chat ? 1.0 : 0.01)
|
||||
|
||||
if loadedTabs.contains(.home) {
|
||||
homeTabView
|
||||
.frame(width: viewModel.currentTab == .home ? proxy.size.width : 0)
|
||||
.opacity(viewModel.currentTab == .home ? 1.0 : 0.01)
|
||||
}
|
||||
|
||||
if loadedTabs.contains(.live) {
|
||||
liveView
|
||||
.frame(width: viewModel.currentTab == .live ? proxy.size.width : 0)
|
||||
.opacity(viewModel.currentTab == .live ? 1.0 : 0.01)
|
||||
}
|
||||
|
||||
if loadedTabs.contains(.chat) {
|
||||
chatTabView
|
||||
.frame(width: viewModel.currentTab == .chat ? proxy.size.width : 0)
|
||||
.opacity(viewModel.currentTab == .chat ? 1.0 : 0.01)
|
||||
}
|
||||
|
||||
if viewModel.currentTab == .mypage {
|
||||
MyPageView()
|
||||
}
|
||||
@@ -183,6 +190,8 @@ struct HomeView: View {
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
markTabAsLoaded(viewModel.currentTab)
|
||||
|
||||
payload.applicationId = BOOTPAY_APP_ID
|
||||
payload.price = 0
|
||||
payload.pg = "다날"
|
||||
@@ -197,6 +206,9 @@ struct HomeView: View {
|
||||
viewModel.addAllPlaybackTracking()
|
||||
}
|
||||
}
|
||||
.valueChanged(value: viewModel.currentTab) { currentTab in
|
||||
markTabAsLoaded(currentTab)
|
||||
}
|
||||
|
||||
if appState.isShowNotificationSettingsDialog {
|
||||
NotificationSettingsDialog()
|
||||
@@ -525,6 +537,10 @@ struct HomeView: View {
|
||||
self.viewModel.pushTokenUpdate(pushToken: pushToken)
|
||||
}
|
||||
}
|
||||
|
||||
private func markTabAsLoaded(_ tab: HomeViewModel.CurrentTab) {
|
||||
loadedTabs.insert(tab)
|
||||
}
|
||||
}
|
||||
|
||||
extension Notification.Name {
|
||||
|
||||
Reference in New Issue
Block a user