feat(home): 팔로잉 탭 API 상태를 추가한다
This commit is contained in:
@@ -11,6 +11,7 @@ struct MainHomeView: View {
|
||||
let onTapCommunity: (Int) -> Void
|
||||
let onTapBanner: (RecommendationBannerResponse) -> Void
|
||||
let onTapFollowAll: (@escaping () -> Void) -> Void
|
||||
let onSelectFollowingTab: () -> Bool
|
||||
|
||||
@State private var selectedTab: MainHomeTab = .recommendation
|
||||
|
||||
@@ -31,7 +32,7 @@ struct MainHomeView: View {
|
||||
|
||||
TextTabBar(
|
||||
items: MainHomeTab.allCases,
|
||||
selectedItem: $selectedTab,
|
||||
selectedItem: selectedTabBinding,
|
||||
title: { $0.title }
|
||||
)
|
||||
|
||||
@@ -41,6 +42,19 @@ struct MainHomeView: View {
|
||||
.background(Color.black.ignoresSafeArea())
|
||||
}
|
||||
|
||||
private var selectedTabBinding: Binding<MainHomeTab> {
|
||||
Binding(
|
||||
get: { selectedTab },
|
||||
set: { newValue in
|
||||
if newValue == .following, onSelectFollowingTab() == false {
|
||||
return
|
||||
}
|
||||
|
||||
selectedTab = newValue
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var tabContent: some View {
|
||||
switch selectedTab {
|
||||
@@ -91,7 +105,8 @@ struct MainHomeView_Previews: PreviewProvider {
|
||||
onTapCharacter: { _ in },
|
||||
onTapCommunity: { _ in },
|
||||
onTapBanner: { _ in },
|
||||
onTapFollowAll: { action in action() }
|
||||
onTapFollowAll: { action in action() },
|
||||
onSelectFollowingTab: { true }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user