mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-02 06:06:57 +02:00
Release 2.0.0
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
bundle:[NSBundle bundleForClass:[DisabledRoomInputToolbarView class]]];
|
||||
}
|
||||
|
||||
+ (instancetype)roomInputToolbarView
|
||||
+ (MXKRoomInputToolbarView *)instantiateRoomInputToolbarView
|
||||
{
|
||||
if ([[self class] nib])
|
||||
{
|
||||
|
||||
@@ -139,7 +139,7 @@ class RoomInputToolbarTextView: UITextView {
|
||||
}
|
||||
|
||||
private func updateUI() {
|
||||
var height = sizeThatFits(CGSize(width: bounds.size.width, height: CGFloat.greatestFiniteMagnitude)).height
|
||||
var height = contentSize.height
|
||||
height = minHeight > 0 ? max(height, minHeight) : height
|
||||
height = maxHeight > 0 ? min(height, maxHeight) : height
|
||||
|
||||
|
||||
@@ -33,6 +33,17 @@ typedef NS_ENUM(NSUInteger, RoomInputToolbarViewSendMode)
|
||||
};
|
||||
|
||||
|
||||
@protocol RoomInputToolbarViewProtocol
|
||||
|
||||
@property (nonatomic, strong) NSString *eventSenderDisplayName;
|
||||
@property (nonatomic, assign) RoomInputToolbarViewSendMode sendMode;
|
||||
@property (nonatomic, assign) BOOL isEncryptionEnabled;
|
||||
- (void)setVoiceMessageToolbarView:(UIView *)voiceMessageToolbarView;
|
||||
- (CGFloat)toolbarHeight;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@protocol RoomInputToolbarViewDelegate <MXKRoomInputToolbarViewDelegate>
|
||||
|
||||
/**
|
||||
@@ -40,7 +51,7 @@ typedef NS_ENUM(NSUInteger, RoomInputToolbarViewSendMode)
|
||||
|
||||
@param toolbarView the room input toolbar view
|
||||
*/
|
||||
- (void)roomInputToolbarViewDidTapCancel:(RoomInputToolbarView*)toolbarView;
|
||||
- (void)roomInputToolbarViewDidTapCancel:(MXKRoomInputToolbarView<RoomInputToolbarViewProtocol>*)toolbarView;
|
||||
|
||||
/**
|
||||
Inform the delegate that the text message has changed.
|
||||
@@ -70,7 +81,7 @@ typedef NS_ENUM(NSUInteger, RoomInputToolbarViewSendMode)
|
||||
`RoomInputToolbarView` instance is a view used to handle all kinds of available inputs
|
||||
for a room (message composer, attachments selection...).
|
||||
*/
|
||||
@interface RoomInputToolbarView : MXKRoomInputToolbarView
|
||||
@interface RoomInputToolbarView : MXKRoomInputToolbarView<RoomInputToolbarViewProtocol>
|
||||
|
||||
/**
|
||||
The delegate notified when inputs are ready.
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#import "ThemeService.h"
|
||||
#import "GeneratedInterface-Swift.h"
|
||||
#import "GBDeviceInfo_iOS.h"
|
||||
|
||||
static const CGFloat kContextBarHeight = 24;
|
||||
static const CGFloat kActionMenuAttachButtonSpringVelocity = 7;
|
||||
@@ -59,7 +58,7 @@ static const NSTimeInterval kActionMenuComposerHeightAnimationDuration = .3;
|
||||
@implementation RoomInputToolbarView
|
||||
@dynamic delegate;
|
||||
|
||||
+ (instancetype)roomInputToolbarView
|
||||
+ (MXKRoomInputToolbarView *)instantiateRoomInputToolbarView
|
||||
{
|
||||
UINib *nib = [UINib nibWithNibName:NSStringFromClass([RoomInputToolbarView class]) bundle:nil];
|
||||
return [nib instantiateWithOwner:nil options:nil].firstObject;
|
||||
@@ -85,25 +84,6 @@ static const NSTimeInterval kActionMenuComposerHeightAnimationDuration = .3;
|
||||
self.textView.inputAccessoryView = inputAccessoryViewForKeyboard;
|
||||
}
|
||||
|
||||
- (void)setVoiceMessageToolbarView:(UIView *)voiceMessageToolbarView
|
||||
{
|
||||
if (voiceMessageToolbarView) {
|
||||
_voiceMessageToolbarView = voiceMessageToolbarView;
|
||||
self.voiceMessageToolbarView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[self addSubview:self.voiceMessageToolbarView];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[[self.mainToolbarView.topAnchor constraintEqualToAnchor:self.voiceMessageToolbarView.topAnchor],
|
||||
[self.mainToolbarView.leftAnchor constraintEqualToAnchor:self.voiceMessageToolbarView.leftAnchor],
|
||||
[self.mainToolbarView.bottomAnchor constraintEqualToAnchor:self.voiceMessageToolbarView.bottomAnchor],
|
||||
[self.mainToolbarView.rightAnchor constraintEqualToAnchor:self.voiceMessageToolbarView.rightAnchor]]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self.voiceMessageToolbarView removeFromSuperview];
|
||||
_voiceMessageToolbarView = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Override MXKView
|
||||
|
||||
-(void)customizeViewRendering
|
||||
@@ -300,69 +280,6 @@ static const NSTimeInterval kActionMenuComposerHeightAnimationDuration = .3;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updatePlaceholder
|
||||
{
|
||||
// Consider the default placeholder
|
||||
|
||||
NSString *placeholder;
|
||||
|
||||
// Check the device screen size before using large placeholder
|
||||
BOOL shouldDisplayLargePlaceholder = [GBDeviceInfo deviceInfo].family == GBDeviceFamilyiPad || [GBDeviceInfo deviceInfo].displayInfo.display >= GBDeviceDisplay5p8Inch;
|
||||
|
||||
if (!shouldDisplayLargePlaceholder)
|
||||
{
|
||||
switch (_sendMode)
|
||||
{
|
||||
case RoomInputToolbarViewSendModeReply:
|
||||
placeholder = [VectorL10n roomMessageReplyToShortPlaceholder];
|
||||
break;
|
||||
|
||||
case RoomInputToolbarViewSendModeCreateDM:
|
||||
placeholder = [VectorL10n roomFirstMessagePlaceholder];
|
||||
break;
|
||||
|
||||
default:
|
||||
placeholder = [VectorL10n roomMessageShortPlaceholder];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_isEncryptionEnabled)
|
||||
{
|
||||
switch (_sendMode)
|
||||
{
|
||||
case RoomInputToolbarViewSendModeReply:
|
||||
placeholder = [VectorL10n encryptedRoomMessageReplyToPlaceholder];
|
||||
break;
|
||||
|
||||
default:
|
||||
placeholder = [VectorL10n encryptedRoomMessagePlaceholder];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (_sendMode)
|
||||
{
|
||||
case RoomInputToolbarViewSendModeReply:
|
||||
placeholder = [VectorL10n roomMessageReplyToPlaceholder];
|
||||
break;
|
||||
|
||||
case RoomInputToolbarViewSendModeCreateDM:
|
||||
placeholder = [VectorL10n roomFirstMessagePlaceholder];
|
||||
break;
|
||||
|
||||
default:
|
||||
placeholder = [VectorL10n roomMessagePlaceholder];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.placeholder = placeholder;
|
||||
}
|
||||
|
||||
- (void)setPlaceholder:(NSString *)inPlaceholder
|
||||
{
|
||||
[super setPlaceholder:inPlaceholder];
|
||||
@@ -543,4 +460,28 @@ static const NSTimeInterval kActionMenuComposerHeightAnimationDuration = .3;
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - RoomInputToolbarViewProtocol
|
||||
|
||||
- (CGFloat)toolbarHeight {
|
||||
return self.mainToolbarHeightConstraint.constant;
|
||||
}
|
||||
|
||||
- (void)setVoiceMessageToolbarView:(UIView *)voiceMessageToolbarView
|
||||
{
|
||||
if (voiceMessageToolbarView) {
|
||||
_voiceMessageToolbarView = voiceMessageToolbarView;
|
||||
self.voiceMessageToolbarView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[self addSubview:self.voiceMessageToolbarView];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[[self.mainToolbarView.topAnchor constraintEqualToAnchor:self.voiceMessageToolbarView.topAnchor],
|
||||
[self.mainToolbarView.leftAnchor constraintEqualToAnchor:self.voiceMessageToolbarView.leftAnchor],
|
||||
[self.mainToolbarView.bottomAnchor constraintEqualToAnchor:self.voiceMessageToolbarView.bottomAnchor],
|
||||
[self.mainToolbarView.rightAnchor constraintEqualToAnchor:self.voiceMessageToolbarView.rightAnchor]]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self.voiceMessageToolbarView removeFromSuperview];
|
||||
_voiceMessageToolbarView = nil;
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import GBDeviceInfo
|
||||
|
||||
extension RoomInputToolbarView {
|
||||
open override func sendCurrentMessage() {
|
||||
@@ -28,15 +29,66 @@ extension RoomInputToolbarView {
|
||||
self.becomeFirstResponder()
|
||||
temp.removeFromSuperview()
|
||||
}
|
||||
|
||||
|
||||
// Send message if any.
|
||||
if let messageToSend = self.attributedTextMessage, messageToSend.length > 0 {
|
||||
self.delegate.roomInputToolbarView(self, sendAttributedTextMessage: messageToSend)
|
||||
}
|
||||
|
||||
|
||||
// Reset message, disable view animation during the update to prevent placeholder distorsion.
|
||||
UIView.setAnimationsEnabled(false)
|
||||
self.attributedTextMessage = nil
|
||||
UIView.setAnimationsEnabled(true)
|
||||
}
|
||||
}
|
||||
|
||||
@objc extension RoomInputToolbarView {
|
||||
func updatePlaceholder() {
|
||||
updatePlaceholderText()
|
||||
}
|
||||
}
|
||||
|
||||
extension RoomInputToolbarViewProtocol where Self: MXKRoomInputToolbarView {
|
||||
func updatePlaceholderText() {
|
||||
// Consider the default placeholder
|
||||
|
||||
let placeholder: String
|
||||
|
||||
// Check the device screen size before using large placeholder
|
||||
let shouldDisplayLargePlaceholder = GBDeviceInfo.deviceInfo().family == .familyiPad || GBDeviceInfo.deviceInfo().displayInfo.display.rawValue >= GBDeviceDisplay.display5p8Inch.rawValue
|
||||
|
||||
if !shouldDisplayLargePlaceholder {
|
||||
switch sendMode {
|
||||
case .reply:
|
||||
placeholder = VectorL10n.roomMessageReplyToShortPlaceholder
|
||||
case .createDM:
|
||||
placeholder = VectorL10n.roomFirstMessagePlaceholder
|
||||
|
||||
default:
|
||||
placeholder = VectorL10n.roomMessageShortPlaceholder
|
||||
}
|
||||
} else {
|
||||
if isEncryptionEnabled {
|
||||
switch sendMode {
|
||||
case .reply:
|
||||
placeholder = VectorL10n.encryptedRoomMessageReplyToPlaceholder
|
||||
|
||||
default:
|
||||
placeholder = VectorL10n.encryptedRoomMessagePlaceholder
|
||||
}
|
||||
} else {
|
||||
switch sendMode {
|
||||
case .reply:
|
||||
placeholder = VectorL10n.roomMessageReplyToPlaceholder
|
||||
|
||||
case .createDM:
|
||||
placeholder = VectorL10n.roomFirstMessagePlaceholder
|
||||
default:
|
||||
placeholder = VectorL10n.roomMessagePlaceholder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.placeholder = placeholder
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -27,7 +27,7 @@
|
||||
<action selector="onTouchUpInside:" destination="iN0-l3-epB" eventType="touchUpInside" id="WbU-WH-gwL"/>
|
||||
</connections>
|
||||
</button>
|
||||
<scrollView hidden="YES" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ESv-9w-KJF" customClass="RoomActionsBar" customModule="Riot" customModuleProvider="target">
|
||||
<scrollView hidden="YES" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ESv-9w-KJF" customClass="RoomActionsBar" customModule="Element" customModuleProvider="target">
|
||||
<rect key="frame" x="60" y="8" width="540" height="38"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="38" id="i6C-gL-ADZ"/>
|
||||
@@ -41,7 +41,7 @@
|
||||
<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="484" height="36"/>
|
||||
</imageView>
|
||||
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jXI-9E-Bgl">
|
||||
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jXI-9E-Bgl" userLabel="Input Context View">
|
||||
<rect key="frame" x="0.0" y="0.0" width="484" height="32"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="input_edit_icon" translatesAutoresizingMaskIntoConstraints="NO" id="PZ4-0Y-TmL">
|
||||
@@ -69,7 +69,7 @@
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="dVr-ZM-kkX" secondAttribute="bottom" constant="4" id="58M-yd-hhK"/>
|
||||
<constraint firstItem="PZ4-0Y-TmL" firstAttribute="centerY" secondItem="dVr-ZM-kkX" secondAttribute="centerY" id="Bu1-sl-qDk"/>
|
||||
<constraint firstAttribute="height" constant="32" id="KNn-ng-NHK"/>
|
||||
<constraint firstAttribute="height" priority="750" 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="leading" secondItem="dVr-ZM-kkX" secondAttribute="trailing" constant="4" id="bmi-rg-TNM"/>
|
||||
<constraint firstItem="PZ4-0Y-TmL" firstAttribute="leading" secondItem="jXI-9E-Bgl" secondAttribute="leading" constant="8" id="mp0-tl-IIe"/>
|
||||
@@ -77,7 +77,7 @@
|
||||
<constraint firstItem="48y-kn-7b5" firstAttribute="centerY" secondItem="dVr-ZM-kkX" secondAttribute="centerY" id="z5v-Vy-6tc"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wgb-ON-N29" customClass="RoomInputToolbarTextView" customModule="Riot" customModuleProvider="target">
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wgb-ON-N29" customClass="RoomInputToolbarTextView" customModule="Element" customModuleProvider="target">
|
||||
<rect key="frame" x="5" y="33" width="474" 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"/>
|
||||
|
||||
Reference in New Issue
Block a user