mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 00:02:47 +00:00
Merge pull request #236 from vector-im/improve_chat_header
Improve chat header
This commit is contained in:
commit
ba2c8ce02d
3 changed files with 30 additions and 68 deletions
|
@ -25,7 +25,6 @@
|
||||||
@interface RoomViewController : MXKRoomViewController <UISearchBarDelegate, UIGestureRecognizerDelegate, RoomTitleViewTapGestureDelegate>
|
@interface RoomViewController : MXKRoomViewController <UISearchBarDelegate, UIGestureRecognizerDelegate, RoomTitleViewTapGestureDelegate>
|
||||||
|
|
||||||
// The expanded header
|
// The expanded header
|
||||||
@property (weak, nonatomic) IBOutlet UIScrollView *expandedHeaderScrollView;
|
|
||||||
@property (weak, nonatomic) IBOutlet UIView *expandedHeaderContainer;
|
@property (weak, nonatomic) IBOutlet UIView *expandedHeaderContainer;
|
||||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *expandedHeaderContainerHeightConstraint;
|
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *expandedHeaderContainerHeightConstraint;
|
||||||
|
|
||||||
|
|
|
@ -71,9 +71,6 @@
|
||||||
// The preview header
|
// The preview header
|
||||||
PreviewRoomTitleView *previewHeader;
|
PreviewRoomTitleView *previewHeader;
|
||||||
|
|
||||||
// The content offset at the beginning of header scrolling
|
|
||||||
CGFloat beginDraggingHeaderContentOffset;
|
|
||||||
|
|
||||||
// The customized room data source for Vector
|
// The customized room data source for Vector
|
||||||
RoomDataSource *customizedRoomDataSource;
|
RoomDataSource *customizedRoomDataSource;
|
||||||
|
|
||||||
|
@ -210,6 +207,12 @@
|
||||||
|
|
||||||
[NSLayoutConstraint activateConstraints:@[leftConstraint, rightConstraint, topConstraint, bottomConstraint]];
|
[NSLayoutConstraint activateConstraints:@[leftConstraint, rightConstraint, topConstraint, bottomConstraint]];
|
||||||
|
|
||||||
|
|
||||||
|
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(onSwipeGesture:)];
|
||||||
|
[swipe setNumberOfTouchesRequired:1];
|
||||||
|
[swipe setDirection:UISwipeGestureRecognizerDirectionUp];
|
||||||
|
[self.expandedHeaderContainer addGestureRecognizer:swipe];
|
||||||
|
|
||||||
// Prepare preview header container
|
// Prepare preview header container
|
||||||
self.previewHeaderContainer.backgroundColor = kVectorColorLightGrey;
|
self.previewHeaderContainer.backgroundColor = kVectorColorLightGrey;
|
||||||
|
|
||||||
|
@ -345,7 +348,7 @@
|
||||||
contentInset.bottom = self.bottomLayoutGuide.length;
|
contentInset.bottom = self.bottomLayoutGuide.length;
|
||||||
self.bubblesTableView.contentInset = contentInset;
|
self.bubblesTableView.contentInset = contentInset;
|
||||||
|
|
||||||
if (self.expandedHeaderScrollView.isHidden == NO)
|
if (self.expandedHeaderContainer.isHidden == NO)
|
||||||
{
|
{
|
||||||
// Adjust the top constraint of the bubbles table
|
// Adjust the top constraint of the bubbles table
|
||||||
self.bubblesTableViewTopConstraint.constant = self.expandedHeaderContainerHeightConstraint.constant - self.bubblesTableView.contentInset.top;
|
self.bubblesTableViewTopConstraint.constant = self.expandedHeaderContainerHeightConstraint.constant - self.bubblesTableView.contentInset.top;
|
||||||
|
@ -621,6 +624,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)onSwipeGesture:(UISwipeGestureRecognizer*)swipeGestureRecognizer
|
||||||
|
{
|
||||||
|
UIView *view = swipeGestureRecognizer.view;
|
||||||
|
|
||||||
|
if (view == self.expandedHeaderContainer)
|
||||||
|
{
|
||||||
|
// Hide the expanded header when user swipes upward on expanded header.
|
||||||
|
// We reset here the property 'showExpandedHeader'. Then the header is not expanded automatically on viewWillAppear.
|
||||||
|
self.showExpandedHeader = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Hide/Show expanded header
|
#pragma mark - Hide/Show expanded header
|
||||||
|
|
||||||
- (void)showExpandedHeader:(BOOL)isVisible
|
- (void)showExpandedHeader:(BOOL)isVisible
|
||||||
|
@ -632,9 +647,9 @@
|
||||||
// - if the room data source does not manage a live timeline.
|
// - if the room data source does not manage a live timeline.
|
||||||
// - if the user's membership is not 'join'.
|
// - if the user's membership is not 'join'.
|
||||||
// - if the view controller is not embedded inside a split view controller yet.
|
// - if the view controller is not embedded inside a split view controller yet.
|
||||||
if (self.expandedHeaderScrollView.isHidden == isVisible && isSizeTransitionInProgress == NO && self.roomDataSource && self.roomDataSource.isLive && self.roomDataSource.room.state.membership == MXMembershipJoin && self.splitViewController)
|
if (self.expandedHeaderContainer.isHidden == isVisible && isSizeTransitionInProgress == NO && self.roomDataSource && self.roomDataSource.isLive && self.roomDataSource.room.state.membership == MXMembershipJoin && self.splitViewController)
|
||||||
{
|
{
|
||||||
self.expandedHeaderScrollView.hidden = !isVisible;
|
self.expandedHeaderContainer.hidden = !isVisible;
|
||||||
|
|
||||||
// Consider the main navigation controller if the current view controller is embedded inside a split view controller.
|
// Consider the main navigation controller if the current view controller is embedded inside a split view controller.
|
||||||
UINavigationController *mainNavigationController = self.navigationController;
|
UINavigationController *mainNavigationController = self.navigationController;
|
||||||
|
@ -1437,41 +1452,6 @@
|
||||||
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
|
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - UIScrollViewDelegate
|
|
||||||
|
|
||||||
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
|
|
||||||
{
|
|
||||||
if ([MXKRoomViewController instancesRespondToSelector:@selector(scrollViewWillBeginDragging:)])
|
|
||||||
{
|
|
||||||
[super scrollViewWillBeginDragging:scrollView];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scrollView == self.expandedHeaderScrollView)
|
|
||||||
{
|
|
||||||
// Store the current offset to detect scroll down
|
|
||||||
beginDraggingHeaderContentOffset = scrollView.contentOffset.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
|
|
||||||
{
|
|
||||||
if ([MXKRoomViewController instancesRespondToSelector:@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:)])
|
|
||||||
{
|
|
||||||
[super scrollViewWillEndDragging:scrollView withVelocity:velocity targetContentOffset:targetContentOffset];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scrollView == self.expandedHeaderScrollView)
|
|
||||||
{
|
|
||||||
// Hide the expanded header on scroll down.
|
|
||||||
if (beginDraggingHeaderContentOffset < scrollView.contentOffset.y)
|
|
||||||
{
|
|
||||||
// We reset here the property 'showExpandedHeader'. Then the header is not expanded automatically on viewWillAppear.
|
|
||||||
self.showExpandedHeader = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - MXKRoomTitleViewDelegate
|
#pragma mark - MXKRoomTitleViewDelegate
|
||||||
|
|
||||||
- (BOOL)roomTitleViewShouldBeginEditing:(MXKRoomTitleView*)titleView
|
- (BOOL)roomTitleViewShouldBeginEditing:(MXKRoomTitleView*)titleView
|
||||||
|
@ -1488,7 +1468,7 @@
|
||||||
|
|
||||||
if (view == titleView.titleMask)
|
if (view == titleView.titleMask)
|
||||||
{
|
{
|
||||||
if (self.expandedHeaderScrollView.isHidden)
|
if (self.expandedHeaderContainer.isHidden)
|
||||||
{
|
{
|
||||||
// Expand the header
|
// Expand the header
|
||||||
[self showExpandedHeader:YES];
|
[self showExpandedHeader:YES];
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
<outlet property="bubblesTableViewTopConstraint" destination="X14-4s-uGM" id="Hic-6h-N05"/>
|
<outlet property="bubblesTableViewTopConstraint" destination="X14-4s-uGM" id="Hic-6h-N05"/>
|
||||||
<outlet property="expandedHeaderContainer" destination="uK2-9a-rZj" id="0lY-NB-cR1"/>
|
<outlet property="expandedHeaderContainer" destination="uK2-9a-rZj" id="0lY-NB-cR1"/>
|
||||||
<outlet property="expandedHeaderContainerHeightConstraint" destination="w9z-HS-7wJ" id="6uK-Bn-TcU"/>
|
<outlet property="expandedHeaderContainerHeightConstraint" destination="w9z-HS-7wJ" id="6uK-Bn-TcU"/>
|
||||||
<outlet property="expandedHeaderScrollView" destination="IUM-JV-dby" id="Ncv-kA-ZBq"/>
|
|
||||||
<outlet property="previewHeaderContainer" destination="54r-18-K1g" id="Klt-RV-V1E"/>
|
<outlet property="previewHeaderContainer" destination="54r-18-K1g" id="Klt-RV-V1E"/>
|
||||||
<outlet property="previewHeaderContainerHeightConstraint" destination="goj-GZ-IkD" id="GbA-T9-kiL"/>
|
<outlet property="previewHeaderContainerHeightConstraint" destination="goj-GZ-IkD" id="GbA-T9-kiL"/>
|
||||||
<outlet property="roomActivitiesContainer" destination="XX4-n6-hCm" id="uD0-ab-8s8"/>
|
<outlet property="roomActivitiesContainer" destination="XX4-n6-hCm" id="uD0-ab-8s8"/>
|
||||||
|
@ -32,29 +31,13 @@
|
||||||
<rect key="frame" x="0.0" y="0.0" width="600" height="559"/>
|
<rect key="frame" x="0.0" y="0.0" width="600" height="559"/>
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||||
</tableView>
|
</tableView>
|
||||||
<scrollView hidden="YES" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IUM-JV-dby">
|
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uK2-9a-rZj" userLabel="Expanded Header Container" customClass="ExpandedRoomTitleView">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="600" height="239"/>
|
<rect key="frame" x="0.0" y="0.0" width="600" height="240"/>
|
||||||
<subviews>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uK2-9a-rZj" userLabel="Expanded Header Container" customClass="ExpandedRoomTitleView">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="600" height="240"/>
|
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
|
||||||
<constraints>
|
|
||||||
<constraint firstAttribute="height" constant="240" id="w9z-HS-7wJ"/>
|
|
||||||
</constraints>
|
|
||||||
</view>
|
|
||||||
</subviews>
|
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstItem="uK2-9a-rZj" firstAttribute="leading" secondItem="IUM-JV-dby" secondAttribute="leading" id="CG2-bd-fub"/>
|
<constraint firstAttribute="height" constant="240" id="w9z-HS-7wJ"/>
|
||||||
<constraint firstAttribute="height" constant="239" id="KfF-yg-HjH"/>
|
|
||||||
<constraint firstItem="uK2-9a-rZj" firstAttribute="centerX" secondItem="IUM-JV-dby" secondAttribute="centerX" id="VDg-jZ-ZBu"/>
|
|
||||||
<constraint firstAttribute="trailing" secondItem="uK2-9a-rZj" secondAttribute="trailing" id="W7t-FM-Ibo"/>
|
|
||||||
<constraint firstAttribute="bottom" secondItem="uK2-9a-rZj" secondAttribute="bottom" id="jTU-0Z-y2J"/>
|
|
||||||
<constraint firstItem="uK2-9a-rZj" firstAttribute="top" secondItem="IUM-JV-dby" secondAttribute="top" id="wgT-kJ-vKl"/>
|
|
||||||
</constraints>
|
</constraints>
|
||||||
<connections>
|
</view>
|
||||||
<outlet property="delegate" destination="-1" id="jPm-tb-GxK"/>
|
|
||||||
</connections>
|
|
||||||
</scrollView>
|
|
||||||
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="54r-18-K1g">
|
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="54r-18-K1g">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="600" height="368"/>
|
<rect key="frame" x="0.0" y="0.0" width="600" height="368"/>
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||||
|
@ -81,8 +64,7 @@
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="trailing" secondItem="BGD-sd-SQR" secondAttribute="trailing" id="0la-ok-MBr"/>
|
<constraint firstAttribute="trailing" secondItem="BGD-sd-SQR" secondAttribute="trailing" id="0la-ok-MBr"/>
|
||||||
<constraint firstItem="nLd-BP-JAE" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="4Q7-hr-rqi"/>
|
<constraint firstItem="nLd-BP-JAE" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="4Q7-hr-rqi"/>
|
||||||
<constraint firstItem="IUM-JV-dby" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="6xF-AH-Lzh"/>
|
<constraint firstAttribute="trailing" secondItem="uK2-9a-rZj" secondAttribute="trailing" id="HbF-85-ctI"/>
|
||||||
<constraint firstItem="IUM-JV-dby" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="I5M-01-LVc"/>
|
|
||||||
<constraint firstAttribute="bottom" secondItem="BGD-sd-SQR" secondAttribute="bottom" constant="41" id="Ksk-39-kfi"/>
|
<constraint firstAttribute="bottom" secondItem="BGD-sd-SQR" secondAttribute="bottom" constant="41" id="Ksk-39-kfi"/>
|
||||||
<constraint firstItem="54r-18-K1g" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="QGq-T0-Epo"/>
|
<constraint firstItem="54r-18-K1g" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="QGq-T0-Epo"/>
|
||||||
<constraint firstItem="XX4-n6-hCm" firstAttribute="bottom" secondItem="nLd-BP-JAE" secondAttribute="top" id="QO8-nF-xys"/>
|
<constraint firstItem="XX4-n6-hCm" firstAttribute="bottom" secondItem="nLd-BP-JAE" secondAttribute="top" id="QO8-nF-xys"/>
|
||||||
|
@ -93,8 +75,9 @@
|
||||||
<constraint firstItem="XX4-n6-hCm" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="csl-KT-4s9"/>
|
<constraint firstItem="XX4-n6-hCm" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="csl-KT-4s9"/>
|
||||||
<constraint firstItem="BGD-sd-SQR" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="haP-Kv-OLI"/>
|
<constraint firstItem="BGD-sd-SQR" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="haP-Kv-OLI"/>
|
||||||
<constraint firstAttribute="bottom" secondItem="nLd-BP-JAE" secondAttribute="bottom" id="kQ6-Cg-FMi"/>
|
<constraint firstAttribute="bottom" secondItem="nLd-BP-JAE" secondAttribute="bottom" id="kQ6-Cg-FMi"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="IUM-JV-dby" secondAttribute="trailing" id="mq8-kD-ZVW"/>
|
|
||||||
<constraint firstItem="54r-18-K1g" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="t02-d3-Zyf"/>
|
<constraint firstItem="54r-18-K1g" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="t02-d3-Zyf"/>
|
||||||
|
<constraint firstItem="uK2-9a-rZj" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="u8r-eN-1g8"/>
|
||||||
|
<constraint firstItem="uK2-9a-rZj" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="y6b-JK-CF5"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<nil key="simulatedStatusBarMetrics"/>
|
<nil key="simulatedStatusBarMetrics"/>
|
||||||
</view>
|
</view>
|
||||||
|
|
Loading…
Reference in a new issue