Part of speech highlighting when tapped from dictionary list
This commit is contained in:
49
Toki Trainer/Views/PartsOfSpeechView.swift
Normal file
49
Toki Trainer/Views/PartsOfSpeechView.swift
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// PartsOfSpeechView.swift
|
||||
// Toki Trainer
|
||||
//
|
||||
// Created by Avery Ada Pace on 11/4/21.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct PartsOfSpeechView: View {
|
||||
var selectedPartOfSpeech: String? = nil
|
||||
|
||||
@ObservedObject var tokiDictViewModel: TokiDictionaryViewModel
|
||||
|
||||
// init(selectedPartOfSpeech: String) {
|
||||
// _selectedPartOfSpeech = State(initialValue: selectedPartOfSpeech)
|
||||
// }
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text("Parts of Speech")
|
||||
.padding()
|
||||
VStack(alignment: .leading) {
|
||||
ForEach(tokiDictViewModel.partsOfSpeech, id: \.pos) { pos in
|
||||
HStack {
|
||||
Text(pos.pos)
|
||||
.frame(width: 45, height: 22, alignment: .center)
|
||||
.background(Color(K.posColors[pos.pos]!))
|
||||
.cornerRadius(5.0)
|
||||
.padding(1)
|
||||
Text(pos.definition)
|
||||
Spacer()
|
||||
}
|
||||
//.background(.blue)
|
||||
.background((selectedPartOfSpeech == pos.pos) ? Color(UIColor.systemGray4) : .white)
|
||||
.cornerRadius(5.0)
|
||||
.padding(2)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct PartsOfSpeechView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
PartsOfSpeechView(selectedPartOfSpeech: "sep", tokiDictViewModel: TokiDictionaryViewModel())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user