Add option to clear profile avatar.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-08-01 11:58:51 -04:00
parent 83a02536a4
commit a748987d72
7 changed files with 49 additions and 2 deletions

View File

@ -19,6 +19,14 @@ NS_ASSUME_NONNULL_BEGIN
- (UIViewController *)fromViewController;
- (BOOL)hasClearAvatarAction;
@optional
- (NSString *)clearAvatarActionLabel;
- (void)clearAvatar;
@end
#pragma mark -

View File

@ -53,6 +53,15 @@ NS_ASSUME_NONNULL_BEGIN
}];
[actionSheetController addAction:choosePictureAction];
if (self.delegate.hasClearAvatarAction) {
UIAlertAction *clearAction = [UIAlertAction actionWithTitle:self.delegate.clearAvatarActionLabel
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[self.delegate clearAvatar];
}];
[actionSheetController addAction:clearAction];
}
[self.delegate.fromViewController presentViewController:actionSheetController animated:true completion:nil];
}

View File

@ -626,6 +626,11 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
return self;
}
- (BOOL)hasClearAvatarAction
{
return NO;
}
#pragma mark - AddToGroupViewControllerDelegate
- (void)recipientIdWasAdded:(NSString *)recipientId

View File

@ -272,7 +272,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)avatarActionSheetTitle
{
return NSLocalizedString(
@"PROFILE_AVATAR_ACTIONSHEET_TITLE", @"Action Sheet title prompting the user for a profile avatar");
@"PROFILE_VIEW_AVATAR_ACTIONSHEET_TITLE", @"Action Sheet title prompting the user for a profile avatar");
}
- (void)avatarDidChange:(UIImage *)image
@ -289,6 +289,21 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (BOOL)hasClearAvatarAction
{
return YES;
}
- (NSString *)clearAvatarActionLabel
{
return NSLocalizedString(@"PROFILE_VIEW_CLEAR_AVATAR", @"Label for action that clear's the user's profile avatar");
}
- (void)clearAvatar
{
self.avatar = nil;
}
#pragma mark - Logging
+ (NSString *)tag

View File

@ -507,6 +507,11 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (BOOL)hasClearAvatarAction
{
return NO;
}
#pragma mark - AddToGroupViewControllerDelegate
- (void)recipientIdWasAdded:(NSString *)recipientId

View File

@ -1037,7 +1037,7 @@
"PROCEED_BUTTON" = "Proceed";
/* Action Sheet title prompting the user for a profile avatar */
"PROFILE_AVATAR_ACTIONSHEET_TITLE" = "Set Profile Avatar";
"PROFILE_VIEW_AVATAR_ACTIONSHEET_TITLE" = "Set Profile Avatar";
/* Instructions for how to change the profile avatar. */
"PROFILE_VIEW_AVATAR_INSTRUCTIONS" = "Tap to Select Avatar";
@ -1045,6 +1045,9 @@
/* Header title for the profile avatar field of the profile view. */
"PROFILE_VIEW_AVATAR_SECTION_HEADER" = "Avatar";
/* Label for action that clear's the user's profile avatar */
"PROFILE_VIEW_CLEAR_AVATAR" = "Clear Avatar";
/* Default text for the profile name field of the profile view. */
"PROFILE_VIEW_NAME_DEFAULT_TEXT" = "Enter your name.";

View File

@ -443,6 +443,8 @@ static const NSInteger kProfileKeyLength = 16;
return profileAvatarsDirPath;
}
// TODO: We may want to clean up this directory in the "orphan cleanup" logic.
#pragma mark - Notifications
- (void)applicationDidBecomeActive:(NSNotification *)notification