Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Read receipts details #310

Merged
merged 13 commits into from Jun 30, 2017
Merged

Conversation

aramsargsyan
Copy link
Contributor

No description provided.

Copy link
Contributor

@morozkin morozkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback

@optional

- (void)didTapReceiptsContainerWithRestClient:(MXRestClient *)restClient RoomMembers:(NSArray *)roomMembers avatars:(NSArray *)avatars recieptDescriptions:(NSArray *)recieptDescriptions;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You used generic annotations for ReadReceiptsViewController and i think it's a good idea to add them for MXKRecieptSendersContainerDelegate . Also RoomMembers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About a protocol for a delegate, a good practice is to return the concerned instance as the first parameter:

  • (void)receiptSendersContainer:(MXKReceiptSendersContainer*)receiptSendersContainer...

then the delegate is able to use the instance's property (you don't have to pass them in parameters), like the REST client here.

BTW after reviewing your PRs, I regret to say that we will not be able to use a delegate at the MXKReceiptSendersContainer level. As we can see in the usage of this delegate in Riot ios (see RoomDataSource file) this is not easy to define the actual delegate. You decided to use [AppDelegate theDelegate].masterTabBarController.currentRoomViewController as delegate but nothing guarantee that the current data source is working for this view controller (there are several room view controller instances in the app, like the one used to display the context of a room message resulting of a search session...)

To sum up, you should remove the definition and the usage of this new delegate. I will expose to you an other solution based on the - (void)cell:(id)cell didRecognizeAction:(NSString*)actionIdentifier userInfo:(NSDictionary *)userInfo; defined in MXKCellRenderingDelegate protocol. Sorry to have missed that point before.


#import <UIKit/UIKit.h>
#import "MXKImageView.h"
#import "MXKTableViewCell.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MXKImageView can be forward declared

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with Denis (because of swift compiler), even if we don't really like forward declaration :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aramsargsyan: please apply the forward declaration suggested by morozkin.

{
[super awakeFromNib];
[self configureAvatarImageView];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put code from configureAvatarImageView right into awakeFromNib ? You know, it's just 3 lines of code

Copy link
Member

@giomfo giomfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented

  • Typo: please replace the wrong reciept prefix with receipt.

@@ -59,6 +70,16 @@ typedef NS_ENUM(NSInteger, ReadReceiptsAlignment)
@property (nonatomic) UILabel* moreLabel;

/**
The receipt descriptions to show in the details view controller.
*/
@property (nonatomic) NSArray <NSString *> *recieptDescriptions;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to store here the original array of read receipts (instead of the formatted dates). The receipt descriptions will be prepared only when the user decides to display the details.

Please replace this property with:
NSArray <MXReceiptData *> *readReceipt;

@interface MXKReceiptSendersContainer ()

@property (nonatomic) NSArray <MXRoomMember *> *roomMembers;
@property (nonatomic) NSArray <UIImage *> *placeholders;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should expose this 2 arrays in the header (in readonly mode). This will ease their use at the RR details screen level.

@@ -29,12 +38,35 @@ - (instancetype)initWithFrame:(CGRect)frame andRestClient:(MXRestClient*)restcli
_maxDisplayedAvatars = 3;
_avatarMargin = 2.0;
_moreLabel = nil;

[self addTapGestureRecognizer];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this tap gesture recogniser, the tap will be handled at the cell level


#import <UIKit/UIKit.h>
#import "MXKImageView.h"
#import "MXKTableViewCell.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with Denis (because of swift compiler), even if we don't really like forward declaration :(


- (void)configureAvatarImageView
{
self.avatarImageView.layer.cornerRadius = CGRectGetWidth(self.avatarImageView.frame)/2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to override - (void)layoutSubviews to set correctly the corner radius. Set this value during awakeFromNib may be too early.

Please use the following code:
`- (void)layoutSubviews
{
[super layoutSubviews];

if (self.avatarImageView)
{
    // Round image view
    [self.avatarImageView.layer setCornerRadius:self.pictureView.frame.size.width / 2];
    self.avatarImageView.clipsToBounds = YES;
}

}`

You should move self.avatarImageView.enableInMemoryCache = YES; in awakeFromNib

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please adjust the cell height by using for example 74 (instead of 180)?
For the design of this cell, you should copy the existing ContactTableViewCell.xib (riot-ios) by considering only the following items:thumbnailView, contactDisplayNameLabel and contactInformationLabel (Do not rename your properties, your naming is fine).
You could not define a specific label with a fix string like the "Read" label. We won't be able to translate it. You will have to use an attributed string for the receiptDescriptionLabel
(Note: remove the white space before ':': "Read: xxx").

/*
The MXSession used to format the events in the details view
*/
@property (nonatomic) MXSession *mxSession;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the matrix session here. The receipt description will be created in the RR details view controller.

aramsargsyan and others added 5 commits June 26, 2017 19:32
…ad, fixing the potential issue of sending the wrong Room controller.
…of the added subviews,

which have to be removed before reusing the cell.

element-hq/element-ios#59
Read Receipts Details - MXKRoomBubbleTableViewCell

#import <UIKit/UIKit.h>
#import "MXKImageView.h"
#import "MXKTableViewCell.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aramsargsyan: please apply the forward declaration suggested by morozkin.

self.avatarImageView.enableInMemoryCache = YES;
NSMutableAttributedString *readString = [[NSMutableAttributedString alloc] initWithAttributedString:self.readLabel.attributedText];
[readString setAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:15]} range:NSMakeRange(0, readString.length)];
self.readLabel.attributedText = readString;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I advised you to use an attributed string to display the receipt details in only one UILabel instance (instead of using 2 labels:readLabel and receiptDescriptionLabel).

If you decide to keep this label named readLabel for the constant prefix "Read:", you don't have to use attributed string. And you may define the text font in the xib file.
About the label text value, you have to add a new key-value in the MatrixKit.strings file to handle correctly the translation (for example "receipt_status_read" = "Read:";). Then you use the key to define the label text:
self.readLabel.text = [NSBundle mxk_localizedStringForKey:@"receipt_status_read"].

Personally I would prefer to remove the readLabel object. We should let the owner of the MXKReadReceiptTableViewCell instance set an attributed string in the receiptDescriptionLabel label to include the receipt status ("Read:" or something else). In that case the attributed string will be handled at the application level (in Riot-ios source code for example). CAUTION: the string translation will be handled at application level (see Vector.strings in Riot-ios ressources).

Copy link
Member

@giomfo giomfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some few remarks
Don't forget to sign off your PR ;)

@@ -270,6 +270,7 @@
"network_error_not_reachable" = "Please check your network connectivity";
"user_id_placeholder" = "ex: @bob:homeserver";
"ssl_homeserver_url" = "Home Server URL: %@";
"receipt_status_read" = "Read: ";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this key-value at the application level in Vector.strings
You may group it with read_receipts_list key.

self.avatarImageView.enableInMemoryCache = YES;
}

- (void)layoutSubviews {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a new line before starting a new block {}. Like you did for the other blocks

…level. Signed-off-by: Aram Sargsyan aram.sargsyan.1997@gmail.com
@giomfo giomfo merged commit 97e11d7 into matrix-org:develop Jun 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants