Parts of Speech buttons, safe area inset

This commit is contained in:
Avery Pace 2021-11-03 19:38:53 -04:00
parent 3b2b0bc3b5
commit c7f50a4d3a

View File

@ -13,27 +13,49 @@ struct ContentView: View {
@ObservedObject var jsonLoader = TokiJSONLoader() @ObservedObject var jsonLoader = TokiJSONLoader()
var body: some View { var body: some View {
List(jsonLoader.dictionary, id: \.word) { entry in VStack {
VStack(alignment: .leading) { TextField("Enter Toki Pona Word or Phrase", text: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Value@*/.constant("")/*@END_MENU_TOKEN@*/)
Text(entry.word) .multilineTextAlignment(.center)
.font(.title) .padding(8)
ForEach(entry.definitions, id: \.pos) { definition in List(jsonLoader.dictionary, id: \.word) { entry in
HStack(alignment: .top) { VStack(alignment: .leading) {
Text(definition.pos) Text(entry.word)
.frame(width: 60, height: 22, alignment: .center) .font(.title)
.background(Color(K.posColors[definition.pos]!)) ForEach(entry.definitions, id: \.pos) { definition in
.cornerRadius(5.0) HStack(alignment: .top) {
.padding(4) Button(action: openPartsOfSpeechView) {
Text(definition.definition) Text(definition.pos)
.fixedSize(horizontal: false, vertical: true) .frame(width: 45, height: 22, alignment: .center)
.padding(4) .foregroundColor(.black)
.background(Color(K.posColors[definition.pos]!))
.cornerRadius(5.0)
.padding(4)
}
Text(definition.definition)
.fixedSize(horizontal: false, vertical: true)
.padding(4)
}
} }
}} }
}
} .safeAreaInset(edge: .bottom) {
.onAppear { HStack() {
self.jsonLoader.loadDictionary() Button(action: openPartsOfSpeechView) {
Text("Parts of Speech")
}
.padding(8)
}
.frame(maxWidth: .infinity)
.background(.thinMaterial)
}
.onAppear {
self.jsonLoader.loadDictionary()
}
} }
}
func openPartsOfSpeechView() {
print("Button pressed.")
} }
} }