Skip to content

Commit

Permalink
🔧 chore(project.pbxproj): update CURRENT_PROJECT_VERSION and MARKETIN…
Browse files Browse the repository at this point in the history
…G_VERSION to 2.0.3

✨ feat(Word.swift): add function to generate comparative adjective forms
🐛 fix(WordService.swift): add missing variables for generating comparative adjective forms

🔨 refactor(DynamicTable.swift): reformat code for better readability and maintainability
andskur committed Jan 10, 2024
1 parent edd5976 commit 148a40c
Showing 4 changed files with 180 additions and 14 deletions.
16 changes: 8 additions & 8 deletions OldNorseDictionary.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -575,7 +575,7 @@
CODE_SIGN_ENTITLEMENTS = Source/OldNorseDictionary.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.0.1;
CURRENT_PROJECT_VERSION = 2.0.3;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 4V482C5WA8;
ENABLE_HARDENED_RUNTIME = YES;
@@ -596,7 +596,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.3;
MARKETING_VERSION = 2.0.1;
MARKETING_VERSION = 2.0.3;
PRODUCT_BUNDLE_IDENTIFIER = Andskur.OldNorseDictionary;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -618,7 +618,7 @@
CODE_SIGN_ENTITLEMENTS = Source/OldNorseDictionary.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.0.1;
CURRENT_PROJECT_VERSION = 2.0.3;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 4V482C5WA8;
ENABLE_HARDENED_RUNTIME = YES;
@@ -639,7 +639,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.3;
MARKETING_VERSION = 2.0.1;
MARKETING_VERSION = 2.0.3;
PRODUCT_BUNDLE_IDENTIFIER = Andskur.OldNorseDictionary;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -701,7 +701,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.0.1;
CURRENT_PROJECT_VERSION = 2.0.3;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 4V482C5WA8;
ENABLE_PREVIEWS = YES;
@@ -713,7 +713,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.1;
MARKETING_VERSION = 2.0.3;
PRODUCT_BUNDLE_IDENTIFIER = Andskur.OldNorseDictionary.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
@@ -731,7 +731,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.0.1;
CURRENT_PROJECT_VERSION = 2.0.3;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 4V482C5WA8;
ENABLE_PREVIEWS = YES;
@@ -743,7 +743,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.1;
MARKETING_VERSION = 2.0.3;
PRODUCT_BUNDLE_IDENTIFIER = Andskur.OldNorseDictionary.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
72 changes: 68 additions & 4 deletions Source/Models/Word.swift
Original file line number Diff line number Diff line change
@@ -63,6 +63,69 @@ struct Word: Codable, Identifiable {

var id = UUID()

func generateComparativeAdjective(number: Number, gender: Gender, caseWeak: Case) -> String? {
if type != .adjective {
return nil
}

var weak = base

switch caseWeak {
case .nominative:
switch number {
case .singular:
switch gender {
case .masculine, .feminine:
return base! + "ari"
default:
return weak! + "ara"
}
case .dual, .plural:
return weak! + "ari"
}
case .accusative:
switch number {
case .singular:
switch gender {
case .feminine:
return weak! + "ari"
default:
return weak! + "ara"
}
case .dual, .plural:
return weak! + "ari"
}
case .dative:
switch number {
case .singular:
switch gender {
case .feminine:
return weak! + "ari"
default:
return weak! + "ara"
}
case .dual, .plural:
if base?.last == "v" {
weak?.removeLast()
}
return weak! + "urum"
}
case .genitive:
switch number {
case .singular:
switch gender {
case .feminine:
return weak! + "ari"
default:
return weak! + "ara"
}
case .dual, .plural:
return weak! + "ari"
}
}
}
func generateWeakAdjective(number: Number, gender: Gender, caseWeak: Case) -> String? {
if type != .adjective {
return nil
@@ -127,11 +190,12 @@ struct Word: Codable, Identifiable {
if acc.hasSuffix("ja") {
weak! += "j"
}

if base?.last == "v" {
weak?.removeLast()
}
}

if base?.last == "v" {
weak?.removeLast()
}

return weak! + "u"
}
case .dative:
5 changes: 4 additions & 1 deletion Source/Services/WordService.swift
Original file line number Diff line number Diff line change
@@ -191,12 +191,15 @@ class WordService {
let accGenitivePluralNeuter = word.generateCase(wordCase: .genitive, number: .plural, gender: .neuter)?.lowercased().contains(query) == true

let accComparative = word.generateComparative()?.lowercased().contains(query) == true
let accComparativeAdjective1 = word.generateComparativeAdjective(number: .singular, gender: .masculine, caseWeak: .nominative)?.lowercased().contains(query) == true
let accComparativeAdjective2 = word.generateComparativeAdjective(number: .singular, gender: .neuter, caseWeak: .nominative)?.lowercased().contains(query) == true
let accComparativeAdjective3 = word.generateComparativeAdjective(number: .plural, gender: .any, caseWeak: .dative)?.lowercased().contains(query) == true

let accInfinitive = word.generateInfinitive()?.lowercased().contains(query) == true
let accImerativeSingular = word.generateImperative(number: .singular)?.lowercased().contains(query) == true
let accImerativePlural = word.generateImperative(number: .plural)?.lowercased().contains(query) == true


return wordMatchesQuery || nominativeSingularMatchesQuery || nominativeDualMatchesQuery || nominativePluralMatchesQuery || accusativeSingularMatchesQuery || accusativeDualMatchesQuery || accusativePluralMatchesQuery || dativeSingularMatchesQuery || dativeDualMatchesQuery || dativePluralMatchesQuery || firstSingularMatchesQuery || secondSingularMatchesQuery || thirdSingularMatchesQuery || firstPluralMatchesQuery || secondPluralMatchesQuery || thirdPluralMatchesQuery || firstSingularMatchesQueryPast || secondSingularMatchesQueryPast || thirdSingularMatchesQueryPast || firstPluralMatchesQueryPast || secondPluralMatchesQueryPast || thirdPluralMatchesQueryPast || genitiveSingularMatchesQuery || genitiveDualMatchesQuery || genitivePluralMatchesQuery || accNominativeSingularMasculine || accNominativeSingularFemenine || accNominativeSingularNeuter || accNominativeDualMasculine || accNominativeDualFemenine || accNominativeDualNeuter || accNominativePluralMasculine || accNominativePluralFemenine || accAccusativePluralNeuter || accAccusativeSingularMasculine || accAccusativeSingularFemenine || accAccusativeSingularNeuter || accAccusativeDualMasculine || accAccusativeDualFemenine || accAccusativeDualNeuter || accAccusativePluralMasculine || accDativePluralFemenine || accDativePluralNeuter || accGenitiveSingularMasculine || accGenitiveSingularFemenine || accGenitiveSingularNeuter || accGenitiveDualMasculine || accGenitiveDualFemenine || accGenitiveDualNeuter || accGenitivePluralMasculine || accGenitivePluralFemenine || accGenitivePluralNeuter || accNominativePluralNeuter || accDativeSingularMasculine || accDativePluralMasculine || accDativeDualNeuter || accDativeDualFemenine || accDativeDualMasculine || accDativeSingularFemenine || accDativeSingularNeuter || accAccusativePluralFemenine || accComparative || accInfinitive || accImerativeSingular || accImerativePlural
return wordMatchesQuery || nominativeSingularMatchesQuery || nominativeDualMatchesQuery || nominativePluralMatchesQuery || accusativeSingularMatchesQuery || accusativeDualMatchesQuery || accusativePluralMatchesQuery || dativeSingularMatchesQuery || dativeDualMatchesQuery || dativePluralMatchesQuery || firstSingularMatchesQuery || secondSingularMatchesQuery || thirdSingularMatchesQuery || firstPluralMatchesQuery || secondPluralMatchesQuery || thirdPluralMatchesQuery || firstSingularMatchesQueryPast || secondSingularMatchesQueryPast || thirdSingularMatchesQueryPast || firstPluralMatchesQueryPast || secondPluralMatchesQueryPast || thirdPluralMatchesQueryPast || genitiveSingularMatchesQuery || genitiveDualMatchesQuery || genitivePluralMatchesQuery || accNominativeSingularMasculine || accNominativeSingularFemenine || accNominativeSingularNeuter || accNominativeDualMasculine || accNominativeDualFemenine || accNominativeDualNeuter || accNominativePluralMasculine || accNominativePluralFemenine || accAccusativePluralNeuter || accAccusativeSingularMasculine || accAccusativeSingularFemenine || accAccusativeSingularNeuter || accAccusativeDualMasculine || accAccusativeDualFemenine || accAccusativeDualNeuter || accAccusativePluralMasculine || accDativePluralFemenine || accDativePluralNeuter || accGenitiveSingularMasculine || accGenitiveSingularFemenine || accGenitiveSingularNeuter || accGenitiveDualMasculine || accGenitiveDualFemenine || accGenitiveDualNeuter || accGenitivePluralMasculine || accGenitivePluralFemenine || accGenitivePluralNeuter || accNominativePluralNeuter || accDativeSingularMasculine || accDativePluralMasculine || accDativeDualNeuter || accDativeDualFemenine || accDativeDualMasculine || accDativeSingularFemenine || accDativeSingularNeuter || accAccusativePluralFemenine || accComparative || accInfinitive || accImerativeSingular || accImerativePlural || accComparativeAdjective1 || accComparativeAdjective2 || accComparativeAdjective3
}
}
101 changes: 100 additions & 1 deletion Source/Views/DynamicTable.swift
Original file line number Diff line number Diff line change
@@ -193,7 +193,106 @@ struct DynamicTable: View {
.padding(.vertical, 10)
.border(Color.black, width: 1)
}

}
}
}
}
}
}
}

