Compare commits

...

1 Commits

Author SHA1 Message Date
Pariece McKinney 2fb22a6256 Public release/2.2.10 (#1548)
Fix ORKNavigationContainerView so that it does not call didMoveToWindow from tintColorDidChange
Bumped version to 2.2.10
2023-05-10 17:40:25 -04:00
5 changed files with 80 additions and 10 deletions
@@ -162,10 +162,8 @@ static const CGFloat detailTextBottomSpacing = 16.0;
}
- (void)didMoveToWindow {
_appTintColor = ORKViewTintColor(self);
_continueButton.normalTintColor = _appTintColor;
_skipButton.normalTintColor = _appTintColor;
[self udpateTintColor];
[super didMoveToWindow];
}
- (void)setSkipButtonStyle:(ORKNavigationContainerButtonStyle)skipButtonStyle {
@@ -559,8 +557,15 @@ static const CGFloat detailTextBottomSpacing = 16.0;
}
- (void)tintColorDidChange {
[self udpateTintColor];
[super tintColorDidChange];
[self didMoveToWindow];
}
- (void)udpateTintColor {
_appTintColor = ORKViewTintColor(self);
_continueButton.normalTintColor = _appTintColor;
_skipButton.normalTintColor = _appTintColor;
}
@end
@@ -25,7 +25,7 @@ SYSTEM_FRAMEWORK_SEARCH_PATHS = $(inherited)
SYSTEM_HEADER_SEARCH_PATHS = $(inherited)
CLANG_STATIC_ANALYZER_MODE = deep
ORK_FRAMEWORK_VERSION_NUMBER = 2.2.9
ORK_FRAMEWORK_VERSION_NUMBER = 2.2.10
ORK_FRAMEWORK_BUILD_NUMBER = $(ORK_FRAMEWORK_BUILD_NUMBER_CI_$(CI)) // ORK_FRAMEWORK_BUILD_NUMBER_CI_TRUE or ORK_FRAMEWORK_BUILD_NUMBER_CI_
ORK_FRAMEWORK_BUILD_NUMBER_CI_TRUE = $(CI_BUILD_NUMBER)
@@ -2,7 +2,7 @@
// ORKCatalog-Shared.xcconfig
//
ORK_CATALOG_VERSION_NUMBER = 2.2.9
ORK_CATALOG_VERSION_NUMBER = 2.2.10
ORK_CATALOG_BUILD_NUMBER = $(ORK_CATALOG_BUILD_NUMBER_CI_$(CI)) // ORK_CATALOG_BUILD_NUMBER_CI_TRUE or ORK_CATALOG_BUILD_NUMBER_CI_
ORK_CATALOG_BUILD_NUMBER_CI_TRUE = $(CI_BUILD_NUMBER) // if CI_BUILD_NUMBER is defined (presumably by CI) just use it
@@ -123,7 +123,7 @@ enum TaskListRow: Int, CustomStringConvertible {
case contrastSensitivityPeakLandoltC
case videoInstruction
case webView
case tintColor
class TaskListRowSection {
var title: String
@@ -213,6 +213,7 @@ enum TaskListRow: Int, CustomStringConvertible {
]),
TaskListRowSection(title: "Miscellaneous", rows:
[
.tintColor,
.videoInstruction,
.webView
])]
@@ -409,7 +410,10 @@ enum TaskListRow: Int, CustomStringConvertible {
case .webView:
return NSLocalizedString("Web View", comment: "")
case .tintColor:
return NSLocalizedString("Tint Color", comment: "")
}
}
@@ -615,6 +619,11 @@ enum TaskListRow: Int, CustomStringConvertible {
case webViewTask
case webViewStep
// Tint color
case tintColorTask
case tintColorStep
case tintColorQuestion
}
// MARK: Properties
@@ -799,6 +808,9 @@ enum TaskListRow: Int, CustomStringConvertible {
case .contrastSensitivityPeakLandoltC:
return contrastSensitivityPeakLandoltC
case .tintColor:
return tintColor
case .videoInstruction:
return videoInstruction
@@ -2060,7 +2072,32 @@ enum TaskListRow: Int, CustomStringConvertible {
webViewStep.showSignatureAfterContent = true
return ORKOrderedTask(identifier: String(describing: Identifier.webViewTask), steps: [webViewStep])
}
private var tintColor: ORKTask {
let customStep = ORKFormStep(identifier: String(describing: Identifier.tintColorStep))
customStep.formItems = [
ORKFormItem(
identifier: String(describing: Identifier.tintColorQuestion),
text: NSLocalizedString("Select a Tint Color", comment: ""),
detailText: NSLocalizedString("The tint color you select will be propagated to the app window after the task completes", comment: ""),
learnMoreItem: nil,
showsProgress: false,
answerFormat: ORKAnswerFormat.choiceAnswerFormat(
with: .singleChoice,
textChoices: [
ORKTextChoice(text: "Green", value: NSString(string: #keyPath(UIColor.green))),
ORKTextChoice(text: "Red", value: NSString(string: #keyPath(UIColor.red))),
ORKTextChoice(text: "Yellow", value: NSString(string: #keyPath(UIColor.yellow))),
ORKTextChoice(text: "Blue", value: NSString(string: #keyPath(UIColor.blue))),
]
),
tagText: nil,
optional: true
)
]
return ORKOrderedTask(identifier: String(describing: Identifier.tintColorTask), steps: [customStep])
}
// MARK: `ORKTask` Reused Text Convenience
private var exampleDescription: String {
@@ -169,6 +169,12 @@ class TaskListViewController: UITableViewController, ORKTaskViewControllerDelega
case .completed, .earlyTermination, .failed:
// For any other reason, we also reset restoration data
resetRestorationDataFor(taskViewController);
// For testing tintColor propagation: specifically for the tintColor task
if taskViewController.result.identifier == String(describing: TaskListRow.Identifier.tintColorTask) {
updateForTintColorTaskResult(taskViewController.result)
}
break;
default:
@@ -253,4 +259,26 @@ class TaskListViewController: UITableViewController, ORKTaskViewControllerDelega
restorationDataByTaskID[taskID] = nil
}
// MARK: Helpers
func updateForTintColorTaskResult(_ taskResult: ORKTaskResult) {
let stepIdentifier = String(describing: TaskListRow.Identifier.tintColorStep)
let stepResult = taskResult.stepResult(forStepIdentifier: stepIdentifier)
let questionResultIdentifier = String(describing: TaskListRow.Identifier.tintColorQuestion)
let result = stepResult?.result(forIdentifier: questionResultIdentifier)
guard let questionResult = result as? ORKChoiceQuestionResult else {
fatalError("Expected tintColor task result to have a result of type ORKChoiceQuestionResult for identifier \(questionResultIdentifier)")
}
guard
let colorName = questionResult.choiceAnswers?.first as? String,
let color = UIColor.value(forKey: colorName) as? UIColor
else {
fatalError("Couldn't create a color from question result \(questionResult)")
}
// Finally, set the tintColor
self.view.window?.tintColor = color
}
}