Merge pull request #5711 from vector-im/steve/bubbles_refacto

Timeline: Use appropriate class name for Swift cells.
This commit is contained in:
SBiOSoftWhare 2022-03-01 12:51:30 +01:00 committed by GitHub
commit f8516d6cc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 278 additions and 284 deletions

View file

@ -21,7 +21,7 @@
#import "AvatarGenerator.h"
#import "Tools.h"
#import "BubbleReactionsViewSizer.h"
#import "RoomReactionsViewSizer.h"
#import "GeneratedInterface-Swift.h"
@ -754,18 +754,18 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
if (reactionCount)
{
CGFloat bubbleReactionsViewWidth = self.maxTextViewWidth - 4;
CGFloat reactionsViewWidth = self.maxTextViewWidth - 4;
static BubbleReactionsViewSizer *bubbleReactionsViewSizer;
static RoomReactionsViewSizer *reactionsViewSizer;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
bubbleReactionsViewSizer = [BubbleReactionsViewSizer new];
reactionsViewSizer = [RoomReactionsViewSizer new];
});
BOOL showAllReactions = [self.eventsToShowAllReactions containsObject:eventId];
BubbleReactionsViewModel *viewModel = [[BubbleReactionsViewModel alloc] initWithAggregatedReactions:aggregatedReactions eventId:eventId showAll:showAllReactions];
height = [bubbleReactionsViewSizer heightForViewModel:viewModel fittingWidth:bubbleReactionsViewWidth] + PlainRoomCellLayoutConstants.reactionsViewTopMargin;
RoomReactionsViewModel *viewModel = [[RoomReactionsViewModel alloc] initWithAggregatedReactions:aggregatedReactions eventId:eventId showAll:showAllReactions];
height = [reactionsViewSizer heightForViewModel:viewModel fittingWidth:reactionsViewWidth] + PlainRoomCellLayoutConstants.reactionsViewTopMargin;
}
return height;

View file

