Skip to content

Commit afa8c86

Browse files
Updated per comments from Erin
1 parent 6f10738 commit afa8c86

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

APCAppCore/APCAppCore/UI/TabBarControllers/Profile/APCProfileViewController.m

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -444,18 +444,8 @@ - (void) setEditing:(BOOL) isEditing
444444
{
445445
[super setEditing:isEditing];
446446

447-
NSArray* visibleCells = [self.tableView visibleCells];
448-
for (UITableViewCell* cell in visibleCells) {
449-
450-
// Segment control cells do not respond to didSelectRowAtIndex,
451-
// So we need to change the editable property here, instead of blocking it in didSelectRowAtIndex
452-
if ([cell isKindOfClass:[APCSegmentedTableViewCell class]])
453-
{
454-
NSIndexPath* indexPath = [self.tableView indexPathForCell:cell];
455-
APCTableViewItem *field = [self itemForIndexPath:indexPath];
456-
cell.userInteractionEnabled = field.editable && self.isEditing;
457-
}
458-
}
447+
// Reload the table so that all the field items and cells are in the correct state for new "isEditing" property
448+
[self.tableView reloadData];
459449
}
460450

461451
#pragma mark - Prepare Content
@@ -540,7 +530,7 @@ - (NSArray *)prepareContent
540530
}
541531
field = dateField;
542532
}
543-
else // if we cant edit sex, show a simple default table view cell
533+
else // if we cant edit birthdate, show a simple default table view cell
544534
{
545535
field = [APCTableViewItem new];
546536
field.editable = NO;
@@ -1221,7 +1211,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
12211211

12221212
case kAPCUserInfoItemTypeDateOfBirth:
12231213
{
1224-
if (![self isEditingAllowedForHealthKitProperty:HKCharacteristicTypeIdentifierDateOfBirth])
1214+
if (self.canEditBirthDate &&
1215+
![self isEditingAllowedForHealthKitProperty:HKCharacteristicTypeIdentifierDateOfBirth])
12251216
{
12261217
[self showEditingNotAllowedAlertForHealthKitProperty:HKCharacteristicTypeIdentifierDateOfBirth];
12271218
[tableView deselectRowAtIndexPath:indexPath animated:YES];
@@ -1235,6 +1226,11 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
12351226
}
12361227
}
12371228
break;
1229+
1230+
case kAPCUserInfoItemTypeHeight:
1231+
{
1232+
[self setEditing:!self.isEditing];
1233+
}
12381234

12391235
default:{
12401236
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
@@ -1334,7 +1330,8 @@ - (void)segmentedTableViewCell:(APCSegmentedTableViewCell *) __unused cell
13341330
{
13351331
[super segmentedTableViewCell:cell didSelectSegmentAtIndex:index];
13361332

1337-
if (![self isEditingAllowedForHealthKitProperty:HKCharacteristicTypeIdentifierBiologicalSex])
1333+
if (self.canEditBiologicalSex &&
1334+
![self isEditingAllowedForHealthKitProperty:HKCharacteristicTypeIdentifierBiologicalSex])
13381335
{
13391336
[self showEditingNotAllowedAlertForHealthKitProperty:HKCharacteristicTypeIdentifierBiologicalSex];
13401337
// Revert back to whatever the index was originally
@@ -1367,12 +1364,12 @@ - (void) showEditingNotAllowedAlertForHealthKitProperty:(NSString*)healthKitProp
13671364
- (BOOL) isEditingAllowedForHealthKitProperty:(NSString*) healthKitPropertyIdentifier
13681365
{
13691366
if (healthKitPropertyIdentifier == HKCharacteristicTypeIdentifierBiologicalSex &&
1370-
self.canEditBiologicalSex && [self.user hasBiologicalSexInHealthKit])
1367+
[self.user hasBiologicalSexInHealthKit])
13711368
{
13721369
return NO;
13731370
}
13741371
else if (healthKitPropertyIdentifier == HKCharacteristicTypeIdentifierDateOfBirth &&
1375-
self.canEditBirthDate && [self.user hasBirthDateInHealthKit])
1372+
[self.user hasBirthDateInHealthKit])
13761373
{
13771374
return NO;
13781375
}

0 commit comments

Comments
 (0)