Let users edit group name and avatar by tapping on them in group settings view.
// FREEBIE
This commit is contained in:
parent
8e332395db
commit
9779527cf2
|
@ -1,9 +1,5 @@
|
|||
//
|
||||
// NewGroupViewController.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Dylan Bourgeois on 13/11/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
@ -17,12 +13,16 @@
|
|||
UITextFieldDelegate>
|
||||
|
||||
- (void)configWithThread:(TSGroupThread *)thread;
|
||||
@property (nonatomic, strong) IBOutlet UITableView *tableView;
|
||||
@property (nonatomic, strong) IBOutlet UITextField *nameGroupTextField;
|
||||
@property (nonatomic, strong) IBOutlet UIButton *groupImageButton;
|
||||
@property (nonatomic, strong) IBOutlet UIView *tapToDismissView;
|
||||
@property (nonatomic, strong) IBOutlet UILabel *addPeopleLabel;
|
||||
@property (nonatomic, strong) UIImage *groupImage;
|
||||
@property (nonatomic, strong) TSGroupModel *groupModel;
|
||||
|
||||
@property (nonatomic) IBOutlet UITableView *tableView;
|
||||
@property (nonatomic) IBOutlet UITextField *nameGroupTextField;
|
||||
@property (nonatomic) IBOutlet UIButton *groupImageButton;
|
||||
@property (nonatomic) IBOutlet UIView *tapToDismissView;
|
||||
@property (nonatomic) IBOutlet UILabel *addPeopleLabel;
|
||||
@property (nonatomic) UIImage *groupImage;
|
||||
@property (nonatomic) TSGroupModel *groupModel;
|
||||
|
||||
@property (nonatomic) BOOL shouldEditGroupNameOnAppear;
|
||||
@property (nonatomic) BOOL shouldEditAvatarOnAppear;
|
||||
|
||||
@end
|
||||
|
|
|
@ -244,6 +244,19 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
|
|||
_addPeopleLabel.text = NSLocalizedString(@"NEW_GROUP_REQUEST_ADDPEOPLE", @"");
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
if (self.shouldEditGroupNameOnAppear) {
|
||||
[self.nameGroupTextField becomeFirstResponder];
|
||||
} else if (self.shouldEditAvatarOnAppear) {
|
||||
[self addGroupPhoto:nil];
|
||||
}
|
||||
self.shouldEditGroupNameOnAppear = NO;
|
||||
self.shouldEditAvatarOnAppear = NO;
|
||||
}
|
||||
|
||||
#pragma mark - Initializers
|
||||
|
||||
- (void)initializeDelegates {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#import "Environment.h"
|
||||
#import "FingerprintViewController.h"
|
||||
#import "NewGroupViewController.h"
|
||||
#import "OWSAnyTouchGestureRecognizer.h"
|
||||
#import "OWSAvatarBuilder.h"
|
||||
#import "OWSBlockingManager.h"
|
||||
#import "OWSContactsManager.h"
|
||||
|
@ -42,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic, readonly) OWSMessageSender *messageSender;
|
||||
@property (nonatomic, readonly) OWSBlockingManager *blockingManager;
|
||||
|
||||
@property (nonatomic, readonly) UIImageView *avatarView;
|
||||
@property (nonatomic, readonly) UILabel *disappearingMessagesDurationLabel;
|
||||
|
||||
@end
|
||||
|
@ -500,6 +502,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
OWSAssert(avatar);
|
||||
const CGFloat kAvatarSize = 68.f;
|
||||
UIImageView *avatarView = [[UIImageView alloc] initWithImage:avatar];
|
||||
_avatarView = avatarView;
|
||||
avatarView.layer.borderColor = UIColor.clearColor.CGColor;
|
||||
avatarView.layer.masksToBounds = YES;
|
||||
avatarView.layer.cornerRadius = kAvatarSize / 2.0f;
|
||||
|
@ -543,9 +546,39 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[threadTitleLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom];
|
||||
}
|
||||
|
||||
[firstSectionHeader
|
||||
addGestureRecognizer:[[OWSAnyTouchGestureRecognizer alloc] initWithTarget:self
|
||||
action:@selector(conversationNameTouched:)]];
|
||||
firstSectionHeader.userInteractionEnabled = YES;
|
||||
for (UIView *subview in firstSectionHeader.subviews) {
|
||||
subview.userInteractionEnabled = NO;
|
||||
}
|
||||
|
||||
return firstSectionHeader;
|
||||
}
|
||||
|
||||
- (void)conversationNameTouched:(UIGestureRecognizer *)sender
|
||||
{
|
||||
if (sender.state == UIGestureRecognizerStateBegan || sender.state == UIGestureRecognizerStateRecognized) {
|
||||
if (self.isGroupThread) {
|
||||
NewGroupViewController *newGroupViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL]
|
||||
instantiateViewControllerWithIdentifier:@"NewGroupViewController"];
|
||||
[newGroupViewController configWithThread:(TSGroupThread *)self.thread];
|
||||
|
||||
CGPoint location = [sender locationInView:self.avatarView];
|
||||
if (CGRectContainsPoint(self.avatarView.bounds, location)) {
|
||||
newGroupViewController.shouldEditAvatarOnAppear = YES;
|
||||
} else {
|
||||
newGroupViewController.shouldEditGroupNameOnAppear = YES;
|
||||
}
|
||||
|
||||
[self.navigationController pushViewController:newGroupViewController animated:YES];
|
||||
} else {
|
||||
// TODO: Edit 1:1 contact.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (UIImageView *)viewForIconWithName:(NSString *)iconName
|
||||
{
|
||||
UIImage *icon = [UIImage imageNamed:iconName];
|
||||
|
|
|
@ -38,6 +38,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (UIView *)rootViewInViewHierarchy:(UIView *)view
|
||||
{
|
||||
OWSAssert(view);
|
||||
UIResponder *responder = view;
|
||||
UIView *lastView = nil;
|
||||
while (responder) {
|
||||
if ([responder isKindOfClass:[UIView class]]) {
|
||||
lastView = (UIView *)responder;
|
||||
}
|
||||
responder = [responder nextResponder];
|
||||
}
|
||||
return lastView;
|
||||
}
|
||||
|
||||
- (BOOL)isValidTouch:(NSSet<UITouch *> *)touches event:(UIEvent *)event
|
||||
{
|
||||
if (event.allTouches.count > 1) {
|
||||
|
@ -59,8 +73,10 @@
|
|||
|
||||
// Ignore touches that start near the top or bottom edge of the screen;
|
||||
// they may be a system edge swipe gesture.
|
||||
CGFloat distanceToTopEdge = MAX(0, location.y);
|
||||
CGFloat distanceToBottomEdge = MAX(0, self.view.bounds.size.height - location.y);
|
||||
UIView *rootView = [self rootViewInViewHierarchy:self.view];
|
||||
CGPoint rootLocation = [touch locationInView:rootView];
|
||||
CGFloat distanceToTopEdge = MAX(0, rootLocation.y);
|
||||
CGFloat distanceToBottomEdge = MAX(0, rootView.bounds.size.height - rootLocation.y);
|
||||
CGFloat distanceToNearestEdge = MIN(distanceToTopEdge, distanceToBottomEdge);
|
||||
CGFloat kSystemEdgeSwipeTolerance = 50.f;
|
||||
if (distanceToNearestEdge < kSystemEdgeSwipeTolerance) {
|
||||
|
|
Loading…
Reference in New Issue