@ -29,7 +29,7 @@
const CGFloat kTypingCellHeight = 24;
@interface RoomDataSource() <BubbleReactionsViewModelDelegate, URLPreviewViewDelegate, ThreadSummaryViewDelegate, MXThreadingServiceDelegate>
@interface RoomDataSource() <RoomReactionsViewModelDelegate, URLPreviewViewDelegate, ThreadSummaryViewDelegate, MXThreadingServiceDelegate>
{
// Observe kThemeServiceDidChangeThemeNotification to handle user interface theme change.
id kThemeServiceDidChangeThemeNotificationObserver;
@ -348,7 +348,7 @@ const CGFloat kTypingCellHeight = 24;
{
if (indexPath.row == self.typingCellIndex)
{
RoomTypingBubbleCell *cell = [tableView dequeueReusableCellWithIdentifier:RoomTypingBubbleCell.defaultReuseIdentifier forIndexPath:indexPath];
MessageTypingCell *cell = [tableView dequeueReusableCellWithIdentifier:MessageTypingCell.defaultReuseIdentifier forIndexPath:indexPath];
[cell updateWithTheme:ThemeService.shared.theme];
[cell updateTypingUsers:_currentTypingUsers mediaManager:self.mxSession.mediaManager];
return cell;
@ -431,21 +431,21 @@ const CGFloat kTypingCellHeight = 24;
MXAggregatedReactions* reactions = cellData.reactions[componentEventId].aggregatedReactionsWithNonZeroCount;
BubbleReactionsView *reactionsView;
RoomReactionsView *reactionsView;
if (!component.event.isRedactedEvent && reactions && !isCollapsableCellCollapsed)
{
BOOL showAllReactions = [cellData showAllReactionsForEvent:componentEventId];
BubbleReactionsViewModel *bubbleReactionsViewModel = [[BubbleReactionsViewModel alloc] initWithAggregatedReactions:reactions
RoomReactionsViewModel *roomReactionsViewModel = [[RoomReactionsViewModel alloc] initWithAggregatedReactions:reactions
eventId:componentEventId
showAll:showAllReactions];
reactionsView = [BubbleReactionsView new];
reactionsView.viewModel = bubbleReactionsViewModel;
reactionsView = [RoomReactionsView new];
reactionsView.viewModel = roomReactionsViewModel;
reactionsView.tag = index;
[reactionsView updateWithTheme:ThemeService.shared.theme];
bubbleReactionsViewModel.viewModelDelegate = self;
roomReactionsViewModel.viewModelDelegate = self;
[temporaryViews addObject:reactionsView];
[cellDecorator addReactionView:reactionsView toCell:bubbleCell
@ -989,9 +989,9 @@ const CGFloat kTypingCellHeight = 24;
}
}
#pragma mark - BubbleReactionsViewModelDelegate
#pragma mark - RoomReactionsViewModelDelegate
- (void)bubbleReactionsViewModel:(BubbleReactionsViewModel *)viewModel didAddReaction:(MXReactionCount *)reactionCount forEventId:(NSString *)eventId
- (void)roomReactionsViewModel:(RoomReactionsViewModel *)viewModel didAddReaction:(MXReactionCount *)reactionCount forEventId:(NSString *)eventId
{
[self addReaction:reactionCount.reaction forEventId:eventId success:^{
@ -1000,7 +1000,7 @@ const CGFloat kTypingCellHeight = 24;
}];
}
- (void)bubbleReactionsViewModel:(BubbleReactionsViewModel *)viewModel didRemoveReaction:(MXReactionCount * _Nonnull)reactionCount forEventId:(NSString * _Nonnull)eventId
- (void)roomReactionsViewModel:(RoomReactionsViewModel *)viewModel didRemoveReaction:(MXReactionCount * _Nonnull)reactionCount forEventId:(NSString * _Nonnull)eventId
{
[self removeReaction:reactionCount.reaction forEventId:eventId success:^{
@ -1009,12 +1009,12 @@ const CGFloat kTypingCellHeight = 24;
}];
}
- (void)bubbleReactionsViewModel:(BubbleReactionsViewModel *)viewModel didShowAllTappedForEventId:(NSString * _Nonnull)eventId
- (void)roomReactionsViewModel:(RoomReactionsViewModel *)viewModel didShowAllTappedForEventId:(NSString * _Nonnull)eventId
{
[self setShowAllReactions:YES forEvent:eventId];
}
- (void)bubbleReactionsViewModel:(BubbleReactionsViewModel *)viewModel didShowLessTappedForEventId:(NSString * _Nonnull)eventId
- (void)roomReactionsViewModel:(RoomReactionsViewModel *)viewModel didShowLessTappedForEventId:(NSString * _Nonnull)eventId
{
[self setShowAllReactions:NO forEvent:eventId];
}
@ -1033,7 +1033,7 @@ const CGFloat kTypingCellHeight = 24;
}
}
- (void)bubbleReactionsViewModel:(BubbleReactionsViewModel *)viewModel didLongPressForEventId:(NSString *)eventId
- (void)roomReactionsViewModel:(RoomReactionsViewModel *)viewModel didLongPressForEventId:(NSString *)eventId
{
[self.delegate dataSource:self didRecognizeAction:kMXKRoomBubbleCellLongPressOnReactionView inCell:nil userInfo:@{ kMXKRoomBubbleCellEventIdKey: eventId }];
}

View file

@ -3260,14 +3260,14 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
[self showReactionHistoryForEventId:tappedEventId animated:YES];
}
}
else if ([actionIdentifier isEqualToString:RoomDirectCallStatusBubbleCell.callBackAction])
else if ([actionIdentifier isEqualToString:RoomDirectCallStatusCell.callBackAction])
{
MXEvent *callInviteEvent = userInfo[kMXKRoomBubbleCellEventKey];
MXCallInviteEventContent *eventContent = [MXCallInviteEventContent modelFromJSON:callInviteEvent.content];
[self placeCallWithVideo2:eventContent.isVideoCall];
}
else if ([actionIdentifier isEqualToString:RoomDirectCallStatusBubbleCell.declineAction])
else if ([actionIdentifier isEqualToString:RoomDirectCallStatusCell.declineAction])
{
MXEvent *callInviteEvent = userInfo[kMXKRoomBubbleCellEventKey];
MXCallInviteEventContent *eventContent = [MXCallInviteEventContent modelFromJSON:callInviteEvent.content];
@ -3275,7 +3275,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
MXCall *call = [self.mainSession.callManager callWithCallId:eventContent.callId];
[call hangup];
}
else if ([actionIdentifier isEqualToString:RoomDirectCallStatusBubbleCell.answerAction])
else if ([actionIdentifier isEqualToString:RoomDirectCallStatusCell.answerAction])
{
MXEvent *callInviteEvent = userInfo[kMXKRoomBubbleCellEventKey];
MXCallInviteEventContent *eventContent = [MXCallInviteEventContent modelFromJSON:callInviteEvent.content];
@ -3283,7 +3283,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
MXCall *call = [self.mainSession.callManager callWithCallId:eventContent.callId];
[call answer];
}
else if ([actionIdentifier isEqualToString:RoomDirectCallStatusBubbleCell.endCallAction])
else if ([actionIdentifier isEqualToString:RoomDirectCallStatusCell.endCallAction])
{
MXEvent *callInviteEvent = userInfo[kMXKRoomBubbleCellEventKey];
MXCallInviteEventContent *eventContent = [MXCallInviteEventContent modelFromJSON:callInviteEvent.content];
@ -3291,8 +3291,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
MXCall *call = [self.mainSession.callManager callWithCallId:eventContent.callId];
[call hangup];
}
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusBubbleCell.joinAction] ||
[actionIdentifier isEqualToString:RoomGroupCallStatusBubbleCell.answerAction])
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusCell.joinAction] ||
[actionIdentifier isEqualToString:RoomGroupCallStatusCell.answerAction])
{
MXWeakify(self);
@ -3323,12 +3323,12 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
inMatrixSession:customizedRoomDataSource.mxSession];
[[JitsiService shared] resetDeclineForWidgetWithId:widget.widgetId];
}
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusBubbleCell.leaveAction])
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusCell.leaveAction])
{
[self endActiveJitsiCall];
[self reloadBubblesTable:YES];
}
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusBubbleCell.declineAction])
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusCell.declineAction])
{
MXEvent *widgetEvent = userInfo[kMXKRoomBubbleCellEventKey];
Widget *widget = [[Widget alloc] initWithWidgetEvent:widgetEvent

View file

@ -212,9 +212,9 @@ extension RoomCellContentView: RoomCellReactionsDisplayable {
self.reactionsContentView.vc_removeAllSubviews()
// Update reactions alignment according to current decoration alignment
if let bubbleReactionsView = reactionsView as? BubbleReactionsView {
if let reactionsView = reactionsView as? RoomReactionsView {
let reactionsAlignment: BubbleReactionsViewAlignment
let reactionsAlignment: RoomReactionsViewAlignment
switch self.decorationViewsAlignment {
case .left:
@ -223,7 +223,7 @@ extension RoomCellContentView: RoomCellReactionsDisplayable {
reactionsAlignment = .right
}
bubbleReactionsView.alignment = reactionsAlignment
reactionsView.alignment = reactionsAlignment
}
self.reactionsContentView.vc_addSubViewMatchingParent(reactionsView)

View file

@ -17,7 +17,7 @@
import UIKit
import Reusable
class CallBubbleCellBaseContentView: UIView {
class CallCellContentView: UIView {
private enum Constants {
static let callSummaryWithBottomViewHeight: CGFloat = 20
@ -88,11 +88,11 @@ class CallBubbleCellBaseContentView: UIView {
}
extension CallBubbleCellBaseContentView: NibLoadable {
extension CallCellContentView: NibLoadable {
}
extension CallBubbleCellBaseContentView: Themable {
extension CallCellContentView: Themable {
func update(theme: Theme) {
self.theme = theme
@ -114,7 +114,7 @@ extension CallBubbleCellBaseContentView: Themable {
// MARK: - RoomCellReadReceiptsDisplayable
extension CallBubbleCellBaseContentView: RoomCellReadReceiptsDisplayable {
extension CallCellContentView: RoomCellReadReceiptsDisplayable {
func addReadReceiptsView(_ readReceiptsView: UIView) {
self.readReceiptsContentView.vc_removeAllSubviews()

View file

@ -1,15 +1,15 @@
<?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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" 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"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<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" translatesAutoresizingMaskIntoConstraints="NO" id="iN0-l3-epB" customClass="CallBubbleCellBaseContentView" customModule="Riot" customModuleProvider="target">
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iN0-l3-epB" customClass="CallCellContentView" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="414" height="220"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="pdr-Jo-LHQ">

View file

@ -20,7 +20,7 @@ import UIKit
private let MSEC_PER_SEC: TimeInterval = 1000
@objcMembers
class RoomDirectCallStatusBubbleCell: RoomBaseCallBubbleCell {
class RoomDirectCallStatusCell: RoomCallBaseCell {
private static var className: String {
return String(describing: self)
@ -446,7 +446,7 @@ class RoomDirectCallStatusBubbleCell: RoomBaseCallBubbleCell {
return ""
}
return RoomDirectCallStatusBubbleCell.callDurationFormatter.string(from: duration) ?? ""
return RoomDirectCallStatusCell.callDurationFormatter.string(from: duration) ?? ""
}
}

View file

@ -20,7 +20,7 @@ import UIKit
private let MSEC_PER_SEC: TimeInterval = 1000
@objcMembers
class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell {
class RoomGroupCallStatusCell: RoomCallBaseCell {
private static var className: String {
return String(describing: self)
@ -335,7 +335,7 @@ class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell {
return ""
}
return RoomGroupCallStatusBubbleCell.callDurationFormatter.string(from: duration) ?? ""
return RoomGroupCallStatusCell.callDurationFormatter.string(from: duration) ?? ""
}
}

View file

@ -17,10 +17,10 @@
import UIKit
import Reusable
class RoomBaseCallBubbleCell: MXKRoomBubbleTableViewCell {
class RoomCallBaseCell: MXKRoomBubbleTableViewCell {
lazy var innerContentView: CallBubbleCellBaseContentView = {
return CallBubbleCellBaseContentView.loadFromNib()
lazy var innerContentView: CallCellContentView = {
return CallCellContentView.loadFromNib()
}()
override required init!(style: UITableViewCell.CellStyle, reuseIdentifier: String!) {
@ -65,7 +65,7 @@ class RoomBaseCallBubbleCell: MXKRoomBubbleTableViewCell {
innerContentView.bottomContainerView.vc_addSubViewMatchingParent(bottomContentView)
}
class func createSizingView() -> RoomBaseCallBubbleCell {
class func createSizingView() -> RoomCallBaseCell {
return self.init(style: .default, reuseIdentifier: self.defaultReuseIdentifier())
}
@ -144,7 +144,7 @@ class RoomBaseCallBubbleCell: MXKRoomBubbleTableViewCell {
}
extension RoomBaseCallBubbleCell: RoomCellReadReceiptsDisplayable {
extension RoomCallBaseCell: RoomCellReadReceiptsDisplayable {
func addReadReceiptsView(_ readReceiptsView: UIView) {
innerContentView.addReadReceiptsView(readReceiptsView)
@ -156,7 +156,7 @@ extension RoomBaseCallBubbleCell: RoomCellReadReceiptsDisplayable {
}
extension RoomBaseCallBubbleCell: Themable {
extension RoomCallBaseCell: Themable {
func update(theme: Theme) {
innerContentView.update(theme: theme)
@ -167,6 +167,6 @@ extension RoomBaseCallBubbleCell: Themable {
}
extension RoomBaseCallBubbleCell: NibReusable {
extension RoomCallBaseCell: NibReusable {
}

View file

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" 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="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<capability name="Safe area layout guides" minToolsVersion="9.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"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" translatesAutoresizingMaskIntoConstraints="NO" id="KGk-i7-Jjw" customClass="RoomBaseCallBubbleCell" customModule="Riot" customModuleProvider="target">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" translatesAutoresizingMaskIntoConstraints="NO" id="KGk-i7-Jjw" customClass="RoomCallBaseCell" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="160"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" translatesAutoresizingMaskIntoConstraints="NO" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="160"/>

View file

@ -17,7 +17,7 @@
import Foundation
@objcMembers
class KeyVerificationBaseBubbleCell: MXKRoomBubbleTableViewCell {
class KeyVerificationBaseCell: MXKRoomBubbleTableViewCell {
// MARK: - Constants
@ -121,7 +121,7 @@ class KeyVerificationBaseBubbleCell: MXKRoomBubbleTableViewCell {
return senderDisplayName
}
class func sizingView() -> KeyVerificationBaseBubbleCell {
class func sizingView() -> KeyVerificationBaseCell {
fatalError("[KeyVerificationBaseBubbleCell] Subclass should implement this method")
}
@ -249,7 +249,7 @@ class KeyVerificationBaseBubbleCell: MXKRoomBubbleTableViewCell {
}
// MARK: - RoomCellReadReceiptsDisplayable
extension KeyVerificationBaseBubbleCell: RoomCellReadReceiptsDisplayable {
extension KeyVerificationBaseCell: RoomCellReadReceiptsDisplayable {
func addReadReceiptsView(_ readReceiptsView: UIView) {
self.roomCellContentView?.addReadReceiptsView(readReceiptsView)

View file

@ -17,12 +17,12 @@
import UIKit
@objcMembers
class KeyVerificationConclusionBubbleCell: KeyVerificationBaseBubbleCell {
class KeyVerificationConclusionCell: KeyVerificationBaseCell {
// MARK: - Constants
private enum Sizing {
static let view = KeyVerificationConclusionBubbleCell(style: .default, reuseIdentifier: nil)
static let view = KeyVerificationConclusionCell(style: .default, reuseIdentifier: nil)
}
// MARK: - Setup
@ -58,7 +58,7 @@ class KeyVerificationConclusionBubbleCell: KeyVerificationBaseBubbleCell {
keyVerificationCellInnerContentView.updateSenderInfo(with: viewData.senderId, userDisplayName: viewData.senderDisplayName)
}
override class func sizingView() -> KeyVerificationBaseBubbleCell {
override class func sizingView() -> KeyVerificationBaseCell {
return self.Sizing.view
}

View file

@ -17,12 +17,12 @@
import UIKit
@objcMembers
final class KeyVerificationConclusionWithPaginationTitleBubbleCell: KeyVerificationConclusionBubbleCell {
final class KeyVerificationConclusionWithPaginationTitleCell: KeyVerificationConclusionCell {
// MARK: - Constants
private enum Sizing {
static let view = KeyVerificationConclusionWithPaginationTitleBubbleCell(style: .default, reuseIdentifier: nil)
static let view = KeyVerificationConclusionWithPaginationTitleCell(style: .default, reuseIdentifier: nil)
}
// MARK: - Setup
@ -38,7 +38,7 @@ final class KeyVerificationConclusionWithPaginationTitleBubbleCell: KeyVerificat
private func commonInit() {
guard let roomCellContentView = self.roomCellContentView else {
fatalError("[KeyVerificationConclusionWithPaginationTitleBubbleCell] bubbleCellContentView should not be nil")
fatalError("[KeyVerificationConclusionWithPaginationTitleCell] bubbleCellContentView should not be nil")
}
roomCellContentView.showPaginationTitle = true
@ -46,7 +46,7 @@ final class KeyVerificationConclusionWithPaginationTitleBubbleCell: KeyVerificat
// MARK: - Overrides
override class func sizingView() -> KeyVerificationBaseBubbleCell {
override class func sizingView() -> KeyVerificationBaseCell {
return self.Sizing.view
}
}

View file

@ -17,12 +17,12 @@
import UIKit
@objcMembers
class KeyVerificationIncomingRequestApprovalBubbleCell: KeyVerificationBaseBubbleCell {
class KeyVerificationIncomingRequestApprovalCell: KeyVerificationBaseCell {
// MARK: - Constants
private enum Sizing {
static let view = KeyVerificationIncomingRequestApprovalBubbleCell(style: .default, reuseIdentifier: nil)
static let view = KeyVerificationIncomingRequestApprovalCell(style: .default, reuseIdentifier: nil)
}
// MARK: - Setup
@ -85,7 +85,7 @@ class KeyVerificationIncomingRequestApprovalBubbleCell: KeyVerificationBaseBubbl
}
}
override class func sizingView() -> KeyVerificationBaseBubbleCell {
override class func sizingView() -> KeyVerificationBaseCell {
return self.Sizing.view
}

View file

@ -17,12 +17,12 @@
import UIKit
@objcMembers
final class KeyVerificationIncomingRequestApprovalWithPaginationTitleBubbleCell: KeyVerificationIncomingRequestApprovalBubbleCell {
final class KeyVerificationIncomingRequestApprovalWithPaginationTitleCell: KeyVerificationIncomingRequestApprovalCell {
// MARK: - Constants
private enum Sizing {
static let view = KeyVerificationIncomingRequestApprovalWithPaginationTitleBubbleCell(style: .default, reuseIdentifier: nil)
static let view = KeyVerificationIncomingRequestApprovalWithPaginationTitleCell(style: .default, reuseIdentifier: nil)
}
// MARK: - Setup
@ -38,7 +38,7 @@ final class KeyVerificationIncomingRequestApprovalWithPaginationTitleBubbleCell:
private func commonInit() {
guard let roomCellContentView = self.roomCellContentView else {
fatalError("[KeyVerificationRequestStatusWithPaginationTitleBubbleCell] bubbleCellContentView should not be nil")
fatalError("[KeyVerificationRequestStatusWithPaginationTitleCell] roomCellContentView should not be nil")
}
roomCellContentView.showPaginationTitle = true
@ -46,7 +46,7 @@ final class KeyVerificationIncomingRequestApprovalWithPaginationTitleBubbleCell:
// MARK: - Overrides
override class func sizingView() -> KeyVerificationBaseBubbleCell {
override class func sizingView() -> KeyVerificationBaseCell {
return self.Sizing.view
}
}

View file

@ -17,12 +17,12 @@
import UIKit
@objcMembers
class KeyVerificationRequestStatusBubbleCell: KeyVerificationBaseBubbleCell {
class KeyVerificationRequestStatusCell: KeyVerificationBaseCell {
// MARK: - Constants
private enum Sizing {
static let view = KeyVerificationRequestStatusBubbleCell(style: .default, reuseIdentifier: nil)
static let view = KeyVerificationRequestStatusCell(style: .default, reuseIdentifier: nil)
}
// MARK: - Setup
@ -63,7 +63,7 @@ class KeyVerificationRequestStatusBubbleCell: KeyVerificationBaseBubbleCell {
keyVerificationCellInnerContentView.requestStatusText = viewData.statusText
}
override class func sizingView() -> KeyVerificationBaseBubbleCell {
override class func sizingView() -> KeyVerificationBaseCell {
return self.Sizing.view
}

View file

@ -17,12 +17,12 @@
import UIKit
@objcMembers
final class KeyVerificationRequestStatusWithPaginationTitleBubbleCell: KeyVerificationRequestStatusBubbleCell {
final class KeyVerificationRequestStatusWithPaginationTitleCell: KeyVerificationRequestStatusCell {
// MARK: - Constants
private enum Sizing {
static let view = KeyVerificationRequestStatusWithPaginationTitleBubbleCell(style: .default, reuseIdentifier: nil)
static let view = KeyVerificationRequestStatusWithPaginationTitleCell(style: .default, reuseIdentifier: nil)
}
// MARK: - Setup
@ -38,7 +38,7 @@ final class KeyVerificationRequestStatusWithPaginationTitleBubbleCell: KeyVerifi
private func commonInit() {
guard let roomCellContentView = self.roomCellContentView else {
fatalError("[KeyVerificationRequestStatusWithPaginationTitleBubbleCell] bubbleCellContentView should not be nil")
fatalError("[KeyVerificationRequestStatusWithPaginationTitleCell] roomCellContentView should not be nil")
}
roomCellContentView.showPaginationTitle = true
@ -46,7 +46,7 @@ final class KeyVerificationRequestStatusWithPaginationTitleBubbleCell: KeyVerifi
// MARK: - Overrides
override class func sizingView() -> KeyVerificationBaseBubbleCell {
override class func sizingView() -> KeyVerificationBaseCell {
return self.Sizing.view
}
}

View file

@ -17,7 +17,7 @@
import UIKit
@objcMembers
class RoomTypingBubbleCell: MXKTableViewCell, Themable {
class MessageTypingCell: MXKTableViewCell, Themable {
// MARK: - Constants
private enum Constants {

View file

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" 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="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<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"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="nQB-23-kip" customClass="RoomTypingBubbleCell" customModule="Riot" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="nQB-23-kip" customClass="MessageTypingCell" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="nQB-23-kip" id="vRo-3W-dC9">

View file

@ -29,10 +29,10 @@ class SizableBaseRoomCell: BaseRoomCell, SizableBaseRoomCellType {
private static let sizingViewHeightStore = SizingViewHeightStore()
private static var sizingViews: [String: SizableBaseRoomCell] = [:]
private static let sizingReactionsView = BubbleReactionsView()
private static let sizingReactionsView = RoomReactionsView()
private static let reactionsViewSizer = BubbleReactionsViewSizer()
private static let reactionsViewModelBuilder = BubbleReactionsViewModelBuilder()
private static let reactionsViewSizer = RoomReactionsViewSizer()
private static let reactionsViewModelBuilder = RoomReactionsViewModelBuilder()
private static let urlPreviewViewSizer = URLPreviewViewSizer()
@ -126,11 +126,11 @@ class SizableBaseRoomCell: BaseRoomCell, SizableBaseRoomCellType {
// Add reactions view height if needed
if sizingView is RoomCellReactionsDisplayable,
let roomBubbleCellData = cellData as? RoomBubbleCellData,
let bubbleReactionsViewModel = self.reactionsViewModelBuilder.buildForFirstVisibleComponent(of: roomBubbleCellData) {
let reactionsViewModel = self.reactionsViewModelBuilder.buildForFirstVisibleComponent(of: roomBubbleCellData) {
let reactionWidth = sizingView.roomCellContentView?.reactionsContentView.frame.width ?? roomBubbleCellData.maxTextViewWidth
let reactionsHeight = self.reactionsViewSizer.height(for: bubbleReactionsViewModel, fittingWidth: reactionWidth)
let reactionsHeight = self.reactionsViewSizer.height(for: reactionsViewModel, fittingWidth: reactionWidth)
height+=reactionsHeight
}

View file

@ -67,7 +67,7 @@ class BubbleRoomTimelineCellDecorator: PlainRoomTimelineCellDecorator {
} else {
super.addTimestampLabel(toCell: cell, cellData: cellData)
}
} else if let voiceMessageCell = cell as? VoiceMessageBubbleCell, let playbackView = voiceMessageCell.playbackController?.playbackView {
} else if let voiceMessageCell = cell as? VoiceMessagePlainCell, let playbackView = voiceMessageCell.playbackController?.playbackView {
// Add timestamp on cell inherting from VoiceMessageBubbleCell
@ -90,7 +90,7 @@ class BubbleRoomTimelineCellDecorator: PlainRoomTimelineCellDecorator {
}
}
override func addReactionView(_ reactionsView: BubbleReactionsView,
override func addReactionView(_ reactionsView: RoomReactionsView,
toCell cell: MXKRoomBubbleTableViewCell, cellData: RoomBubbleCellData, contentViewPositionY: CGFloat, upperDecorationView: UIView?) {
if let reactionsDisplayable = cell as? RoomCellReactionsDisplayable {

View file

@ -16,7 +16,7 @@
import Foundation
class LocationIncomingBubbleCell: LocationBubbleCell, BubbleIncomingRoomCellProtocol {
class LocationIncomingBubbleCell: LocationPlainCell, BubbleIncomingRoomCellProtocol {
override func setupViews() {
super.setupViews()

View file

@ -16,7 +16,7 @@
import Foundation
class LocationOutgoingWithoutSenderInfoBubbleCell: LocationBubbleCell, BubbleOutgoingRoomCellProtocol {
class LocationOutgoingWithoutSenderInfoBubbleCell: LocationPlainCell, BubbleOutgoingRoomCellProtocol {
override func setupViews() {
super.setupViews()

View file

@ -16,7 +16,7 @@
import UIKit
class PollBaseBubbleCell: PollBubbleCell {
class PollBaseBubbleCell: PollPlainCell {
// MARK: - Properties

View file

@ -16,7 +16,7 @@
import Foundation
class VoiceMessageIncomingBubbleCell: VoiceMessageBubbleCell, BubbleIncomingRoomCellProtocol {
class VoiceMessageIncomingBubbleCell: VoiceMessagePlainCell, BubbleIncomingRoomCellProtocol {
override func setupViews() {
super.setupViews()

View file

@ -16,7 +16,7 @@
import Foundation
class VoiceMessageOutgoingWithoutSenderInfoBubbleCell: VoiceMessageBubbleCell, BubbleOutgoingRoomCellProtocol {
class VoiceMessageOutgoingWithoutSenderInfoBubbleCell: VoiceMessagePlainCell, BubbleOutgoingRoomCellProtocol {
override func setupViews() {
super.setupViews()

View file

@ -16,7 +16,7 @@
import Foundation
class LocationBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCellReadMarkerDisplayable {
class LocationPlainCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCellReadMarkerDisplayable {
private var locationView: RoomTimelineLocationView!

View file

@ -16,7 +16,7 @@
import Foundation
class LocationWithPaginationTitleBubbleCell: LocationBubbleCell {
class LocationWithPaginationTitlePlainCell: LocationPlainCell {
override func setupViews() {
super.setupViews()

View file

@ -16,7 +16,7 @@
import Foundation
class LocationWithoutSenderInfoBubbleCell: LocationBubbleCell {
class LocationWithoutSenderInfoPlainCell: LocationPlainCell {
override func setupViews() {
super.setupViews()

View file

@ -16,7 +16,7 @@
import Foundation
class PollBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCellReadMarkerDisplayable {
class PollPlainCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCellReadMarkerDisplayable {
private var pollView: UIView?
private var event: MXEvent?
@ -62,4 +62,4 @@ class PollBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCel
}
}
extension PollBubbleCell: RoomCellThreadSummaryDisplayable {}
extension PollPlainCell: RoomCellThreadSummaryDisplayable {}

View file

@ -16,7 +16,7 @@
import Foundation
class PollWithPaginationTitleBubbleCell: PollBubbleCell {
class PollWithPaginationTitlePlainCell: PollPlainCell {
override func setupViews() {
super.setupViews()

View file

@ -16,7 +16,7 @@
import Foundation
class PollWithoutSenderInfoBubbleCell: PollBubbleCell {
class PollWithoutSenderInfoPlainCell: PollPlainCell {
override func setupViews() {
super.setupViews()

View file

@ -16,7 +16,7 @@
import Foundation
class VoiceMessageBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCellReadMarkerDisplayable {
class VoiceMessagePlainCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCellReadMarkerDisplayable {
private(set) var playbackController: VoiceMessagePlaybackController!

View file

@ -16,7 +16,7 @@
import Foundation
class VoiceMessageWithPaginationTitleBubbleCell: VoiceMessageBubbleCell {
class VoiceMessageWithPaginationTitlePlainCell: VoiceMessagePlainCell {
override func setupViews() {
super.setupViews()

View file

@ -16,7 +16,7 @@
import Foundation
class VoiceMessageWithoutSenderInfoBubbleCell: VoiceMessageBubbleCell {
class VoiceMessageWithoutSenderInfoPlainCell: VoiceMessagePlainCell {
override func setupViews() {
super.setupViews()

View file

@ -68,7 +68,7 @@ class PlainRoomTimelineCellDecorator: RoomTimelineCellDecorator {
])
}
func addReactionView(_ reactionsView: BubbleReactionsView,
func addReactionView(_ reactionsView: RoomReactionsView,
toCell cell: MXKRoomBubbleTableViewCell,
cellData: RoomBubbleCellData,
contentViewPositionY: CGFloat,

View file

@ -119,7 +119,7 @@
[tableView registerClass:RoomCreationIntroCell.class forCellReuseIdentifier:RoomCreationIntroCell.defaultReuseIdentifier];
[tableView registerNib:RoomTypingBubbleCell.nib forCellReuseIdentifier:RoomTypingBubbleCell.defaultReuseIdentifier];
[tableView registerNib:MessageTypingCell.nib forCellReuseIdentifier:MessageTypingCell.defaultReuseIdentifier];
}
- (Class<MXKCellRendering>)cellViewClassForCellIdentifier:(RoomTimelineCellIdentifier)identifier
@ -220,12 +220,12 @@
- (void)registerKeyVerificationCellsForTableView:(UITableView*)tableView
{
[tableView registerClass:KeyVerificationIncomingRequestApprovalBubbleCell.class forCellReuseIdentifier:KeyVerificationIncomingRequestApprovalBubbleCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationIncomingRequestApprovalWithPaginationTitleBubbleCell.class forCellReuseIdentifier:KeyVerificationIncomingRequestApprovalWithPaginationTitleBubbleCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationRequestStatusBubbleCell.class forCellReuseIdentifier:KeyVerificationRequestStatusBubbleCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationRequestStatusWithPaginationTitleBubbleCell.class forCellReuseIdentifier:KeyVerificationRequestStatusWithPaginationTitleBubbleCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationConclusionBubbleCell.class forCellReuseIdentifier:KeyVerificationConclusionBubbleCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationConclusionWithPaginationTitleBubbleCell.class forCellReuseIdentifier:KeyVerificationConclusionWithPaginationTitleBubbleCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationIncomingRequestApprovalCell.class forCellReuseIdentifier:KeyVerificationIncomingRequestApprovalCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationIncomingRequestApprovalWithPaginationTitleCell.class forCellReuseIdentifier:KeyVerificationIncomingRequestApprovalWithPaginationTitleCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationRequestStatusCell.class forCellReuseIdentifier:KeyVerificationRequestStatusCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationRequestStatusWithPaginationTitleCell.class forCellReuseIdentifier:KeyVerificationRequestStatusWithPaginationTitleCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationConclusionCell.class forCellReuseIdentifier:KeyVerificationConclusionCell.defaultReuseIdentifier];
[tableView registerClass:KeyVerificationConclusionWithPaginationTitleCell.class forCellReuseIdentifier:KeyVerificationConclusionWithPaginationTitleCell.defaultReuseIdentifier];
}
- (void)registerRoomCreationCellsForTableView:(UITableView*)tableView
@ -236,29 +236,29 @@
- (void)registerCallCellsForTableView:(UITableView*)tableView
{
[tableView registerClass:RoomDirectCallStatusBubbleCell.class forCellReuseIdentifier:RoomDirectCallStatusBubbleCell.defaultReuseIdentifier];
[tableView registerClass:RoomGroupCallStatusBubbleCell.class forCellReuseIdentifier:RoomGroupCallStatusBubbleCell.defaultReuseIdentifier];
[tableView registerClass:RoomDirectCallStatusCell.class forCellReuseIdentifier:RoomDirectCallStatusCell.defaultReuseIdentifier];
[tableView registerClass:RoomGroupCallStatusCell.class forCellReuseIdentifier:RoomGroupCallStatusCell.defaultReuseIdentifier];
}
- (void)registerVoiceMessageCellsForTableView:(UITableView*)tableView
{
[tableView registerClass:VoiceMessageBubbleCell.class forCellReuseIdentifier:VoiceMessageBubbleCell.defaultReuseIdentifier];
[tableView registerClass:VoiceMessageWithoutSenderInfoBubbleCell.class forCellReuseIdentifier:VoiceMessageWithoutSenderInfoBubbleCell.defaultReuseIdentifier];
[tableView registerClass:VoiceMessageWithPaginationTitleBubbleCell.class forCellReuseIdentifier:VoiceMessageWithPaginationTitleBubbleCell.defaultReuseIdentifier];
[tableView registerClass:VoiceMessagePlainCell.class forCellReuseIdentifier:VoiceMessagePlainCell.defaultReuseIdentifier];
[tableView registerClass:VoiceMessageWithoutSenderInfoPlainCell.class forCellReuseIdentifier:VoiceMessageWithoutSenderInfoPlainCell.defaultReuseIdentifier];
[tableView registerClass:VoiceMessageWithPaginationTitlePlainCell.class forCellReuseIdentifier:VoiceMessageWithPaginationTitlePlainCell.defaultReuseIdentifier];
}
- (void)registerPollCellsForTableView:(UITableView*)tableView
{
[tableView registerClass:PollBubbleCell.class forCellReuseIdentifier:PollBubbleCell.defaultReuseIdentifier];
[tableView registerClass:PollWithoutSenderInfoBubbleCell.class forCellReuseIdentifier:PollWithoutSenderInfoBubbleCell.defaultReuseIdentifier];
[tableView registerClass:PollWithPaginationTitleBubbleCell.class forCellReuseIdentifier:PollWithPaginationTitleBubbleCell.defaultReuseIdentifier];
[tableView registerClass:PollPlainCell.class forCellReuseIdentifier:PollPlainCell.defaultReuseIdentifier];
[tableView registerClass:PollWithoutSenderInfoPlainCell.class forCellReuseIdentifier:PollWithoutSenderInfoPlainCell.defaultReuseIdentifier];
[tableView registerClass:PollWithPaginationTitlePlainCell.class forCellReuseIdentifier:PollWithPaginationTitlePlainCell.defaultReuseIdentifier];
}
- (void)registerLocationCellsForTableView:(UITableView*)tableView
{
[tableView registerClass:LocationBubbleCell.class forCellReuseIdentifier:LocationBubbleCell.defaultReuseIdentifier];
[tableView registerClass:LocationWithoutSenderInfoBubbleCell.class forCellReuseIdentifier:LocationWithoutSenderInfoBubbleCell.defaultReuseIdentifier];
[tableView registerClass:LocationWithPaginationTitleBubbleCell.class forCellReuseIdentifier:LocationWithPaginationTitleBubbleCell.defaultReuseIdentifier];
[tableView registerClass:LocationPlainCell.class forCellReuseIdentifier:LocationPlainCell.defaultReuseIdentifier];
[tableView registerClass:LocationWithoutSenderInfoPlainCell.class forCellReuseIdentifier:LocationWithoutSenderInfoPlainCell.defaultReuseIdentifier];
[tableView registerClass:LocationWithPaginationTitlePlainCell.class forCellReuseIdentifier:LocationWithPaginationTitlePlainCell.defaultReuseIdentifier];
}
#pragma mark Cell class association
@ -324,7 +324,7 @@
@(RoomTimelineCellIdentifierSelectedSticker) : RoomSelectedStickerBubbleCell.class,
@(RoomTimelineCellIdentifierRoomPredecessor) : RoomPredecessorBubbleCell.class,
@(RoomTimelineCellIdentifierRoomCreationIntro) : RoomCreationIntroCell.class,
@(RoomTimelineCellIdentifierTyping) : RoomTypingBubbleCell.class,
@(RoomTimelineCellIdentifierTyping) : MessageTypingCell.class,
};
[cellClasses addEntriesFromDictionary:othersCells];
@ -474,12 +474,12 @@
- (NSDictionary<NSNumber*, Class>*)keyVerificationCellsMapping
{
return @{
@(RoomTimelineCellIdentifierKeyVerificationIncomingRequestApproval) : KeyVerificationIncomingRequestApprovalBubbleCell.class,
@(RoomTimelineCellIdentifierKeyVerificationIncomingRequestApprovalWithPaginationTitle) : KeyVerificationIncomingRequestApprovalWithPaginationTitleBubbleCell.class,
@(RoomTimelineCellIdentifierKeyVerificationRequestStatus) : KeyVerificationRequestStatusBubbleCell.class,
@(RoomTimelineCellIdentifierKeyVerificationRequestStatusWithPaginationTitle) : KeyVerificationRequestStatusWithPaginationTitleBubbleCell.class,
@(RoomTimelineCellIdentifierKeyVerificationConclusion) : KeyVerificationConclusionBubbleCell.class,
@(RoomTimelineCellIdentifierKeyVerificationConclusionWithPaginationTitle) : KeyVerificationConclusionWithPaginationTitleBubbleCell.class,
@(RoomTimelineCellIdentifierKeyVerificationIncomingRequestApproval) : KeyVerificationIncomingRequestApprovalCell.class,
@(RoomTimelineCellIdentifierKeyVerificationIncomingRequestApprovalWithPaginationTitle) : KeyVerificationIncomingRequestApprovalWithPaginationTitleCell.class,
@(RoomTimelineCellIdentifierKeyVerificationRequestStatus) : KeyVerificationRequestStatusCell.class,
@(RoomTimelineCellIdentifierKeyVerificationRequestStatusWithPaginationTitle) : KeyVerificationRequestStatusWithPaginationTitleCell.class,
@(RoomTimelineCellIdentifierKeyVerificationConclusion) : KeyVerificationConclusionCell.class,
@(RoomTimelineCellIdentifierKeyVerificationConclusionWithPaginationTitle) : KeyVerificationConclusionWithPaginationTitleCell.class,
};
}
@ -494,8 +494,8 @@
- (NSDictionary<NSNumber*, Class>*)callCellsMapping
{
return @{
@(RoomTimelineCellIdentifierDirectCallStatus) : RoomDirectCallStatusBubbleCell.class,
@(RoomTimelineCellIdentifierGroupCallStatus) : RoomGroupCallStatusBubbleCell.class,
@(RoomTimelineCellIdentifierDirectCallStatus) : RoomDirectCallStatusCell.class,
@(RoomTimelineCellIdentifierGroupCallStatus) : RoomGroupCallStatusCell.class,
};
}
@ -503,13 +503,13 @@
{
return @{
// Incoming
@(RoomTimelineCellIdentifierIncomingVoiceMessage) : VoiceMessageBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingVoiceMessageWithoutSenderInfo) : VoiceMessageWithoutSenderInfoBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingVoiceMessageWithPaginationTitle) : VoiceMessageWithPaginationTitleBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingVoiceMessage) : VoiceMessagePlainCell.class,
@(RoomTimelineCellIdentifierIncomingVoiceMessageWithoutSenderInfo) : VoiceMessageWithoutSenderInfoPlainCell.class,
@(RoomTimelineCellIdentifierIncomingVoiceMessageWithPaginationTitle) : VoiceMessageWithPaginationTitlePlainCell.class,
// Outoing
@(RoomTimelineCellIdentifierOutgoingVoiceMessage) : VoiceMessageBubbleCell.class,
@(RoomTimelineCellIdentifierOutgoingVoiceMessageWithoutSenderInfo) : VoiceMessageWithoutSenderInfoBubbleCell.class,
@(RoomTimelineCellIdentifierOutgoingVoiceMessageWithPaginationTitle) : VoiceMessageWithPaginationTitleBubbleCell.class
@(RoomTimelineCellIdentifierOutgoingVoiceMessage) : VoiceMessagePlainCell.class,
@(RoomTimelineCellIdentifierOutgoingVoiceMessageWithoutSenderInfo) : VoiceMessageWithoutSenderInfoPlainCell.class,
@(RoomTimelineCellIdentifierOutgoingVoiceMessageWithPaginationTitle) : VoiceMessageWithPaginationTitlePlainCell.class
};
}
@ -517,13 +517,13 @@
{
return @{
// Incoming
@(RoomTimelineCellIdentifierIncomingPoll) : PollBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingPollWithoutSenderInfo) : PollWithoutSenderInfoBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingPollWithPaginationTitle) : PollWithPaginationTitleBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingPoll) : PollPlainCell.class,
@(RoomTimelineCellIdentifierIncomingPollWithoutSenderInfo) : PollWithoutSenderInfoPlainCell.class,
@(RoomTimelineCellIdentifierIncomingPollWithPaginationTitle) : PollWithPaginationTitlePlainCell.class,
// Outoing
@(RoomTimelineCellIdentifierOutgoingPoll) : PollBubbleCell.class,
@(RoomTimelineCellIdentifierOutgoingPollWithoutSenderInfo) : PollWithoutSenderInfoBubbleCell.class,
@(RoomTimelineCellIdentifierOutgoingPollWithPaginationTitle) : PollWithPaginationTitleBubbleCell.class
@(RoomTimelineCellIdentifierOutgoingPoll) : PollPlainCell.class,
@(RoomTimelineCellIdentifierOutgoingPollWithoutSenderInfo) : PollWithoutSenderInfoPlainCell.class,
@(RoomTimelineCellIdentifierOutgoingPollWithPaginationTitle) : PollWithPaginationTitlePlainCell.class
};
}
@ -531,13 +531,13 @@
{
return @{
// Incoming
@(RoomTimelineCellIdentifierIncomingLocation) : LocationBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingLocationWithoutSenderInfo) : LocationWithoutSenderInfoBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingLocationWithPaginationTitle) : LocationWithPaginationTitleBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingLocation) : LocationPlainCell.class,
@(RoomTimelineCellIdentifierIncomingLocationWithoutSenderInfo) : LocationWithoutSenderInfoPlainCell.class,
@(RoomTimelineCellIdentifierIncomingLocationWithPaginationTitle) : LocationWithPaginationTitlePlainCell.class,
// Outgoing
@(RoomTimelineCellIdentifierOutgoingLocation) : LocationBubbleCell.class,
@(RoomTimelineCellIdentifierOutgoingLocationWithoutSenderInfo) : LocationWithoutSenderInfoBubbleCell.class,
@(RoomTimelineCellIdentifierOutgoingLocationWithPaginationTitle) : LocationWithPaginationTitleBubbleCell.class
@(RoomTimelineCellIdentifierOutgoingLocation) : LocationPlainCell.class,
@(RoomTimelineCellIdentifierOutgoingLocationWithoutSenderInfo) : LocationWithoutSenderInfoPlainCell.class,
@(RoomTimelineCellIdentifierOutgoingLocationWithPaginationTitle) : LocationWithPaginationTitlePlainCell.class
};
}

View file

@ -30,7 +30,7 @@ protocol RoomTimelineCellDecorator {
cellData: RoomBubbleCellData,
contentViewPositionY: CGFloat)
func addReactionView(_ reactionsView: BubbleReactionsView,
func addReactionView(_ reactionsView: RoomReactionsView,
toCell cell: MXKRoomBubbleTableViewCell,
cellData: RoomBubbleCellData,
contentViewPositionY: CGFloat,

View file

@ -1,59 +0,0 @@
/*
Copyright 2019 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
enum BubbleReactionsViewAction {
case loadData
case tapReaction(index: Int)
case addNewReaction
case tapShowAction(action: ShowAction)
case longPress
enum ShowAction {
case showAll
case showLess
}
}
enum BubbleReactionsViewState {
case loaded(reactionsViewData: [BubbleReactionViewData], showAllButtonState: ShowAllButtonState)
enum ShowAllButtonState {
case none
case showAll
case showLess
}
}
@objc protocol BubbleReactionsViewModelDelegate: AnyObject {
func bubbleReactionsViewModel(_ viewModel: BubbleReactionsViewModel, didAddReaction reactionCount: MXReactionCount, forEventId eventId: String)
func bubbleReactionsViewModel(_ viewModel: BubbleReactionsViewModel, didRemoveReaction reactionCount: MXReactionCount, forEventId eventId: String)
func bubbleReactionsViewModel(_ viewModel: BubbleReactionsViewModel, didShowAllTappedForEventId eventId: String)
func bubbleReactionsViewModel(_ viewModel: BubbleReactionsViewModel, didShowLessTappedForEventId eventId: String)
func bubbleReactionsViewModel(_ viewModel: BubbleReactionsViewModel, didLongPressForEventId eventId: String)
}
protocol BubbleReactionsViewModelViewDelegate: AnyObject {
func bubbleReactionsViewModel(_ viewModel: BubbleReactionsViewModel, didUpdateViewState viewState: BubbleReactionsViewState)
}
protocol BubbleReactionsViewModelType {
var viewModelDelegate: BubbleReactionsViewModelDelegate? { get set }
var viewDelegate: BubbleReactionsViewModelViewDelegate? { get set }
func process(viewAction: BubbleReactionsViewAction)
}

View file

@ -17,7 +17,7 @@
import UIKit
import Reusable
final class BubbleReactionActionViewCell: UICollectionViewCell, NibReusable, Themable {
final class RoomReactionActionViewCell: UICollectionViewCell, NibReusable, Themable {
// MARK: - Constants

View file

@ -1,18 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" 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="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<capability name="Safe area layout guides" minToolsVersion="9.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"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="BubbleReactionActionViewCell" customModule="Riot" customModuleProvider="target">
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="RoomReactionActionViewCell" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="66" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
@ -39,13 +37,13 @@
</view>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<constraints>
<constraint firstItem="jjn-uq-kYN" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="1" id="E5H-9a-us9"/>
<constraint firstAttribute="bottom" secondItem="jjn-uq-kYN" secondAttribute="bottom" constant="1" id="Ggm-1f-3EB"/>
<constraint firstItem="jjn-uq-kYN" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="1" id="iT6-rk-qd6"/>
<constraint firstAttribute="trailing" secondItem="jjn-uq-kYN" secondAttribute="trailing" constant="1" id="ztM-7J-Dnf"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<size key="customSize" width="443" height="170"/>
<connections>
<outlet property="actionLabel" destination="gyn-ux-gmi" id="qme-DX-UAc"/>

View file

@ -17,7 +17,7 @@
import UIKit
import Reusable
final class BubbleReactionViewCell: UICollectionViewCell, NibReusable, Themable {
final class RoomReactionViewCell: UICollectionViewCell, NibReusable, Themable {
// MARK: - Constants
@ -70,7 +70,7 @@ final class BubbleReactionViewCell: UICollectionViewCell, NibReusable, Themable
// MARK: - Public
func fill(viewData: BubbleReactionViewData) {
func fill(viewData: RoomReactionViewData) {
self.emojiLabel.text = viewData.emoji
self.countLabel.text = viewData.countString
self.isReactionSelected = viewData.isCurrentUserReacted

View file

@ -1,18 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" 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="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<capability name="Safe area layout guides" minToolsVersion="9.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"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="BubbleReactionViewCell" customModule="Riot" customModuleProvider="target">
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="RoomReactionViewCell" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="36" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
@ -53,13 +51,13 @@
</view>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<constraints>
<constraint firstItem="jjn-uq-kYN" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="1" id="E5H-9a-us9"/>
<constraint firstAttribute="bottom" secondItem="jjn-uq-kYN" secondAttribute="bottom" constant="1" id="Ggm-1f-3EB"/>
<constraint firstItem="jjn-uq-kYN" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="1" id="iT6-rk-qd6"/>
<constraint firstAttribute="trailing" secondItem="jjn-uq-kYN" secondAttribute="trailing" constant="1" id="ztM-7J-Dnf"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<size key="customSize" width="413" height="170"/>
<connections>
<outlet property="countLabel" destination="DQc-oh-Wus" id="GZt-aS-umB"/>

View file

@ -16,7 +16,7 @@
import Foundation
struct BubbleReactionViewData {
struct RoomReactionViewData {
let emoji: String
let countString: String
let isCurrentUserReacted: Bool

View file

@ -21,14 +21,14 @@ import DGCollectionViewLeftAlignFlowLayout
import UIKit
import UICollectionViewRightAlignedLayout
/// BubbleReactionsView items alignment
enum BubbleReactionsViewAlignment {
/// RoomReactionsView items alignment
enum RoomReactionsViewAlignment {
case left
case right
}
@objcMembers
final class BubbleReactionsView: UIView, NibOwnerLoadable {
final class RoomReactionsView: UIView, NibOwnerLoadable {
// MARK: - Constants
@ -45,21 +45,21 @@ final class BubbleReactionsView: UIView, NibOwnerLoadable {
// MARK: Private
private var reactionsViewData: [BubbleReactionViewData] = []
private var showAllButtonState: BubbleReactionsViewState.ShowAllButtonState = .none
private var reactionsViewData: [RoomReactionViewData] = []
private var showAllButtonState: RoomReactionsViewState.ShowAllButtonState = .none
private var theme: Theme?
// MARK: Public
// Do not use `BubbleReactionsViewModelType` here due to Objective-C incompatibily
var viewModel: BubbleReactionsViewModel? {
// Do not use `RoomReactionsViewModelType` here due to Objective-C incompatibily
var viewModel: RoomReactionsViewModel? {
didSet {
self.viewModel?.viewDelegate = self
self.viewModel?.process(viewAction: .loadData)
}
}
var alignment: BubbleReactionsViewAlignment = .left {
var alignment: RoomReactionsViewAlignment = .left {
didSet {
self.updateCollectionViewLayout(for: alignment)
}
@ -103,12 +103,12 @@ final class BubbleReactionsView: UIView, NibOwnerLoadable {
self.collectionView.dataSource = self
self.alignment = .left
self.collectionView.register(cellType: BubbleReactionViewCell.self)
self.collectionView.register(cellType: BubbleReactionActionViewCell.self)
self.collectionView.register(cellType: RoomReactionViewCell.self)
self.collectionView.register(cellType: RoomReactionActionViewCell.self)
self.collectionView.reloadData()
}
private func updateCollectionViewLayout(for alignment: BubbleReactionsViewAlignment) {
private func updateCollectionViewLayout(for alignment: RoomReactionsViewAlignment) {
let collectionViewLayout = self.collectionViewLayout(for: alignment)
@ -124,7 +124,7 @@ final class BubbleReactionsView: UIView, NibOwnerLoadable {
self.collectionView.collectionViewLayout.invalidateLayout()
}
private func collectionViewLayout(for alignment: BubbleReactionsViewAlignment) -> UICollectionViewLayout {
private func collectionViewLayout(for alignment: RoomReactionsViewAlignment) -> UICollectionViewLayout {
let collectionViewLayout: UICollectionViewLayout
@ -151,7 +151,7 @@ final class BubbleReactionsView: UIView, NibOwnerLoadable {
self.viewModel?.process(viewAction: .longPress)
}
private func fill(reactionsViewData: [BubbleReactionViewData], showAllButtonState: BubbleReactionsViewState.ShowAllButtonState) {
private func fill(reactionsViewData: [RoomReactionViewData], showAllButtonState: RoomReactionsViewState.ShowAllButtonState) {
self.reactionsViewData = reactionsViewData
self.showAllButtonState = showAllButtonState
self.collectionView.reloadData()
@ -174,7 +174,7 @@ final class BubbleReactionsView: UIView, NibOwnerLoadable {
}
// MARK: - UICollectionViewDataSource
extension BubbleReactionsView: UICollectionViewDataSource {
extension RoomReactionsView: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// "Show all" or "Show less" is a cell in the same section as reactions cells
@ -185,7 +185,7 @@ extension BubbleReactionsView: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.row < self.reactionsViewData.count {
let cell: BubbleReactionViewCell = collectionView.dequeueReusableCell(for: indexPath)
let cell: RoomReactionViewCell = collectionView.dequeueReusableCell(for: indexPath)
if let theme = self.theme {
cell.update(theme: theme)
@ -196,7 +196,7 @@ extension BubbleReactionsView: UICollectionViewDataSource {
return cell
} else {
let cell: BubbleReactionActionViewCell = collectionView.dequeueReusableCell(for: indexPath)
let cell: RoomReactionActionViewCell = collectionView.dequeueReusableCell(for: indexPath)
if let theme = self.theme {
cell.update(theme: theme)
@ -211,7 +211,7 @@ extension BubbleReactionsView: UICollectionViewDataSource {
}
// MARK: - UICollectionViewDelegate
extension BubbleReactionsView: UICollectionViewDelegate {
extension RoomReactionsView: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if indexPath.row < self.reactionsViewData.count {
@ -229,10 +229,10 @@ extension BubbleReactionsView: UICollectionViewDelegate {
}
}
// MARK: - BubbleReactionsViewModelViewDelegate
extension BubbleReactionsView: BubbleReactionsViewModelViewDelegate {
// MARK: - RoomReactionsViewModelViewDelegate
extension RoomReactionsView: RoomReactionsViewModelViewDelegate {
func bubbleReactionsViewModel(_ viewModel: BubbleReactionsViewModel, didUpdateViewState viewState: BubbleReactionsViewState) {
func roomReactionsViewModel(_ viewModel: RoomReactionsViewModel, didUpdateViewState viewState: RoomReactionsViewState) {
switch viewState {
case .loaded(reactionsViewData: let reactionsViewData, showAllButtonState: let showAllButtonState):
self.fill(reactionsViewData: reactionsViewData, showAllButtonState: showAllButtonState)

View file

@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BubbleReactionsView" customModule="Riot" customModuleProvider="target">
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RoomReactionsView" customModule="Riot" customModuleProvider="target">
<connections>
<outlet property="collectionView" destination="uTe-bw-bWE" id="EGc-ca-YSM"/>
</connections>

View file

@ -16,7 +16,7 @@
import Foundation
@objc final class BubbleReactionsViewModel: NSObject, BubbleReactionsViewModelType {
@objc final class RoomReactionsViewModel: NSObject, RoomReactionsViewModelType {
// MARK: - Constants
@ -34,8 +34,8 @@ import Foundation
// MARK: Public
@objc weak var viewModelDelegate: BubbleReactionsViewModelDelegate?
weak var viewDelegate: BubbleReactionsViewModelViewDelegate?
@objc weak var viewModelDelegate: RoomReactionsViewModelDelegate?
weak var viewDelegate: RoomReactionsViewModelViewDelegate?
// MARK: - Setup
@ -49,7 +49,7 @@ import Foundation
// MARK: - Public
func process(viewAction: BubbleReactionsViewAction) {
func process(viewAction: RoomReactionsViewAction) {
switch viewAction {
case .loadData:
self.loadData()
@ -59,24 +59,24 @@ import Foundation
}
let reactionCount = self.aggregatedReactions.reactions[index]
if reactionCount.myUserHasReacted {
self.viewModelDelegate?.bubbleReactionsViewModel(self, didRemoveReaction: reactionCount, forEventId: self.eventId)
self.viewModelDelegate?.roomReactionsViewModel(self, didRemoveReaction: reactionCount, forEventId: self.eventId)
} else {
self.viewModelDelegate?.bubbleReactionsViewModel(self, didAddReaction: reactionCount, forEventId: self.eventId)
self.viewModelDelegate?.roomReactionsViewModel(self, didAddReaction: reactionCount, forEventId: self.eventId)
}
case .addNewReaction:
break
case .tapShowAction(.showAll):
self.viewModelDelegate?.bubbleReactionsViewModel(self, didShowAllTappedForEventId: self.eventId)
self.viewModelDelegate?.roomReactionsViewModel(self, didShowAllTappedForEventId: self.eventId)
case .tapShowAction(.showLess):
self.viewModelDelegate?.bubbleReactionsViewModel(self, didShowLessTappedForEventId: self.eventId)
self.viewModelDelegate?.roomReactionsViewModel(self, didShowLessTappedForEventId: self.eventId)
case .longPress:
self.viewModelDelegate?.bubbleReactionsViewModel(self, didLongPressForEventId: self.eventId)
self.viewModelDelegate?.roomReactionsViewModel(self, didLongPressForEventId: self.eventId)
}
}
func loadData() {
var reactions = self.aggregatedReactions.reactions
var showAllButtonState: BubbleReactionsViewState.ShowAllButtonState = .none
var showAllButtonState: RoomReactionsViewState.ShowAllButtonState = .none
// Limit displayed reactions if required
if reactions.count > Constants.maxItemsWhenLimited {
@ -88,11 +88,11 @@ import Foundation
}
}
let reactionsViewData = reactions.map { (reactionCount) -> BubbleReactionViewData in
return BubbleReactionViewData(emoji: reactionCount.reaction, countString: "\(reactionCount.count)", isCurrentUserReacted: reactionCount.myUserHasReacted)
let reactionsViewData = reactions.map { (reactionCount) -> RoomReactionViewData in
return RoomReactionViewData(emoji: reactionCount.reaction, countString: "\(reactionCount.count)", isCurrentUserReacted: reactionCount.myUserHasReacted)
}
self.viewDelegate?.bubbleReactionsViewModel(self, didUpdateViewState: .loaded(reactionsViewData: reactionsViewData, showAllButtonState: showAllButtonState))
self.viewDelegate?.roomReactionsViewModel(self, didUpdateViewState: .loaded(reactionsViewData: reactionsViewData, showAllButtonState: showAllButtonState))
}
// MARK: - Hashable

View file

@ -16,11 +16,11 @@ limitations under the License.
import Foundation
/// `BubbleReactionsViewModelBuilder` enables to build a BubbleReactionsViewModel for a given `RoomBubbleCellData` and `MXKRoomBubbleComponent` index.
/// `RoomReactionsViewModelBuilder` enables to build a RoomReactionsViewModel for a given `RoomBubbleCellData` and `MXKRoomBubbleComponent` index.
@objcMembers
final class BubbleReactionsViewModelBuilder: NSObject {
final class RoomReactionsViewModelBuilder: NSObject {
func buildForFirstVisibleComponent(of roomBubbleCellData: RoomBubbleCellData) -> BubbleReactionsViewModel? {
func buildForFirstVisibleComponent(of roomBubbleCellData: RoomBubbleCellData) -> RoomReactionsViewModel? {
guard roomBubbleCellData.firstVisibleComponentIndex() != NSNotFound else {
return nil
@ -29,7 +29,7 @@ final class BubbleReactionsViewModelBuilder: NSObject {
return self.build(from: roomBubbleCellData, componentIndex: roomBubbleCellData.firstVisibleComponentIndex())
}
func build(from roomBubbleCellData: RoomBubbleCellData, componentIndex: Int) -> BubbleReactionsViewModel? {
func build(from roomBubbleCellData: RoomBubbleCellData, componentIndex: Int) -> RoomReactionsViewModel? {
let isCollapsableCellCollapsed = roomBubbleCellData.collapsable && roomBubbleCellData.collapsed
@ -53,7 +53,7 @@ final class BubbleReactionsViewModelBuilder: NSObject {
}
let showAllReactions = roomBubbleCellData.showAllReactions(forEvent: componentEventId)
return BubbleReactionsViewModel(aggregatedReactions: aggregatedReactions,
return RoomReactionsViewModel(aggregatedReactions: aggregatedReactions,
eventId: componentEventId,
showAll: showAllReactions)
}

View file

@ -0,0 +1,59 @@
/*
Copyright 2019 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
enum RoomReactionsViewAction {
case loadData
case tapReaction(index: Int)
case addNewReaction
case tapShowAction(action: ShowAction)
case longPress
enum ShowAction {
case showAll
case showLess
}
}
enum RoomReactionsViewState {
case loaded(reactionsViewData: [RoomReactionViewData], showAllButtonState: ShowAllButtonState)
enum ShowAllButtonState {
case none
case showAll
case showLess
}
}
@objc protocol RoomReactionsViewModelDelegate: AnyObject {
func roomReactionsViewModel(_ viewModel: RoomReactionsViewModel, didAddReaction reactionCount: MXReactionCount, forEventId eventId: String)
func roomReactionsViewModel(_ viewModel: RoomReactionsViewModel, didRemoveReaction reactionCount: MXReactionCount, forEventId eventId: String)
func roomReactionsViewModel(_ viewModel: RoomReactionsViewModel, didShowAllTappedForEventId eventId: String)
func roomReactionsViewModel(_ viewModel: RoomReactionsViewModel, didShowLessTappedForEventId eventId: String)
func roomReactionsViewModel(_ viewModel: RoomReactionsViewModel, didLongPressForEventId eventId: String)
}
protocol RoomReactionsViewModelViewDelegate: AnyObject {
func roomReactionsViewModel(_ viewModel: RoomReactionsViewModel, didUpdateViewState viewState: RoomReactionsViewState)
}
protocol RoomReactionsViewModelType {
var viewModelDelegate: RoomReactionsViewModelDelegate? { get set }
var viewDelegate: RoomReactionsViewModelViewDelegate? { get set }
func process(viewAction: RoomReactionsViewAction)
}

View file

@ -17,15 +17,15 @@ limitations under the License.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@class BubbleReactionsViewModel;
@class RoomReactionsViewModel;
NS_ASSUME_NONNULL_BEGIN
// `BubbleReactionsViewSizer` allows to determine reactions view height for a given viewModel and width.
@interface BubbleReactionsViewSizer : NSObject
// `RoomReactionsViewSizer` allows to determine reactions view height for a given viewModel and width.
@interface RoomReactionsViewSizer : NSObject
// Use Objective-C as workaround as there is an issue affecting UICollectionView sizing. See https://developer.apple.com/forums/thread/105523 for more information.
- (CGFloat)heightForViewModel:(BubbleReactionsViewModel*)viewModel
- (CGFloat)heightForViewModel:(RoomReactionsViewModel*)viewModel
fittingWidth:(CGFloat)fittingWidth;
@end

View file

@ -14,33 +14,33 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
#import "BubbleReactionsViewSizer.h"
#import "RoomReactionsViewSizer.h"
#import <MatrixSDK/MatrixSDK.h>
#import "GeneratedInterface-Swift.h"
@implementation BubbleReactionsViewSizer
@implementation RoomReactionsViewSizer
- (CGFloat)heightForViewModel:(BubbleReactionsViewModel*)viewModel
- (CGFloat)heightForViewModel:(RoomReactionsViewModel*)viewModel
fittingWidth:(CGFloat)fittingWidth
{
CGSize fittingSize = UILayoutFittingCompressedSize;
fittingSize.width = fittingWidth;
static BubbleReactionsView *bubbleReactionsView;
static RoomReactionsView *reactionsView;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
bubbleReactionsView = [BubbleReactionsView new];
reactionsView = [RoomReactionsView new];
});
bubbleReactionsView.frame = CGRectMake(0, 0, fittingWidth, 1.0);
bubbleReactionsView.viewModel = viewModel;
[bubbleReactionsView setNeedsLayout];
[bubbleReactionsView layoutIfNeeded];
reactionsView.frame = CGRectMake(0, 0, fittingWidth, 1.0);
reactionsView.viewModel = viewModel;
[reactionsView setNeedsLayout];
[reactionsView layoutIfNeeded];
return [bubbleReactionsView systemLayoutSizeFittingSize:fittingSize withHorizontalFittingPriority:UILayoutPriorityRequired verticalFittingPriority:UILayoutPriorityFittingSizeLevel].height;
return [reactionsView systemLayoutSizeFittingSize:fittingSize withHorizontalFittingPriority:UILayoutPriorityRequired verticalFittingPriority:UILayoutPriorityFittingSizeLevel].height;
}
@end

View file

@ -18,7 +18,7 @@
#import "RoomBubbleCellData.h"
#import "MXKRoomBubbleTableViewCell+Riot.h"
#import "UserEncryptionTrustLevel.h"
#import "BubbleReactionsViewSizer.h"
#import "RoomReactionsViewSizer.h"
#import "RoomEncryptedDataBubbleCell.h"
#import "LegacyAppDelegate.h"
#import "DirectoryServerPickerViewController.h"