feat(ios): tab tabanlı navigasyon ve okuma durumu takibi ekle

This commit is contained in:
2026-02-11 18:26:17 +03:00
parent 52212f015b
commit 362b9b7d1b
16 changed files with 976 additions and 442 deletions

View File

@@ -3,17 +3,25 @@ import SwiftUI
@MainActor
final class AppRouter: ObservableObject {
enum Tab: Hashable {
case library
case discover
case stats
case profile
}
enum Route: Hashable {
case addBooks
case category(name: String)
case detail(BookRemote)
}
@Published var isAuthenticated = false
@Published var selectedTab: Tab = .library
@Published var path: [Route] = []
func resetToHome() {
path.removeAll()
selectedTab = .library
}
}

View File

@@ -33,15 +33,13 @@ private struct RootView: View {
NavigationStack(path: $router.path) {
Group {
if router.isAuthenticated {
HomeView(viewModel: HomeViewModel())
MainTabView()
} else {
AuthView(viewModel: AuthViewModel(authService: dependencies.authService, keychain: dependencies.keychain))
}
}
.navigationDestination(for: AppRouter.Route.self) { route in
switch route {
case .addBooks:
AddBooksView(viewModel: AddBooksViewModel(booksService: dependencies.booksService))
case .category(let name):
CategoryListView(viewModel: CategoryViewModel(categoryName: name))
case .detail(let book):
@@ -70,3 +68,66 @@ private struct RootView: View {
}
}
}
private struct MainTabView: View {
@EnvironmentObject private var router: AppRouter
@Environment(\.dependencies) private var dependencies
var body: some View {
TabView(selection: $router.selectedTab) {
HomeView(viewModel: HomeViewModel())
.tabItem {
Label("Library", systemImage: "books.vertical")
}
.tag(AppRouter.Tab.library)
AddBooksView(viewModel: AddBooksViewModel(booksService: dependencies.booksService))
.tabItem {
Label("Discover", systemImage: "sparkle.magnifyingglass")
}
.tag(AppRouter.Tab.discover)
StatsPlaceholderView()
.tabItem {
Label("Stats", systemImage: "chart.line.uptrend.xyaxis")
}
.tag(AppRouter.Tab.stats)
ProfilePlaceholderView()
.tabItem {
Label("Profile", systemImage: "person.crop.circle")
}
.tag(AppRouter.Tab.profile)
}
}
}
private struct StatsPlaceholderView: View {
var body: some View {
ContentUnavailableView {
Label("Stats", systemImage: "chart.bar.xaxis")
} description: {
Text("Reading analytics yakında eklenecek.")
}
}
}
private struct ProfilePlaceholderView: View {
@EnvironmentObject private var router: AppRouter
@Environment(\.dependencies) private var dependencies
var body: some View {
NavigationStack {
List {
Section("Session") {
Button("Logout", role: .destructive) {
_ = dependencies.keychain.delete(for: AuthViewModel.tokenKey)
router.isAuthenticated = false
router.resetToHome()
}
}
}
.navigationTitle("Profile")
}
}
}