Definition text formatting, colorize parts of speech

This commit is contained in:
Avery Pace
2021-11-03 14:40:45 -04:00
parent 731a71904a
commit 3b2b0bc3b5
3 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
//
// Constants.swift
// Toki Trainer
//
// Created by Avery Ada Pace on 11/2/21.
//
import Foundation
import UIKit
struct K {
static let posColors = [
"n": UIColor.systemGreen,
"mod": UIColor.systemYellow,
"sep": UIColor.systemPurple,
"vt": UIColor.systemBlue,
"vi": UIColor.systemCyan,
"interj": UIColor.systemRed,
"prep": UIColor.systemBrown,
"conj": UIColor.systemBrown,
"kama": UIColor.systemBrown,
"cont": UIColor.systemBrown,
"oth": UIColor.systemBrown,
"extra": UIColor.systemBrown
]
}

View File

@@ -20,7 +20,13 @@ struct ContentView: View {
ForEach(entry.definitions, id: \.pos) { definition in
HStack(alignment: .top) {
Text(definition.pos)
.frame(width: 60, height: 22, alignment: .center)
.background(Color(K.posColors[definition.pos]!))
.cornerRadius(5.0)
.padding(4)
Text(definition.definition)
.fixedSize(horizontal: false, vertical: true)
.padding(4)
}
}}