Skip to content

Commit

Permalink
Applied patch from Akshay Yadav
Browse files Browse the repository at this point in the history
  • Loading branch information
moppymopperson committed Jan 31, 2018
1 parent a6eac70 commit 1c5f3cf
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 77 deletions.
2 changes: 1 addition & 1 deletion CareKit/CareCard/OCKCareCardViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ OCK_CLASS_AVAILABLE
If the value is not specified, nothing will be shown when the table is empty.
*/
@property (nonatomic, nullable) NSString *noEventsText;
@property (nonatomic, nullable) NSString *noActivitiesText;

/**
The property that allows activities to be grouped.
Expand Down
29 changes: 14 additions & 15 deletions CareKit/CareCard/OCKCareCardViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ @implementation OCKCareCardViewController {
BOOL _isGrouped;
BOOL _isSorted;
UIRefreshControl *_refreshControl;
OCKLabel *_noDataLabel;
OCKLabel *_noActivitiesLabel;
}

- (instancetype)init {
Expand Down Expand Up @@ -127,15 +127,15 @@ - (void)viewDidLoad {
_tableView.refreshControl = _refreshControl;
[self updatePullToRefreshControl];

_noDataLabel = [OCKLabel new];
_noDataLabel.hidden = YES;
_noDataLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_noDataLabel.textStyle = UIFontTextStyleTitle2;
_noDataLabel.textColor = [UIColor lightGrayColor];
_noDataLabel.text = self.noEventsText;
_noDataLabel.textAlignment = NSTextAlignmentCenter;
_noDataLabel.numberOfLines = 0;
_tableView.backgroundView = _noDataLabel;
_noActivitiesLabel = [OCKLabel new];
_noActivitiesLabel.hidden = YES;
_noActivitiesLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_noActivitiesLabel.textStyle = UIFontTextStyleTitle2;
_noActivitiesLabel.textColor = [UIColor lightGrayColor];
_noActivitiesLabel.text = self.noActivitiesText;
_noActivitiesLabel.textAlignment = NSTextAlignmentCenter;
_noActivitiesLabel.numberOfLines = 0;
_tableView.backgroundView = _noActivitiesLabel;

self.navigationController.navigationBar.translucent = NO;
[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:245.0/255.0 green:244.0/255.0 blue:246.0/255.0 alpha:1.0]];
Expand Down Expand Up @@ -359,12 +359,11 @@ - (void)setDelegate:(id<OCKCareCardViewControllerDelegate>)delegate
}
}

- (void)setNoEventsText:(NSString *)noEventsText {
_noEventsText = noEventsText;
_noDataLabel.text = noEventsText;
- (void)setNoActivitiesText:(NSString *)noActivitiesText {
_noActivitiesText = noActivitiesText;
_noActivitiesLabel.text = noActivitiesText;
}


#pragma mark - Helpers

- (void)fetchEvents {
Expand All @@ -383,7 +382,7 @@ - (void)fetchEvents {
[self.delegate careCardViewController:self willDisplayEvents:[_events copy] dateComponents:_selectedDate];
}

_noDataLabel.hidden = (_events.count > 0);
_noActivitiesLabel.hidden = (_events.count > 0);
[self createGroupedEventDictionaryForEvents:_events];

[self updateHeaderView];
Expand Down
26 changes: 1 addition & 25 deletions CareKit/CareContents/OCKCareContentsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,30 +186,6 @@ OCK_CLASS_AVAILABLE
*/
@property (nonatomic, readonly, nullable) OCKCarePlanEvent *lastSelectedEvent;

/**
Indicates if any `OCKCarePlanEvents` of the type `OCKCarePlanActivityTypeIntervention`
are currently being displayed.
This value is false to begin and gets updated each time the store is queried.
*/
@property (nonatomic, readonly) BOOL hasInterventions;

/**
Indicates if any `OCKCarePlanEvents` of the type `OCKCarePlanActivityTypeAssessment`
are currently being displayed.
This value is false to begin and get updated each time the store is queried.
*/
@property (nonatomic, readonly) BOOL hasAssesments;

/**
Indicates if any `OCKCarePlanEvents` of the type `OCKCarePlanActivityTypeReadOnly`
are currently being displayed.
This value is false to begin and gets updated each time the store is queried.
*/
@property (nonatomic, readonly) BOOL hasReadOnlyItems;

