Rough dictionary list working
This commit is contained in:
		
							
								
								
									
										39
									
								
								Toki Trainer/Views/ContentView.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								Toki Trainer/Views/ContentView.swift
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
//
 | 
			
		||||
//  ContentView.swift
 | 
			
		||||
//  Toki Trainer
 | 
			
		||||
//
 | 
			
		||||
//  Created by Avery Ada Pace on 11/2/21.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
import SwiftUI
 | 
			
		||||
import CoreData
 | 
			
		||||
 | 
			
		||||
struct ContentView: View {
 | 
			
		||||
    
 | 
			
		||||
    @ObservedObject var jsonLoader = TokiJSONLoader()
 | 
			
		||||
    
 | 
			
		||||
    var body: some View {
 | 
			
		||||
        List(jsonLoader.dictionary, id: \.word) { entry in
 | 
			
		||||
            VStack(alignment: .leading) {
 | 
			
		||||
                Text(entry.word)
 | 
			
		||||
                    .font(.title)
 | 
			
		||||
                ForEach(entry.definitions, id: \.pos) { definition in
 | 
			
		||||
                    HStack(alignment: .top) {
 | 
			
		||||
                        Text(definition.pos)
 | 
			
		||||
                        Text(definition.definition)
 | 
			
		||||
                    }
 | 
			
		||||
                }}
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        .onAppear {
 | 
			
		||||
            self.jsonLoader.loadDictionary()
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct ContentView_Previews: PreviewProvider {
 | 
			
		||||
    static var previews: some View {
 | 
			
		||||
        ContentView()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										20
									
								
								Toki Trainer/Views/Toki_TrainerApp.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								Toki Trainer/Views/Toki_TrainerApp.swift
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
//
 | 
			
		||||
//  Toki_TrainerApp.swift
 | 
			
		||||
//  Toki Trainer
 | 
			
		||||
//
 | 
			
		||||
//  Created by Avery Ada Pace on 11/2/21.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
import SwiftUI
 | 
			
		||||
 | 
			
		||||
@main
 | 
			
		||||
struct Toki_TrainerApp: App {
 | 
			
		||||
    let persistenceController = PersistenceController.shared
 | 
			
		||||
 | 
			
		||||
    var body: some Scene {
 | 
			
		||||
        WindowGroup {
 | 
			
		||||
            ContentView()
 | 
			
		||||
                .environment(\.managedObjectContext, persistenceController.container.viewContext)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user