Skip to content

Track changes #5

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
wants to merge 12 commits into
base: dev/SwiftUI
Choose a base branch
from
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
381 changes: 186 additions & 195 deletions ResearchKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,6 @@
<Test
Identifier = "ORKDataCollectionTests">
</Test>
<Test
Identifier = "ORKJSONSerializationTests">
</Test>
<Test
Identifier = "ORKJSONSerializationTests/testAddResult">
</Test>
<Test
Identifier = "ORKJSONSerializationTests/testDateComponentsSerialization">
</Test>
<Test
Identifier = "ORKJSONSerializationTests/testEquality">
</Test>
<Test
Identifier = "ORKJSONSerializationTests/testInvalidDBHLValue">
</Test>
<Test
Identifier = "ORKJSONSerializationTests/testMissingDefaultValueKeyInScaleAnswerFormat">
</Test>
<Test
Identifier = "ORKJSONSerializationTests/testORKSampleDeserialization">
</Test>
<Test
Identifier = "ORKJSONSerializationTests/testORKSerialization">
</Test>
<Test
Identifier = "ORKJSONSerializationTests/testSecureCoding">
</Test>
<Test
Identifier = "ORKJSONSerializationTests/testTaskModel">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
Expand Down
17 changes: 13 additions & 4 deletions ResearchKit/Common/ORKAnswerFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


#import <UIKit/UIKit.h>


#if TARGET_OS_IOS
#import <ResearchKit/ORKTypes.h>

@class ORKScaleAnswerFormat;
Expand All @@ -52,6 +56,7 @@
@class ORKLocationAnswerFormat;
@class ORKSESAnswerFormat;
@class ORKImageChoice;
#endif

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -434,6 +439,10 @@ ORK_CLASS_AVAILABLE

@end


#pragma mark - iOS

#if TARGET_OS_IOS
@interface ORKAnswerFormat()

/// @name Factory methods
Expand Down Expand Up @@ -523,7 +532,7 @@ ORK_CLASS_AVAILABLE
minimumValue:(double)minimumValue
maximumValue:(double)maximumValue
defaultValue:(double)defaultValue;
#if ORK_FEATURE_CLLOCATIONMANAGER_AUTHORIZATION && TARGET_OS_IOS
#if ORK_FEATURE_CLLOCATIONMANAGER_AUTHORIZATION
+ (ORKLocationAnswerFormat *)locationAnswerFormat;
#endif

Expand Down Expand Up @@ -1781,7 +1790,6 @@ This By default, the value of this property is `NO`.
*/
@property (copy, nullable) NSString *placeholder;

#if !TARGET_OS_WATCH
/**
The autocapitalization type that applies to the user's input.

Expand Down Expand Up @@ -1824,7 +1832,6 @@ This By default, the value of this property is `NO`.
If specified, overrides the default password generation rules for fields with secureTextEntry.
*/
@property (nonatomic, copy, nullable) UITextInputPasswordRules *passwordRules API_AVAILABLE(ios(12));
#endif

@end

Expand Down Expand Up @@ -2207,7 +2214,7 @@ ORK_CLASS_AVAILABLE

An `ORKLocationAnswerFormat` object produces an `ORKLocationQuestionResult` object.
*/
#if ORK_FEATURE_CLLOCATIONMANAGER_AUTHORIZATION && TARGET_OS_IOS
#if ORK_FEATURE_CLLOCATIONMANAGER_AUTHORIZATION
ORK_CLASS_AVAILABLE
@interface ORKLocationAnswerFormat : ORKAnswerFormat

Expand Down Expand Up @@ -2243,4 +2250,6 @@ ORK_CLASS_AVAILABLE

@end

#endif

NS_ASSUME_NONNULL_END
36 changes: 26 additions & 10 deletions ResearchKit/Common/ORKAnswerFormat.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ BOOL ORKIsAnswerEmpty(id answer) {
}


#if TARGET_OS_IOS
static NSNumberFormatterStyle ORKNumberFormattingStyleConvert(ORKNumberFormattingStyle style) {
return style == ORKNumberFormattingStylePercent ? NSNumberFormatterPercentStyle : NSNumberFormatterDecimalStyle;
}

#if TARGET_OS_IOS
@implementation ORKAnswerDefaultSource {
NSMutableDictionary *_unitsTable;
}
Expand Down Expand Up @@ -289,6 +289,8 @@ - (void)updateHealthKitUnitForAnswerFormat:(ORKAnswerFormat *)answerFormat force

@implementation ORKAnswerFormat

#if TARGET_OS_IOS

