Skip to content
Open
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 Scribe/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
initializeFontSize()
// Override point for customization after application launch.
if #available(iOS 13.0, *) {
let appearance = UITabBarAppearance()
Expand Down
2 changes: 2 additions & 0 deletions Scribe/AppExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ extension Locale {

extension Notification.Name {
static let keyboardsUpdatedNotification = Notification.Name("keyboardsHaveUpdated")
static let fontSizeUpdatedNotification = Notification.Name("fontSizeHasUpdated")

}
15 changes: 15 additions & 0 deletions Scribe/AppTexts/AppTextStyling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,22 @@ import UIKit
let preferredLanguage = Locale.preferredLanguages[0]

var fontSize = CGFloat(0)
func initializeFontSize() {
if DeviceType.isPhone {
if UIScreen.main.bounds.width > 413 || UIScreen.main.bounds.width <= 375 {
fontSize = UIScreen.main.bounds.height / 59
} else {
fontSize = UIScreen.main.bounds.height / 50
}
} else if DeviceType.isPad {
fontSize = UIScreen.main.bounds.height / 50
}

let userDefaults = UserDefaults(suiteName: "group.be.scri.userDefaultsContainer")!
if userDefaults.bool(forKey: "increaseTextSize") {
fontSize *= 1.25
}
}
/// Concatenates attributed strings.
///
/// - Parameters
Expand Down
6 changes: 5 additions & 1 deletion Scribe/Button/CTAButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
import SwiftUI

struct CTAButton: View {
@AppStorage("increaseTextSize", store: UserDefaults(suiteName: "group.be.scri.userDefaultsContainer"))
var increaseTextSize: Bool = false
var textSizeMultiplier: CGFloat { increaseTextSize ? 1.25 : 1.0 }

let title: String
let action: () -> Void
@Environment(\.colorScheme) var colorScheme

var body: some View {
Button(action: action) {
Text(title)
.font(.system(size: 20, weight: .bold))
.font(.system(size: 20 * textSizeMultiplier, weight: .bold))
.foregroundColor(Color("lightTextDarkCTA"))
.frame(maxWidth: .infinity)
.padding(.vertical, 16)
Expand Down
6 changes: 5 additions & 1 deletion Scribe/Button/DownloadButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ struct ButtonConfig {
}

struct DownloadButton: View {
@AppStorage("increaseTextSize", store: UserDefaults(suiteName: "group.be.scri.userDefaultsContainer"))
var increaseTextSize: Bool = false
var textSizeMultiplier: CGFloat { increaseTextSize ? 1.25 : 1.0 }

let state: ButtonState
let action: () -> Void
@Environment(\.colorScheme) var colorScheme
Expand All @@ -86,7 +90,7 @@ struct DownloadButton: View {
Image(systemName: state.config.icon)
}
}
.font(.system(size: 12, weight: .semibold))
.font(.system(size: 12 * textSizeMultiplier, weight: .semibold))
.foregroundColor(state.config.foregroundColor)
.frame(width: 120, height: 20)
.padding(.vertical, 6)
Expand Down
9 changes: 7 additions & 2 deletions Scribe/ConfirmDialog/ConfirmDialogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import SwiftUI

struct ConfirmDialogView: View {
@AppStorage("increaseTextSize", store: UserDefaults(suiteName: "group.be.scri.userDefaultsContainer"))
var increaseTextSize: Bool = false
var textSizeMultiplier: CGFloat { increaseTextSize ? 1.25 : 1.0 }

private let cardCornerRadius: CGFloat = 10
private let iconSize: CGFloat = 30.0
private let cardPadding: CGFloat = 16
Expand Down Expand Up @@ -35,7 +39,7 @@ struct ConfirmDialogView: View {
.foregroundColor(Color.scribeCTA)

Text(infoText)
.font(.system(size: DeviceType.isPad ? 22 : 0))
.font(.system(size: DeviceType.isPad ? 22 * textSizeMultiplier : 17 * textSizeMultiplier))
.fixedSize(horizontal: false, vertical: true)
}

Expand All @@ -45,7 +49,7 @@ struct ConfirmDialogView: View {
action: onChange,
label: {
Text(changeButtonText)
.font(.system(size: DeviceType.isPad ? 22 : 0))
.font(.system(size: DeviceType.isPad ? 22 * textSizeMultiplier : 17 * textSizeMultiplier))
.foregroundColor(Color.keyChar)
})
.buttonStyle(.borderedProminent)
Expand All @@ -61,6 +65,7 @@ struct ConfirmDialogView: View {
label: {
Text(confirmButtonText)
.font(.system(size: DeviceType.isPad ? 22 : 0))
.font(.system(size: DeviceType.isPad ? 22 * textSizeMultiplier : 17 * textSizeMultiplier))
.foregroundColor(Color.keyChar)
})
.buttonStyle(.borderedProminent)
Expand Down
18 changes: 14 additions & 4 deletions Scribe/InstallationTab/DownloadDataScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ struct RadioCircle: View {
}

struct UpdateDataCardView: View {
@AppStorage("increaseTextSize", store: UserDefaults(suiteName: "group.be.scri.userDefaultsContainer"))
var increaseTextSize: Bool = false
var textSizeMultiplier: CGFloat { increaseTextSize ? 1.25 : 1.0 }

var languages: [Section]
private let title = NSLocalizedString(
"i18n.app.download.menu_ui.update_data",
Expand All @@ -53,14 +57,14 @@ struct UpdateDataCardView: View {
var body: some View {
VStack(alignment: .leading, spacing: 6) {
Text(title)
.font(.system(size: 19, weight: .semibold))
.font(.system(size: 19 * textSizeMultiplier, weight: .semibold))
.foregroundColor(.primary)

VStack(alignment: .leading, spacing: 12) {
if !languages.isEmpty {
HStack {
Text(checkText)
.font(.body)
.font(.system(size: 17 * textSizeMultiplier))
.foregroundColor(.primary)

Spacer()
Expand All @@ -86,6 +90,9 @@ struct UpdateDataCardView: View {
}

struct LanguageDownloadCard: View {
@AppStorage("increaseTextSize", store: UserDefaults(suiteName: "group.be.scri.userDefaultsContainer"))
var increaseTextSize: Bool = false
var textSizeMultiplier: CGFloat { increaseTextSize ? 1.25 : 1.0 }
let language: String
let state: ButtonState
let action: () -> Void
Expand All @@ -94,7 +101,7 @@ struct LanguageDownloadCard: View {
VStack(alignment: .leading, spacing: 12) {
HStack {
Text(language)
.font(.body)
.font(.system(size: 17 * textSizeMultiplier))
.foregroundColor(.primary)

Spacer()
Expand Down Expand Up @@ -145,6 +152,9 @@ struct EmptyStateView: View {
struct LanguageListView: View {
var onNavigateToTranslationSource: ((String, String) -> Void)?
var languages: [Section]
@AppStorage("increaseTextSize", store: UserDefaults(suiteName: "group.be.scri.userDefaultsContainer"))
var increaseTextSize: Bool = false
var textSizeMultiplier: CGFloat { increaseTextSize ? 1.25 : 1.0 }

@ObservedObject private var stateManager = DownloadStateManager.shared

Expand Down Expand Up @@ -180,7 +190,7 @@ struct LanguageListView: View {
ZStack {
VStack(alignment: .leading, spacing: 6) {
Text(title)
.font(.system(size: 19, weight: .semibold))
.font(.system(size: 19 * textSizeMultiplier, weight: .semibold))
.foregroundColor(.primary)
if languages.isEmpty {
EmptyStateView()
Expand Down
12 changes: 9 additions & 3 deletions Scribe/InstallationTab/InstallationDownload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,23 @@ struct CardView: View {
let mainText: String
let subtitle: String
let action: () -> Void
@AppStorage("increaseTextSize", store: UserDefaults(suiteName: "group.be.scri.userDefaultsContainer"))
var increaseTextSize: Bool = false

var textSizeMultiplier: CGFloat {
increaseTextSize ? 1.25 : 1.0
}

var body: some View {
VStack(alignment: .leading, spacing: 6) {
Text(title)
.font(.system(size: 19, weight: .semibold))
.font(.system(size: 19 * textSizeMultiplier, weight: .semibold))
.foregroundColor(.primary)

VStack(alignment: .leading, spacing: 6) {
HStack {
Text(mainText)
.font(.body)
.font(.system(size: 17 * textSizeMultiplier))
.foregroundColor(.primary)

Spacer()
Expand All @@ -31,7 +37,7 @@ struct CardView: View {
}

Text(subtitle)
.font(.subheadline)
.font(.system(size: 15 * textSizeMultiplier))
.foregroundColor(.secondary)
}
.padding()
Expand Down
24 changes: 14 additions & 10 deletions Scribe/InstallationTab/InstallationVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI

/// A UIViewController that provides instructions on how to install Keyboards as well as information about Scribe.
class InstallationVC: UIViewController {

// Variables linked to elements in AppScreen.storyboard.
@IBOutlet var appTextViewPhone: UITextView!
@IBOutlet var appTextViewPad: UITextView!
Expand Down Expand Up @@ -106,7 +107,18 @@ class InstallationVC: UIViewController {
name: NSNotification.Name("NavigateToDownloadScreen"),
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(handleFontSizeUpdate),
name: .fontSizeUpdatedNotification,
object: nil
)
}
@objc func handleFontSizeUpdate() {
DispatchQueue.main.async {
self.setCurrentUI()
}
}

@objc private func handleNavigateToDownloadScreen() {
navigateToDownloadDataScreen()
Expand Down Expand Up @@ -246,17 +258,9 @@ class InstallationVC: UIViewController {

/// Creates the current app UI by applying constraints and calling child UI functions.
func setCurrentUI() {
// Sets the font size for the text in the app screen and corresponding UIImage icons.
if DeviceType.isPhone {
if UIScreen.main.bounds.width > 413 || UIScreen.main.bounds.width <= 375 {
fontSize = UIScreen.main.bounds.height / 59
} else if UIScreen.main.bounds.width <= 413 && UIScreen.main.bounds.width > 375 {
fontSize = UIScreen.main.bounds.height / 50
}

} else if DeviceType.isPad {
fontSize = UIScreen.main.bounds.height / 50
}
// Sets the font size for the text in the app screen and corresponding UIImage icons
initializeFontSize()

installationHeaderLabel.text = NSLocalizedString(
"i18n.app.installation.keyboard.title", value: "Keyboard installation", comment: ""
Expand Down
1 change: 1 addition & 0 deletions Scribe/ParentTableCellModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ enum UserInteractiveState {
case autosuggestEmojis
case toggleAccentCharacters
case toggleWordForWordDeletion
case increaseTextSize
case none
}

Expand Down
7 changes: 7 additions & 0 deletions Scribe/SettingsTab/SettingsTableData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ enum SettingsTableData {
hasToggle: false,
sectionState: .appLang,
shortDescription: NSLocalizedString("i18n.app.settings.keyboard.translation.select_source", value: "Select language for app texts.", comment: "")
),
Section(
sectionTitle: NSLocalizedString("i18n.app.settings.menu.increase_text_size", value: "Increase app text size", comment: ""),
hasToggle: true,
sectionState: .none(.increaseTextSize),
shortDescription: NSLocalizedString("i18n.app.settings.menu.increase_text_size_description", value: "Increase text sizes for better readability", comment: "")
)

],
hasDynamicData: nil
),
Expand Down
17 changes: 17 additions & 0 deletions Scribe/SettingsTab/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final class SettingsViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

setHeaderHeight()
showTipCardView()

Expand Down Expand Up @@ -68,7 +69,23 @@ final class SettingsViewController: UIViewController {

self.commonMethodToRefresh()
}
NotificationCenter.default.addObserver(
self,
selector: #selector(handleFontSizeUpdate),
name: .fontSizeUpdatedNotification,
object: nil
)
}
@objc func handleFontSizeUpdate() {
DispatchQueue.main.async {
self.parentTable.reloadData()
self.setFooterButtonView()
}
}

deinit {
NotificationCenter.default.removeObserver(self)
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Expand Down
6 changes: 5 additions & 1 deletion Scribe/TipCard/TipCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import SwiftUI

struct TipCardView: View {
@AppStorage("increaseTextSize", store: UserDefaults(suiteName: "group.be.scri.userDefaultsContainer"))
var increaseTextSize: Bool = false
var textSizeMultiplier: CGFloat { increaseTextSize ? 1.25 : 1.0 }

private let buttonHeight = 70.0
private let multiplicityPadding = 0.5
private let leadingPadding = 40.0
Expand All @@ -26,7 +30,7 @@ struct TipCardView: View {
.foregroundColor(Color.scribeCTA)
.padding(.horizontal)
Text(infoText)
.font(Font.system(size: DeviceType.isPad ? 22 : 0, weight: .medium))
.font(Font.system(size: DeviceType.isPad ? 22 * textSizeMultiplier : 17 * textSizeMultiplier, weight: .medium))
Spacer()
Button {
tipCardState = false
Expand Down
18 changes: 18 additions & 0 deletions Scribe/Views/BaseTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,25 @@ class BaseTableViewController: UITableViewController {
if let tabBarController = tabBarController as? SwipeableTabBarController {
tabBarController.isCyclingEnabled = true
}

NotificationCenter.default.addObserver(
self,
selector: #selector(handleFontSizeUpdate),
name: .fontSizeUpdatedNotification,
object: nil
)

}

@objc func handleFontSizeUpdate() {
DispatchQueue.main.async {
self.tableView.reloadData()
}
}

deinit {
NotificationCenter.default.removeObserver(self)
}
}

// MARK: UITableViewDataSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ final class InfoChildTableViewCell: UITableViewCell {
selectionStyle = .none

setTableView()
titleLabel.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
descriptionLabel.font = UIFont.systemFont(ofSize: fontSize * 0.9)
titleLabel.text = section.sectionTitle

if let shortDescription = section.shortDescription {
Expand Down Expand Up @@ -151,6 +153,11 @@ final class InfoChildTableViewCell: UITableViewCell {
let dictionaryKey = languageCode + "WordForWordDeletion"
userDefaults.setValue(toggleSwitch.isOn, forKey: dictionaryKey)

case .increaseTextSize:
userDefaults.setValue(toggleSwitch.isOn, forKey: "increaseTextSize")
initializeFontSize()
NotificationCenter.default.post(name: .fontSizeUpdatedNotification, object: nil)

case .none: break
}

Expand Down Expand Up @@ -199,6 +206,13 @@ final class InfoChildTableViewCell: UITableViewCell {
toggleSwitch.isOn = false // Default value
}

case .increaseTextSize:
if let toggleValue = userDefaults.object(forKey: "increaseTextSize") as? Bool {
toggleSwitch.isOn = toggleValue
} else {
toggleSwitch.isOn = false // Default off
}

case .none: break
}
}
Expand Down
Loading
Loading