mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-30 21:26:57 +02:00
Chat screen: Display network status, and handle unsent messages.
This commit is contained in:
@@ -20,16 +20,42 @@
|
||||
/**
|
||||
`RoomExtraInfosInfoView` instance is a view used to display extra information
|
||||
*/
|
||||
@interface RoomActivitiesView : MXKRoomActivitiesView
|
||||
@interface RoomActivitiesView : MXKRoomActivitiesView <UIGestureRecognizerDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView *separatorView;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *typingImageView;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *messageLabel;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mainHeightConstraint;
|
||||
|
||||
/**
|
||||
Notify that some messages are not sent.
|
||||
Replace the current notification if any.
|
||||
|
||||
@param labelText the notification message
|
||||
@param onLabelTapGesture block called when user taps on label.
|
||||
*/
|
||||
- (void)displayUnsentMessagesNotification:(NSAttributedString*)labelText onLabelTapGesture:(void (^)(void))onLabelTapGesture;
|
||||
|
||||
/**
|
||||
Display network error.
|
||||
Replace the current notification if any.
|
||||
|
||||
@param labelText the notification message
|
||||
*/
|
||||
- (void)displayNetworkErrorNotification:(NSString*)labelText;
|
||||
|
||||
/**
|
||||
Display a typing notification.
|
||||
Replace the current notification if any.
|
||||
|
||||
@param labelText the current typing message.
|
||||
*/
|
||||
- (void)displayTypingNotification:(NSString*)labelText;
|
||||
|
||||
/**
|
||||
Remove any displayed information.
|
||||
*/
|
||||
- (void)reset;
|
||||
|
||||
// update the displayed typing message.
|
||||
// nil message hides the typing icon too.
|
||||
- (void)updateTypingMessage:(NSString*)message;
|
||||
@end
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#import "VectorDesignValues.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@implementation RoomActivitiesView
|
||||
|
||||
+ (UINib *)nib
|
||||
@@ -37,27 +39,89 @@
|
||||
|
||||
self.separatorView.backgroundColor = kVectorColorLightGrey;
|
||||
self.messageLabel.textColor = kVectorTextColorGray;
|
||||
|
||||
// self.typingImageView.backgroundColor = kVectorColorGreen;
|
||||
// self.typingImageView.layer.cornerRadius = self.typingImageView.frame.size.height / 2;
|
||||
|
||||
}
|
||||
|
||||
// update the displayed typing message.
|
||||
// nil message hides the typing icon too.
|
||||
- (void)updateTypingMessage:(NSString*)message
|
||||
- (void)displayUnsentMessagesNotification:(NSAttributedString*)labelText onLabelTapGesture:(void (^)(void))onLabelTapGesture
|
||||
{
|
||||
if (message)
|
||||
[self reset];
|
||||
|
||||
if (labelText.length)
|
||||
{
|
||||
self.typingImageView.hidden = false;
|
||||
self.messageLabel.hidden = false;
|
||||
self.messageLabel.text = message;
|
||||
self.iconImageView.image = [UIImage imageNamed:@"error"];
|
||||
self.messageLabel.attributedText = labelText;
|
||||
self.messageLabel.textColor = kVectorTextColorRed;
|
||||
|
||||
self.iconImageView.hidden = NO;
|
||||
self.messageLabel.hidden = NO;
|
||||
|
||||
if (onLabelTapGesture)
|
||||
{
|
||||
objc_setAssociatedObject(self.messageLabel, "onLabelTapGesture", [onLabelTapGesture copy], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
|
||||
// Listen to label tap
|
||||
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onLabelTap:)];
|
||||
[tapGesture setNumberOfTouchesRequired:1];
|
||||
[tapGesture setNumberOfTapsRequired:1];
|
||||
[tapGesture setDelegate:self];
|
||||
[self.messageLabel addGestureRecognizer:tapGesture];
|
||||
self.messageLabel.userInteractionEnabled = YES;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
- (void)onLabelTap:(UITapGestureRecognizer*)sender
|
||||
{
|
||||
void (^onLabelTapGesture)(void) = objc_getAssociatedObject(self.messageLabel, "onLabelTapGesture");
|
||||
if (onLabelTapGesture)
|
||||
{
|
||||
self.typingImageView.hidden = true;
|
||||
self.messageLabel.hidden = true;
|
||||
onLabelTapGesture ();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)displayNetworkErrorNotification:(NSString*)labelText
|
||||
{
|
||||
[self reset];
|
||||
|
||||
if (labelText.length)
|
||||
{
|
||||
self.iconImageView.image = [UIImage imageNamed:@"error"];
|
||||
self.messageLabel.text = labelText;
|
||||
self.messageLabel.textColor = kVectorTextColorRed;
|
||||
|
||||
self.iconImageView.hidden = NO;
|
||||
self.messageLabel.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)displayTypingNotification:(NSString*)labelText
|
||||
{
|
||||
[self reset];
|
||||
|
||||
if (labelText.length)
|
||||
{
|
||||
self.iconImageView.image = [UIImage imageNamed:@"typing"];
|
||||
self.messageLabel.text = labelText;
|
||||
|
||||
self.iconImageView.hidden = NO;
|
||||
self.messageLabel.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reset
|
||||
{
|
||||
self.iconImageView.hidden = YES;
|
||||
self.messageLabel.hidden = YES;
|
||||
|
||||
self.messageLabel.textColor = kVectorTextColorGray;
|
||||
|
||||
// Remove all gesture recognizer
|
||||
while (self.messageLabel.gestureRecognizers.count)
|
||||
{
|
||||
[self.messageLabel removeGestureRecognizer:self.messageLabel.gestureRecognizers[0]];
|
||||
}
|
||||
self.messageLabel.userInteractionEnabled = NO;
|
||||
|
||||
objc_removeAssociatedObjects(self.messageLabel);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
@@ -63,10 +63,10 @@
|
||||
<nil key="simulatedBottomBarMetrics"/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<connections>
|
||||
<outlet property="iconImageView" destination="d6j-oN-9uA" id="Qhw-fw-uGc"/>
|
||||
<outlet property="mainHeightConstraint" destination="xPK-Yw-hQ9" id="dJ5-pI-KyT"/>
|
||||
<outlet property="messageLabel" destination="7bS-1u-GUX" id="5c1-hT-y49"/>
|
||||
<outlet property="separatorView" destination="1Mq-77-vvo" id="8fc-AO-8hF"/>
|
||||
<outlet property="typingImageView" destination="d6j-oN-9uA" id="kvp-J3-bVj"/>
|
||||
</connections>
|
||||
</view>
|
||||
</objects>
|
||||
|
||||
Reference in New Issue
Block a user