Composer update - UI enhancements

- composer max height
- unread messages on scroll to bottom button
- changed input toolbar background
- new missed discussions notifications
- Edit a message mode
- Reply to a message mode
- support for landscape mode
This commit is contained in:
Gil Eluard
2021-03-24 22:17:09 +01:00
parent f9e87b6a13
commit 6f94f9ea32
22 changed files with 346 additions and 31 deletions
@@ -59,6 +59,13 @@ typedef enum : NSUInteger
*/
- (void)roomInputToolbarViewDidTapMediaLibrary:(MXKRoomInputToolbarView*)toolbarView;
/**
Tells the delegate that the user wants to cancel the current edition / reply.
@param toolbarView the room input toolbar view
*/
- (void)roomInputToolbarViewDidTapCancel:(MXKRoomInputToolbarView*)toolbarView;
@end
/**
@@ -84,11 +91,21 @@ typedef enum : NSUInteger
@property (weak, nonatomic) IBOutlet UIImageView *inputTextBackgroundView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *inputContextViewHeightConstraint;
@property (weak, nonatomic) IBOutlet UIImageView *inputContextImageView;
@property (weak, nonatomic) IBOutlet UILabel *inputContextLabel;
@property (weak, nonatomic) IBOutlet UIButton *inputContextButton;
/**
Tell whether the filled data will be sent encrypted. NO by default.
*/
@property (nonatomic) BOOL isEncryptionEnabled;
/**
Sender of the event being edited / replied.
*/
@property (nonatomic, strong) NSString *eventSenderDisplayName;
/**
Destination of the message in the composer.
*/
@@ -27,6 +27,8 @@
#import "WidgetManager.h"
#import "IntegrationManagerViewController.h"
const double RoomInputToolbarViewContextBarHeight = 30;
@interface RoomInputToolbarView()
{
// The intermediate action sheet
@@ -61,7 +63,8 @@
[super awakeFromNib];
_sendMode = RoomInputToolbarViewSendModeSend;
self.inputContextViewHeightConstraint.constant = 0;
[self.rightInputToolbarButton setTitle:nil forState:UIControlStateNormal];
[self.rightInputToolbarButton setTitle:nil forState:UIControlStateHighlighted];
@@ -113,6 +116,10 @@
else if (@available(iOS 12.0, *) && ThemeService.shared.theme.userInterfaceStyle == UIUserInterfaceStyleDark) {
[self.attachMediaButton setImage:[UIImage imageNamed:@"upload_icon_dark"] forState:UIControlStateNormal];
}
self.inputContextImageView.tintColor = ThemeService.shared.theme.textSecondaryColor;
self.inputContextLabel.textColor = ThemeService.shared.theme.textSecondaryColor;
self.inputContextButton.tintColor = ThemeService.shared.theme.textSecondaryColor;
}
#pragma mark -
@@ -132,30 +139,77 @@
- (void)setSendMode:(RoomInputToolbarViewSendMode)sendMode
{
RoomInputToolbarViewSendMode previousMode = _sendMode;
_sendMode = sendMode;
[self updatePlaceholder];
[self updateToolbarButtonLabel];
[self updateToolbarButtonLabelWithPreviousMode: previousMode];
}
- (void)updateToolbarButtonLabel
- (void)updateToolbarButtonLabelWithPreviousMode:(RoomInputToolbarViewSendMode)previousMode
{
UIImage *buttonImage;
double updatedHeight = self.mainToolbarHeightConstraint.constant;
switch (_sendMode)
{
case RoomInputToolbarViewSendModeReply:
buttonImage = [UIImage imageNamed:@"send_icon"];
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;
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;
break;
default:
buttonImage = [UIImage imageNamed:@"send_icon"];
if (previousMode != _sendMode)
{
updatedHeight -= RoomInputToolbarViewContextBarHeight;
self->growingTextView.maxHeight += RoomInputToolbarViewContextBarHeight;
}
self.inputContextViewHeightConstraint.constant = 0;
break;
}
[self.rightInputToolbarButton setImage:buttonImage forState:UIControlStateNormal];
if (self.maxHeight && updatedHeight > self.maxHeight)
{
growingTextView.maxHeight -= updatedHeight - self.maxHeight;
updatedHeight = self.maxHeight;
}
if (updatedHeight < self.mainToolbarMinHeightConstraint.constant)
{
updatedHeight = self.mainToolbarMinHeightConstraint.constant;
}
if (self.mainToolbarHeightConstraint.constant != updatedHeight)
{
[UIView animateWithDuration:.3 animations:^{
self.mainToolbarHeightConstraint.constant = updatedHeight;
[self layoutIfNeeded];
// Update toolbar superview
if ([self.delegate respondsToSelector:@selector(roomInputToolbarView:heightDidChanged:completion:)])
{
[self.delegate roomInputToolbarView:self heightDidChanged:updatedHeight completion:nil];
}
}];
}
}
- (void)updatePlaceholder
@@ -213,6 +267,16 @@
self.placeholder = placeholder;
}
#pragma mark - Actions
- (IBAction)cancelAction:(id)sender
{
if ([self.delegate respondsToSelector:@selector(roomInputToolbarViewDidTapCancel:)])
{
[self.delegate roomInputToolbarViewDidTapCancel:self];
}
}
#pragma mark - HPGrowingTextView delegate
- (BOOL)growingTextView:(HPGrowingTextView *)growingTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
@@ -237,8 +301,14 @@
- (void)growingTextView:(HPGrowingTextView *)hpGrowingTextView willChangeHeight:(float)height
{
// Update height of the main toolbar (message composer)
CGFloat updatedHeight = height + (self.messageComposerContainerTopConstraint.constant + self.messageComposerContainerBottomConstraint.constant);
CGFloat updatedHeight = height + (self.messageComposerContainerTopConstraint.constant + self.messageComposerContainerBottomConstraint.constant) + self.inputContextViewHeightConstraint.constant;
if (self.maxHeight && updatedHeight > self.maxHeight)
{
hpGrowingTextView.maxHeight -= updatedHeight - self.maxHeight;
updatedHeight = self.maxHeight;
}
if (updatedHeight < self.mainToolbarMinHeightConstraint.constant)
{
updatedHeight = self.mainToolbarMinHeightConstraint.constant;
@@ -31,23 +31,62 @@
<rect key="frame" x="60" y="9" width="528" height="36"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="input_text_background" translatesAutoresizingMaskIntoConstraints="NO" id="uH7-Q7-hpZ">
<rect key="frame" x="0.0" y="0.0" width="528" height="38"/>
<rect key="frame" x="0.0" y="0.0" width="528" height="36"/>
</imageView>
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jXI-9E-Bgl">
<rect key="frame" x="0.0" y="0.0" width="528" height="32"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="input_edit_icon" translatesAutoresizingMaskIntoConstraints="NO" id="PZ4-0Y-TmL">
<rect key="frame" x="12" y="11" width="10.5" height="10"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dVr-ZM-kkX">
<rect key="frame" x="26.5" y="9" width="461.5" height="14.5"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="48y-kn-7b5">
<rect key="frame" x="492" y="1" width="30" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="I17-S0-9fp"/>
<constraint firstAttribute="width" constant="30" id="cCe-RB-ET2"/>
</constraints>
<state key="normal" image="input_close_icon"/>
<connections>
<action selector="cancelAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="Bdx-ld-cWP"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="KNn-ng-NHK"/>
<constraint firstItem="dVr-ZM-kkX" firstAttribute="leading" secondItem="PZ4-0Y-TmL" secondAttribute="trailing" constant="4" id="RbN-mc-y2P"/>
<constraint firstItem="48y-kn-7b5" firstAttribute="centerY" secondItem="jXI-9E-Bgl" secondAttribute="centerY" id="XbN-rm-nDw"/>
<constraint firstItem="48y-kn-7b5" firstAttribute="leading" secondItem="dVr-ZM-kkX" secondAttribute="trailing" constant="4" id="bmi-rg-TNM"/>
<constraint firstItem="PZ4-0Y-TmL" firstAttribute="centerY" secondItem="jXI-9E-Bgl" secondAttribute="centerY" id="f9O-vU-41g"/>
<constraint firstItem="PZ4-0Y-TmL" firstAttribute="leading" secondItem="jXI-9E-Bgl" secondAttribute="leading" constant="12" id="mp0-tl-IIe"/>
<constraint firstAttribute="trailing" secondItem="48y-kn-7b5" secondAttribute="trailing" constant="6" id="qPb-EI-csl"/>
<constraint firstItem="dVr-ZM-kkX" firstAttribute="centerY" secondItem="jXI-9E-Bgl" secondAttribute="centerY" id="yb4-bq-XNb"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wgb-ON-N29" customClass="KeyboardGrowingTextView">
<rect key="frame" x="4" y="1" width="520" height="36"/>
<rect key="frame" x="4" y="33" width="520" height="4"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="GrowingTextView"/>
</view>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="wgb-ON-N29" firstAttribute="top" secondItem="QWp-NV-uh5" secondAttribute="top" constant="1" id="0jt-Ye-2DW"/>
<constraint firstAttribute="trailing" secondItem="wgb-ON-N29" secondAttribute="trailing" constant="4" id="30f-rE-CKj"/>
<constraint firstAttribute="trailing" secondItem="jXI-9E-Bgl" secondAttribute="trailing" id="3EM-Mc-ZaI"/>
<constraint firstItem="jXI-9E-Bgl" firstAttribute="top" secondItem="QWp-NV-uh5" secondAttribute="top" id="Bp8-45-jvJ"/>
<constraint firstItem="uH7-Q7-hpZ" firstAttribute="leading" secondItem="QWp-NV-uh5" secondAttribute="leading" id="Fli-kz-OcS"/>
<constraint firstItem="uH7-Q7-hpZ" firstAttribute="top" secondItem="QWp-NV-uh5" secondAttribute="top" id="Gqc-ya-F1W"/>
<constraint firstItem="wgb-ON-N29" firstAttribute="leading" secondItem="QWp-NV-uh5" secondAttribute="leading" constant="4" id="N7q-ch-iRz"/>
<constraint firstItem="uH7-Q7-hpZ" firstAttribute="top" secondItem="wgb-ON-N29" secondAttribute="top" constant="-1" id="TH3-h8-9e9"/>
<constraint firstItem="wgb-ON-N29" firstAttribute="top" secondItem="jXI-9E-Bgl" secondAttribute="bottom" constant="1" id="UV2-Sh-peE"/>
<constraint firstAttribute="bottom" secondItem="uH7-Q7-hpZ" secondAttribute="bottom" id="dAX-uO-gvm"/>
<constraint firstAttribute="bottom" secondItem="wgb-ON-N29" secondAttribute="bottom" constant="-1" id="fFG-SH-Hjh"/>
<constraint firstItem="uH7-Q7-hpZ" firstAttribute="bottom" secondItem="wgb-ON-N29" secondAttribute="bottom" constant="1" id="mAh-nF-xXj"/>
<constraint firstItem="jXI-9E-Bgl" firstAttribute="leading" secondItem="QWp-NV-uh5" secondAttribute="leading" id="gfP-dn-HGK"/>
<constraint firstAttribute="trailing" secondItem="uH7-Q7-hpZ" secondAttribute="trailing" id="wS9-oU-alv"/>
</constraints>
</view>
@@ -88,6 +127,10 @@
<connections>
<outlet property="attachMediaButton" destination="Hga-l8-Wua" id="Osr-ek-c91"/>
<outlet property="growingTextView" destination="wgb-ON-N29" id="nwF-uV-Ng9"/>
<outlet property="inputContextButton" destination="48y-kn-7b5" id="yRn-1S-96w"/>
<outlet property="inputContextImageView" destination="PZ4-0Y-TmL" id="PMS-K7-aMr"/>
<outlet property="inputContextLabel" destination="dVr-ZM-kkX" id="ve6-gY-cV9"/>
<outlet property="inputContextViewHeightConstraint" destination="KNn-ng-NHK" id="B9M-tr-SOv"/>
<outlet property="inputTextBackgroundView" destination="uH7-Q7-hpZ" id="Wa3-2W-8gN"/>
<outlet property="mainToolbarHeightConstraint" destination="Yjj-ua-rbe" id="Lu8-UC-Vbo"/>
<outlet property="mainToolbarMinHeightConstraint" destination="1FO-iu-urG" id="2U6-h2-0zQ"/>
@@ -102,6 +145,8 @@
</view>
</objects>
<resources>
<image name="input_close_icon" width="12" height="12"/>
<image name="input_edit_icon" width="10.5" height="10"/>
<image name="input_text_background" width="30" height="20"/>
<image name="send_icon" width="36" height="36"/>
<image name="upload_icon" width="36" height="36"/>