iOS_app_test/tg_test/ContentView.swift
2026-09-24 14:06:21 +08:00

65 lines
1.7 KiB
Swift

//
// ContentView.swift
// tg_test
//
// Created by 陳奕呈 on 2026/9/23.
//
import SwiftUI
struct ContentView: View {
@State private var selectedIndex = 0
private let tabs = TabItem.allTabs
var body: some View {
ZStack {
// Background View Container
Group {
switch selectedIndex {
case 0:
HomeView()
case 1:
SearchView()
case 2:
NotificationsView()
case 3:
ProfileView()
case 4:
AnalyticsView()
case 5:
MessagesView()
case 6:
FavoritesView()
case 7:
DownloadsView()
case 8:
CloudView()
case 9:
SettingsView()
case 10:
HelpView()
default:
HomeView()
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.id(selectedIndex) // Enables smooth transition animation per view change
.transition(.asymmetric(
insertion: .opacity.combined(with: .scale(scale: 0.98)),
removal: .opacity
))
.safeAreaInset(edge: .bottom) {
// Spacer height corresponding to the WheelNavBar height
Color.clear.frame(height: 120)
}
}
.overlay(alignment: .bottom) {
WheelNavBar(selectedIndex: $selectedIndex, tabs: tabs)
}
.ignoresSafeArea(.keyboard, edges: .bottom)
}
}
#Preview {
ContentView()
}