/**
The image that will be used to mask the fill shape in the week view.
Expand Down Expand Up @@ -257,7 +233,7 @@ OCK_CLASS_AVAILABLE
Optional: A message that will be displayed in the table view's background view
if there are no interventions, assessments, or ReadOnly activities to display.
*/
@property (nonatomic, nullable) NSString *noEventsText;
@property (nonatomic, nullable) NSString *noActivitiesText;

/**
The property that allows activities to be grouped.
Expand Down
38 changes: 20 additions & 18 deletions CareKit/CareContents/OCKCareContentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ @interface OCKCareContentsViewController() <OCKWeekViewDelegate, OCKCarePlanStor
@implementation OCKCareContentsViewController {
UITableView *_tableView;
UIRefreshControl *_refreshControl;
OCKLabel *_noDataLabel;
OCKLabel *_noActivitiesLabel;
NSMutableArray<NSMutableArray<OCKCarePlanEvent *> *> *_events;
NSMutableArray *_weekValues;
OCKHeaderView *_headerView;
Expand All @@ -72,6 +72,10 @@ @implementation OCKCareContentsViewController {
NSMutableArray<NSMutableArray <NSMutableArray <OCKCarePlanEvent *> *> *> *_tableViewData;
NSMutableDictionary *_allEvents;

BOOL _hasInterventions;
BOOL _hasAssessments;
BOOL _hasReadOnlyItems;

NSString *_otherString;
NSString *_optionalString;
NSString *_readOnlyString;
Expand All @@ -92,9 +96,6 @@ - (instancetype)initWithCarePlanStore:(OCKCarePlanStore *)store {
_glyphTintColor = nil;
_isGrouped = YES;
_isSorted = YES;
_hasInterventions = NO;
_hasAssesments = NO;
_hasReadOnlyItems = NO;
}
return self;
}
Expand Down Expand Up @@ -144,15 +145,15 @@ - (void)viewDidLoad {
_tableView.refreshControl = _refreshControl;
[self updatePullToRefreshControl];

_noDataLabel = [OCKLabel new];
_noDataLabel.hidden = YES;
_noDataLabel.textStyle = UIFontTextStyleTitle2;
_noDataLabel.textColor = [UIColor lightGrayColor];
_noDataLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_noDataLabel.text = self.noEventsText;
_noDataLabel.numberOfLines = 0;
_noDataLabel.textAlignment = NSTextAlignmentCenter;
_tableView.backgroundView = _noDataLabel;
_noActivitiesLabel = [OCKLabel new];
_noActivitiesLabel.hidden = YES;
_noActivitiesLabel.textStyle = UIFontTextStyleTitle2;
_noActivitiesLabel.textColor = [UIColor lightGrayColor];
_noActivitiesLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_noActivitiesLabel.text = self.noActivitiesText;
_noActivitiesLabel.numberOfLines = 0;
_noActivitiesLabel.textAlignment = NSTextAlignmentCenter;
_tableView.backgroundView = _noActivitiesLabel;

self.navigationController.navigationBar.translucent = NO;
[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:245.0/255.0 green:244.0/255.0 blue:246.0/255.0 alpha:1.0]];
Expand Down Expand Up @@ -365,9 +366,10 @@ - (void)setDelegate:(id<OCKCareContentsViewControllerDelegate>)delegate
[self updatePullToRefreshControl];
}
}
- (void)setNoEventsText:(NSString *)noEventsText {
_noEventsText = noEventsText;
_noDataLabel.text = noEventsText;

- (void)setNoActivitiesText:(NSString *)noActivitiesText {
_noActivitiesText = noActivitiesText;
_noActivitiesLabel.text = noActivitiesText;
}

#pragma mark - Helpers
Expand Down Expand Up @@ -408,7 +410,7 @@ - (void)fetchEventsOfType:(OCKCarePlanActivityType)type {
break;

case OCKCarePlanActivityTypeAssessment:
_hasAssesments = _events.count > 0;
_hasAssessments = _events.count > 0;
break;

case OCKCarePlanActivityTypeReadOnly:
Expand All @@ -418,7 +420,7 @@ - (void)fetchEventsOfType:(OCKCarePlanActivityType)type {
default:
break;
}
_noDataLabel.hidden = _hasAssesments || _hasInterventions || _hasReadOnlyItems;
_noActivitiesLabel.hidden = _hasAssessments || _hasInterventions || _hasReadOnlyItems;
[_tableView reloadData];
});
}];
Expand Down
4 changes: 2 additions & 2 deletions CareKit/SymptomTracker/OCKSymptomTrackerViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ OCK_CLASS_AVAILABLE

/**
Optional: A message that will be displayed in the table view's background view
if there are no interventions, assessments, or ReadOnly activities to display.
if there are no assessments to display.
*/
@property (nonatomic, nullable) NSString *noEventsText;
@property (nonatomic, nullable) NSString *noActivitiesText;

