-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1 base modularization of app ViewController
- Loading branch information
1 parent
4e4aedb
commit 2216734
Showing
6 changed files
with
262 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// | ||
// ENAppText.swift | ||
// | ||
// The English app text for the Scribe app. | ||
// | ||
|
||
import UIKit | ||
|
||
/// Formats and returns the text for the installation guidelines. | ||
/// | ||
/// - Parameters | ||
/// - fontSize: the size of the font derived for the app text given screen dimensions. | ||
func setAttributedInstallation(fontSize: CGFloat) -> NSMutableAttributedString { | ||
// The down right arrow character as a text attachment. | ||
let arrowAttachment = NSTextAttachment() | ||
let selectArrowIconConfig = UIImage.SymbolConfiguration(pointSize: fontSize, weight: .medium, scale: .medium) | ||
arrowAttachment.image = UIImage( | ||
systemName: "arrow.turn.down.right", | ||
withConfiguration: selectArrowIconConfig | ||
)?.withTintColor(.scribeGrey) | ||
|
||
// The globe character as a text attachment. | ||
let globeAttachment = NSTextAttachment() | ||
let selectGlobeIconConfig = UIImage.SymbolConfiguration(pointSize: fontSize, weight: .medium, scale: .medium) | ||
globeAttachment.image = UIImage( | ||
systemName: "globe", | ||
withConfiguration: selectGlobeIconConfig | ||
)?.withTintColor(.scribeGrey) | ||
|
||
// Wrap the attachments in their own attributed strings so we can append them. | ||
let arrowString = NSAttributedString(attachment: arrowAttachment) | ||
let globeString = NSAttributedString(attachment: globeAttachment) | ||
|
||
// Create components of the installation text, format their font sizes and add them step by step. | ||
let installationTextTitle = NSMutableAttributedString(string: """ | ||
Keyboard Installation | ||
""", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: fontSize * 1.5)]) | ||
|
||
let startOfBody = NSMutableAttributedString(string: """ | ||
\n | ||
1.\u{0020} | ||
""", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize)]) | ||
|
||
let settingsLink = addHyperLinks( | ||
originalText: "Open Settings", | ||
links: ["Open Settings": "<makeTextLink>"], // placeholder as there's a button over it | ||
fontSize: fontSize | ||
) | ||
|
||
let installStart = concatAttributedStrings(left: startOfBody, right: settingsLink) | ||
|
||
let installDirections = NSMutableAttributedString(string: """ | ||
\n | ||
2. In General do the following: | ||
Keyboard | ||
""", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize)]) | ||
|
||
installDirections.append(NSAttributedString(string: "\n ")) | ||
|
||
installDirections.append(arrowString) | ||
|
||
installDirections.append(NSMutableAttributedString(string: """ | ||
\u{0020} Keyboards | ||
""", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize)])) | ||
|
||
installDirections.append(NSMutableAttributedString( | ||
string: "\n ", | ||
attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize)] | ||
) | ||
) | ||
|
||
installDirections.append(arrowString) | ||
|
||
installDirections.append(NSMutableAttributedString(string: """ | ||
\u{0020} Add New Keyboard | ||
3. Select Scribe and then activate keyboards | ||
4. When typing press\u{0020} | ||
""", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize)])) | ||
|
||
installDirections.append(globeString) | ||
|
||
installDirections.append(NSMutableAttributedString(string: """ | ||
\u{0020}to select keyboards | ||
""", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize)])) | ||
|
||
let installFullDirections = concatAttributedStrings(left: installStart, right: installDirections) | ||
|
||
return concatAttributedStrings( | ||
left: installationTextTitle, | ||
right: installFullDirections | ||
) as! NSMutableAttributedString | ||
} | ||
|
||
/// Formats and returns the text for a notice about Scribe's GitHub. | ||
/// | ||
/// - Parameters | ||
/// - fontSize: the size of the font derived for the app text given screen dimensions. | ||
func setAttributedGitHubText(fontSize: CGFloat) -> NSMutableAttributedString { | ||
let GHTextTitle = NSMutableAttributedString(string: """ | ||
Community | ||
""", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: fontSize * 1.5)]) | ||
|
||
// Initialize the main body of the text. | ||
let GHInfoText = NSMutableAttributedString(string: """ | ||
\n | ||
Scribe is fully open-source. To report issues or contribute please visit us at\u{0020} | ||
""", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize)]) | ||
|
||
// A second NSAttributedString that includes a link to the GitHub. | ||
let ghLink = addHyperLinks( | ||
originalText: "github.com/scribe-org.", | ||
links: ["github.com/scribe-org": "https://github.com/scribe-org"], | ||
fontSize: fontSize | ||
) | ||
|
||
let GHInfoTextToLink = concatAttributedStrings(left: GHTextTitle, right: GHInfoText) | ||
|
||
return concatAttributedStrings( | ||
left: GHInfoTextToLink, | ||
right: ghLink | ||
) as! NSMutableAttributedString | ||
} |
33 changes: 32 additions & 1 deletion
33
Scribe/PrivacyPolicy.swift → ...be/AppTexts/English/ENPrivacyPolicy.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// TextSymbols.swift | ||
// | ||
// Symbols needed for the app UI. | ||
// | ||
|
||
import UIKit | ||
|
||
/// Formats and returns the settings symbol for the app text. | ||
/// | ||
/// - Parameters | ||
/// - fontSize: the size of the font derived for the app text given screen dimensions. | ||
func getSettingsSymbol(fontSize: CGFloat) -> UIImage { | ||
var settingsSymbolConfig = UIImage.SymbolConfiguration(pointSize: fontSize * 0.2, weight: .medium, scale: .medium) | ||
if DeviceType.isPad { | ||
if UIScreen.main.bounds.height < UIScreen.main.bounds.width { | ||
settingsSymbolConfig = UIImage.SymbolConfiguration(pointSize: fontSize * 0.05, weight: .medium, scale: .medium) | ||
} else { | ||
settingsSymbolConfig = UIImage.SymbolConfiguration(pointSize: fontSize * 0.15, weight: .medium, scale: .medium) | ||
} | ||
} | ||
let settingsSymbol: UIImage = UIImage(systemName: "gear", withConfiguration: settingsSymbolConfig)! | ||
|
||
return settingsSymbol | ||
} | ||
|
||
/// Formats and returns the privacy symbol for the app text. | ||
/// | ||
/// - Parameters | ||
/// - fontSize: the size of the font derived for the app text given screen dimensions. | ||
func getPrivacySymbol(fontSize: CGFloat) -> UIImage { | ||
var privacySymbolConfig = UIImage.SymbolConfiguration(pointSize: fontSize * 0.25, weight: .medium, scale: .medium) | ||
if DeviceType.isPad { | ||
if UIScreen.main.bounds.height < UIScreen.main.bounds.width { | ||
privacySymbolConfig = UIImage.SymbolConfiguration(pointSize: fontSize * 0.15, weight: .medium, scale: .medium) | ||
} else { | ||
privacySymbolConfig = UIImage.SymbolConfiguration(pointSize: fontSize * 0.2, weight: .medium, scale: .medium) | ||
} | ||
} | ||
let privacySymbol: UIImage = UIImage(systemName: "lock.shield", withConfiguration: privacySymbolConfig)! | ||
|
||
return privacySymbol | ||
} |
Oops, something went wrong.