Merge branch 'ismail/5068_design_tweaks' into ismail/5096_thread_notifications

This commit is contained in:
ismailgulek
2022-01-19 00:12:40 +03:00
102 changed files with 1607 additions and 771 deletions
@@ -279,6 +279,10 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
if (self.tag == RoomBubbleCellDataTagPoll)
{
if (self.events.lastObject.isEditEvent) {
return YES;
}
return NO;
}
@@ -297,6 +301,12 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
// do not consider this cell data if threads not enabled in the timeline
return NO;
}
if (roomDataSource.threadId)
{
// do not consider this cell data if in a thread view
return NO;
}
return super.hasThreadRoot;
}
@@ -573,6 +583,8 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
additionalVerticalHeight+= [self reactionHeightForEventId:eventId];
// Add vertical whitespace in case of a thread root
additionalVerticalHeight+= [self threadSummaryViewHeightForEventId:eventId];
// Add vertical whitespace in case of from a thread
additionalVerticalHeight+= [self fromThreadViewHeightForEventId:eventId];
// Add vertical whitespace in case of read receipts.
additionalVerticalHeight+= [self readReceiptHeightForEventId:eventId];
@@ -593,6 +605,7 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
height+= [self urlPreviewHeightForEventId:eventId];
height+= [self reactionHeightForEventId:eventId];
height+= [self threadSummaryViewHeightForEventId:eventId];
height+= [self fromThreadViewHeightForEventId:eventId];
height+= [self readReceiptHeightForEventId:eventId];
}
@@ -654,7 +667,35 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
// component is not a thread root
return 0;
}
return RoomBubbleCellLayout.threadSummaryViewTopMargin + [ThreadSummaryView contentViewHeightForThread:component.thread fitting:self.maxTextViewWidth];
return RoomBubbleCellLayout.threadSummaryViewTopMargin +
[ThreadSummaryView contentViewHeightForThread:component.thread fitting:self.maxTextViewWidth];
}
- (CGFloat)fromThreadViewHeightForEventId:(NSString*)eventId
{
if (!RiotSettings.shared.enableThreads)
{
// do not show from thread view if threads not enabled
return 0;
}
if (roomDataSource.threadId)
{
// do not show from thread view on threads
return 0;
}
NSInteger index = [self bubbleComponentIndexForEventId:eventId];
if (index == NSNotFound)
{
return 0;
}
MXKRoomBubbleComponent *component = self.bubbleComponents[index];
if (!component.event.isInThread)
{
// event is not in a thread
return 0;
}
return RoomBubbleCellLayout.fromThreadViewTopMargin +
[FromThreadView contentViewHeightForEvent:component.event fitting:self.maxTextViewWidth];
}
- (CGFloat)urlPreviewHeightForEventId:(NSString*)eventId
+41 -31
View File
@@ -527,45 +527,55 @@ const CGFloat kTypingCellHeight = 24;
{
threadSummaryView = [[ThreadSummaryView alloc] initWithThread:component.thread];
threadSummaryView.delegate = self;
[temporaryViews addObject:threadSummaryView];
[bubbleCell.tmpSubviews addObject:threadSummaryView];
threadSummaryView.translatesAutoresizingMaskIntoConstraints = NO;
[bubbleCell.contentView addSubview:threadSummaryView];
CGFloat leftMargin = RoomBubbleCellLayout.reactionsViewLeftMargin;
if (roomBubbleCellData.containsBubbleComponentWithEncryptionBadge)
if ([[bubbleCell class] conformsToProtocol:@protocol(BubbleCellThreadSummaryDisplayable)])
{
leftMargin+= RoomBubbleCellLayout.encryptedContentLeftMargin;
}
// The top constraint may need to include the URL preview view or reactions view
NSLayoutConstraint *topConstraint;
if (reactionsView)
{
topConstraint = [threadSummaryView.topAnchor constraintEqualToAnchor:reactionsView.bottomAnchor
constant:RoomBubbleCellLayout.threadSummaryViewTopMargin];
}
else if (urlPreviewView)
{
topConstraint = [threadSummaryView.topAnchor constraintEqualToAnchor:urlPreviewView.bottomAnchor
constant:RoomBubbleCellLayout.threadSummaryViewTopMargin];
id<BubbleCellThreadSummaryDisplayable> threadSummaryDisplayable = (id<BubbleCellThreadSummaryDisplayable>)bubbleCell;
[threadSummaryDisplayable addThreadSummaryView:threadSummaryView];
}
else
{
topConstraint = [threadSummaryView.topAnchor constraintEqualToAnchor:threadSummaryView.superview.topAnchor
constant:bottomPositionY + RoomBubbleCellLayout.threadSummaryViewTopMargin];
[bubbleCell.contentView addSubview:threadSummaryView];
CGFloat leftMargin = RoomBubbleCellLayout.reactionsViewLeftMargin;
if (roomBubbleCellData.containsBubbleComponentWithEncryptionBadge)
{
leftMargin+= RoomBubbleCellLayout.encryptedContentLeftMargin;
}
// The top constraint may need to include the URL preview view or reactions view
NSLayoutConstraint *topConstraint;
if (reactionsView)
{
topConstraint = [threadSummaryView.topAnchor constraintEqualToAnchor:reactionsView.bottomAnchor
constant:RoomBubbleCellLayout.threadSummaryViewTopMargin];
}
else if (urlPreviewView)
{
topConstraint = [threadSummaryView.topAnchor constraintEqualToAnchor:urlPreviewView.bottomAnchor
constant:RoomBubbleCellLayout.threadSummaryViewTopMargin];
}
else
{
topConstraint = [threadSummaryView.topAnchor constraintEqualToAnchor:threadSummaryView.superview.topAnchor
constant:bottomPositionY + RoomBubbleCellLayout.threadSummaryViewTopMargin];
}
// Set constraints for the summary view
[NSLayoutConstraint activateConstraints: @[
[threadSummaryView.leadingAnchor constraintEqualToAnchor:threadSummaryView.superview.leadingAnchor
constant:leftMargin],
topConstraint,
[threadSummaryView.heightAnchor constraintEqualToConstant:[ThreadSummaryView contentViewHeightForThread:component.thread fitting:cellData.maxTextViewWidth]],
[threadSummaryView.trailingAnchor constraintLessThanOrEqualToAnchor:threadSummaryView.superview.trailingAnchor constant:-RoomBubbleCellLayout.reactionsViewRightMargin]
]];
}
// Set constraints for the summary view
[NSLayoutConstraint activateConstraints: @[
[threadSummaryView.leadingAnchor constraintEqualToAnchor:threadSummaryView.superview.leadingAnchor
constant:leftMargin],
topConstraint,
[threadSummaryView.heightAnchor constraintEqualToConstant:[ThreadSummaryView contentViewHeightForThread:component.thread fitting:cellData.maxTextViewWidth]],
[threadSummaryView.trailingAnchor constraintLessThanOrEqualToAnchor:threadSummaryView.superview.trailingAnchor constant:-RoomBubbleCellLayout.reactionsViewRightMargin]
]];
}
MXKReceiptSendersContainer* avatarsContainer;
+39 -23
View File
@@ -81,7 +81,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
self.activityIndicatorPresenter = ActivityIndicatorPresenter()
if #available(iOS 14, *) {
PollTimelineProvider.shared.session = parameters.session
TimelinePollProvider.shared.session = parameters.session
}
super.init()
@@ -289,6 +289,29 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
navigationRouter.present(coordinator, animated: true)
coordinator.start()
}
private func startEditPollCoordinator(startEvent: MXEvent? = nil) {
guard #available(iOS 14.0, *) else {
return
}
let parameters = PollEditFormCoordinatorParameters(room: roomViewController.roomDataSource.room, pollStartEvent: startEvent)
let coordinator = PollEditFormCoordinator(parameters: parameters)
coordinator.completion = { [weak self, weak coordinator] in
guard let self = self, let coordinator = coordinator else {
return
}
self.navigationRouter?.dismissModule(animated: true, completion: nil)
self.remove(childCoordinator: coordinator)
}
add(childCoordinator: coordinator)
navigationRouter?.present(coordinator, animated: true)
coordinator.start()
}
}
// MARK: - RoomIdentifiable
@@ -352,26 +375,7 @@ extension RoomCoordinator: RoomViewControllerDelegate {
}
func roomViewControllerDidRequestPollCreationFormPresentation(_ roomViewController: RoomViewController) {
guard #available(iOS 14.0, *) else {
return
}
let parameters = PollEditFormCoordinatorParameters(room: roomViewController.roomDataSource.room)
let coordinator = PollEditFormCoordinator(parameters: parameters)
coordinator.completion = { [weak self, weak coordinator] in
guard let self = self, let coordinator = coordinator else {
return
}
self.navigationRouter?.dismissModule(animated: true, completion: nil)
self.remove(childCoordinator: coordinator)
}
add(childCoordinator: coordinator)
navigationRouter?.present(coordinator, animated: true)
coordinator.start()
startEditPollCoordinator()
}
func roomViewControllerDidRequestLocationSharingFormPresentation(_ roomViewController: RoomViewController) {
@@ -387,7 +391,7 @@ extension RoomCoordinator: RoomViewControllerDelegate {
return false
}
return PollTimelineProvider.shared.pollTimelineCoordinatorForEventIdentifier(eventIdentifier)?.canEndPoll() ?? false
return TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.canEndPoll() ?? false
}
func roomViewController(_ roomViewController: RoomViewController, endPollWithEventIdentifier eventIdentifier: String) {
@@ -395,6 +399,18 @@ extension RoomCoordinator: RoomViewControllerDelegate {
return
}
PollTimelineProvider.shared.pollTimelineCoordinatorForEventIdentifier(eventIdentifier)?.endPoll()
TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.endPoll()
}
func roomViewController(_ roomViewController: RoomViewController, canEditPollWithEventIdentifier eventIdentifier: String) -> Bool {
guard #available(iOS 14.0, *) else {
return false
}
return TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.canEditPoll() ?? false
}
func roomViewController(_ roomViewController: RoomViewController, didRequestEditForPollWithStart startEvent: MXEvent) {
startEditPollCoordinator(startEvent: startEvent)
}
}
@@ -24,21 +24,27 @@ class RoomDisplayConfiguration: NSObject {
let integrationsEnabled: Bool
let jitsiWidgetRemoverEnabled: Bool
let sendingPollsEnabled: Bool
init(callsEnabled: Bool,
integrationsEnabled: Bool,
jitsiWidgetRemoverEnabled: Bool) {
jitsiWidgetRemoverEnabled: Bool,
sendingPollsEnabled: Bool) {
self.callsEnabled = callsEnabled
self.integrationsEnabled = integrationsEnabled
self.jitsiWidgetRemoverEnabled = jitsiWidgetRemoverEnabled
self.sendingPollsEnabled = sendingPollsEnabled
super.init()
}
static let `default`: RoomDisplayConfiguration = RoomDisplayConfiguration(callsEnabled: true,
integrationsEnabled: true,
jitsiWidgetRemoverEnabled: true)
jitsiWidgetRemoverEnabled: true,
sendingPollsEnabled: true)
static let forThreads: RoomDisplayConfiguration = RoomDisplayConfiguration(callsEnabled: false,
integrationsEnabled: false,
jitsiWidgetRemoverEnabled: false)
jitsiWidgetRemoverEnabled: false,
sendingPollsEnabled: false)
}
+6
View File
@@ -225,6 +225,12 @@ canEndPollWithEventIdentifier:(NSString *)eventIdentifier;
- (void)roomViewController:(RoomViewController *)roomViewController
endPollWithEventIdentifier:(NSString *)eventIdentifier;
- (BOOL)roomViewController:(RoomViewController *)roomViewController
canEditPollWithEventIdentifier:(NSString *)eventIdentifier;
- (void)roomViewController:(RoomViewController *)roomViewController
didRequestEditForPollWithStartEvent:(MXEvent *)startEvent;
@end
NS_ASSUME_NONNULL_END
+30 -11
View File
@@ -1564,7 +1564,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
- (BadgedBarButtonItem *)threadListBarButtonItem
{
UIButton *button = [UIButton new];
UIImage *icon = [[UIImage imageNamed:@"threads_icon"] vc_resizedWith:CGSizeMake(24, 24)];
UIImage *icon = [[UIImage imageNamed:@"threads_icon"] vc_resizedWith:CGSizeMake(21, 21)];
button.contentEdgeInsets = UIEdgeInsetsMake(4, 8, 4, 8);
[button setImage:icon
forState:UIControlStateNormal];
@@ -2121,7 +2121,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
[self roomInputToolbarViewDidTapFileUpload];
}]];
}
if (RiotSettings.shared.roomScreenAllowPollsAction)
if (BuildSettings.pollsEnabled && self.displayConfiguration.sendingPollsEnabled)
{
[actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_poll"] andAction:^{
MXStrongifyAndReturnIfNil(self);
@@ -3918,6 +3918,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
[actionsMenu mxk_setAccessibilityIdentifier:@"RoomVCEventMenuAlert"];
[actionsMenu popoverPresentationController].sourceView = roomBubbleTableViewCell;
[actionsMenu popoverPresentationController].sourceRect = sourceRect;
[self dismissKeyboard];
[self presentViewController:actionsMenu animated:animated completion:nil];
currentAlert = actionsMenu;
}
@@ -6335,16 +6336,34 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
MXWeakify(self);
RoomContextualMenuItem *editMenuItem = [[RoomContextualMenuItem alloc] initWithMenuAction:RoomContextualMenuActionEdit];
editMenuItem.action = ^{
MXStrongifyAndReturnIfNil(self);
[self hideContextualMenuAnimated:YES cancelEventSelection:NO completion:nil];
[self editEventContentWithId:event.eventId];
// And display the keyboard
[self.inputToolbarView becomeFirstResponder];
};
editMenuItem.isEnabled = [self.roomDataSource canEditEventWithId:event.eventId];
switch (event.eventType) {
case MXEventTypePollStart: {
editMenuItem.action = ^{
MXStrongifyAndReturnIfNil(self);
[self hideContextualMenuAnimated:YES cancelEventSelection:YES completion:nil];
[self.delegate roomViewController:self didRequestEditForPollWithStartEvent:event];
};
editMenuItem.isEnabled = [self.delegate roomViewController:self canEditPollWithEventIdentifier:event.eventId];
break;
}
default: {
editMenuItem.action = ^{
MXStrongifyAndReturnIfNil(self);
[self hideContextualMenuAnimated:YES cancelEventSelection:NO completion:nil];
[self editEventContentWithId:event.eventId];
// And display the keyboard
[self.inputToolbarView becomeFirstResponder];
};
editMenuItem.isEnabled = [self.roomDataSource canEditEventWithId:event.eventId];
break;
}
}
return editMenuItem;
}
@@ -69,7 +69,10 @@
if (cellData)
{
// Highlight the search pattern
[cellData highlightPatternInTextMessage:self.searchText withForegroundColor:ThemeService.shared.theme.tintColor andFont:patternFont];
[cellData highlightPatternInTextMessage:self.searchText
withBackgroundColor:[UIColor clearColor]
foregroundColor:ThemeService.shared.theme.tintColor
andFont:patternFont];
// Use profile information as data to display
MXSearchUserProfile *userProfile = result.context.profileInfo[result.result.sender];
@@ -91,11 +94,65 @@
if ([cell isKindOfClass:MXKRoomBubbleTableViewCell.class])
{
MXKRoomBubbleTableViewCell *bubbleCell = (MXKRoomBubbleTableViewCell*)cell;
// Display date for each message
[bubbleCell addDateLabel];
RoomBubbleCellData *cellData = (RoomBubbleCellData*)[self cellDataAtIndex:indexPath.row];
MXEvent *event = cellData.events.firstObject;
if (event)
{
if (cellData.hasThreadRoot)
{
MXThread *thread = cellData.bubbleComponents.firstObject.thread;
ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread];
[bubbleCell.tmpSubviews addObject:threadSummaryView];
threadSummaryView.translatesAutoresizingMaskIntoConstraints = NO;
[bubbleCell.contentView addSubview:threadSummaryView];
CGFloat leftMargin = RoomBubbleCellLayout.reactionsViewLeftMargin;
CGRect bubbleComponentFrame = [bubbleCell componentFrameInContentViewForIndex:0];
CGFloat bottomPositionY = bubbleComponentFrame.origin.y + bubbleComponentFrame.size.height;
// Set constraints for the summary view
[NSLayoutConstraint activateConstraints: @[
[threadSummaryView.leadingAnchor constraintEqualToAnchor:threadSummaryView.superview.leadingAnchor
constant:leftMargin],
[threadSummaryView.topAnchor constraintEqualToAnchor:threadSummaryView.superview.topAnchor
constant:bottomPositionY + RoomBubbleCellLayout.threadSummaryViewTopMargin],
[threadSummaryView.heightAnchor constraintEqualToConstant:[ThreadSummaryView contentViewHeightForThread:thread fitting:cellData.maxTextViewWidth]],
[threadSummaryView.trailingAnchor constraintLessThanOrEqualToAnchor:threadSummaryView.superview.trailingAnchor constant:-RoomBubbleCellLayout.reactionsViewRightMargin]
]];
}
else if (event.isInThread)
{
FromThreadView *fromThreadView = [FromThreadView instantiate];
[bubbleCell.tmpSubviews addObject:fromThreadView];
fromThreadView.translatesAutoresizingMaskIntoConstraints = NO;
[bubbleCell.contentView addSubview:fromThreadView];
CGFloat leftMargin = RoomBubbleCellLayout.reactionsViewLeftMargin;
CGRect bubbleComponentFrame = [bubbleCell componentFrameInContentViewForIndex:0];
CGFloat bottomPositionY = bubbleComponentFrame.origin.y + bubbleComponentFrame.size.height;
// Set constraints for the summary view
[NSLayoutConstraint activateConstraints: @[
[fromThreadView.leadingAnchor constraintEqualToAnchor:fromThreadView.superview.leadingAnchor
constant:leftMargin],
[fromThreadView.topAnchor constraintEqualToAnchor:fromThreadView.superview.topAnchor
constant:bottomPositionY + RoomBubbleCellLayout.fromThreadViewTopMargin],
[fromThreadView.heightAnchor constraintEqualToConstant:[FromThreadView contentViewHeightForEvent:event fitting:cellData.maxTextViewWidth]],
[fromThreadView.trailingAnchor constraintLessThanOrEqualToAnchor:fromThreadView.superview.trailingAnchor constant:-RoomBubbleCellLayout.reactionsViewRightMargin]
]];
}
}
}
return cell;
}
@@ -168,6 +168,10 @@ class BaseBubbleCell: MXKRoomBubbleTableViewCell, BaseBubbleCellType {
if let bubbleCellReactionsDisplayable = self as? BubbleCellReactionsDisplayable {
bubbleCellReactionsDisplayable.removeReactionsView()
}
if let bubbleCellThreadSummaryDisplayable = self as? BubbleCellThreadSummaryDisplayable {
bubbleCellThreadSummaryDisplayable.removeThreadSummaryView()
}
}
override func render(_ cellData: MXKCellData!) {
@@ -244,6 +248,16 @@ class BaseBubbleCell: MXKRoomBubbleTableViewCell, BaseBubbleCellType {
func removeReactionsView() {
self.bubbleCellContentView?.removeReactionsView()
}
// MARK: - BubbleCellThreadSummaryDisplayable
func addThreadSummaryView(_ threadSummaryView: ThreadSummaryView) {
self.bubbleCellContentView?.addThreadSummaryView(threadSummaryView)
}
func removeThreadSummaryView() {
self.bubbleCellContentView?.removeThreadSummaryView()
}
// Encryption status
@@ -47,6 +47,8 @@ final class BubbleCellContentView: UIView, NibLoadable {
@IBOutlet weak var reactionsContainerView: UIView!
@IBOutlet weak var reactionsContentView: UIView!
@IBOutlet weak var threadSummaryContainerView: UIView!
@IBOutlet weak var bubbleOverlayContainer: UIView!
@@ -69,6 +71,14 @@ final class BubbleCellContentView: UIView, NibLoadable {
self.reactionsContainerView.isHidden = !newValue
}
}
private var showThreadSummary: Bool {
get {
return !self.threadSummaryContainerView.isHidden
} set {
self.threadSummaryContainerView.isHidden = !newValue
}
}
// MARK: Public
@@ -143,3 +153,27 @@ extension BubbleCellContentView: BubbleCellReactionsDisplayable {
self.reactionsContentView.vc_removeAllSubviews()
}
}
// MARK: - BubbleCellThreadSummaryDisplayable
extension BubbleCellContentView: BubbleCellThreadSummaryDisplayable {
func addThreadSummaryView(_ threadSummaryView: ThreadSummaryView) {
self.threadSummaryContainerView.vc_removeAllSubviews()
self.threadSummaryContainerView.addSubview(threadSummaryView)
NSLayoutConstraint.activate([
threadSummaryView.leadingAnchor.constraint(equalTo: innerContentView.leadingAnchor),
threadSummaryView.topAnchor.constraint(equalTo: threadSummaryContainerView.topAnchor),
threadSummaryView.heightAnchor.constraint(equalToConstant: RoomBubbleCellLayout.threadSummaryViewHeight),
threadSummaryView.bottomAnchor.constraint(equalTo: threadSummaryContainerView.bottomAnchor),
threadSummaryView.trailingAnchor.constraint(lessThanOrEqualTo: threadSummaryContainerView.trailingAnchor,
constant: -RoomBubbleCellLayout.reactionsViewRightMargin)
])
self.showThreadSummary = true
}
func removeThreadSummaryView() {
self.showThreadSummary = false
self.threadSummaryContainerView.vc_removeAllSubviews()
}
}
@@ -195,6 +195,10 @@
<constraint firstAttribute="trailing" secondItem="SNw-aM-ILI" secondAttribute="trailing" constant="15" id="ynR-d4-6cf"/>
</constraints>
</view>
<view hidden="YES" clipsSubviews="YES" contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="2eB-kB-m20">
<rect key="frame" x="0.0" y="0.0" width="595" height="0.0"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
</subviews>
<constraints>
<constraint firstItem="Dj1-m6-1Jw" firstAttribute="width" secondItem="5GX-gn-bK1" secondAttribute="width" id="0Px-jL-CMJ"/>
@@ -238,6 +242,7 @@
<outlet property="readReceiptsContainerView" destination="4zo-V8-CNe" id="7ek-u4-CX8"/>
<outlet property="readReceiptsContentView" destination="rQt-NH-Cb0" id="tqw-je-kp9"/>
<outlet property="senderInfoContainerView" destination="w0C-6a-f5M" id="fZE-vY-0nR"/>
<outlet property="threadSummaryContainerView" destination="2eB-kB-m20" id="0Y4-4E-I9K"/>
<outlet property="userNameLabel" destination="meG-P8-61b" id="ETK-ag-WYR"/>
<outlet property="userNameTouchMaskView" destination="ohU-Sc-mgb" id="FwW-aL-kc5"/>
</connections>
@@ -0,0 +1,23 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
/// `BubbleCellThreadSummaryDisplayable` is a protocol indicating that a cell support displaying a thread summary.
@objc protocol BubbleCellThreadSummaryDisplayable {
func addThreadSummaryView(_ threadSummaryView: ThreadSummaryView)
func removeThreadSummaryView()
}
@@ -50,4 +50,6 @@ final class RoomBubbleCellLayout: NSObject {
// Threads
static let threadSummaryViewTopMargin: CGFloat = 8.0
static let threadSummaryViewHeight: CGFloat = 40.0
static let fromThreadViewTopMargin: CGFloat = 8.0
}
@@ -29,7 +29,7 @@ class PollBubbleCell: SizableBaseBubbleCell, BubbleCellReactionsDisplayable {
let bubbleData = cellData as? RoomBubbleCellData,
let event = bubbleData.events.last,
event.eventType == __MXEventType.pollStart,
let view = PollTimelineProvider.shared.buildPollTimelineViewForEvent(event) else {
let view = TimelinePollProvider.shared.buildTimelinePollViewForEvent(event) else {
return
}
@@ -57,3 +57,5 @@ class PollBubbleCell: SizableBaseBubbleCell, BubbleCellReactionsDisplayable {
delegate.cell(self, didRecognizeAction: kMXKRoomBubbleCellTapOnContentView, userInfo: [kMXKRoomBubbleCellEventKey: event])
}
}
extension PollBubbleCell: BubbleCellThreadSummaryDisplayable {}
@@ -130,6 +130,13 @@ class SizableBaseBubbleCell: BaseBubbleCell, SizableBaseBubbleCellType {
let reactionsHeight = self.reactionsViewSizer.height(for: bubbleReactionsViewModel, fittingWidth: reactionWidth)
height+=reactionsHeight
}
// Add thread summary view height if needed
if sizingView is BubbleCellThreadSummaryDisplayable,
let roomBubbleCellData = cellData as? RoomBubbleCellData,
roomBubbleCellData.hasThreadRoot {
height += RoomBubbleCellLayout.threadSummaryViewHeight
}
return height
}
@@ -0,0 +1,54 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import Reusable
@objcMembers
class FromThreadView: UIView {
private enum Constants {
static let viewHeight: CGFloat = 18
}
@IBOutlet private weak var iconView: UIImageView!
@IBOutlet private weak var titleLabel: UILabel!
static func contentViewHeight(forEvent event: MXEvent,
fitting maxWidth: CGFloat) -> CGFloat {
return Constants.viewHeight
}
static func instantiate() -> FromThreadView {
let view = FromThreadView.loadFromNib()
view.update(theme: ThemeService.shared().theme)
view.titleLabel.text = VectorL10n.messageFromAThread
return view
}
}
extension FromThreadView: NibLoadable {}
extension FromThreadView: Themable {
func update(theme: Theme) {
backgroundColor = .clear
iconView.tintColor = theme.colors.secondaryContent
titleLabel.textColor = theme.colors.secondaryContent
}
}
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="FromThreadView" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="139" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="gZf-Nh-De6">
<rect key="frame" x="0.0" y="0.0" width="139" height="44"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="threads_icon" translatesAutoresizingMaskIntoConstraints="NO" id="cdy-fz-kjn">
<rect key="frame" x="0.0" y="0.0" width="18" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="18" id="3mH-It-De7"/>
<constraint firstAttribute="width" constant="18" id="Jzw-cL-zxG"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="From a thread" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fX6-Xz-I4e">
<rect key="frame" x="22" y="0.0" width="117" height="44"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="gZf-Nh-De6" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="0Hy-t1-GHo"/>
<constraint firstAttribute="bottom" secondItem="gZf-Nh-De6" secondAttribute="bottom" id="Pye-fH-Zny"/>
<constraint firstItem="gZf-Nh-De6" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="b2i-tg-f7D"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="gZf-Nh-De6" secondAttribute="trailing" id="w9I-0I-lD2"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="iconView" destination="cdy-fz-kjn" id="Kev-ko-oTu"/>
<outlet property="titleLabel" destination="fX6-Xz-I4e" id="65X-PJ-RpF"/>
</connections>
<point key="canvasLocation" x="-119.56521739130436" y="-252.45535714285714"/>
</view>
</objects>
<resources>
<image name="threads_icon" width="27" height="28.5"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
@@ -27,9 +27,8 @@ protocol ThreadSummaryViewDelegate: AnyObject {
class ThreadSummaryView: UIView {
private enum Constants {
static let viewHeight: CGFloat = 40
static let viewDefaultWidth: CGFloat = 320
static let cornerRadius: CGFloat = 4
static let cornerRadius: CGFloat = 8
static let lastMessageFont: UIFont = .systemFont(ofSize: 13)
}
@@ -53,14 +52,14 @@ class ThreadSummaryView: UIView {
self.thread = thread
super.init(frame: CGRect(origin: .zero,
size: CGSize(width: Constants.viewDefaultWidth,
height: Constants.viewHeight)))
height: RoomBubbleCellLayout.threadSummaryViewHeight)))
loadNibContent()
update(theme: ThemeService.shared().theme)
configure()
}
static func contentViewHeight(forThread thread: MXThread, fitting maxWidth: CGFloat) -> CGFloat {
return Constants.viewHeight
return RoomBubbleCellLayout.threadSummaryViewHeight
}
required init?(coder: NSCoder) {
@@ -25,14 +25,15 @@
<rect key="frame" x="8" y="4" width="398" height="32"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="threads_icon" translatesAutoresizingMaskIntoConstraints="NO" id="vva-PV-3Ya">
<rect key="frame" x="4" y="3" width="26" height="26"/>
<rect key="frame" x="4" y="7" width="18" height="18"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="vva-PV-3Ya" secondAttribute="height" multiplier="1:1" id="972-WJ-2Zq"/>
<constraint firstAttribute="height" constant="18" id="1Tz-Xd-AQx"/>
<constraint firstAttribute="width" constant="18" id="PY6-xa-ldK"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="1" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GcG-W8-9LR">
<rect key="frame" x="34" y="0.0" width="6" height="32"/>
<rect key="frame" x="26" y="0.0" width="6" height="32"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="6" id="9Nt-Rk-O81"/>
@@ -42,14 +43,15 @@
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9wW-1f-f69" customClass="UserAvatarView" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="52" y="0.0" width="32" height="32"/>
<rect key="frame" x="44" y="4" width="24" height="24"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="9wW-1f-f69" secondAttribute="height" multiplier="1:1" id="V4H-JA-w4O"/>
<constraint firstAttribute="width" constant="24" id="Dmj-av-Udn"/>
<constraint firstAttribute="height" constant="24" id="GHv-19-Tjh"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DVT-JI-3kw">
<rect key="frame" x="92" y="0.0" width="298" height="32"/>
<rect key="frame" x="76" y="0.0" width="314" height="32"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
@@ -58,18 +60,16 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="vva-PV-3Ya" firstAttribute="top" secondItem="TFL-sS-eJc" secondAttribute="top" constant="3" id="3JV-P7-s7n"/>
<constraint firstAttribute="bottom" secondItem="DVT-JI-3kw" secondAttribute="bottom" id="ArM-9P-35J"/>
<constraint firstAttribute="bottom" secondItem="GcG-W8-9LR" secondAttribute="bottom" id="FI4-bk-goz"/>
<constraint firstItem="9wW-1f-f69" firstAttribute="top" secondItem="TFL-sS-eJc" secondAttribute="top" id="GBe-gi-Iwc"/>
<constraint firstItem="DVT-JI-3kw" firstAttribute="top" secondItem="TFL-sS-eJc" secondAttribute="top" id="MSs-PD-tov"/>
<constraint firstItem="GcG-W8-9LR" firstAttribute="leading" secondItem="vva-PV-3Ya" secondAttribute="trailing" constant="4" id="PhI-J3-Ycb"/>
<constraint firstItem="GcG-W8-9LR" firstAttribute="top" secondItem="TFL-sS-eJc" secondAttribute="top" id="Twp-gS-w3u"/>
<constraint firstAttribute="bottom" secondItem="9wW-1f-f69" secondAttribute="bottom" id="VG5-XU-DAK"/>
<constraint firstItem="9wW-1f-f69" firstAttribute="centerY" secondItem="TFL-sS-eJc" secondAttribute="centerY" id="UYy-PQ-m7A"/>
<constraint firstAttribute="trailing" secondItem="DVT-JI-3kw" secondAttribute="trailing" constant="8" id="bX2-Ha-8bf"/>
<constraint firstItem="vva-PV-3Ya" firstAttribute="centerY" secondItem="TFL-sS-eJc" secondAttribute="centerY" id="mkf-Hx-FLe"/>
<constraint firstItem="DVT-JI-3kw" firstAttribute="leading" secondItem="9wW-1f-f69" secondAttribute="trailing" constant="8" id="qGg-0A-C6M"/>
<constraint firstItem="9wW-1f-f69" firstAttribute="leading" secondItem="GcG-W8-9LR" secondAttribute="trailing" constant="12" id="s2V-X9-cyI"/>
<constraint firstAttribute="bottom" secondItem="vva-PV-3Ya" secondAttribute="bottom" constant="3" id="smY-cv-CoE"/>
<constraint firstItem="vva-PV-3Ya" firstAttribute="leading" secondItem="TFL-sS-eJc" secondAttribute="leading" constant="4" id="vyh-e4-Vy3"/>
</constraints>
</view>
@@ -87,6 +87,6 @@
</view>
</objects>
<resources>
<image name="threads_icon" width="32" height="32"/>
<image name="threads_icon" width="27" height="28.5"/>
</resources>
</document>
@@ -16,31 +16,31 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="1" translatesAutoresizingMaskIntoConstraints="NO" id="0tP-MX-JE1">
<rect key="frame" x="6" y="0.0" width="221" height="44"/>
<rect key="frame" x="6" y="0.0" width="181" height="44"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Bkf-Ia-XzU">
<rect key="frame" x="0.0" y="0.0" width="221" height="0.0"/>
<rect key="frame" x="0.0" y="0.0" width="181" height="0.0"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" id="sTs-mz-Sem"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Thread" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="BnG-NU-7Mg">
<rect key="frame" x="0.0" y="1" width="221" height="20.5"/>
<rect key="frame" x="0.0" y="1" width="181" height="20.5"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ABf-Vz-jLY">
<rect key="frame" x="0.0" y="22.5" width="221" height="2"/>
<rect key="frame" x="0.0" y="22.5" width="181" height="2"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="2" id="kec-7k-q3g"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5Ww-tc-6by">
<rect key="frame" x="0.0" y="25.5" width="221" height="17.5"/>
<rect key="frame" x="0.0" y="25.5" width="181" height="17.5"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FJB-2F-rrQ" customClass="RoomAvatarView" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="0.0" y="1" width="16" height="16"/>
@@ -59,7 +59,7 @@
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Room name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.69999999999999996" translatesAutoresizingMaskIntoConstraints="NO" id="8lk-sN-3IP">
<rect key="frame" x="27" y="1.5" width="194" height="14.5"/>
<rect key="frame" x="26" y="1.5" width="155" height="14.5"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@@ -72,12 +72,12 @@
<constraint firstAttribute="trailing" secondItem="8lk-sN-3IP" secondAttribute="trailing" id="HCl-gK-Xhs"/>
<constraint firstItem="FJB-2F-rrQ" firstAttribute="centerY" secondItem="5Ww-tc-6by" secondAttribute="centerY" id="NiB-In-y7x"/>
<constraint firstItem="FJB-2F-rrQ" firstAttribute="leading" secondItem="5Ww-tc-6by" secondAttribute="leading" id="Smn-wx-c0n"/>
<constraint firstItem="8lk-sN-3IP" firstAttribute="leading" secondItem="FJB-2F-rrQ" secondAttribute="trailing" constant="11" id="Y1z-dr-Y0X"/>
<constraint firstItem="8lk-sN-3IP" firstAttribute="leading" secondItem="FJB-2F-rrQ" secondAttribute="trailing" constant="10" id="Y1z-dr-Y0X"/>
<constraint firstItem="Mli-PC-WUh" firstAttribute="leading" secondItem="5Ww-tc-6by" secondAttribute="leading" constant="10" id="zH1-h4-JAC"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tf4-ZQ-a7v">
<rect key="frame" x="0.0" y="44" width="221" height="0.0"/>
<rect key="frame" x="0.0" y="44" width="181" height="0.0"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" id="Pb4-25-yBS"/>
@@ -95,7 +95,7 @@
<constraint firstItem="0tP-MX-JE1" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="30P-0k-oLG"/>
<constraint firstItem="0tP-MX-JE1" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="6" id="Ef8-9o-qNh"/>
<constraint firstAttribute="bottom" secondItem="0tP-MX-JE1" secondAttribute="bottom" id="EqL-Br-ple"/>
<constraint firstAttribute="trailing" secondItem="0tP-MX-JE1" secondAttribute="trailing" constant="16" id="JQX-7q-vCS"/>
<constraint firstAttribute="trailing" secondItem="0tP-MX-JE1" secondAttribute="trailing" constant="56" id="JQX-7q-vCS"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>