본인인증을 한 유저만 메시지 탭이 보이도록 수정

This commit is contained in:
Yu Sung 2023-08-21 04:20:13 +09:00
parent 3ab5735fde
commit 8b7f3fbd07
1 changed files with 38 additions and 26 deletions

View File

@ -9,12 +9,22 @@ import SwiftUI
struct BottomTabView: View { struct BottomTabView: View {
let width: CGFloat let width: CGFloat
let tabWidth: CGFloat
@Binding var currentTab: HomeViewModel.CurrentTab @Binding var currentTab: HomeViewModel.CurrentTab
init(width: CGFloat, currentTab: Binding<HomeViewModel.CurrentTab>) {
self.width = width
self._currentTab = currentTab
if UserDefaults.bool(forKey: .auth) {
tabWidth = width / 5
} else {
tabWidth = width / 4
}
}
var body: some View { var body: some View {
HStack(spacing: 0) { HStack(spacing: 0) {
let tabWidth = width / 5
TabButton( TabButton(
title: "콘텐츠", title: "콘텐츠",
action: { action: {
@ -90,30 +100,32 @@ struct BottomTabView: View {
width: tabWidth width: tabWidth
) )
TabButton( if UserDefaults.bool(forKey: .auth) {
title: "메시지", TabButton(
action: { title: "메시지",
if currentTab != .message { action: {
currentTab = .message if currentTab != .message {
} currentTab = .message
}, }
image: { },
currentTab == .message ? image: {
"ic_tabbar_message_selected" : currentTab == .message ?
"ic_tabbar_message_normal" "ic_tabbar_message_selected" :
}, "ic_tabbar_message_normal"
fontName: { },
currentTab == .message ? fontName: {
Font.bold.rawValue : currentTab == .message ?
Font.medium.rawValue Font.bold.rawValue :
}, Font.medium.rawValue
color: { },
currentTab == .message ? color: {
Color(hex: "9970ff") : currentTab == .message ?
Color(hex: "909090") Color(hex: "9970ff") :
}, Color(hex: "909090")
width: tabWidth },
) width: tabWidth
)
}
TabButton( TabButton(
title: "마이", title: "마이",