Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Reactions component #6244

Merged
merged 9 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "reactions_more_action.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Riot/Assets/en.lproj/Untranslated.strings
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@
"leave_space_selection_title" = "SELECT ROOMS";
"leave_space_selection_all_rooms" = "Select all rooms";
"leave_space_selection_no_rooms" = "Select no rooms";


// MARK: Reactions

"room_event_action_reaction_more" = "%@ more";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to check, strings added to Untranslated.strings will never be added to Weblate, so can't be translated by the community. Is this the intention here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all! I thought we should put all new untranslated strings in this file. Thanks for the heads up :)

7 changes: 7 additions & 0 deletions Riot/Categories/MXKRoomBubbleTableViewCell+Riot.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ extern NSString *const kMXKRoomBubbleCellRiotEditButtonPressed;
*/
extern NSString *const kMXKRoomBubbleCellTapOnReceiptsContainer;

/**
Action identifier used when the user tapped on the add reaction button.

The 'userInfo' dictionary contains a 'NSString' object under the 'kMXKRoomBubbleCellEventIdKey' key, representing the event id of the event associated with the reactions.
*/
extern NSString *const kMXKRoomBubbleCellTapOnAddReaction;

/**
Action identifier used when the user perform a long press on reactions view.

Expand Down
1 change: 1 addition & 0 deletions Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

NSString *const kMXKRoomBubbleCellRiotEditButtonPressed = @"kMXKRoomBubbleCellRiotEditButtonPressed";
NSString *const kMXKRoomBubbleCellTapOnReceiptsContainer = @"kMXKRoomBubbleCellTapOnReceiptsContainer";
NSString *const kMXKRoomBubbleCellTapOnAddReaction = @"kMXKRoomBubbleCellTapOnAddReaction";
NSString *const kMXKRoomBubbleCellLongPressOnReactionView = @"kMXKRoomBubbleCellLongPressOnReactionView";
NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestAcceptPressed = @"kMXKRoomBubbleCellKeyVerificationAcceptPressed";
NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed = @"kMXKRoomBubbleCellKeyVerificationDeclinePressed";
Expand Down
1 change: 1 addition & 0 deletions Riot/Generated/Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ internal class Asset: NSObject {
internal static let modIcon = ImageAsset(name: "mod_icon")
internal static let moreReactions = ImageAsset(name: "more_reactions")
internal static let notifications = ImageAsset(name: "notifications")
internal static let reactionsMoreAction = ImageAsset(name: "reactions_more_action")
internal static let roomAccessInfoHeaderIcon = ImageAsset(name: "room_access_info_header_icon")
internal static let scrollup = ImageAsset(name: "scrollup")
internal static let roomsEmptyScreenArtwork = ImageAsset(name: "rooms_empty_screen_artwork")
Expand Down
4 changes: 4 additions & 0 deletions Riot/Generated/UntranslatedStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ public extension VectorL10n {
static var leaveSpaceSelectionTitle: String {
return VectorL10n.tr("Untranslated", "leave_space_selection_title")
}
/// %@ more
static func roomEventActionReactionMore(_ p1: String) -> String {
return VectorL10n.tr("Untranslated", "room_event_action_reaction_more", p1)
}
/// This feature isn't available here. For now, you can do this with %@ on your computer.
static func spacesFeatureNotAvailable(_ p1: String) -> String {
return VectorL10n.tr("Untranslated", "spaces_feature_not_available", p1)
Expand Down
5 changes: 5 additions & 0 deletions Riot/Modules/Room/DataSources/RoomDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,11 @@ - (void)roomReactionsViewModel:(RoomReactionsViewModel *)viewModel didShowLessTa
[self setShowAllReactions:NO forEvent:eventId];
}

- (void)roomReactionsViewModel:(RoomReactionsViewModel *)viewModel didTapAddReactionForEventId:(NSString * _Nonnull)eventId
{
[self.delegate dataSource:self didRecognizeAction:kMXKRoomBubbleCellTapOnAddReaction inCell:nil userInfo:@{ kMXKRoomBubbleCellEventIdKey: eventId }];
}

- (void)setShowAllReactions:(BOOL)showAllReactions forEvent:(NSString*)eventId
{
id<MXKRoomBubbleCellDataStoring> cellData = [self cellDataOfEventWithEventId:eventId];
Expand Down
65 changes: 39 additions & 26 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,35 @@ - (void)updateTopBanners
[self updateLiveLocationBannerViewVisibility];
}

- (void)showEmojiPickerForEventId:(NSString *)eventId
{
EmojiPickerCoordinatorBridgePresenter *emojiPickerCoordinatorBridgePresenter = [[EmojiPickerCoordinatorBridgePresenter alloc] initWithSession:self.mainSession roomId:self.roomDataSource.roomId eventId:eventId];
emojiPickerCoordinatorBridgePresenter.delegate = self;

NSInteger cellRow = [self.roomDataSource indexOfCellDataWithEventId:eventId];

UIView *sourceView;
CGRect sourceRect = CGRectNull;

if (cellRow >= 0)
{
NSIndexPath *cellIndexPath = [NSIndexPath indexPathForRow:cellRow inSection:0];
UITableViewCell *cell = [self.bubblesTableView cellForRowAtIndexPath:cellIndexPath];
sourceView = cell;

if ([cell isKindOfClass:[MXKRoomBubbleTableViewCell class]])
{
MXKRoomBubbleTableViewCell *roomBubbleTableViewCell = (MXKRoomBubbleTableViewCell*)cell;
NSInteger bubbleComponentIndex = [roomBubbleTableViewCell.bubbleData bubbleComponentIndexForEventId:eventId];
sourceRect = [roomBubbleTableViewCell componentFrameInContentViewForIndex:bubbleComponentIndex];
}

}

[emojiPickerCoordinatorBridgePresenter presentFrom:self sourceView:sourceView sourceRect:sourceRect animated:YES];
self.emojiPickerCoordinatorBridgePresenter = emojiPickerCoordinatorBridgePresenter;
}

#pragma mark - Jitsi

- (void)showJitsiCallWithWidget:(Widget*)widget
Expand Down Expand Up @@ -3382,6 +3411,14 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac
[self showReactionHistoryForEventId:tappedEventId animated:YES];
}
}
else if ([actionIdentifier isEqualToString:kMXKRoomBubbleCellTapOnAddReaction])
{
NSString *tappedEventId = userInfo[kMXKRoomBubbleCellEventIdKey];
if (tappedEventId)
{
[self showEmojiPickerForEventId:tappedEventId];
}
}
else if ([actionIdentifier isEqualToString:RoomDirectCallStatusCell.callBackAction])
{
MXEvent *callInviteEvent = userInfo[kMXKRoomBubbleCellEventKey];
Expand Down Expand Up @@ -7125,32 +7162,8 @@ - (void)reactionsMenuViewModel:(ReactionsMenuViewModel *)viewModel didRemoveReac
- (void)reactionsMenuViewModelDidTapMoreReactions:(ReactionsMenuViewModel *)viewModel forEventId:(NSString *)eventId
{
[self hideContextualMenuAnimated:YES];

EmojiPickerCoordinatorBridgePresenter *emojiPickerCoordinatorBridgePresenter = [[EmojiPickerCoordinatorBridgePresenter alloc] initWithSession:self.mainSession roomId:self.roomDataSource.roomId eventId:eventId];
emojiPickerCoordinatorBridgePresenter.delegate = self;

NSInteger cellRow = [self.roomDataSource indexOfCellDataWithEventId:eventId];

UIView *sourceView;
CGRect sourceRect = CGRectNull;

if (cellRow >= 0)
{
NSIndexPath *cellIndexPath = [NSIndexPath indexPathForRow:cellRow inSection:0];
UITableViewCell *cell = [self.bubblesTableView cellForRowAtIndexPath:cellIndexPath];
sourceView = cell;

if ([cell isKindOfClass:[MXKRoomBubbleTableViewCell class]])
{
MXKRoomBubbleTableViewCell *roomBubbleTableViewCell = (MXKRoomBubbleTableViewCell*)cell;
NSInteger bubbleComponentIndex = [roomBubbleTableViewCell.bubbleData bubbleComponentIndexForEventId:eventId];
sourceRect = [roomBubbleTableViewCell componentFrameInContentViewForIndex:bubbleComponentIndex];
}

}

[emojiPickerCoordinatorBridgePresenter presentFrom:self sourceView:sourceView sourceRect:sourceRect animated:YES];
self.emojiPickerCoordinatorBridgePresenter = emojiPickerCoordinatorBridgePresenter;

[self showEmojiPickerForEventId:eventId];
}

#pragma mark -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class RoomReactionActionViewCell: UICollectionViewCell, NibReusable, Thema

// MARK: Outlets

@IBOutlet private weak var reactionBackgroundView: UIView!
@IBOutlet private weak var actionLabel: UILabel!

// MARK: Private
Expand All @@ -33,6 +34,19 @@ final class RoomReactionActionViewCell: UICollectionViewCell, NibReusable, Thema

// MARK: Public

override func awakeFromNib() {
super.awakeFromNib()
// Initialization code

self.reactionBackgroundView.layer.masksToBounds = true
}

override func layoutSubviews() {
super.layoutSubviews()

self.reactionBackgroundView.layer.cornerRadius = self.reactionBackgroundView.bounds.midY
}

// MARK: - Life cycle

override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
Expand All @@ -54,6 +68,14 @@ final class RoomReactionActionViewCell: UICollectionViewCell, NibReusable, Thema
self.updateViews()
}

func fill(actionIcon: UIImage) {
let attachment = NSTextAttachment()
attachment.image = actionIcon.vc_resized(with: CGSize(width: self.actionLabel.bounds.size.height, height: self.actionLabel.bounds.size.height))?.withRenderingMode(.alwaysTemplate)

self.actionLabel.attributedText = NSAttributedString(attachment: attachment)
self.updateViews()
}

func update(theme: Theme) {
self.theme = theme
self.updateViews()
Expand All @@ -62,6 +84,9 @@ final class RoomReactionActionViewCell: UICollectionViewCell, NibReusable, Thema
// MARK: - Private

private func updateViews() {
self.actionLabel.textColor = self.theme?.tintColor
self.actionLabel.textColor = self.theme?.textSecondaryColor

self.reactionBackgroundView.layer.borderWidth = 0.0
self.reactionBackgroundView.backgroundColor = self.theme?.headerBackgroundColor
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" 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="19519"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<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="RoomReactionActionViewCell" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="66" height="22"/>
<rect key="frame" x="0.0" y="0.0" width="101" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="66" height="22"/>
<rect key="frame" x="0.0" y="0.0" width="101" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jjn-uq-kYN">
<rect key="frame" x="1" y="1" width="64" height="20"/>
<rect key="frame" x="1" y="1" width="99" height="20"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" text="Show all" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gyn-ux-gmi">
<rect key="frame" x="6" y="4" width="52" height="12"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" text="Show all" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gyn-ux-gmi">
<rect key="frame" x="6" y="4" width="87" height="12"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="gyn-ux-gmi" firstAttribute="leading" secondItem="jjn-uq-kYN" secondAttribute="leading" constant="6" id="7hb-HC-Usg"/>
<constraint firstAttribute="trailing" secondItem="gyn-ux-gmi" secondAttribute="trailing" constant="6" id="HAk-8U-Qky"/>
<constraint firstItem="gyn-ux-gmi" firstAttribute="leading" secondItem="jjn-uq-kYN" secondAttribute="leading" constant="6" id="OZ2-Xd-9f3"/>
<constraint firstItem="gyn-ux-gmi" firstAttribute="top" secondItem="jjn-uq-kYN" secondAttribute="top" constant="4" id="et3-mn-8dh"/>
<constraint firstAttribute="bottom" secondItem="gyn-ux-gmi" secondAttribute="bottom" constant="4" id="thv-mo-0kv"/>
</constraints>
Expand All @@ -44,11 +44,12 @@
<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>
<size key="customSize" width="443" height="170"/>
<size key="customSize" width="478" height="170"/>
<connections>
<outlet property="actionLabel" destination="gyn-ux-gmi" id="qme-DX-UAc"/>
<outlet property="reactionBackgroundView" destination="jjn-uq-kYN" id="vKf-Un-6PZ"/>
</connections>
<point key="canvasLocation" x="-459.4202898550725" y="-207.58928571428569"/>
<point key="canvasLocation" x="-431.15942028985512" y="-207.58928571428569"/>
</collectionViewCell>
</objects>
</document>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" 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="19519"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down
Loading