mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 18:12:44 +02:00
Prepare UX rework
- Bug Fix: the sticky headers display failed on screen rotation.
This commit is contained in:
@@ -271,6 +271,8 @@
|
||||
frame.size.height -= self.bottomLayoutGuide.length;
|
||||
tableViewMaskLayer.frame = frame;
|
||||
}
|
||||
|
||||
[self refreshStickyHeadersContainersHeight];
|
||||
}
|
||||
|
||||
#pragma mark - Override MXKRecentListViewController
|
||||
@@ -509,22 +511,48 @@
|
||||
{
|
||||
if (_enableStickyHeaders)
|
||||
{
|
||||
UIView *firstDisplayedSectionHeader = displayedSectionHeaders.firstObject;
|
||||
// Retrieve the first and the last headers actually visible in the recents table view.
|
||||
// Caution: In some cases like the screen rotation, some displayed section headers are temporarily not visible.
|
||||
UIView *firstDisplayedSectionHeader, *lastDisplayedSectionHeader;
|
||||
CGFloat containerHeight;
|
||||
CGFloat maxVisiblePosY = self.recentsTableView.contentOffset.y + (self.recentsTableView.frame.size.height - self.recentsTableView.contentInset.bottom);
|
||||
|
||||
for (UIView *header in displayedSectionHeaders)
|
||||
{
|
||||
if (!firstDisplayedSectionHeader)
|
||||
{
|
||||
if (header.frame.origin.y + header.frame.size.height > self.recentsTableView.contentOffset.y)
|
||||
{
|
||||
firstDisplayedSectionHeader = lastDisplayedSectionHeader = header;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (header.frame.origin.y < maxVisiblePosY)
|
||||
{
|
||||
lastDisplayedSectionHeader = header;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (firstDisplayedSectionHeader)
|
||||
{
|
||||
// Check whether the header positon is not floating
|
||||
// Consider the first visible section header to update the height of the top container of the sticky headers.
|
||||
// Check whether the header positon is not floating.
|
||||
if (firstDisplayedSectionHeader.frame.origin.y == firstDisplayedSectionHeaderPosY)
|
||||
{
|
||||
// Compute the height of the hidden part
|
||||
// Compute the height of the hidden part.
|
||||
CGFloat delta = self.recentsTableView.contentOffset.y - firstDisplayedSectionHeader.frame.origin.y;
|
||||
if (delta < 0)
|
||||
{
|
||||
delta = 0;
|
||||
}
|
||||
|
||||
// Update the layout of the top container of the sticky headers.
|
||||
// Compute the top container height.
|
||||
containerHeight = 0;
|
||||
for (UIView *header in _stickyHeadersTopContainer.subviews)
|
||||
{
|
||||
@@ -566,15 +594,11 @@
|
||||
|
||||
self.stickyHeadersTopContainerHeightConstraint.constant = containerHeight;
|
||||
}
|
||||
}
|
||||
|
||||
UIView *lastDisplayedSectionHeader = displayedSectionHeaders.lastObject;
|
||||
if (lastDisplayedSectionHeader)
|
||||
{
|
||||
// Update the layout of the bottom container of the sticky headers.
|
||||
|
||||
// Consider the last visible section header to update the height of the bottom container of the sticky headers.
|
||||
containerHeight = 0;
|
||||
CGRect bounds = self.stickyHeadersBottomContainer.frame;
|
||||
CGFloat maxVisiblePosY = self.recentsTableView.contentOffset.y + (self.recentsTableView.frame.size.height - self.recentsTableView.contentInset.bottom);
|
||||
|
||||
for (UIView *header in _stickyHeadersBottomContainer.subviews)
|
||||
{
|
||||
if (header.tag == lastDisplayedSectionHeader.tag)
|
||||
@@ -609,11 +633,10 @@
|
||||
self.stickyHeadersBottomContainer.bounds = bounds;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle here the case where no header is currently displayed.
|
||||
if (!firstDisplayedSectionHeader)
|
||||
else
|
||||
{
|
||||
// No section header is displayed in the table, no more than one section is displayed.
|
||||
// Handle here the case where no section header is currently displayed in the table.
|
||||
// No more than one section is then displayed, we retrieve this section by checking the first visible cell.
|
||||
NSIndexPath *firstCellIndexPath = [self.recentsTableView indexPathForRowAtPoint:CGPointMake(0, self.recentsTableView.contentOffset.y)];
|
||||
if (firstCellIndexPath)
|
||||
{
|
||||
@@ -1103,13 +1126,21 @@
|
||||
// Update first displayed section position
|
||||
firstDisplayedSectionHeader = displayedSectionHeaders.firstObject;
|
||||
firstDisplayedSectionHeaderPosY = firstDisplayedSectionHeader.frame.origin.y;
|
||||
|
||||
[self refreshStickyHeadersContainersHeight];
|
||||
}
|
||||
else
|
||||
{
|
||||
[displayedSectionHeaders removeLastObject];
|
||||
// This section header is the last displayed one.
|
||||
// Add a sanity check in case of the header has been already removed.
|
||||
UIView *lastDisplayedSectionHeader = displayedSectionHeaders.lastObject;
|
||||
if (section == lastDisplayedSectionHeader.tag)
|
||||
{
|
||||
[displayedSectionHeaders removeLastObject];
|
||||
|
||||
[self refreshStickyHeadersContainersHeight];
|
||||
}
|
||||
}
|
||||
|
||||
[self refreshStickyHeadersContainersHeight];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user