Skip to content

Commit

Permalink
Public release/2.2.10 (#1548)
Browse files Browse the repository at this point in the history
Fix ORKNavigationContainerView so that it does not call didMoveToWindow from tintColorDidChange
Bumped version to 2.2.10
  • Loading branch information
Pariecemckinney-apple committed May 10, 2023
1 parent bd60d94 commit 2fb22a6
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 10 deletions.
15 changes: 10 additions & 5 deletions ResearchKit/Common/ORKNavigationContainerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,8 @@ - (void)setupViews {
}

- (void)didMoveToWindow {
_appTintColor = ORKViewTintColor(self);

_continueButton.normalTintColor = _appTintColor;
_skipButton.normalTintColor = _appTintColor;
[self udpateTintColor];
[super didMoveToWindow];
}

- (void)setSkipButtonStyle:(ORKNavigationContainerButtonStyle)skipButtonStyle {
Expand Down Expand Up @@ -559,8 +557,15 @@ - (void)setUseExtendedPadding:(BOOL)useExtendedPadding {
}

- (void)tintColorDidChange {
[self udpateTintColor];
[super tintColorDidChange];
[self didMoveToWindow];
}

- (void)udpateTintColor {
_appTintColor = ORKViewTintColor(self);

_continueButton.normalTintColor = _appTintColor;
_skipButton.normalTintColor = _appTintColor;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 40 additions & 3 deletions samples/ORKCatalog/ORKCatalog/Tasks/TaskListRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ enum TaskListRow: Int, CustomStringConvertible {
case contrastSensitivityPeakLandoltC
case videoInstruction
case webView

case tintColor

class TaskListRowSection {
var title: String
Expand Down Expand Up @@ -213,6 +213,7 @@ enum TaskListRow: Int, CustomStringConvertible {
]),
TaskListRowSection(title: "Miscellaneous", rows:
[
.tintColor,
.videoInstruction,
.webView
])]
Expand Down Expand Up @@ -409,7 +410,10 @@ enum TaskListRow: Int, CustomStringConvertible {

case .webView:
return NSLocalizedString("Web View", comment: "")


case .tintColor:
return NSLocalizedString("Tint Color", comment: "")

}
}

Expand Down Expand Up @@ -615,6 +619,11 @@ enum TaskListRow: Int, CustomStringConvertible {
case webViewTask
case webViewStep

// Tint color
case tintColorTask
case tintColorStep
case tintColorQuestion

}

// MARK: Properties
Expand Down Expand Up @@ -799,6 +808,9 @@ enum TaskListRow: Int, CustomStringConvertible {
case .contrastSensitivityPeakLandoltC:
return contrastSensitivityPeakLandoltC

case .tintColor:
return tintColor

case .videoInstruction:
return videoInstruction

Expand Down Expand Up @@ -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 {
Expand Down
28 changes: 28 additions & 0 deletions samples/ORKCatalog/ORKCatalog/Tasks/TaskListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
}

}

0 comments on commit 2fb22a6

Please sign in to comment.