/**
The property that allows activities to be grouped.
Expand Down
29 changes: 14 additions & 15 deletions CareKit/SymptomTracker/OCKSymptomTrackerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ @implementation OCKSymptomTrackerViewController {
NSMutableArray<NSMutableArray <NSMutableArray <OCKCarePlanEvent *> *> *> *_tableViewData;
NSString *_otherString;
NSString *_optionalString;
OCKLabel *_noDataLabel;
OCKLabel *_noActivitiesLabel;
BOOL _isGrouped;
BOOL _isSorted;
}
Expand Down Expand Up @@ -119,15 +119,15 @@ - (void)viewDidLoad {
_tableView.estimatedSectionHeaderHeight = 0;
_tableView.estimatedSectionFooterHeight = 0;

_noDataLabel = [OCKLabel new];
_noDataLabel.hidden = YES;
_noDataLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_noDataLabel.textStyle = UIFontTextStyleTitle2;
_noDataLabel.textColor = [UIColor lightGrayColor];
_noDataLabel.textAlignment = NSTextAlignmentCenter;
_noDataLabel.numberOfLines = 0;
_noDataLabel.text = self.noEventsText;
_tableView.backgroundView = _noDataLabel;
_noActivitiesLabel = [OCKLabel new];
_noActivitiesLabel.hidden = YES;
_noActivitiesLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_noActivitiesLabel.textStyle = UIFontTextStyleTitle2;
_noActivitiesLabel.textColor = [UIColor lightGrayColor];
_noActivitiesLabel.textAlignment = NSTextAlignmentCenter;
_noActivitiesLabel.numberOfLines = 0;
_noActivitiesLabel.text = self.noActivitiesText;
_tableView.backgroundView = _noActivitiesLabel;

_refreshControl = [[UIRefreshControl alloc] init];
_refreshControl.tintColor = [UIColor grayColor];
Expand Down Expand Up @@ -358,12 +358,11 @@ - (void)setDelegate:(id<OCKSymptomTrackerViewControllerDelegate>)delegate
}
}

- (void)setNoEventsText:(NSString *)noEventsText {
_noEventsText = noEventsText;
_noDataLabel.text = noEventsText;
- (void)setNoActivitiesText:(NSString *)noActivitiesText {
_noActivitiesText = noActivitiesText;
_noActivitiesLabel.text = noActivitiesText;
}


#pragma mark - Helpers

- (void)fetchEvents {
Expand All @@ -382,7 +381,7 @@ - (void)fetchEvents {
[self.delegate symptomTrackerViewController:self willDisplayEvents:[_events copy] dateComponents:_selectedDate];
}

_noDataLabel.hidden = (_events.count > 0);
_noActivitiesLabel.hidden = (_events.count > 0);
[self createGroupedEventDictionaryForEvents:_events];

[self updateHeaderView];
Expand Down
2 changes: 1 addition & 1 deletion Sample/OCKSample/RootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class RootViewController: UITabBarController {
let viewController = OCKCareContentsViewController(carePlanStore: storeManager.store)
viewController.title = NSLocalizedString("Care Contents", comment: "")
viewController.tabBarItem = UITabBarItem(title: viewController.title, image: UIImage(named:"carecard"), selectedImage: UIImage(named: "carecard-filled"))
viewController.noEventsText = "No events to show yet!";
viewController.noActivitiesText = NSLocalizedString("There are no activities to show!", comment: "")
viewController.delegate = self;
return viewController

Expand Down

0 comments on commit 1c5f3cf

Please sign in to comment.