Handle key verification cells data filling.

This commit is contained in:
SBiOSoftWhare
2020-01-14 20:14:17 +01:00
parent 332f25ff9b
commit 60d8c8f5c7
5 changed files with 181 additions and 88 deletions
@@ -23,7 +23,7 @@ final class KeyVerificationCellInnerContentView: UIView, NibLoadable {
private enum Constants {
static let cornerRadius: CGFloat = 8.0
static let buttonBackgroundColorAlpha: CGFloat = 0.8
static let buttonBackgroundColorAlpha: CGFloat = 0.2
static let buttonCornerRadius: CGFloat = 6.0
}
@@ -34,10 +34,11 @@ final class KeyVerificationCellInnerContentView: UIView, NibLoadable {
@IBOutlet private weak var badgeImageView: UIImageView!
@IBOutlet private weak var titleLabel: UILabel!
@IBOutlet private weak var userInformationsLabel: UILabel!
@IBOutlet private weak var otherUserInformationLabel: UILabel!
@IBOutlet private weak var requestStatusLabel: UILabel!
@IBOutlet private weak var buttonsContainerView: UIView!
@IBOutlet private weak var acceptButton: UIButton!
@IBOutlet private weak var declineButton: UIButton!
@@ -48,8 +49,7 @@ final class KeyVerificationCellInnerContentView: UIView, NibLoadable {
return self.acceptButton.isHidden && self.declineButton.isHidden
}
set {
self.acceptButton.isHidden = newValue
self.declineButton.isHidden = newValue
self.buttonsContainerView.isHidden = newValue
}
}
@@ -80,6 +80,10 @@ final class KeyVerificationCellInnerContentView: UIView, NibLoadable {
}
}
var otherUserInfo: String? {
return self.otherUserInformationLabel.text
}
var requestStatusText: String? {
get {
return self.requestStatusLabel.text
@@ -106,6 +110,21 @@ final class KeyVerificationCellInnerContentView: UIView, NibLoadable {
super.awakeFromNib()
self.layer.masksToBounds = true
self.acceptButton.layer.masksToBounds = true
self.acceptButton.titleLabel?.adjustsFontSizeToFitWidth = true
self.acceptButton.titleLabel?.minimumScaleFactor = 0.5
self.acceptButton.titleLabel?.baselineAdjustment = .alignCenters
self.acceptButton.setTitle(VectorL10n.keyVerificationTileRequestIncomingApprovalAccept, for: .normal)
self.declineButton.layer.masksToBounds = true
self.declineButton.titleLabel?.adjustsFontSizeToFitWidth = true
self.declineButton.titleLabel?.minimumScaleFactor = 0.5
self.declineButton.titleLabel?.baselineAdjustment = .alignCenters
self.declineButton.setTitle(VectorL10n.keyVerificationTileRequestIncomingApprovalDecline, for: .normal)
}
override func layoutSubviews() {
@@ -124,14 +143,14 @@ final class KeyVerificationCellInnerContentView: UIView, NibLoadable {
func update(theme: Theme) {
self.backgroundColor = theme.headerBackgroundColor
self.titleLabel.textColor = theme.textPrimaryColor
self.userInformationsLabel.textColor = theme.textSecondaryColor
self.otherUserInformationLabel.textColor = theme.textSecondaryColor
self.acceptButton.vc_setBackgroundColor(theme.tintColor.withAlphaComponent(Constants.buttonBackgroundColorAlpha), for: .normal)
self.declineButton.vc_setBackgroundColor(theme.noticeColor.withAlphaComponent(Constants.buttonBackgroundColorAlpha), for: .normal)
}
func updateSenderInfo(with userId: String, userDisplayName: String?) {
self.userInformationsLabel.text = self.buildUserInfoText(with: userId, userDisplayName: userDisplayName)
self.otherUserInformationLabel.text = self.buildUserInfoText(with: userId, userDisplayName: userDisplayName)
}
// MARK: - Private
@@ -149,6 +168,8 @@ final class KeyVerificationCellInnerContentView: UIView, NibLoadable {
return userInfoText
}
// MARK: - Action
@IBAction private func declineButtonAction(_ sender: Any) {
self.declineActionHandler?()
}
@@ -1,10 +1,6 @@
<?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>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@@ -12,64 +8,85 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="KeyVerificationCellInnerContentView" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="313" height="159"/>
<rect key="frame" x="0.0" y="0.0" width="313" height="133"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="17" translatesAutoresizingMaskIntoConstraints="NO" id="2Sr-GM-aAU">
<rect key="frame" x="10" y="10" width="293" height="139"/>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="2Sr-GM-aAU">
<rect key="frame" x="10" y="10" width="293" height="113"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="5gD-pX-GFz">
<rect key="frame" x="70" y="0.0" width="153.5" height="18"/>
<rect key="frame" x="70" y="0.0" width="153.5" height="16"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="encryption_normal" translatesAutoresizingMaskIntoConstraints="NO" id="EHJ-3L-OPJ">
<rect key="frame" x="0.0" y="0.0" width="16" height="18"/>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" image="encryption_normal" translatesAutoresizingMaskIntoConstraints="NO" id="EHJ-3L-OPJ">
<rect key="frame" x="0.0" y="0.0" width="16" height="16"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Verification request" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BOd-4B-LQX">
<rect key="frame" x="20" y="0.0" width="133.5" height="18"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Verification request" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BOd-4B-LQX">
<rect key="frame" x="20" y="0.0" width="133.5" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="User (@user:matrix.org)" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e1n-WP-GTb">
<rect key="frame" x="83.5" y="35" width="126" height="13.5"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalCompressionResistancePriority="751" text="User (@user:matrix.org)" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e1n-WP-GTb">
<rect key="frame" x="83.5" y="26" width="126" height="13.5"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" red="0.1803921568627451" green="0.18431372549019609" blue="0.19607843137254902" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Waiting..." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e6I-aZ-RRO">
<rect key="frame" x="118" y="65.5" width="57" height="16"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Waiting..." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e6I-aZ-RRO">
<rect key="frame" x="118" y="49.5" width="57" height="13.5"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="0.38039215686274508" green="0.4392156862745098" blue="0.54509803921568623" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" alignment="center" spacing="30" translatesAutoresizingMaskIntoConstraints="NO" id="WxG-vh-Bn0">
<rect key="frame" x="44.5" y="98.5" width="204" height="40.5"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5Tr-gP-gPB">
<rect key="frame" x="0.0" y="73" width="293" height="40"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="atD-LF-sGH">
<rect key="frame" x="0.0" y="11.5" width="105" height="18"/>
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
<state key="normal" title="Decline (60)">
<color key="titleColor" red="1" green="0.29411764705882354" blue="0.33333333333333331" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="declineButtonAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="dS6-Xr-6jZ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="irs-8W-qcs">
<rect key="frame" x="135" y="11.5" width="69" height="18"/>
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
<state key="normal" title="Accept">
<color key="titleColor" red="0.011764705882352941" green="0.70196078431372544" blue="0.50588235294117645" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="acceptButtonAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="IQ6-be-vJt"/>
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="WxG-vh-Bn0">
<rect key="frame" x="71" y="0.0" width="151" height="40"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="atD-LF-sGH">
<rect key="frame" x="0.0" y="0.0" width="72" height="40"/>
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
<state key="normal" title="Decline">
<color key="titleColor" red="1" green="0.29411764705882354" blue="0.33333333333333331" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="declineButtonAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="dS6-Xr-6jZ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="irs-8W-qcs">
<rect key="frame" x="82" y="0.0" width="69" height="40"/>
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
<state key="normal" title="Accept">
<color key="titleColor" red="0.011764705882352941" green="0.70196078431372544" blue="0.50588235294117645" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="acceptButtonAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="IQ6-be-vJt"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="atD-LF-sGH" firstAttribute="height" secondItem="WxG-vh-Bn0" secondAttribute="height" priority="999" id="3sT-HV-Os0"/>
<constraint firstItem="irs-8W-qcs" firstAttribute="height" secondItem="WxG-vh-Bn0" secondAttribute="height" priority="999" id="CfM-Vc-MQ2"/>
</constraints>
</stackView>
</subviews>
</stackView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="WxG-vh-Bn0" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="5Tr-gP-gPB" secondAttribute="leading" id="4al-oB-NpF"/>
<constraint firstAttribute="bottom" secondItem="WxG-vh-Bn0" secondAttribute="bottom" id="rCo-gP-UF5"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="WxG-vh-Bn0" secondAttribute="trailing" id="u47-KK-aKk"/>
<constraint firstAttribute="height" priority="999" constant="40" id="ujN-jh-fde"/>
<constraint firstItem="WxG-vh-Bn0" firstAttribute="top" secondItem="5Tr-gP-gPB" secondAttribute="top" id="wNH-CW-iLB"/>
<constraint firstItem="WxG-vh-Bn0" firstAttribute="centerX" secondItem="5Tr-gP-gPB" secondAttribute="centerX" id="yWq-qo-MY7"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="5Tr-gP-gPB" firstAttribute="width" secondItem="2Sr-GM-aAU" secondAttribute="width" id="VJx-xp-NZE"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" red="0.95294117647058818" green="0.97254901960784312" blue="0.99215686274509807" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -85,12 +102,13 @@
<connections>
<outlet property="acceptButton" destination="irs-8W-qcs" id="LKq-qE-bbg"/>
<outlet property="badgeImageView" destination="EHJ-3L-OPJ" id="eNW-bg-eYy"/>
<outlet property="buttonsContainerView" destination="5Tr-gP-gPB" id="aqy-vT-mu3"/>
<outlet property="declineButton" destination="atD-LF-sGH" id="CfI-FW-ySy"/>
<outlet property="otherUserInformationLabel" destination="e1n-WP-GTb" id="jhY-gH-QnO"/>
<outlet property="requestStatusLabel" destination="e6I-aZ-RRO" id="zQf-qy-3Rq"/>
<outlet property="titleLabel" destination="BOd-4B-LQX" id="4sw-3J-faF"/>
<outlet property="userInformationsLabel" destination="e1n-WP-GTb" id="jhY-gH-QnO"/>
</connections>
<point key="canvasLocation" x="-408" y="-225"/>
<point key="canvasLocation" x="-828.26086956521749" y="-386.04910714285711"/>
</view>
</objects>
<resources>
@@ -17,8 +17,8 @@
import UIKit
@objcMembers
final class KeyVerificationConclusionBubbleCell: KeyVerificationBaseBubbleCell {
class KeyVerificationConclusionBubbleCell: KeyVerificationBaseBubbleCell {
// MARK: - Constants
private enum Sizing {
@@ -47,7 +47,7 @@ final class KeyVerificationConclusionBubbleCell: KeyVerificationBaseBubbleCell {
super.render(cellData)
guard let keyVerificationCellInnerContentView = self.keyVerificationCellInnerContentView,
let bubbleData = self.bubbleData,
let bubbleData = self.bubbleData as? RoomBubbleCellData,
let viewData = self.viewData(from: bubbleData) else {
NSLog("[KeyVerificationConclusionBubbleCell] Fail to render \(String(describing: cellData))")
return
@@ -58,37 +58,52 @@ final class KeyVerificationConclusionBubbleCell: KeyVerificationBaseBubbleCell {
keyVerificationCellInnerContentView.updateSenderInfo(with: viewData.senderId, userDisplayName: viewData.senderDisplayName)
}
override class func sizingView() -> MXKRoomBubbleTableViewCell {
override class func sizingView() -> KeyVerificationBaseBubbleCell {
return self.Sizing.view
}
// MARK: - Private
// TODO: Handle view data filling
private func viewData(from bubbleData: MXKRoomBubbleCellData) -> KeyVerificationConclusionViewData? {
guard let event = bubbleData.bubbleComponents.first?.event else {
private func viewData(from roomBubbleData: RoomBubbleCellData) -> KeyVerificationConclusionViewData? {
guard let event = roomBubbleData.bubbleComponents.first?.event else {
return nil
}
let viewData: KeyVerificationConclusionViewData?
let senderId = self.senderId(from: bubbleData)
let senderDisplayName = self.senderDisplayName(from: bubbleData)
let title: String?
let badgeImage: UIImage?
let badgeImage: UIImage?
switch event.eventType {
case .keyVerificationDone:
title = "Verified"
badgeImage = Asset.Images.encryptionTrusted.image
title = VectorL10n.keyVerificationTileConclusionDoneTitle
case .keyVerificationCancel:
title = "Cancelled"
badgeImage = Asset.Images.encryptionNormal.image
// TODO: Use right titles here
if let keyVerification = roomBubbleData.keyVerification, let cancelCodeValue = keyVerification.transaction?.reasonCancelCode?.value {
switch cancelCodeValue {
case MXTransactionCancelCode.mismatchedSas().value:
title = "TODO"
case MXTransactionCancelCode.unexpectedMessage().value:
title = "TODO"
case MXTransactionCancelCode.mismatchedCommitment().value:
title = "TODO"
default:
title = nil
}
} else {
title = nil
}
default:
badgeImage = nil
title = nil
}
if let title = title, let badgeImage = badgeImage {
viewData = KeyVerificationConclusionViewData(badgeImage: badgeImage,
title: title,
@@ -97,7 +112,7 @@ final class KeyVerificationConclusionBubbleCell: KeyVerificationBaseBubbleCell {
} else {
viewData = nil
}
return viewData
}
}
@@ -17,12 +17,12 @@
import UIKit
@objcMembers
final class KeyVerificationIncomingRequestApprovalBubbleCell: KeyVerificationBaseBubbleCell {
class KeyVerificationIncomingRequestApprovalBubbleCell: KeyVerificationBaseBubbleCell {
// MARK: - Constants
private enum Sizing {
static let view = KeyVerificationConclusionBubbleCell(style: .default, reuseIdentifier: nil)
static let view = KeyVerificationIncomingRequestApprovalBubbleCell(style: .default, reuseIdentifier: nil)
}
// MARK: - Setup
@@ -68,29 +68,34 @@ final class KeyVerificationIncomingRequestApprovalBubbleCell: KeyVerificationBas
keyVerificationCellInnerContentView.title = viewData.title
keyVerificationCellInnerContentView.updateSenderInfo(with: viewData.senderId, userDisplayName: viewData.senderDisplayName)
let actionUserInfo: [AnyHashable: Any]?
if let eventId = bubbleData.getFirstBubbleComponentWithDisplay()?.event.eventId {
actionUserInfo = [kMXKRoomBubbleCellEventIdKey: eventId]
} else {
actionUserInfo = nil
}
keyVerificationCellInnerContentView.acceptActionHandler = { [weak self] in
// TODO: Use correct action identifier
self?.delegate?.cell(self, didRecognizeAction: kMXKRoomBubbleCellTapOnContentView, userInfo: nil)
self?.delegate?.cell(self, didRecognizeAction: kMXKRoomBubbleCellKeyVerificationIncomingRequestAcceptPressed, userInfo: actionUserInfo)
}
keyVerificationCellInnerContentView.declineActionHandler = { [weak self] in
// TODO: Use correct action identifier
self?.delegate?.cell(self, didRecognizeAction: kMXKRoomBubbleCellTapOnContentView, userInfo: nil)
self?.delegate?.cell(self, didRecognizeAction: kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed, userInfo: actionUserInfo)
}
}
override class func sizingView() -> MXKRoomBubbleTableViewCell {
override class func sizingView() -> KeyVerificationBaseBubbleCell {
return self.Sizing.view
}
// MARK: - Private
// TODO: Handle view data filling
private func viewData(from bubbleData: MXKRoomBubbleCellData) -> KeyVerificationIncomingRequestApprovalViewData? {
let senderId = self.senderId(from: bubbleData)
let senderDisplayName = self.senderDisplayName(from: bubbleData)
let title = "Verification request"
let title = VectorL10n.keyVerificationTileRequestIncomingTitle
return KeyVerificationIncomingRequestApprovalViewData(title: title,
senderId: senderId,
@@ -17,8 +17,8 @@
import UIKit
@objcMembers
final class KeyVerificationRequestStatusBubbleCell: KeyVerificationBaseBubbleCell {
class KeyVerificationRequestStatusBubbleCell: KeyVerificationBaseBubbleCell {
// MARK: - Constants
private enum Sizing {
@@ -52,8 +52,8 @@ final class KeyVerificationRequestStatusBubbleCell: KeyVerificationBaseBubbleCel
super.render(cellData)
guard let keyVerificationCellInnerContentView = self.keyVerificationCellInnerContentView,
let bubbleData = self.bubbleData,
let viewData = self.viewData(from: bubbleData) else {
let roomBubbleCellData = self.bubbleData as? RoomBubbleCellData,
let viewData = self.viewData(from: roomBubbleCellData) else {
NSLog("[KeyVerificationRequestStatusBubbleCell] Fail to render \(String(describing: cellData))")
return
}
@@ -63,29 +63,63 @@ final class KeyVerificationRequestStatusBubbleCell: KeyVerificationBaseBubbleCel
keyVerificationCellInnerContentView.requestStatusText = viewData.statusText
}
override class func sizingView() -> MXKRoomBubbleTableViewCell {
override class func sizingView() -> KeyVerificationBaseBubbleCell {
return self.Sizing.view
}
// MARK: - Private
// TODO: Handle view data filling
private func viewData(from bubbleData: MXKRoomBubbleCellData) -> KeyVerificationRequestStatusViewData? {
private func viewData(from roomBubbleCellData: RoomBubbleCellData) -> KeyVerificationRequestStatusViewData? {
let senderId = self.senderId(from: bubbleData)
let senderDisplayName = self.senderDisplayName(from: bubbleData)
let senderDisplayName = self.senderDisplayName(from: bubbleData)
let title: String
let statusText: String = "You accepted"
let statusText: String?
if senderId.isEmpty == false {
title = "Verification request"
if roomBubbleCellData.isIncoming {
title = VectorL10n.keyVerificationTileRequestIncomingTitle
} else {
title = "Verification sent"
title = VectorL10n.keyVerificationTileRequestOutgoingTitle
}
return KeyVerificationRequestStatusViewData(title: title,
senderId: senderId,
senderDisplayName: senderDisplayName,
statusText: statusText)
if let keyVerification = roomBubbleCellData.keyVerification {
switch keyVerification.state {
case .requestPending:
if !roomBubbleCellData.isIncoming {
statusText = VectorL10n.keyVerificationTileRequestStatusWaiting
} else {
if roomBubbleCellData.isKeyVerificationOperationPending {
statusText = VectorL10n.keyVerificationTileRequestStatusDataLoading
} else {
// Should not happen, KeyVerificationIncomingRequestApprovalBubbleCell should be displayed in this case.
statusText = nil
}
}
case .requestExpired:
statusText = VectorL10n.keyVerificationTileRequestStatusExpired
case .requestCancelled, .transactionCancelled:
let userName = senderDisplayName ?? senderId
statusText = VectorL10n.keyVerificationTileRequestStatusCancelled(userName)
case .requestCancelledByMe, .transactionCancelledByMe:
statusText = VectorL10n.keyVerificationTileRequestStatusCancelledByMe
default:
statusText = VectorL10n.keyVerificationTileRequestStatusAccepted
}
} else {
statusText = VectorL10n.keyVerificationTileRequestStatusDataLoading
}
let viewData: KeyVerificationRequestStatusViewData?
if let statusText = statusText {
viewData = KeyVerificationRequestStatusViewData(title: title,
senderId: senderId,
senderDisplayName: senderDisplayName,
statusText: statusText)
} else {
viewData = nil
}
return viewData
}
}