Skip to content

Commit

Permalink
[scribe-org#330] Add information tooltips to settings options
Browse files Browse the repository at this point in the history
Changed static data to constants to avoid unwanted modifications.
Added localization catalog to the Scribe App.
Added a shortDescription field to cell model.
  • Loading branch information
damien-rivet authored and SaurabhJamadagni committed Apr 18, 2024
1 parent aa8b00d commit 93ddb18
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 22 deletions.
15 changes: 15 additions & 0 deletions Scribe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,7 @@
38BD213222D5907F00C6795D /* Scribe */ = {
isa = PBXGroup;
children = (
EDB4601E2AF9FFAA00BEA967 /* Utils */,
144B56F22A568AC200C2F447 /* Scribe.entitlements */,
1406B7882A2DFE4C001DF45B /* InstallationTab */,
147797B62A2CFB560044A53E /* SettingsTab */,
Expand All @@ -1247,6 +1248,7 @@
38BD213F22D5908100C6795D /* LaunchScreen.storyboard */,
38BD213D22D5908100C6795D /* Assets.xcassets */,
38BD214222D5908100C6795D /* Info.plist */,
EDB4601A2AF9FD8200BEA967 /* Localizable.xcstrings */,
);
path = Scribe;
sourceTree = "<group>";
Expand Down Expand Up @@ -1497,6 +1499,13 @@
path = Keyboards;
sourceTree = "<group>";
};
EDB4601E2AF9FFAA00BEA967 /* Utils */ = {
isa = PBXGroup;
children = (
);
path = Utils;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -1811,6 +1820,7 @@
knownRegions = (
en,
Base,
fr,
);
mainGroup = 38BD212722D5907E00C6795D;
packageReferences = (
Expand Down Expand Up @@ -1845,6 +1855,7 @@
files = (
38BD214122D5908100C6795D /* LaunchScreen.storyboard in Resources */,
147797B12A2CD3370044A53E /* InfoChildTableViewCell.xib in Resources */,
EDB4601B2AF9FD8200BEA967 /* Localizable.xcstrings in Resources */,
38BD213922D5907F00C6795D /* AppScreen.storyboard in Resources */,
147797AD2A2CD2F70044A53E /* ParentTableViewCell.xib in Resources */,
38BD213E22D5908100C6795D /* Assets.xcassets in Resources */,
Expand Down Expand Up @@ -2810,6 +2821,7 @@
isa = PBXVariantGroup;
children = (
38BD213822D5907F00C6795D /* Base */,
EDB4601C2AF9FDD600BEA967 /* fr */,
);
name = AppScreen.storyboard;
sourceTree = "<group>";
Expand All @@ -2818,6 +2830,7 @@
isa = PBXVariantGroup;
children = (
38BD214022D5908100C6795D /* Base */,
EDB4601D2AF9FDD600BEA967 /* fr */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
Expand All @@ -2829,6 +2842,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -2891,6 +2905,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down
17 changes: 10 additions & 7 deletions Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,26 +144,29 @@ extension ParentTableViewCell: UITableViewDelegate {

case .specificLang:
if let viewController = parentViewController?.storyboard?.instantiateViewController(identifier: "TableViewTemplateViewController") as? TableViewTemplateViewController {
// Copy base settings
var data = SettingsTableData.languageSettingsData

// 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
{

if accentKeyLanguages.firstIndex(of: section.sectionTitle) == nil && accentKeyOptionIndex != -1 {
// As there are no accent keys we can remove the `Disable accent characters` option.
let accentKeySettings = SettingsTableData.languageSettingsData[0].section.remove(at: accentKeyOptionIndex)
let accentKeySettings = data[0].section.remove(at: accentKeyOptionIndex)
print(accentKeySettings)
} else if accentKeyLanguages.firstIndex(of: section.sectionTitle) != nil && accentKeyOptionIndex == -1
{
SettingsTableData.languageSettingsData[0].section.insert(Section(
} else if accentKeyLanguages.firstIndex(of: section.sectionTitle) != nil && accentKeyOptionIndex == -1 {
data[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)

viewController.configureTable(for: data, parentSection: section)

parentViewController?.navigationController?.pushViewController(viewController, animated: true)
}
Expand Down
124 changes: 124 additions & 0 deletions Scribe/Localizable.xcstrings
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"sourceLanguage" : "en",
"strings" : {
"settings.appLanguage" : {
"comment" : "The title of the app language section",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "App language"
}
}
}
},
"settings.appLanguage.system" : {
"comment" : "Use the system language",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "System language"
}
}
}
},
"settings.functionality" : {
"comment" : "The title of the functionality section",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Functionality"
}
}
}
},
"settings.functionality.autoSuggestEmoji" : {
"comment" : "Toggles the suggestion of Emoji",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Autosuggest emojis"
}
}
}
},
"settings.installedKeyboards" : {
"comment" : "The title of the installed keyboards section",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Select installed keyboard"
}
}
}
},
"settings.layout" : {
"comment" : "The title of the layout section",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Layout"
}
}
}
},
"settings.layout.autoSuggestEmoji.description" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Turn on emoji suggestions and completions for more expressive typing."
}
}
}
},
"settings.layout.disableAccentCharacters" : {
"comment" : "Toggles accented characters for the selected keyboard",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Disable accent characters"
}
}
}
},
"settings.layout.disableAccentCharacters.description" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Include accented letter keys on the primary keyboard layout."
}
}
}
},
"settings.layout.periodAndComma" : {
"comment" : "Toggles period and commas for the selected keyboard",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Period and comma on ABC"
}
}
}
},
"settings.layout.periodAndComma.description" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Include comma and period keys on the main keyboard for convenient typing."
}
}
}
}
},
"version" : "1.0"
}
14 changes: 12 additions & 2 deletions Scribe/ParentTableCellModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,20 @@ struct ParentTableCellModel {
}