+ (ORKScaleAnswerFormat *)scaleAnswerFormatWithMaximumValue:(NSInteger)scaleMaximum
minimumValue:(NSInteger)scaleMinimum
defaultValue:(NSInteger)defaultValue
Expand Down Expand Up @@ -422,7 +424,7 @@ + (ORKDateAnswerFormat *)dateAnswerFormatWithStyle:(ORKDateAnswerStyle)style
calendar:calendar];
[answerFormat setDaysBeforeCurrentDateToSetMinimumDate:daysBefore];
[answerFormat setDaysAfterCurrentDateToSetMinimumDate:daysAfter];

return answerFormat;
}

Expand Down Expand Up @@ -487,7 +489,7 @@ + (ORKWeightAnswerFormat *)weightAnswerFormatWithMeasurementSystem:(ORKMeasureme
defaultValue:defaultValue];
}

#if ORK_FEATURE_CLLOCATIONMANAGER_AUTHORIZATION && TARGET_OS_IOS
#if ORK_FEATURE_CLLOCATIONMANAGER_AUTHORIZATION
+ (ORKLocationAnswerFormat *)locationAnswerFormat {
return [ORKLocationAnswerFormat new];
}
Expand All @@ -499,6 +501,8 @@ + (ORKSESAnswerFormat *)socioEconomicAnswerFormatWithTopRungText:(NSString *)top
bottomRungText:bottomRungText];
}

#endif

+ (ORKBooleanAnswerFormat *)booleanAnswerFormat {
return [ORKBooleanAnswerFormat new];
}
Expand Down Expand Up @@ -684,6 +688,7 @@ static void ork_validateChoices(NSArray *choices) {
return choices;
}

