-
-
Notifications
You must be signed in to change notification settings - Fork 197
Generate and render acknowledgements as Settings.bundle #230
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
Open
sharplet
wants to merge
10
commits into
master
Choose a base branch
from
as-acknowledgements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1610f41
Fix acknowledgements text being clipped by navigation bar
sharplet fb60e10
Generate and render acknowledgements as a settings bundle
sharplet 4d3ecb4
Generate acknowledgements during deploy
sharplet 42a4739
Improve error messages when generating acknowledgements
sharplet adf423b
Don't fail if acknowledgements dir doesn't exist
sharplet 4ba586c
Move generate-acknowledgements to a sensible source location
sharplet 13b13f3
Don't bother with release configuration for genarate-acknowledgements
sharplet 0945952
Generate acknowledgements in bin/setup
sharplet 88ea633
Write error messages using TextOutputStream
sharplet 70ca910
Build in Xcode 10.2, 11 / Swift 5+
sharplet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| github "ReactiveCocoa/ReactiveObjCBridge" | ||
| github "ReactiveCocoa/ReactiveObjCBridge" "as-ras-6.1.0" | ||
| github "ReactiveCocoa/ReactiveSwift" | ||
| github "mixpanel/mixpanel-iphone" |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,8 +1,7 @@ | ||
| github "AliSoftware/OHHTTPStubs" "6.1.0" | ||
| github "Quick/Nimble" "v8.0.1" | ||
| github "Quick/Quick" "v1.3.0" | ||
| github "ReactiveCocoa/ReactiveObjC" "3.1.0" | ||
| github "ReactiveCocoa/ReactiveObjCBridge" "3.1.0" | ||
| github "ReactiveCocoa/ReactiveSwift" "3.1.0" | ||
| github "antitypical/Result" "3.2.4" | ||
| github "mixpanel/mixpanel-iphone" "v3.3.7" | ||
| github "AliSoftware/OHHTTPStubs" "8.0.0" | ||
| github "Quick/Nimble" "v8.0.2" | ||
| github "Quick/Quick" "v2.1.0" | ||
| github "ReactiveCocoa/ReactiveObjC" "3.1.1" | ||
| github "ReactiveCocoa/ReactiveObjCBridge" "c1c49ea807d783313f696184b55956094c993e2d" | ||
| github "ReactiveCocoa/ReactiveSwift" "6.1.0" | ||
| github "mixpanel/mixpanel-iphone" "v3.4.7" |
This file contains hidden or 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,11 @@ | ||
| // swift-tools-version:4.2 | ||
|
|
||
| import PackageDescription | ||
|
|
||
| let package = Package( | ||
| name: "Tropos", | ||
| targets: [ | ||
| .target(name: "generate-acknowledgements", dependencies: ["Settings"]), | ||
| .target(name: "Settings"), | ||
| ] | ||
| ) |
This file contains hidden or 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,9 @@ | ||
| import class Foundation.Bundle | ||
|
|
||
| extension Bundle { | ||
| public var settingsBundle: Bundle? { | ||
| return url(forResource: "Settings", withExtension: "bundle").flatMap { | ||
| Bundle(url: $0) | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,13 @@ | ||
| public struct PreferencePage { | ||
| public var preferenceSpecifiers: [PreferenceSpecifier] | ||
|
|
||
| public init(preferenceSpecifiers: [PreferenceSpecifier] = []) { | ||
| self.preferenceSpecifiers = preferenceSpecifiers | ||
| } | ||
| } | ||
|
|
||
| extension PreferencePage: Codable { | ||
| private enum CodingKeys: String, CodingKey { | ||
| case preferenceSpecifiers = "PreferenceSpecifiers" | ||
| } | ||
| } |
This file contains hidden or 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,19 @@ | ||
| public struct PreferenceSpecifier { | ||
| public var file: String? | ||
| public var footerText: String? | ||
| public var title: String? | ||
| public let type: String | ||
|
|
||
| public init(type: String) { | ||
| self.type = type | ||
| } | ||
| } | ||
|
|
||
| extension PreferenceSpecifier: Codable { | ||
| private enum CodingKeys: String, CodingKey { | ||
| case file = "File" | ||
| case footerText = "FooterText" | ||
| case title = "Title" | ||
| case type = "Type" | ||
| } | ||
| } |
This file contains hidden or 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,9 @@ | ||
| extension Optional { | ||
| func unwrap(file: StaticString = #file, line: UInt = #line) throws -> Wrapped { | ||
| if let value = self { | ||
| return value | ||
| } else { | ||
| throw NilError(file: file, line: line) | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,20 @@ | ||
| import Foundation | ||
|
|
||
| struct NilError: Error, CustomNSError { | ||
| static let lineNumberKey = "line-number" | ||
|
|
||
| let file: StaticString | ||
| let line: UInt | ||
|
|
||
| var errorDescription: String? { | ||
| return "Unexpectedly found nil while unwrapping optional" | ||
| } | ||
|
|
||
| var errorUserInfo: [String: Any] { | ||
| return [ | ||
| NSFilePathErrorKey: file, | ||
| NSLocalizedDescriptionKey: errorDescription!, | ||
| NilError.lineNumberKey: line, | ||
| ] | ||
| } | ||
| } |
This file contains hidden or 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,19 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>StringsTable</key> | ||
| <string>Root</string> | ||
| <key>PreferenceSpecifiers</key> | ||
| <array> | ||
| <dict> | ||
| <key>Type</key> | ||
| <string>PSChildPaneSpecifier</string> | ||
| <key>File</key> | ||
| <string>Acknowledgements</string> | ||
| <key>Title</key> | ||
| <string>Acknowledgements</string> | ||
| </dict> | ||
| </array> | ||
| </dict> | ||
| </plist> |
Binary file not shown.
74 changes: 60 additions & 14 deletions
74
Sources/Tropos/Resources/Storyboards/Base.lproj/Main.storyboard
Large diffs are not rendered by default.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
Sources/Tropos/ViewControllers/AcknowledgementsViewController.swift
This file contains hidden or 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,79 @@ | ||
| import os.log | ||
| import Settings | ||
| import UIKit | ||
|
|
||
| final class AcknowledgementsViewController: UITableViewController { | ||
| private var acknowledgements = PreferencePage() | ||
| private var settings = Bundle.main.settingsBundle! | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| do { | ||
| acknowledgements = try loadAcknowledgementsList() | ||
| } catch { | ||
| guard #available(iOS 10.0, *) else { return } | ||
| os_log("Failed to load acknowledgements: %{public}@", type: .error, error.localizedDescription) | ||
| } | ||
| } | ||
|
|
||
| override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
| return acknowledgements.preferenceSpecifiers.count | ||
| } | ||
|
|
||
| override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | ||
| return NSLocalizedString("Third-Party Code", comment: "Title for Acknowledgements library list") | ||
| } | ||
|
|
||
| override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
| let library = acknowledgements.preferenceSpecifiers[indexPath.row] | ||
| let cell = tableView.dequeueReusableCell(withIdentifier: "Library", for: indexPath) | ||
| cell.textLabel?.text = library.title | ||
| return cell | ||
| } | ||
|
|
||
| override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
| defer { super.prepare(for: segue, sender: sender) } | ||
|
|
||
| guard let destination = segue.destination as? TextViewController, | ||
| let indexPath = (sender as? UITableViewCell).flatMap(tableView.indexPath(for:)) | ||
| else { return } | ||
|
|
||
| let library = acknowledgements.preferenceSpecifiers[indexPath.row] | ||
| destination.title = library.title | ||
|
|
||
| do { | ||
| let libraryAcknowledgements = try loadAcknowledgements(forLibraryNamed: library.title.unwrap()) | ||
| destination.text = libraryAcknowledgements.footerText | ||
| } catch { | ||
| guard #available(iOS 10.0, *) else { return } | ||
|
|
||
| os_log( | ||
| "Failed to load acknowledgements for library '%{public}@': %{public}@", | ||
| type: .error, | ||
| library.title ?? "nil", | ||
| error.localizedDescription | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private extension AcknowledgementsViewController { | ||
| func loadAcknowledgementsList() throws -> PreferencePage { | ||
| return try settings | ||
| .url(forResource: "Acknowledgements", withExtension: "plist") | ||
| .map { try Data(contentsOf: $0) } | ||
| .map { try PropertyListDecoder().decode(PreferencePage.self, from: $0) } | ||
| .unwrap() | ||
| } | ||
|
|
||
| func loadAcknowledgements(forLibraryNamed libraryName: String) throws -> PreferenceSpecifier { | ||
| let page = try settings | ||
| .url(forResource: libraryName, withExtension: "plist", subdirectory: "Acknowledgements") | ||
| .map { try Data(contentsOf: $0) } | ||
| .map { try PropertyListDecoder().decode(PreferencePage.self, from: $0) } | ||
| .unwrap() | ||
|
|
||
| return try page.preferenceSpecifiers.first.unwrap() | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
1 change: 0 additions & 1 deletion
1
Sources/TroposCore/Extensions/ForecastController+Bridging.swift
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.