mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
MXKRoomBubbleTableViewCell: Add possiblity to choose between left or right display for timestamp.
This commit is contained in:
parent
bd4db16e65
commit
26f4aee144
2 changed files with 34 additions and 7 deletions
|
@ -67,6 +67,17 @@ extern NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePr
|
|||
*/
|
||||
- (void)addTimestampLabelForComponent:(NSUInteger)componentIndex;
|
||||
|
||||
/**
|
||||
Add timestamp label for a component in receiver.
|
||||
|
||||
Note: The label added here is automatically removed when [didEndDisplay] is called.
|
||||
|
||||
@param componentIndex index of the component in bubble message data
|
||||
@param displayOnLeft Indicate true to display label on left and false to display on right
|
||||
*/
|
||||
- (void)addTimestampLabelForComponent:(NSUInteger)componentIndex
|
||||
displayOnLeft:(BOOL)displayOnLeft;
|
||||
|
||||
/**
|
||||
Highlight a component in receiver.
|
||||
|
||||
|
|
|
@ -36,6 +36,29 @@ NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed =
|
|||
@implementation MXKRoomBubbleTableViewCell (Riot)
|
||||
|
||||
- (void)addTimestampLabelForComponent:(NSUInteger)componentIndex
|
||||
{
|
||||
BOOL isFirstDisplayedComponent = (componentIndex == 0);
|
||||
BOOL isLastMessageMostRecentComponent = NO;
|
||||
|
||||
RoomBubbleCellData *roomBubbleCellData;
|
||||
|
||||
if ([bubbleData isKindOfClass:RoomBubbleCellData.class])
|
||||
{
|
||||
roomBubbleCellData = (RoomBubbleCellData*)bubbleData;
|
||||
isFirstDisplayedComponent = (componentIndex == roomBubbleCellData.oldestComponentIndex);
|
||||
isLastMessageMostRecentComponent = roomBubbleCellData.containsLastMessage && (componentIndex == roomBubbleCellData.mostRecentComponentIndex);
|
||||
}
|
||||
|
||||
// Display timestamp on the left for selected component when it cannot overlap other UI elements like user's avatar
|
||||
BOOL displayLabelOnLeft = roomBubbleCellData.displayTimestampForSelectedComponentOnLeftWhenPossible
|
||||
&& !isLastMessageMostRecentComponent
|
||||
&& (!isFirstDisplayedComponent || roomBubbleCellData.shouldHideSenderInformation);
|
||||
|
||||
[self addTimestampLabelForComponent:componentIndex displayOnLeft:displayLabelOnLeft];
|
||||
}
|
||||
|
||||
- (void)addTimestampLabelForComponent:(NSUInteger)componentIndex
|
||||
displayOnLeft:(BOOL)displayLabelOnLeft
|
||||
{
|
||||
MXKRoomBubbleComponent *component;
|
||||
|
||||
|
@ -49,7 +72,6 @@ NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed =
|
|||
if (component && component.date)
|
||||
{
|
||||
BOOL isFirstDisplayedComponent = (componentIndex == 0);
|
||||
BOOL isLastMessageMostRecentComponent = NO;
|
||||
|
||||
RoomBubbleCellData *roomBubbleCellData;
|
||||
|
||||
|
@ -57,14 +79,8 @@ NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed =
|
|||
{
|
||||
roomBubbleCellData = (RoomBubbleCellData*)bubbleData;
|
||||
isFirstDisplayedComponent = (componentIndex == roomBubbleCellData.oldestComponentIndex);
|
||||
isLastMessageMostRecentComponent = roomBubbleCellData.containsLastMessage && (componentIndex == roomBubbleCellData.mostRecentComponentIndex);
|
||||
}
|
||||
|
||||
// Display timestamp on the left for selected component when it cannot overlap other UI elements like user's avatar
|
||||
BOOL displayLabelOnLeft = roomBubbleCellData.displayTimestampForSelectedComponentOnLeftWhenPossible
|
||||
&& !isLastMessageMostRecentComponent
|
||||
&& ( !isFirstDisplayedComponent || roomBubbleCellData.shouldHideSenderInformation);
|
||||
|
||||
[self addTimestampLabelForComponentIndex:componentIndex
|
||||
isFirstDisplayedComponent:isFirstDisplayedComponent
|
||||
viewTag:componentIndex
|
||||
|
|
Loading…
Reference in a new issue