#if TARGET_OS_IOS
@implementation ORKValuePickerAnswerFormat {
ORKChoiceAnswerFormatHelper *_helper;
ORKTextChoice *_nullTextChoice;
Expand Down Expand Up @@ -836,7 +841,7 @@ - (id)copyWithZone:(NSZone *)zone {

- (BOOL)isEqual:(id)object {
BOOL isParentSame = [super isEqual:object];

__typeof(self) castObject = object;
return (isParentSame &&
ORKEqualObjects(self.valuePickers, castObject.valuePickers));
Expand Down Expand Up @@ -885,7 +890,7 @@ - (NSString *)stringForAnswer:(id)answer {
if (![answer isKindOfClass:[NSArray class]] || ([(NSArray*)answer count] != self.valuePickers.count)) {
return nil;
}

NSArray *answers = (NSArray*)answer;
__block NSMutableArray <NSString *> *answerTexts = [NSMutableArray new];
[answers enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
Expand All @@ -896,11 +901,11 @@ - (NSString *)stringForAnswer:(id)answer {
*stop = YES;
}
}];

if (answerTexts.count != self.valuePickers.count) {
return nil;
}

return [answerTexts componentsJoinedByString:self.separator];
}

Expand Down Expand Up @@ -1022,6 +1027,8 @@ - (NSArray *)choices {
}

@end
#endif


#pragma mark - ORKTextChoiceAnswerFormat

Expand Down Expand Up @@ -1481,6 +1488,7 @@ - (BOOL)shouldShowDontKnowButton {


#pragma mark - ORKTextChoiceOther
#if TARGET_OS_IOS
@implementation ORKTextChoiceOther

+ (instancetype)new {
Expand Down Expand Up @@ -1704,6 +1712,7 @@ - (BOOL)shouldShowDontKnowButton {
}

@end
#endif


#pragma mark - ORKBooleanAnswerFormat
Expand Down Expand Up @@ -1791,7 +1800,7 @@ - (BOOL)shouldShowDontKnowButton {


#pragma mark - ORKTimeOfDayAnswerFormat

#if TARGET_OS_IOS
@implementation ORKTimeOfDayAnswerFormat

- (instancetype)init {
Expand Down Expand Up @@ -2818,7 +2827,7 @@ - (BOOL)shouldHideValueMarkers {


#pragma mark - ORKTextScaleAnswerFormat

#if TARGET_OS_IOS
@interface ORKTextScaleAnswerFormat () {

ORKChoiceAnswerFormatHelper *_helper;
Expand Down Expand Up @@ -3029,15 +3038,19 @@ - (NSArray *)choices {

@end

#endif


#pragma mark - ORKTextAnswerFormat

@interface ORKTextAnswerFormat()


@end

@implementation ORKTextAnswerFormat


- (Class)questionResultClass {
return [ORKTextQuestionResult class];
}
Expand All @@ -3056,6 +3069,7 @@ - (void)commonInit {

}


- (instancetype)initWithMaximumLength:(NSInteger)maximumLength {
self = [super init];
if (self) {
Expand Down Expand Up @@ -3307,6 +3321,7 @@ - (NSString *)stringForAnswer:(id)answer {
return answerString;
}


- (ORKQuestionResult *)resultWithIdentifier:(NSString *)identifier answer:(id)answer {
ORKQuestionResult *questionResult = nil;
questionResult = (ORKQuestionResult *)[super resultWithIdentifier:identifier answer:answer];
Expand Down Expand Up @@ -4004,7 +4019,7 @@ + (BOOL)supportsSecureCoding {
@end


#if ORK_FEATURE_CLLOCATIONMANAGER_AUTHORIZATION && TARGET_OS_IOS
#if ORK_FEATURE_CLLOCATIONMANAGER_AUTHORIZATION
#pragma mark - ORKLocationAnswerFormat
@implementation ORKLocationAnswerFormat

Expand Down Expand Up @@ -4138,3 +4153,4 @@ - (NSString *)stringForAnswer:(id)answer {
}

@end
#endif
18 changes: 9 additions & 9 deletions ResearchKit/Common/ORKAnswerFormat_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
#import <HealthKit/HealthKit.h>
#endif

#if TARGET_OS_IOS
#import <ResearchKit/ORKAnswerFormat_Private.h>
#import <ResearchKit/ORKChoiceAnswerFormatHelper.h>

#endif
@class ORKChoiceAnswerFormatHelper;

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -57,7 +58,7 @@ NSString *ORKQuestionTypeString(ORKQuestionType questionType);
@end

ORK_DESIGNATE_CODING_AND_SERIALIZATION_INITIALIZERS(ORKAnswerFormat)
#if TARGET_OS_IOS || TARGET_OS_VISION
#if TARGET_OS_IOS
ORK_DESIGNATE_CODING_AND_SERIALIZATION_INITIALIZERS(ORKImageChoiceAnswerFormat)
ORK_DESIGNATE_CODING_AND_SERIALIZATION_INITIALIZERS(ORKValuePickerAnswerFormat)
ORK_DESIGNATE_CODING_AND_SERIALIZATION_INITIALIZERS(ORKMultipleValuePickerAnswerFormat)
Expand Down Expand Up @@ -134,11 +135,6 @@ ORK_DESIGNATE_CODING_AND_SERIALIZATION_INITIALIZERS(ORKTextChoice)

@end

@interface ORKDateAnswerFormat () {
NSDate *_currentDateOverride;
}
@end

#if TARGET_OS_IOS
@protocol ORKScaleAnswerFormatProvider <NSObject>

Expand Down Expand Up @@ -202,7 +198,6 @@ NSArray<Class> *ORKAllowableValueClasses(void);
@end

#if TARGET_OS_IOS

@interface ORKValuePickerAnswerFormat ()

- (instancetype)initWithTextChoices:(NSArray<ORKTextChoice *> *)textChoices nullChoice:(ORKTextChoice *)nullChoice NS_DESIGNATED_INITIALIZER;
Expand All @@ -211,6 +206,7 @@ NSArray<Class> *ORKAllowableValueClasses(void);

@end


@interface ORKImageChoice () <ORKAnswerOption>

@end
Expand All @@ -222,7 +218,11 @@ NSArray<Class> *ORKAllowableValueClasses(void);

@end

@interface ORKDateAnswerFormat ()

@interface ORKDateAnswerFormat () {
NSDate *_currentDateOverride;
}

- (NSDate *)pickerDefaultDate;
- (nullable NSDate *)pickerMinimumDate;
- (nullable NSDate *)pickerMaximumDate;
Expand Down
7 changes: 7 additions & 0 deletions ResearchKit/Common/ORKAnswerFormat_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/



#if TARGET_OS_IOS
#import <ResearchKit/ORKAnswerFormat.h>
#endif


NS_ASSUME_NONNULL_BEGIN

Expand All @@ -55,6 +60,7 @@ ORK_EXTERN id ORKNullAnswerValue(void) ORK_AVAILABLE_DECL;

An `ORKConfirmTextAnswerFormat` object produces an `ORKBooleanQuestionResult` object.
*/
#if TARGET_OS_IOS
ORK_CLASS_AVAILABLE
@interface ORKConfirmTextAnswerFormat : ORKTextAnswerFormat

Expand Down Expand Up @@ -89,6 +95,7 @@ ORK_CLASS_AVAILABLE
@property (nonatomic, copy, readonly) NSString *errorMessage;

@end
#endif

@protocol ORKAnswerFormatPlatterPresentable <NSObject>

Expand Down
Loading