BF: Cannot join from a room preview for room with a long topic (#1645)

Update the room preview header height according to the screen height
This commit is contained in:
manuroe 2018-03-12 14:59:59 +01:00
parent c5aab876ad
commit 3df7e196eb

View file

@ -1605,7 +1605,33 @@
{
previewHeader.mainHeaderContainer.hidden = NO;
previewHeader.mainHeaderBackgroundHeightConstraint.constant = previewHeader.mainHeaderContainer.frame.size.height;
if ([previewHeader isKindOfClass:PreviewRoomTitleView.class])
{
// In case of preview, update the header height so that we can
// display as much as possible the room topic in this header.
// Note: the header height is the previewHeader.mainHeaderBackgroundHeightConstraint
// just computed
PreviewRoomTitleView *previewRoomTitleView = (PreviewRoomTitleView *)previewHeader;
// Compute the height required to display all the room topic
CGSize sizeThatFitsTextView = [previewRoomTitleView.roomTopic sizeThatFits:CGSizeMake(previewRoomTitleView.roomTopic.frame.size.width, MAXFLOAT)];
// Increase the preview header height according to the room topic height
// but limit it in order to let room for room messages at the screen bottom.
// This free space depends on the device.
// On an iphone 5 screen, the room topic height cannot be more than 50px.
// Then, on larger screen, we can allow it a bit more height but we
// apply a factor to give more priority to the display of more messages.
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
CGFloat maxRoomTopicHeight = 50 + (screenHeight - 568) / 3;
CGFloat additionalHeight = MIN(maxRoomTopicHeight, sizeThatFitsTextView.height)
- previewRoomTitleView.roomTopic.frame.size.height;
previewHeader.mainHeaderBackgroundHeightConstraint.constant += additionalHeight;
}
[self setRoomTitleViewClass:RoomAvatarTitleView.class];
// Note the avatar title view does not define tap gesture.