Sketch out the profile view.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-07-31 17:12:09 -04:00
parent 72ea096970
commit 873f5208c4
8 changed files with 185 additions and 141 deletions

View File

@ -78,7 +78,7 @@
34CCAF3B1F0C2748004084F4 /* OWSAddToContactViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CCAF3A1F0C2748004084F4 /* OWSAddToContactViewController.m */; }; 34CCAF3B1F0C2748004084F4 /* OWSAddToContactViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CCAF3A1F0C2748004084F4 /* OWSAddToContactViewController.m */; };
34CE88E71F2FB9A10098030F /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CE88E61F2FB9A10098030F /* ProfileViewController.m */; }; 34CE88E71F2FB9A10098030F /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CE88E61F2FB9A10098030F /* ProfileViewController.m */; };
34D5CC961EA6AFAD005515DB /* OWSContactsSyncing.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */; }; 34D5CC961EA6AFAD005515DB /* OWSContactsSyncing.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */; };
34D5CCA91EAE3D30005515DB /* GroupViewHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCA81EAE3D30005515DB /* GroupViewHelper.m */; }; 34D5CCA91EAE3D30005515DB /* AvatarViewHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCA81EAE3D30005515DB /* AvatarViewHelper.m */; };
34D5CCB11EAE7E7F005515DB /* SelectRecipientViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCB01EAE7E7F005515DB /* SelectRecipientViewController.m */; }; 34D5CCB11EAE7E7F005515DB /* SelectRecipientViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCB01EAE7E7F005515DB /* SelectRecipientViewController.m */; };
34D8C0271ED3673300188D7C /* DebugUIMessages.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D8C0241ED3673300188D7C /* DebugUIMessages.m */; }; 34D8C0271ED3673300188D7C /* DebugUIMessages.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D8C0241ED3673300188D7C /* DebugUIMessages.m */; };
34D8C0281ED3673300188D7C /* DebugUITableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D8C0261ED3673300188D7C /* DebugUITableViewController.m */; }; 34D8C0281ED3673300188D7C /* DebugUITableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D8C0261ED3673300188D7C /* DebugUITableViewController.m */; };
@ -510,8 +510,8 @@
34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactsSyncing.m; sourceTree = "<group>"; }; 34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactsSyncing.m; sourceTree = "<group>"; };
34D5CC981EA6EB79005515DB /* OWSMessageCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessageCollectionViewCell.h; sourceTree = "<group>"; }; 34D5CC981EA6EB79005515DB /* OWSMessageCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessageCollectionViewCell.h; sourceTree = "<group>"; };
34D5CC9B1EA6ED17005515DB /* OWSMessageMediaAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessageMediaAdapter.h; sourceTree = "<group>"; }; 34D5CC9B1EA6ED17005515DB /* OWSMessageMediaAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessageMediaAdapter.h; sourceTree = "<group>"; };
34D5CCA71EAE3D30005515DB /* GroupViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupViewHelper.h; sourceTree = "<group>"; }; 34D5CCA71EAE3D30005515DB /* AvatarViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AvatarViewHelper.h; sourceTree = "<group>"; };
34D5CCA81EAE3D30005515DB /* GroupViewHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupViewHelper.m; sourceTree = "<group>"; }; 34D5CCA81EAE3D30005515DB /* AvatarViewHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AvatarViewHelper.m; sourceTree = "<group>"; };
34D5CCAB1EAE7136005515DB /* OWSConversationSettingsViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSConversationSettingsViewDelegate.h; sourceTree = "<group>"; }; 34D5CCAB1EAE7136005515DB /* OWSConversationSettingsViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSConversationSettingsViewDelegate.h; sourceTree = "<group>"; };
34D5CCAF1EAE7E7F005515DB /* SelectRecipientViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectRecipientViewController.h; sourceTree = "<group>"; }; 34D5CCAF1EAE7E7F005515DB /* SelectRecipientViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectRecipientViewController.h; sourceTree = "<group>"; };
34D5CCB01EAE7E7F005515DB /* SelectRecipientViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SelectRecipientViewController.m; sourceTree = "<group>"; }; 34D5CCB01EAE7E7F005515DB /* SelectRecipientViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SelectRecipientViewController.m; sourceTree = "<group>"; };
@ -958,6 +958,8 @@
34B3F8381E8DF1700035BE1A /* AttachmentApprovalViewController.swift */, 34B3F8381E8DF1700035BE1A /* AttachmentApprovalViewController.swift */,
34B3F8391E8DF1700035BE1A /* AttachmentSharing.h */, 34B3F8391E8DF1700035BE1A /* AttachmentSharing.h */,
34B3F83A1E8DF1700035BE1A /* AttachmentSharing.m */, 34B3F83A1E8DF1700035BE1A /* AttachmentSharing.m */,
34D5CCA71EAE3D30005515DB /* AvatarViewHelper.h */,
34D5CCA81EAE3D30005515DB /* AvatarViewHelper.m */,
343D3D991E9283F100165CA4 /* BlockListUIUtils.h */, 343D3D991E9283F100165CA4 /* BlockListUIUtils.h */,
343D3D9A1E9283F100165CA4 /* BlockListUIUtils.m */, 343D3D9A1E9283F100165CA4 /* BlockListUIUtils.m */,
34B3F89A1E8DF3270035BE1A /* BlockListViewController.h */, 34B3F89A1E8DF3270035BE1A /* BlockListViewController.h */,
@ -982,8 +984,6 @@
34E8BF371EE9E2FD00F5F4CA /* FingerprintViewScanController.m */, 34E8BF371EE9E2FD00F5F4CA /* FingerprintViewScanController.m */,
34B3F8471E8DF1700035BE1A /* FullImageViewController.h */, 34B3F8471E8DF1700035BE1A /* FullImageViewController.h */,
34B3F8481E8DF1700035BE1A /* FullImageViewController.m */, 34B3F8481E8DF1700035BE1A /* FullImageViewController.m */,
34D5CCA71EAE3D30005515DB /* GroupViewHelper.h */,
34D5CCA81EAE3D30005515DB /* GroupViewHelper.m */,
34B3F8491E8DF1700035BE1A /* InboxTableViewCell.h */, 34B3F8491E8DF1700035BE1A /* InboxTableViewCell.h */,
34B3F84A1E8DF1700035BE1A /* InboxTableViewCell.m */, 34B3F84A1E8DF1700035BE1A /* InboxTableViewCell.m */,
34B3F84C1E8DF1700035BE1A /* InviteFlow.swift */, 34B3F84C1E8DF1700035BE1A /* InviteFlow.swift */,
@ -2222,7 +2222,7 @@
34B3F8881E8DF1700035BE1A /* OversizeTextMessageViewController.swift in Sources */, 34B3F8881E8DF1700035BE1A /* OversizeTextMessageViewController.swift in Sources */,
34330AA31E79686200DF2FB9 /* OWSProgressView.m in Sources */, 34330AA31E79686200DF2FB9 /* OWSProgressView.m in Sources */,
34B3F8A21E8EA6040035BE1A /* ViewControllerUtils.m in Sources */, 34B3F8A21E8EA6040035BE1A /* ViewControllerUtils.m in Sources */,
34D5CCA91EAE3D30005515DB /* GroupViewHelper.m in Sources */, 34D5CCA91EAE3D30005515DB /* AvatarViewHelper.m in Sources */,
453D28BA1D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.m in Sources */, 453D28BA1D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.m in Sources */,
45F170AC1E2F0351003FC1F2 /* CallAudioSession.swift in Sources */, 45F170AC1E2F0351003FC1F2 /* CallAudioSession.swift in Sources */,
34B3F8801E8DF1700035BE1A /* InviteFlow.swift in Sources */, 34B3F8801E8DF1700035BE1A /* InviteFlow.swift in Sources */,

