Add environment object to all views and delete unused code from MainView

This commit is contained in:
2024-02-23 14:17:35 +01:00
parent c253938cb9
commit 5f474ca9cd
5 changed files with 14 additions and 3 deletions

View File

@@ -8,6 +8,7 @@
import SwiftUI
struct AnkiView: View {
@EnvironmentObject var model: WordAXModelView
var body: some View {
Text("This is Anki View")
}
@@ -15,4 +16,5 @@ struct AnkiView: View {
#Preview {
AnkiView()
.environmentObject(WordAXModelView())
}

View File

@@ -29,9 +29,8 @@ struct MainView: View {
Text("Settings")
}
}
.toolbar(.visible, for: .tabBar)
.toolbarBackground(Color.yellow, for: .tabBar)
}
}
}
@@ -39,4 +38,5 @@ struct MainView: View {
#Preview {
MainView()
.environmentObject(WordAXModelView())
}

View File

@@ -15,4 +15,5 @@ struct SettingsView: View {
#Preview {
SettingsView()
.environmentObject(WordAXModelView())
}

View File

@@ -9,9 +9,11 @@ import SwiftUI
@main
struct WordAXApp: App {
@StateObject var model = WordAXModelView()
var body: some Scene {
WindowGroup {
ContentView()
MainView()
.environmentObject(model)
}
}
}

View File

@@ -6,3 +6,9 @@
//
import Foundation
class WordAXModelView: ObservableObject {
init() {
}
}