struct Section {

let sectionTitle: String
let imageString: String
let hasToggle: Bool
let sectionState: SectionState
let shortDescription: String?

init(sectionTitle: String, imageString: String, hasToggle: Bool, sectionState: SectionState, shortDescription: String? = nil) {
self.sectionTitle = sectionTitle
self.imageString = imageString
self.hasToggle = hasToggle
self.sectionState = sectionState
self.shortDescription = shortDescription
}
}

enum SectionState: Equatable {
Expand All @@ -26,8 +36,8 @@ enum SectionState: Equatable {
case rateScribe
case bugReport
case email
case downloadData
case checkData
// case downloadData
// case checkData
// case appHints
case privacyPolicy
case licenses
Expand Down
30 changes: 17 additions & 13 deletions Scribe/SettingsTab/SettingsTableData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,54 @@
import Foundation

struct SettingsTableData {
static var settingsTableData: [ParentTableCellModel] = [

static let settingsTableData: [ParentTableCellModel] = [
ParentTableCellModel(
headingTitle: "App language",
headingTitle: NSLocalizedString("settings.appLanguage", comment: "The title of the app language section"),
section: [
Section(sectionTitle: "System language", imageString: "globe", hasToggle: false, sectionState: .appLang),
Section(sectionTitle: NSLocalizedString("settings.appLanguage.system", comment: "Use the system language"), imageString: "globe", hasToggle: false, sectionState: .appLang),
],
hasDynamicData: nil
),
ParentTableCellModel(
headingTitle: "Select installed keyboard",
headingTitle: NSLocalizedString("settings.installedKeyboards", comment: "The title of the installed keyboards section"),
section: [
// Section(sectionTitle: "All keyboards", imageString: "globe", hasToggle: false, sectionState: .specificLang("all")),
],
hasDynamicData: .installedKeyboards
),
]

static var languageSettingsData: [ParentTableCellModel] = [
static let languageSettingsData: [ParentTableCellModel] = [
ParentTableCellModel(
headingTitle: "Layout",
headingTitle: NSLocalizedString("settings.layout", comment: "The title of the layout section"),
section: [
Section(
sectionTitle: "Period and comma on ABC",
sectionTitle: NSLocalizedString("settings.layout.periodAndComma", comment: "Toggles period and commas for the selected keyboard"),
imageString: "info.circle",
hasToggle: true,
sectionState: .none(.toggleCommaAndPeriod)
sectionState: .none(.toggleCommaAndPeriod),
shortDescription: NSLocalizedString("settings.layout.periodAndComma.description", comment: "")
),
Section(
sectionTitle: "Disable accent characters",
sectionTitle: NSLocalizedString("settings.layout.disableAccentCharacters", comment: "Toggles accented characters for the selected keyboard"),
imageString: "info.circle",
hasToggle: true,
sectionState: .none(.toggleAccentCharacters)
sectionState: .none(.toggleAccentCharacters),
shortDescription: NSLocalizedString("settings.layout.disableAccentCharacters.description", comment: "")
),
],
hasDynamicData: nil
),
ParentTableCellModel(
headingTitle: "Functionality",
headingTitle: NSLocalizedString("settings.functionality", comment: "The title of the functionality section"),
section: [
Section(
sectionTitle: "Autosuggest emojis",
sectionTitle: NSLocalizedString("settings.functionality.autoSuggestEmoji", comment: "Toggles the suggestion of Emoji"),
imageString: "info.circle",
hasToggle: true,
sectionState: .none(.autosuggestEmojis)
sectionState: .none(.autosuggestEmojis),
shortDescription: NSLocalizedString("settings.layout.autoSuggestEmoji.description", comment: "")
),
],
hasDynamicData: nil
Expand Down
27 changes: 27 additions & 0 deletions Scribe/fr.lproj/AppScreen.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

/* Class = "UIButton"; normalTitle = "Button"; ObjectID = "3gB-ix-8Gq"; */
"3gB-ix-8Gq.normalTitle" = "Button";

/* Class = "UITabBarItem"; title = "Installation"; ObjectID = "HNz-5D-1T0"; */
"HNz-5D-1T0.title" = "Installation";

/* Class = "UITabBarItem"; title = "Settings"; ObjectID = "JtD-kc-GDx"; */
"JtD-kc-GDx.title" = "Settings";

/* Class = "UITextView"; text = "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda."; ObjectID = "Q8I-Gg-Baj"; */
"Q8I-Gg-Baj.text" = "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.";

/* Class = "UILabel"; text = "Label"; ObjectID = "QQb-Sb-zfQ"; */
"QQb-Sb-zfQ.text" = "Label";

/* Class = "UITabBarItem"; title = "About"; ObjectID = "U3y-iM-H0G"; */
"U3y-iM-H0G.title" = "About";

/* Class = "UITextView"; text = "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda."; ObjectID = "ZcW-Aa-aDz"; */
"ZcW-Aa-aDz.text" = "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.";

/* Class = "UIButton"; configuration.title = "Button"; ObjectID = "cWe-iO-9F6"; */
"cWe-iO-9F6.configuration.title" = "Button";

/* Class = "UIButton"; normalTitle = "Button"; ObjectID = "cWe-iO-9F6"; */
"cWe-iO-9F6.normalTitle" = "Button";
1 change: 1 addition & 0 deletions Scribe/fr.lproj/LaunchScreen.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 93ddb18

Please sign in to comment.