View File

@ -0,0 +1,34 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class SignalAccount;
@class AvatarViewHelper;
@class OWSContactsManager;
@class TSThread;
@protocol AvatarViewHelperDelegate <NSObject>
- (void)avatarDidChange:(UIImage *)image;
- (UIViewController *)fromViewController;
@end
#pragma mark -
typedef void (^AvatarViewSuccessBlock)();
@interface AvatarViewHelper : NSObject
@property (nonatomic, weak) id<AvatarViewHelperDelegate> delegate;
- (void)showChangeAvatarUI;
@end
NS_ASSUME_NONNULL_END

View File

@ -2,7 +2,7 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// //
#import "GroupViewHelper.h" #import "AvatarViewHelper.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "UIUtil.h" #import "UIUtil.h"
#import <MobileCoreServices/UTCoreTypes.h> #import <MobileCoreServices/UTCoreTypes.h>
@ -13,17 +13,17 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface GroupViewHelper () <UIImagePickerControllerDelegate, UINavigationControllerDelegate> @interface AvatarViewHelper () <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
@end @end
#pragma mark - #pragma mark -
@implementation GroupViewHelper @implementation AvatarViewHelper
#pragma mark - Group Avatar #pragma mark - Avatar Avatar
- (void)showChangeGroupAvatarUI - (void)showChangeAvatarUI
{ {
OWSAssert([NSThread isMainThread]); OWSAssert([NSThread isMainThread]);
OWSAssert(self.delegate); OWSAssert(self.delegate);
@ -117,9 +117,9 @@ NS_ASSUME_NONNULL_BEGIN
if (rawAvatar) { if (rawAvatar) {
// We resize the avatar to fill a 210x210 square. // We resize the avatar to fill a 210x210 square.
// //
// See: GroupCreateActivity.java in Signal-Android.java. // See: AvatarCreateActivity.java in Signal-Android.java.
UIImage *resizedAvatar = [rawAvatar resizedImageToFillPixelSize:CGSizeMake(210, 210)]; UIImage *resizedAvatar = [rawAvatar resizedImageToFillPixelSize:CGSizeMake(210, 210)];
[self.delegate groupAvatarDidChange:resizedAvatar]; [self.delegate avatarDidChange:resizedAvatar];
} }
[self.delegate.fromViewController dismissViewControllerAnimated:YES completion:nil]; [self.delegate.fromViewController dismissViewControllerAnimated:YES completion:nil];

View File

@ -1,34 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class SignalAccount;
@class GroupViewHelper;
@class OWSContactsManager;
@class TSThread;
@protocol GroupViewHelperDelegate <NSObject>
- (void)groupAvatarDidChange:(UIImage *)image;
- (UIViewController *)fromViewController;
@end
#pragma mark -
typedef void (^GroupViewSuccessBlock)();
@interface GroupViewHelper : NSObject
@property (nonatomic, weak) id<GroupViewHelperDelegate> delegate;
- (void)showChangeGroupAvatarUI;
@end
NS_ASSUME_NONNULL_END

View File

@ -4,11 +4,11 @@
#import "NewGroupViewController.h" #import "NewGroupViewController.h"
#import "AddToGroupViewController.h" #import "AddToGroupViewController.h"
#import "AvatarViewHelper.h"
#import "BlockListUIUtils.h" #import "BlockListUIUtils.h"
#import "ContactTableViewCell.h" #import "ContactTableViewCell.h"
#import "ContactsViewHelper.h" #import "ContactsViewHelper.h"
#import "Environment.h" #import "Environment.h"
#import "GroupViewHelper.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSTableViewController.h" #import "OWSTableViewController.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
@ -31,14 +31,14 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
@interface NewGroupViewController () <UIImagePickerControllerDelegate, @interface NewGroupViewController () <UIImagePickerControllerDelegate,
UITextFieldDelegate, UITextFieldDelegate,
ContactsViewHelperDelegate, ContactsViewHelperDelegate,
GroupViewHelperDelegate, AvatarViewHelperDelegate,
AddToGroupViewControllerDelegate, AddToGroupViewControllerDelegate,
OWSTableViewControllerDelegate, OWSTableViewControllerDelegate,
UINavigationControllerDelegate> UINavigationControllerDelegate>
@property (nonatomic, readonly) OWSMessageSender *messageSender; @property (nonatomic, readonly) OWSMessageSender *messageSender;
@property (nonatomic, readonly) ContactsViewHelper *contactsViewHelper; @property (nonatomic, readonly) ContactsViewHelper *contactsViewHelper;
@property (nonatomic, readonly) GroupViewHelper *groupViewHelper; @property (nonatomic, readonly) AvatarViewHelper *avatarViewHelper;
@property (nonatomic, readonly) OWSTableViewController *tableViewController; @property (nonatomic, readonly) OWSTableViewController *tableViewController;
@property (nonatomic, readonly) AvatarImageView *avatarView; @property (nonatomic, readonly) AvatarImageView *avatarView;
@ -84,8 +84,8 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
{ {
_messageSender = [Environment getCurrent].messageSender; _messageSender = [Environment getCurrent].messageSender;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
_groupViewHelper = [GroupViewHelper new]; _avatarViewHelper = [AvatarViewHelper new];
_groupViewHelper.delegate = self; _avatarViewHelper.delegate = self;
self.memberRecipientIds = [NSMutableSet new]; self.memberRecipientIds = [NSMutableSet new];
} }
@ -181,7 +181,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
- (void)avatarTouched:(UIGestureRecognizer *)sender - (void)avatarTouched:(UIGestureRecognizer *)sender
{ {
if (sender.state == UIGestureRecognizerStateRecognized) { if (sender.state == UIGestureRecognizerStateRecognized) {
[self showChangeGroupAvatarUI]; [self showChangeAvatarUI];
} }
} }
@ -520,9 +520,9 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
#pragma mark - Group Avatar #pragma mark - Group Avatar
- (void)showChangeGroupAvatarUI - (void)showChangeAvatarUI
{ {
[self.groupViewHelper showChangeGroupAvatarUI]; [self.avatarViewHelper showChangeAvatarUI];
} }
- (void)setGroupAvatar:(nullable UIImage *)groupAvatar - (void)setGroupAvatar:(nullable UIImage *)groupAvatar
@ -606,9 +606,9 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
return YES; return YES;
} }
#pragma mark - GroupViewHelperDelegate #pragma mark - AvatarViewHelperDelegate
- (void)groupAvatarDidChange:(UIImage *)image - (void)avatarDidChange:(UIImage *)image
{ {
OWSAssert(image); OWSAssert(image);

View File

@ -6,23 +6,8 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
//@class ProfileViewController;
//
//@protocol ProfileViewControllerDelegate <NSObject>
//
//- (void)ProfileViewController:(ProfileViewController *)vc
// didSelectCountryCode:(NSString *)countryCode
// countryName:(NSString *)countryName
// callingCode:(NSString *)callingCode;
//
//@end
//
//#pragma mark -
@interface ProfileViewController : OWSTableViewController @interface ProfileViewController : OWSTableViewController
//@property (nonatomic, weak) id<ProfileViewControllerDelegate> countryCodeDelegate;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@ -3,22 +3,18 @@
// //
#import "ProfileViewController.h" #import "ProfileViewController.h"
#import "AvatarViewHelper.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
#import "UIView+OWS.h" #import "UIView+OWS.h"
#import "UIViewController+OWS.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface ProfileViewController () <UITextFieldDelegate> @interface ProfileViewController () <UITextFieldDelegate, AvatarViewHelperDelegate>
//<
// OWSTableViewControllerDelegate
//// , UISearchBarDelegate
//>
//@property (nonatomic, readonly) UISearchBar *searchBar; @property (nonatomic, readonly) AvatarViewHelper *avatarViewHelper;
//
//@property (nonatomic) NSArray<NSString *> *countryCodes;
@property (nonatomic) UITextField *nameTextField; @property (nonatomic) UITextField *nameTextField;
@ -26,6 +22,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) UILabel *avatarLabel; @property (nonatomic) UILabel *avatarLabel;
@property (nonatomic, nullable) UIImage *avatar;
@property (nonatomic) BOOL hasUnsavedChanges;
@end @end
#pragma mark - #pragma mark -
@ -39,13 +39,11 @@ NS_ASSUME_NONNULL_BEGIN
self.view.backgroundColor = [UIColor whiteColor]; self.view.backgroundColor = [UIColor whiteColor];
[self.navigationController.navigationBar setTranslucent:NO]; [self.navigationController.navigationBar setTranslucent:NO];
self.title = NSLocalizedString(@"PROFILE_VIEW_TITLE", @"Title for the profile view."); self.title = NSLocalizedString(@"PROFILE_VIEW_TITLE", @"Title for the profile view.");
self.navigationItem.leftBarButtonItem =
[self createOWSBackButtonWithTarget:self selector:@selector(backButtonPressed:)];
// self.countryCodes = [PhoneNumberUtil countryCodesForSearchTerm:nil]; _avatarViewHelper = [AvatarViewHelper new];
_avatarViewHelper.delegate = self;
// self.navigationItem.leftBarButtonItem =
// [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
// target:self
// action:@selector(dismissWasPressed:)];
[self createViews]; [self createViews];
} }
@ -54,7 +52,6 @@ NS_ASSUME_NONNULL_BEGIN
{ {
_nameTextField = [UITextField new]; _nameTextField = [UITextField new];
_nameTextField.font = [UIFont ows_mediumFontWithSize:18.f]; _nameTextField.font = [UIFont ows_mediumFontWithSize:18.f];
// _nameTextField.textAlignment = _nameTextField.textAlignmentUnnatural;
_nameTextField.textColor = [UIColor ows_materialBlueColor]; _nameTextField.textColor = [UIColor ows_materialBlueColor];
// TODO: Copy. // TODO: Copy.
_nameTextField.placeholder = NSLocalizedString( _nameTextField.placeholder = NSLocalizedString(
@ -87,34 +84,26 @@ NS_ASSUME_NONNULL_BEGIN
OWSTableSection *avatarSection = [OWSTableSection new]; OWSTableSection *avatarSection = [OWSTableSection new];
avatarSection.headerTitle = NSLocalizedString( avatarSection.headerTitle = NSLocalizedString(
@"PROFILE_VIEW_AVATAR_SECTION_HEADER", @"Header title for the profile avatar field of the profile view."); @"PROFILE_VIEW_AVATAR_SECTION_HEADER", @"Header title for the profile avatar field of the profile view.");
const CGFloat kAvatarHeightPoints = 100.f; const CGFloat kAvatarSizePoints = 100.f;
const CGFloat kAvatarTopMargin = 10.f; const CGFloat kAvatarTopMargin = 10.f;
const CGFloat kAvatarBottomMargin = 10.f; const CGFloat kAvatarBottomMargin = 10.f;
const CGFloat kAvatarVSpacing = 10.f; const CGFloat kAvatarVSpacing = 10.f;
CGFloat avatarCellHeight = round( CGFloat avatarCellHeight
kAvatarHeightPoints + kAvatarTopMargin + kAvatarBottomMargin + kAvatarVSpacing + self.avatarLabel.height); = round(kAvatarSizePoints + kAvatarTopMargin + kAvatarBottomMargin + kAvatarVSpacing + self.avatarLabel.height);
// const CGFloat kCountryRowHeight = 50;
// const CGFloat kPhoneNumberRowHeight = 50;
// const CGFloat examplePhoneNumberRowHeight = self.examplePhoneNumberFont.lineHeight + 3.f;
// const CGFloat kButtonRowHeight = 60;
[avatarSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [avatarSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
// SelectRecipientViewController *strongSelf = weakSelf;
// OWSCAssert(strongSelf);
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [UITableViewCell new];
cell.preservesSuperviewLayoutMargins = YES; cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES; cell.contentView.preservesSuperviewLayoutMargins = YES;
// TODO: Use the current avatar. // TODO: Use the current avatar.
UIImage *defaultAvatarImage = [UIImage imageNamed:@"profile_avatar_default"];
OWSAssert(defaultAvatarImage.size.width == kAvatarHeightPoints);
OWSAssert(defaultAvatarImage.size.height == kAvatarHeightPoints);
AvatarImageView *avatarView = weakSelf.avatarView; AvatarImageView *avatarView = weakSelf.avatarView;
avatarView.image = defaultAvatarImage; [weakSelf updateAvatarView];
[cell.contentView addSubview:avatarView]; [cell.contentView addSubview:avatarView];
[avatarView autoHCenterInSuperview]; [avatarView autoHCenterInSuperview];
[avatarView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:kAvatarTopMargin]; [avatarView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:kAvatarTopMargin];
[avatarView autoSetDimension:ALDimensionWidth toSize:kAvatarSizePoints];
[avatarView autoSetDimension:ALDimensionHeight toSize:kAvatarSizePoints];
UILabel *avatarLabel = weakSelf.avatarLabel; UILabel *avatarLabel = weakSelf.avatarLabel;
[cell.contentView addSubview:avatarLabel]; [cell.contentView addSubview:avatarLabel];
@ -136,22 +125,16 @@ NS_ASSUME_NONNULL_BEGIN
OWSTableSection *nameSection = [OWSTableSection new]; OWSTableSection *nameSection = [OWSTableSection new];
nameSection.headerTitle = NSLocalizedString( nameSection.headerTitle = NSLocalizedString(
@"PROFILE_VIEW_NAME_SECTION_HEADER", @"Label for the profile name field of the profile view."); @"PROFILE_VIEW_NAME_SECTION_HEADER", @"Label for the profile name field of the profile view.");
// const CGFloat kCountryRowHeight = 50;
// const CGFloat kPhoneNumberRowHeight = 50;
// const CGFloat examplePhoneNumberRowHeight = self.examplePhoneNumberFont.lineHeight + 3.f;
// const CGFloat kButtonRowHeight = 60;
[nameSection [nameSection
addItem: addItem:
[OWSTableItem [OWSTableItem
itemWithCustomCellBlock:^{ itemWithCustomCellBlock:^{
// SelectRecipientViewController *strongSelf = weakSelf;
// OWSCAssert(strongSelf);
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [UITableViewCell new];
cell.preservesSuperviewLayoutMargins = YES; cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES; cell.contentView.preservesSuperviewLayoutMargins = YES;
UITextField *nameTextField = weakSelf.nameTextField; UITextField *nameTextField = weakSelf.nameTextField;
// TODO: Use the current profile name.
[cell.contentView addSubview:nameTextField]; [cell.contentView addSubview:nameTextField];
[nameTextField autoPinLeadingToSuperView]; [nameTextField autoPinLeadingToSuperView];
[nameTextField autoPinTrailingToSuperView]; [nameTextField autoPinTrailingToSuperView];
@ -160,41 +143,82 @@ NS_ASSUME_NONNULL_BEGIN
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell; return cell;
} }
// customRowHeight:kCountryRowHeight +
// kPhoneNumberRowHeight
// + examplePhoneNumberRowHeight
// + kButtonRowHeight
actionBlock:nil]]; actionBlock:nil]];
[contents addSection:nameSection]; [contents addSection:nameSection];
self.contents = contents; self.contents = contents;
} }
//- (void)countryCodeWasSelected:(NSString *)countryCode #pragma mark - Event Handling
//{
// OWSAssert(countryCode.length > 0); - (void)backButtonPressed:(id)sender
// {
// NSString *callingCodeSelected = [PhoneNumberUtil callingCodeFromCountryCode:countryCode]; [self.nameTextField resignFirstResponder];
// NSString *countryNameSelected = [PhoneNumberUtil countryNameFromCountryCode:countryCode];
// NSString *countryCodeSelected = countryCode; if (!self.hasUnsavedChanges) {
// [self.countryCodeDelegate ProfileViewController:self // If user made no changes, return to conversation settings view.
// didSelectCountryCode:countryCodeSelected [self.navigationController popViewControllerAnimated:YES];
// countryName:countryNameSelected return;
// callingCode:callingCodeSelected]; }
// [self.searchBar resignFirstResponder];
// [self dismissViewControllerAnimated:YES completion:nil]; UIAlertController *controller = [UIAlertController
//} alertControllerWithTitle:
// NSLocalizedString(@"NEW_GROUP_VIEW_UNSAVED_CHANGES_TITLE",
//- (void)dismissWasPressed:(id)sender { @"The alert title if user tries to exit the new group view without saving changes.")
// [self dismissViewControllerAnimated:YES completion:nil]; message:
//} NSLocalizedString(@"NEW_GROUP_VIEW_UNSAVED_CHANGES_MESSAGE",
@"The alert message if user tries to exit the new group view without saving changes.")
preferredStyle:UIAlertControllerStyleAlert];
[controller
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DISCARD_BUTTON",
@"The label for the 'discard' button in alerts and action sheets.")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
[self.navigationController popViewControllerAnimated:YES];
}]];
[controller addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", nil)
style:UIAlertActionStyleCancel
handler:nil]];
[self presentViewController:controller animated:YES completion:nil];
}
- (void)avatarTapped:(UIGestureRecognizer *)sender - (void)avatarTapped:(UIGestureRecognizer *)sender
{ {
if (sender.state == UIGestureRecognizerStateRecognized) { if (sender.state == UIGestureRecognizerStateRecognized) {
[self.avatarViewHelper showChangeAvatarUI];
} }
} }
- (void)setHasUnsavedChanges:(BOOL)hasUnsavedChanges
{
_hasUnsavedChanges = hasUnsavedChanges;
if (hasUnsavedChanges) {
self.navigationItem.rightBarButtonItem = (self.hasUnsavedChanges
? [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"EDIT_GROUP_UPDATE_BUTTON",
@"The title for the 'update group' button.")
style:UIBarButtonItemStylePlain
target:self
action:@selector(updatePressed)]
: nil);
}
}
- (void)updatePressed
{
[self updateProfile];
}
- (void)updateProfile
{
// OWSAssert(self.conversationSettingsViewDelegate);
//
// [self updateGroup];
//
// [self.conversationSettingsViewDelegate popAllConversationSettingsViews];
// [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - UITextFieldDelegate #pragma mark - UITextFieldDelegate
// TODO: This logic resides in both RegistrationViewController and here. // TODO: This logic resides in both RegistrationViewController and here.
@ -228,9 +252,44 @@ NS_ASSUME_NONNULL_BEGIN
- (void)textFieldDidChange:(id)sender - (void)textFieldDidChange:(id)sender
{ {
self.hasUnsavedChanges = YES;
// [self updatePhoneNumberButtonEnabling]; // [self updatePhoneNumberButtonEnabling];
} }
#pragma mark - Avatar
- (void)setAvatar:(nullable UIImage *)avatar
{
OWSAssert([NSThread isMainThread]);
_avatar = avatar;
self.hasUnsavedChanges = YES;
[self updateAvatarView];
}
- (void)updateAvatarView
{
self.avatarView.image = (self.avatar ?: [UIImage imageNamed:@"profile_avatar_default"]);
}
#pragma mark - AvatarViewHelperDelegate
- (void)avatarDidChange:(UIImage *)image
{
OWSAssert(image);
// TODO: Crop to square and possible resize.
self.avatar = image;
}
- (UIViewController *)fromViewController
{
return self;
}
#pragma mark - Logging #pragma mark - Logging
+ (NSString *)tag + (NSString *)tag

View File

@ -4,11 +4,11 @@
#import "UpdateGroupViewController.h" #import "UpdateGroupViewController.h"
#import "AddToGroupViewController.h" #import "AddToGroupViewController.h"
#import "AvatarViewHelper.h"
#import "BlockListUIUtils.h" #import "BlockListUIUtils.h"
#import "ContactTableViewCell.h" #import "ContactTableViewCell.h"
#import "ContactsViewHelper.h" #import "ContactsViewHelper.h"
#import "Environment.h" #import "Environment.h"
#import "GroupViewHelper.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSTableViewController.h" #import "OWSTableViewController.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
@ -30,14 +30,14 @@ NS_ASSUME_NONNULL_BEGIN
@interface UpdateGroupViewController () <UIImagePickerControllerDelegate, @interface UpdateGroupViewController () <UIImagePickerControllerDelegate,
UITextFieldDelegate, UITextFieldDelegate,
ContactsViewHelperDelegate, ContactsViewHelperDelegate,
GroupViewHelperDelegate, AvatarViewHelperDelegate,
AddToGroupViewControllerDelegate, AddToGroupViewControllerDelegate,
OWSTableViewControllerDelegate, OWSTableViewControllerDelegate,
UINavigationControllerDelegate> UINavigationControllerDelegate>
@property (nonatomic, readonly) OWSMessageSender *messageSender; @property (nonatomic, readonly) OWSMessageSender *messageSender;
@property (nonatomic, readonly) ContactsViewHelper *contactsViewHelper; @property (nonatomic, readonly) ContactsViewHelper *contactsViewHelper;
@property (nonatomic, readonly) GroupViewHelper *groupViewHelper; @property (nonatomic, readonly) AvatarViewHelper *avatarViewHelper;
@property (nonatomic, readonly) OWSTableViewController *tableViewController; @property (nonatomic, readonly) OWSTableViewController *tableViewController;
@property (nonatomic, readonly) AvatarImageView *avatarView; @property (nonatomic, readonly) AvatarImageView *avatarView;
@ -83,8 +83,8 @@ NS_ASSUME_NONNULL_BEGIN
{ {
_messageSender = [Environment getCurrent].messageSender; _messageSender = [Environment getCurrent].messageSender;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
_groupViewHelper = [GroupViewHelper new]; _avatarViewHelper = [AvatarViewHelper new];
_groupViewHelper.delegate = self; _avatarViewHelper.delegate = self;
self.memberRecipientIds = [NSMutableSet new]; self.memberRecipientIds = [NSMutableSet new];
} }
@ -158,7 +158,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.groupNameTextField becomeFirstResponder]; [self.groupNameTextField becomeFirstResponder];
break; break;
case UpdateGroupMode_EditGroupAvatar: case UpdateGroupMode_EditGroupAvatar:
[self showChangeGroupAvatarUI]; [self showChangeAvatarUI];
break; break;
default: default:
break; break;
@ -228,7 +228,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)avatarTouched:(UIGestureRecognizer *)sender - (void)avatarTouched:(UIGestureRecognizer *)sender
{ {
if (sender.state == UIGestureRecognizerStateRecognized) { if (sender.state == UIGestureRecognizerStateRecognized) {
[self showChangeGroupAvatarUI]; [self showChangeAvatarUI];
} }
} }
@ -384,11 +384,11 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Group Avatar #pragma mark - Group Avatar
- (void)showChangeGroupAvatarUI - (void)showChangeAvatarUI
{ {
[self.groupNameTextField resignFirstResponder]; [self.groupNameTextField resignFirstResponder];
[self.groupViewHelper showChangeGroupAvatarUI]; [self.avatarViewHelper showChangeAvatarUI];
} }
- (void)setGroupAvatar:(nullable UIImage *)groupAvatar - (void)setGroupAvatar:(nullable UIImage *)groupAvatar
@ -487,9 +487,9 @@ NS_ASSUME_NONNULL_BEGIN
return YES; return YES;
} }
#pragma mark - GroupViewHelperDelegate #pragma mark - AvatarViewHelperDelegate
- (void)groupAvatarDidChange:(UIImage *)image - (void)avatarDidChange:(UIImage *)image
{ {
OWSAssert(image); OWSAssert(image);