Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions JLPTVoca/JLPTVoca/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ struct ContentView: View {
Label("사전", systemImage: "book.fill")
}

DictionaryView()
SettingView()
.tabItem {
Label("전체 사전", systemImage: "book.fill")
Label("설정", systemImage: "gearshape.fill")
}
}
.environment(wordManager)
Expand Down
2 changes: 1 addition & 1 deletion JLPTVoca/JLPTVoca/Managers/WordManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class WordManager {
if direction == .left {
swipedWord.maturityState += 1
} else {
swipedWord.maturityState = 1
swipedWord.maturityState = 2
}

wordDeck.removeAll { $0.id == id }
Expand Down
19 changes: 19 additions & 0 deletions JLPTVoca/JLPTVoca/Navigation/AppRoute.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

//
// AppRoute.swift
// JLPTVoca
//
// Created by Rama on 8/31/25.
//

import Foundation

enum HomeRoute: Hashable {
case wordStudy
}

enum DictionaryRoute: Hashable {
case entireWords
case favoriteWords
}

25 changes: 25 additions & 0 deletions JLPTVoca/JLPTVoca/Navigation/NavigationManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// NavigationManager.swift
// JLPTVoca
//
// Created by Rama on 8/31/25.
//

import SwiftUI

@Observable
final class NavigationManager<Route: Hashable> {
var path = NavigationPath()

func navigate(_ route: Route) {
path.append(route)
}

func pop() {
path.removeLast()
}

func popToRoot() {
path.removeLast(path.count)
}
}
23 changes: 11 additions & 12 deletions JLPTVoca/JLPTVoca/Views/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,14 @@ import SwiftUI

struct HomeView: View {
@Environment(WordManager.self) private var wordManager

@State private var isStudyViewActive = false
@State private var router = NavigationManager<HomeRoute>()

var body: some View {
NavigationStack {
NavigationStack(path: $router.path) {
VStack(spacing: 20) {
NavigationLink(
destination: WordStudyView(),
isActive: $isStudyViewActive
) {
EmptyView()
}

Button(action: {
wordManager.prepareSession()
isStudyViewActive = true
router.navigate(.wordStudy)
}) {
Text("단어 학습 시작")
.font(.title2)
Expand All @@ -35,8 +27,15 @@ struct HomeView: View {
.cornerRadius(10)
}
}
.navigationTitle("홈")
.navigationTitle("JLPT-VOCA")
.navigationDestination(for: HomeRoute.self) { route in
switch route {
case .wordStudy:
WordStudyView()
}
}
}
.environment(router)
}
}

Expand Down