Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Disable accent characters for menus that it's not needed on #372 #375

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,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 @@ -133,6 +133,21 @@ extension ParentTableViewCell: UITableViewDelegate {
case .appLang: break
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
}
}