HStack(spacing: 0) {
Text("")
.frame(minWidth: 87, minHeight: 0, maxHeight: .infinity, alignment: .center)
.padding(.vertical, 10)
.background(Color.gray.opacity(0.2))
.border(Color.black, width: 1)

Text("Comparative")
.frame(minWidth: 522, minHeight: 0, maxHeight: .infinity, alignment: .center)
.padding(.vertical, 10)
.background(Color.gray.opacity(0.2))
.border(Color.black, width: 1)
}

// Main Headers
HStack(spacing: 0) {
Text("")
.frame(minWidth: 87, minHeight: 0, maxHeight: .infinity, alignment: .center)
.padding(.vertical, 10)
.background(Color.gray.opacity(0.2))
.border(Color.black, width: 1)

ForEach(Number.allCases, id: \.rawValue) { num in
if word.shouldShowNumber(number: num) {
let headerWidthValue = headerWidth(for: num)
Text(num.rawValue.capitalized)
.frame(minWidth: headerWidthValue, minHeight: 0, maxHeight: .infinity, alignment: .center)
.padding(.vertical, 10)
.background(Color.gray.opacity(0.2))
.border(Color.black, width: 1)
}
}
}

// Sub-Headers
HStack(spacing: 0) {
Text("")
.frame(minWidth: 87, maxWidth: 87)
.padding(.vertical, 10)
.background(Color.gray.opacity(0.2))
.border(Color.black, width: 1)

ForEach(Number.allCases, id: \.rawValue) { num in
if num == .plural {
Text("Any")
.frame(minWidth: 261, maxWidth: 261)
.padding(.vertical, 10)
.background(Color.gray.opacity(0.2))
.border(Color.black, width: 1)
} else {
if word.shouldShowNumber(number: num) {
ForEach(Gender.allCases, id: \.rawValue) { gen in
if word.shouldShowGender(number: num, gen: gen) {
Text(gen.rawValue.capitalized)
.frame(minWidth: calcWidth(), maxWidth: calcWidth())
.padding(.vertical, 10)
.background(Color.gray.opacity(0.2))
.border(Color.black, width: 1)
}
}
}
}
}
}

// Rows
ForEach(Case.allCases, id: \.rawValue) { c in
HStack(spacing: 0) {
Text(c.rawValue.capitalized)
.frame(minWidth: 87, maxWidth: 87)
.padding(.vertical, 10)
.border(Color.black, width: 1)
.background(Color.gray.opacity(0.2))

ForEach(Number.allCases, id: \.rawValue) { num in
if num == .plural {
if let weakAdjective = word.generateComparativeAdjective(number: num, gender: .any, caseWeak: c) {
Text(weakAdjective)
.frame(minWidth: 261, maxWidth: 261)
.padding(.vertical, 10)
.border(Color.black, width: 1)
}
} else {
if word.shouldShowNumber(number: num) {
ForEach(Gender.allCases, id: \.rawValue) { gen in
if word.shouldShowGender(number: num, gen: gen) {
if let weakAdjective = word.generateComparativeAdjective(number: num, gender: gen, caseWeak: c) {
Text(weakAdjective)
.frame(minWidth: calcWidth(), maxWidth: calcWidth())
.padding(.vertical, 10)
.border(Color.black, width: 1)
}
}
}
}

0 comments on commit 148a40c

Please sign in to comment.