From 3b2b0bc3b5740847764cb40036b26e70c1b175d1 Mon Sep 17 00:00:00 2001 From: Avery Pace Date: Wed, 3 Nov 2021 14:40:45 -0400 Subject: [PATCH] Definition text formatting, colorize parts of speech --- Toki Trainer.xcodeproj/project.pbxproj | 4 ++++ Toki Trainer/Constants.swift | 26 ++++++++++++++++++++++++++ Toki Trainer/Views/ContentView.swift | 6 ++++++ 3 files changed, 36 insertions(+) create mode 100644 Toki Trainer/Constants.swift diff --git a/Toki Trainer.xcodeproj/project.pbxproj b/Toki Trainer.xcodeproj/project.pbxproj index 9eb81f4..5f47640 100644 --- a/Toki Trainer.xcodeproj/project.pbxproj +++ b/Toki Trainer.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 7E28111C273302860063DC78 /* toki-partsofspeech.json in Resources */ = {isa = PBXBuildFile; fileRef = 7E28111A273302860063DC78 /* toki-partsofspeech.json */; }; 7E28111D273302860063DC78 /* toki-dictionary.json in Resources */ = {isa = PBXBuildFile; fileRef = 7E28111B273302860063DC78 /* toki-dictionary.json */; }; 7E281120273303220063DC78 /* TokiPartsOfSpeechProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E28111F273303220063DC78 /* TokiPartsOfSpeechProvider.swift */; }; + 7E28112227330DD30063DC78 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E28112127330DD20063DC78 /* Constants.swift */; }; 7E943A21273211C200E7DDF4 /* Toki_TrainerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E943A20273211C200E7DDF4 /* Toki_TrainerApp.swift */; }; 7E943A23273211C200E7DDF4 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E943A22273211C200E7DDF4 /* ContentView.swift */; }; 7E943A25273211C300E7DDF4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7E943A24273211C300E7DDF4 /* Assets.xcassets */; }; @@ -28,6 +29,7 @@ 7E28111A273302860063DC78 /* toki-partsofspeech.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "toki-partsofspeech.json"; sourceTree = ""; }; 7E28111B273302860063DC78 /* toki-dictionary.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "toki-dictionary.json"; sourceTree = ""; }; 7E28111F273303220063DC78 /* TokiPartsOfSpeechProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokiPartsOfSpeechProvider.swift; sourceTree = ""; }; + 7E28112127330DD20063DC78 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; 7E943A1D273211C200E7DDF4 /* Toki Trainer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Toki Trainer.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 7E943A20273211C200E7DDF4 /* Toki_TrainerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toki_TrainerApp.swift; sourceTree = ""; }; 7E943A22273211C200E7DDF4 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; @@ -108,6 +110,7 @@ 7E2811122733024F0063DC78 /* Views */, 7E281111273302420063DC78 /* Models */, 7E943A24273211C300E7DDF4 /* Assets.xcassets */, + 7E28112127330DD20063DC78 /* Constants.swift */, 7E943A29273211C300E7DDF4 /* Persistence.swift */, 7E943A2B273211C300E7DDF4 /* Toki_Trainer.xcdatamodeld */, 7E943A26273211C300E7DDF4 /* Preview Content */, @@ -203,6 +206,7 @@ 7E2811172733027F0063DC78 /* TokiDictionary.swift in Sources */, 7E943A21273211C200E7DDF4 /* Toki_TrainerApp.swift in Sources */, 7E2811182733027F0063DC78 /* TokiJSONLoader.swift in Sources */, + 7E28112227330DD30063DC78 /* Constants.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Toki Trainer/Constants.swift b/Toki Trainer/Constants.swift new file mode 100644 index 0000000..ce3f85b --- /dev/null +++ b/Toki Trainer/Constants.swift @@ -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 + ] +} diff --git a/Toki Trainer/Views/ContentView.swift b/Toki Trainer/Views/ContentView.swift index 6f584db..f0f2b43 100644 --- a/Toki Trainer/Views/ContentView.swift +++ b/Toki Trainer/Views/ContentView.swift @@ -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) } }}