mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Update after review
This commit is contained in:
parent
bae0292757
commit
a26a20685e
3 changed files with 65 additions and 76 deletions
|
@ -127,6 +127,7 @@
|
|||
#import "Riot-Swift.h"
|
||||
|
||||
NSNotificationName const RoomCallTileTappedNotification = @"RoomCallTileTappedNotification";
|
||||
const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
|
||||
@interface RoomViewController () <UISearchBarDelegate, UIGestureRecognizerDelegate, UIScrollViewAccessibilityDelegate, RoomTitleViewTapGestureDelegate, RoomParticipantsViewControllerDelegate, MXKRoomMemberDetailsViewControllerDelegate, ContactsTableViewControllerDelegate, MXServerNoticesDelegate, RoomContextualMenuViewControllerDelegate,
|
||||
ReactionsMenuViewModelCoordinatorDelegate, EditHistoryCoordinatorBridgePresenterDelegate, MXKDocumentPickerPresenterDelegate, EmojiPickerCoordinatorBridgePresenterDelegate,
|
||||
|
@ -286,7 +287,7 @@ NSNotificationName const RoomCallTileTappedNotification = @"RoomCallTileTappedNo
|
|||
{
|
||||
[super finalizeInit];
|
||||
|
||||
self.resizeComposerAnimationDuration = 0.05;
|
||||
self.resizeComposerAnimationDuration = kResizeComposerAnimationDuration;
|
||||
|
||||
// Setup `MXKViewControllerHandling` properties
|
||||
self.enableBarTintColorStatusChange = NO;
|
||||
|
@ -1707,47 +1708,35 @@ NSNotificationName const RoomCallTileTappedNotification = @"RoomCallTileTappedNo
|
|||
}
|
||||
|
||||
RoomInputToolbarView *roomInputView = ((RoomInputToolbarView *) self.inputToolbarView);
|
||||
__weak typeof(self) weakSelf = self;
|
||||
MXWeakify(self);
|
||||
roomInputView.actionsBar.actionItems = @[
|
||||
[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_camera"] andAction:^{
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) {
|
||||
((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO;
|
||||
}
|
||||
[self showCameraControllerAnimated:YES];
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) {
|
||||
((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO;
|
||||
}
|
||||
[self showCameraControllerAnimated:YES];
|
||||
}],
|
||||
[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_media_library"] andAction:^{
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) {
|
||||
((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO;
|
||||
}
|
||||
[self showMediaPickerAnimated:YES];
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) {
|
||||
((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO;
|
||||
}
|
||||
[self showMediaPickerAnimated:YES];
|
||||
}],
|
||||
[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_sticker"] andAction:^{
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) {
|
||||
((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO;
|
||||
}
|
||||
[self roomInputToolbarViewPresentStickerPicker];
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) {
|
||||
((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO;
|
||||
}
|
||||
[self roomInputToolbarViewPresentStickerPicker];
|
||||
}],
|
||||
[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_file"] andAction:^{
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) {
|
||||
((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO;
|
||||
}
|
||||
[self roomInputToolbarViewDidTapFileUpload];
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) {
|
||||
((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO;
|
||||
}
|
||||
[self roomInputToolbarViewDidTapFileUpload];
|
||||
}],
|
||||
];
|
||||
}
|
||||
|
@ -1776,8 +1765,8 @@ NSNotificationName const RoomCallTileTappedNotification = @"RoomCallTileTappedNo
|
|||
else
|
||||
{
|
||||
// The Sticker picker widget is not installed yet. Propose the user to install it
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
MXWeakify(self);
|
||||
|
||||
[currentAlert dismissViewControllerAnimated:NO completion:nil];
|
||||
|
||||
NSString *alertMessage = [NSString stringWithFormat:@"%@\n%@",
|
||||
|
@ -1791,11 +1780,8 @@ NSNotificationName const RoomCallTileTappedNotification = @"RoomCallTileTappedNo
|
|||
style:UIAlertActionStyleCancel
|
||||
handler:^(UIAlertAction * action)
|
||||
{
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
self->currentAlert = nil;
|
||||
}
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
self->currentAlert = nil;
|
||||
|
||||
}]];
|
||||
|
||||
|
@ -1803,20 +1789,17 @@ NSNotificationName const RoomCallTileTappedNotification = @"RoomCallTileTappedNo
|
|||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action)
|
||||
{
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
self->currentAlert = nil;
|
||||
|
||||
// Show the sticker picker settings screen
|
||||
IntegrationManagerViewController *modularVC = [[IntegrationManagerViewController alloc]
|
||||
initForMXSession:self.roomDataSource.mxSession
|
||||
inRoom:self.roomDataSource.roomId
|
||||
screen:[IntegrationManagerViewController screenForWidget:kWidgetTypeStickerPicker]
|
||||
widgetId:nil];
|
||||
|
||||
[self presentViewController:modularVC animated:NO completion:nil];
|
||||
}
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
self->currentAlert = nil;
|
||||
|
||||
// Show the sticker picker settings screen
|
||||
IntegrationManagerViewController *modularVC = [[IntegrationManagerViewController alloc]
|
||||
initForMXSession:self.roomDataSource.mxSession
|
||||
inRoom:self.roomDataSource.roomId
|
||||
screen:[IntegrationManagerViewController screenForWidget:kWidgetTypeStickerPicker]
|
||||
widgetId:nil];
|
||||
|
||||
[self presentViewController:modularVC animated:NO completion:nil];
|
||||
}]];
|
||||
|
||||
[currentAlert mxk_setAccessibilityIdentifier:@"RoomVCStickerPickerAlert"];
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import UIKit
|
||||
|
||||
@objcMembers
|
||||
class RoomActionsBar: UIScrollView {
|
||||
class RoomActionsBar: UIScrollView, Themable {
|
||||
// MARK: - Properties
|
||||
|
||||
var itemSpacing: CGFloat = 20 {
|
||||
|
@ -26,9 +26,9 @@ class RoomActionsBar: UIScrollView {
|
|||
}
|
||||
}
|
||||
|
||||
var actionItems: Array<RoomActionItem> = [] {
|
||||
var actionItems: [RoomActionItem] = [] {
|
||||
didSet {
|
||||
var actionButtons: Array<UIButton> = []
|
||||
var actionButtons: [UIButton] = []
|
||||
for (index, item) in actionItems.enumerated() {
|
||||
let button = UIButton(type: .custom)
|
||||
button.setImage(item.image, for: .normal)
|
||||
|
@ -44,7 +44,7 @@ class RoomActionsBar: UIScrollView {
|
|||
}
|
||||
}
|
||||
|
||||
private var actionButtons: Array<UIButton> = [] {
|
||||
private var actionButtons: [UIButton] = [] {
|
||||
willSet {
|
||||
for button in actionButtons {
|
||||
button.removeFromSuperview()
|
||||
|
@ -85,14 +85,16 @@ class RoomActionsBar: UIScrollView {
|
|||
self.contentSize = CGSize(width: currentX - itemSpacing, height: self.bounds.height)
|
||||
}
|
||||
|
||||
// MARK: - Business methods
|
||||
// MARK: - Themable
|
||||
|
||||
func customizeViewRendering() {
|
||||
func update(theme: Theme) {
|
||||
for button in actionButtons {
|
||||
button.tintColor = ThemeService.shared().theme.tintColor
|
||||
button.tintColor = theme.tintColor
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Business methods
|
||||
|
||||
func animate(showIn: Bool, completion: ((Bool) -> Void)? = nil) {
|
||||
if showIn {
|
||||
for button in actionButtons {
|
||||
|
|
|
@ -27,7 +27,13 @@
|
|||
#import "WidgetManager.h"
|
||||
#import "IntegrationManagerViewController.h"
|
||||
|
||||
const double RoomInputToolbarViewContextBarHeight = 24;
|
||||
const double kContextBarHeight = 24;
|
||||
const NSTimeInterval kSendModeAnimationDuration = .15;
|
||||
const NSTimeInterval kActionMenuAttachButtonAnimationDuration = .4;
|
||||
const CGFloat kActionMenuAttachButtonSpringVelocity = 7;
|
||||
const CGFloat kActionMenuAttachButtonSpringDamping = .45;
|
||||
const NSTimeInterval kActionMenuContentAlphaAnimationDuration = .2;
|
||||
const NSTimeInterval kActionMenuComposerHeightAnimationDuration = .3;
|
||||
|
||||
@interface RoomInputToolbarView()
|
||||
{
|
||||
|
@ -120,7 +126,7 @@ const double RoomInputToolbarViewContextBarHeight = 24;
|
|||
self.inputContextImageView.tintColor = ThemeService.shared.theme.textSecondaryColor;
|
||||
self.inputContextLabel.textColor = ThemeService.shared.theme.textSecondaryColor;
|
||||
self.inputContextButton.tintColor = ThemeService.shared.theme.textSecondaryColor;
|
||||
[self.actionsBar customizeViewRendering];
|
||||
[self.actionsBar updateWithTheme:ThemeService.shared.theme];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
@ -161,26 +167,26 @@ const double RoomInputToolbarViewContextBarHeight = 24;
|
|||
self.inputContextImageView.image = [UIImage imageNamed:@"input_reply_icon"];
|
||||
self.inputContextLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_message_replying_to", @"Vector", nil), self.eventSenderDisplayName];
|
||||
|
||||
self.inputContextViewHeightConstraint.constant = RoomInputToolbarViewContextBarHeight;
|
||||
updatedHeight += RoomInputToolbarViewContextBarHeight;
|
||||
self->growingTextView.maxHeight -= RoomInputToolbarViewContextBarHeight;
|
||||
self.inputContextViewHeightConstraint.constant = kContextBarHeight;
|
||||
updatedHeight += kContextBarHeight;
|
||||
self->growingTextView.maxHeight -= kContextBarHeight;
|
||||
break;
|
||||
case RoomInputToolbarViewSendModeEdit:
|
||||
buttonImage = [UIImage imageNamed:@"save_icon"];
|
||||
self.inputContextImageView.image = [UIImage imageNamed:@"input_edit_icon"];
|
||||
self.inputContextLabel.text = NSLocalizedStringFromTable(@"room_message_editing", @"Vector", nil);
|
||||
|
||||
self.inputContextViewHeightConstraint.constant = RoomInputToolbarViewContextBarHeight;
|
||||
updatedHeight += RoomInputToolbarViewContextBarHeight;
|
||||
self->growingTextView.maxHeight -= RoomInputToolbarViewContextBarHeight;
|
||||
self.inputContextViewHeightConstraint.constant = kContextBarHeight;
|
||||
updatedHeight += kContextBarHeight;
|
||||
self->growingTextView.maxHeight -= kContextBarHeight;
|
||||
break;
|
||||
default:
|
||||
buttonImage = [UIImage imageNamed:@"send_icon"];
|
||||
|
||||
if (previousMode != _sendMode)
|
||||
{
|
||||
updatedHeight -= RoomInputToolbarViewContextBarHeight;
|
||||
self->growingTextView.maxHeight += RoomInputToolbarViewContextBarHeight;
|
||||
updatedHeight -= kContextBarHeight;
|
||||
self->growingTextView.maxHeight += kContextBarHeight;
|
||||
}
|
||||
self.inputContextViewHeightConstraint.constant = 0;
|
||||
break;
|
||||
|
@ -201,7 +207,7 @@ const double RoomInputToolbarViewContextBarHeight = 24;
|
|||
|
||||
if (self.mainToolbarHeightConstraint.constant != updatedHeight)
|
||||
{
|
||||
[UIView animateWithDuration:.15 animations:^{
|
||||
[UIView animateWithDuration:kSendModeAnimationDuration animations:^{
|
||||
self.mainToolbarHeightConstraint.constant = updatedHeight;
|
||||
[self layoutIfNeeded];
|
||||
|
||||
|
@ -393,18 +399,16 @@ const double RoomInputToolbarViewContextBarHeight = 24;
|
|||
}];
|
||||
}
|
||||
|
||||
[UIView animateWithDuration:.4 delay:0 usingSpringWithDamping:0.45 initialSpringVelocity:7 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
||||
[UIView animateWithDuration:kActionMenuAttachButtonAnimationDuration delay:0 usingSpringWithDamping:kActionMenuAttachButtonSpringDamping initialSpringVelocity:kActionMenuAttachButtonSpringVelocity options:UIViewAnimationOptionCurveEaseIn animations:^{
|
||||
self.attachMediaButton.transform = actionMenuOpened ? CGAffineTransformMakeRotation(M_PI * 3 / 4) : CGAffineTransformIdentity;
|
||||
} completion:^(BOOL finished) {
|
||||
}];
|
||||
} completion:nil];
|
||||
|
||||
[UIView animateWithDuration:.2 delay:_actionMenuOpened ? 0 : .1 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
||||
[UIView animateWithDuration:kActionMenuContentAlphaAnimationDuration delay:_actionMenuOpened ? 0 : .1 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
||||
self->messageComposerContainer.alpha = actionMenuOpened ? 0 : 1;
|
||||
self.rightInputToolbarButton.alpha = self->growingTextView.text.length == 0 || actionMenuOpened ? 0 : 1;
|
||||
} completion:^(BOOL finished) {
|
||||
}];
|
||||
} completion:nil];
|
||||
|
||||
[UIView animateWithDuration:.3 animations:^{
|
||||
[UIView animateWithDuration:kActionMenuComposerHeightAnimationDuration animations:^{
|
||||
if (actionMenuOpened)
|
||||
{
|
||||
self.mainToolbarHeightConstraint.constant = self.mainToolbarMinHeightConstraint.constant;
|
||||
|
|
Loading…
Reference in a new issue