Skip to content

Commit

Permalink
Merge pull request #375 from henrikth93/henrikth93-#372
Browse files Browse the repository at this point in the history
Remove Disable accent characters for menus that it's not needed on #372
  • Loading branch information
andrewtavis authored Nov 2, 2023
2 parents 859bf2f + ec65b37 commit f450a0a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ 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
15 changes: 15 additions & 0 deletions Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ 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)
{
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)

parentViewController?.navigationController?.pushViewController(viewController, animated: true)
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
10 changes: 6 additions & 4 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 @@ -54,7 +54,7 @@ struct SettingsTableData {
hasDynamicData: nil
)
]

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

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


0 comments on commit f450a0a

Please sign in to comment.