Skip to content

Commit

Permalink
#372 code and comment formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Nov 2, 2023
1 parent f450a0a commit d2e4c67
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
1 change: 0 additions & 1 deletion Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ let languagesAbbrDict = [
"Swedish": "sv",
]


/// Returns the abbreviation of the language for use in commands.
func getControllerLanguageAbbr() -> String {
guard let abbreviation = languagesAbbrDict[controllerLanguage] else {
Expand Down
30 changes: 17 additions & 13 deletions Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,24 @@ extension ParentTableViewCell: UITableViewDelegate {

case .specificLang:
if let viewController = parentViewController?.storyboard?.instantiateViewController(identifier: "TableViewTemplateViewController") as? TableViewTemplateViewController {
let accentKeyLanguages: [String] = ["Swedish", "German", "Spanish"]; //Languages where we can disable accent keys
let accentKeyOptionIndex = SettingsTableData.languageSettingsData[0].section.firstIndex(where: {s in s.sectionTitle.elementsEqual("Disable accent characters")}) ?? -1
if (accentKeyLanguages.firstIndex(of: section.sectionTitle) == nil && accentKeyOptionIndex != -1)
{
let accentKeySettings = SettingsTableData.languageSettingsData[0].section.remove(at: accentKeyOptionIndex )//since there are no accent keys we can remove the option.
print(accentKeySettings)
}
else if (accentKeyLanguages.firstIndex(of: section.sectionTitle) != nil && accentKeyOptionIndex == -1)
// Languages where we can disable accent keys.
let accentKeyLanguages: [String] = ["Swedish", "German", "Spanish"]
let accentKeyOptionIndex = SettingsTableData.languageSettingsData[0].section.firstIndex(where: {
s in s.sectionTitle.elementsEqual("Disable accent characters")
}) ?? -1
if accentKeyLanguages.firstIndex(of: section.sectionTitle) == nil && accentKeyOptionIndex != -1
{
SettingsTableData.languageSettingsData[0].section.insert(Section(
sectionTitle: "Disable accent characters",
imageString: "info.circle",
hasToggle: true,
sectionState: .none(.toggleAccentCharacters)), at: 1)
// As there are no accent keys we can remove the `Disable accent characters` option.
let accentKeySettings = SettingsTableData.languageSettingsData[0].section.remove(at: accentKeyOptionIndex)
print(accentKeySettings)
} else if accentKeyLanguages.firstIndex(of: section.sectionTitle) != nil && accentKeyOptionIndex == -1
{
SettingsTableData.languageSettingsData[0].section.insert(Section(
sectionTitle: "Disable accent characters",
imageString: "info.circle",
hasToggle: true,
sectionState: .none(.toggleAccentCharacters)
), at: 1)
}
viewController.configureTable(for: SettingsTableData.languageSettingsData, parentSection: section)

Expand Down
2 changes: 1 addition & 1 deletion Scribe/Components/TableViewTemplateViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import UIKit
class TableViewTemplateViewController: UIViewController {
@IBOutlet var mainTable: UITableView!

var screenTitle: String = ""
var screenTitle: String = ""
var tableData: [ParentTableCellModel] = []
var parentSection: Section?

Expand Down
14 changes: 6 additions & 8 deletions Scribe/SettingsTab/SettingsTableData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct SettingsTableData {
hasDynamicData: .installedKeyboards
),
]

static var languageSettingsData: [ParentTableCellModel] = [
ParentTableCellModel(
headingTitle: "Layout",
Expand All @@ -32,12 +32,12 @@ struct SettingsTableData {
hasToggle: true,
sectionState: .none(.toggleCommaAndPeriod)
),
Section(
Section(
sectionTitle: "Disable accent characters",
imageString: "info.circle",
hasToggle: true,
sectionState: .none(.toggleAccentCharacters)
)
),
],
hasDynamicData: nil
),
Expand All @@ -49,12 +49,12 @@ struct SettingsTableData {
imageString: "info.circle",
hasToggle: true,
sectionState: .none(.autosuggestEmojis)
)
),
],
hasDynamicData: nil
)
),
]

static func getInstalledKeyboardsSections() -> [Section] {
var installedKeyboards = [String]()

Expand Down Expand Up @@ -86,5 +86,3 @@ struct SettingsTableData {
return sections
}
}


0 comments on commit d2e4c67

Please sign in to comment.