pull/782/head
Ryan Zhao 1 year ago
parent 68efe731e7
commit 0c91f3e258

@ -110,7 +110,6 @@
7B1D74AC27BDE7510030B423 /* Promise+Timeout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1D74AB27BDE7510030B423 /* Promise+Timeout.swift */; };
7B1D74B027C365960030B423 /* Timer+MainThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1D74AF27C365960030B423 /* Timer+MainThread.swift */; };
7B2561C22978B307005C086C /* MediaInfoVC+MediaInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B2561C12978B307005C086C /* MediaInfoVC+MediaInfoView.swift */; };
7B3A392C2971100D002FE4AC /* ContextMenuVC+MessageInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3A392B2971100D002FE4AC /* ContextMenuVC+MessageInfoView.swift */; };
7B3A392E2977791E002FE4AC /* MediaInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3A392D2977791E002FE4AC /* MediaInfoVC.swift */; };
7B46AAAF28766DF4001AF2DC /* AllMediaViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B46AAAE28766DF4001AF2DC /* AllMediaViewController.swift */; };
7B4C75CB26B37E0F0000AC89 /* UnsendRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4C75CA26B37E0F0000AC89 /* UnsendRequest.swift */; };
@ -1179,7 +1178,6 @@
7B1D74AF27C365960030B423 /* Timer+MainThread.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Timer+MainThread.swift"; sourceTree = "<group>"; };
7B2561C12978B307005C086C /* MediaInfoVC+MediaInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MediaInfoVC+MediaInfoView.swift"; sourceTree = "<group>"; };
7B2DB2AD26F1B0FF0035B509 /* si */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = si; path = si.lproj/Localizable.strings; sourceTree = "<group>"; };
7B3A392B2971100D002FE4AC /* ContextMenuVC+MessageInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ContextMenuVC+MessageInfoView.swift"; sourceTree = "<group>"; };
7B3A392D2977791E002FE4AC /* MediaInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaInfoVC.swift; sourceTree = "<group>"; };
7B46AAAE28766DF4001AF2DC /* AllMediaViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllMediaViewController.swift; sourceTree = "<group>"; };
7B4C75CA26B37E0F0000AC89 /* UnsendRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnsendRequest.swift; sourceTree = "<group>"; };
@ -2718,7 +2716,6 @@
C328254825CA60E60062D0A7 /* ContextMenuVC+Action.swift */,
C328255125CA64470062D0A7 /* ContextMenuVC+ActionView.swift */,
7BFA8AE22831D0D4001876F3 /* ContextMenuVC+EmojiReactsView.swift */,
7B3A392B2971100D002FE4AC /* ContextMenuVC+MessageInfoView.swift */,
);
path = "Context Menu";
sourceTree = "<group>";
@ -5623,7 +5620,6 @@
34A8B3512190A40E00218A25 /* MediaAlbumView.swift in Sources */,
FD09C5E828264937000CE219 /* MediaDetailViewController.swift in Sources */,
3496955E219B605E00DCFE74 /* PhotoLibrary.swift in Sources */,
7B3A392C2971100D002FE4AC /* ContextMenuVC+MessageInfoView.swift in Sources */,
7B8C44C528B49DDA00FBE25F /* NewConversationVC.swift in Sources */,
7B1B52E028580D51006069F2 /* EmojiSkinTonePicker.swift in Sources */,
B849789625D4A2F500D0D0B3 /* LinkPreviewView.swift in Sources */,

@ -10,7 +10,6 @@ extension ContextMenuVC {
let isEmojiAction: Bool
let isEmojiPlus: Bool
let isDismissAction: Bool
let shouldDismissAfterAction: Bool
let accessibilityLabel: String?
let work: () -> Void
@ -22,7 +21,6 @@ extension ContextMenuVC {
isEmojiAction: Bool = false,
isEmojiPlus: Bool = false,
isDismissAction: Bool = false,
shouldDismissAfterAction: Bool = true,
accessibilityLabel: String? = nil,
work: @escaping () -> Void
) {
@ -31,7 +29,6 @@ extension ContextMenuVC {
self.isEmojiAction = isEmojiAction
self.isEmojiPlus = isEmojiPlus
self.isDismissAction = isDismissAction
self.shouldDismissAfterAction = shouldDismissAfterAction
self.accessibilityLabel = accessibilityLabel
self.work = work
}
@ -42,7 +39,6 @@ extension ContextMenuVC {
return Action(
icon: UIImage(named: "ic_info"),
title: "context_menu_info".localized(),
shouldDismissAfterAction: false,
accessibilityLabel: "Message info"
) { delegate?.info(cellViewModel) }
}

@ -1,162 +0,0 @@
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import UIKit
import SessionUIKit
import SessionUtilitiesKit
extension ContextMenuVC {
final class MessageInfoView: UIView {
private static let cornerRadius: CGFloat = 8
private let cellViewModel: MessageViewModel
private let dismissAction: () -> Void
// MARK: - UI
private lazy var dismissButton: UIButton = {
let result: UIButton = UIButton(type: .custom)
result.setImage(
UIImage(named: "small_chevron_left")?
.withRenderingMode(.alwaysTemplate),
for: .normal
)
result.addTarget(self, action: #selector(dismiss), for: UIControl.Event.touchUpInside)
result.themeTintColor = .white
result.set(.width, to: 20)
result.set(.height, to: 20)
return result
}()
private lazy var messageSentDateLabel: UILabel = {
let result: UILabel = UILabel()
result.font = .systemFont(ofSize: Values.smallFontSize)
result.themeTextColor = .textPrimary
result.numberOfLines = 0
return result
}()
private lazy var messageReceivedDateLabel: UILabel = {
let result: UILabel = UILabel()
result.font = .systemFont(ofSize: Values.smallFontSize)
result.themeTextColor = .textPrimary
result.numberOfLines = 0
return result
}()
private lazy var profilePictureView: ProfilePictureView = {
let result: ProfilePictureView = ProfilePictureView()
result.set(.height, to: Values.smallProfilePictureSize)
result.size = Values.smallProfilePictureSize
return result
}()
private lazy var displayNameLabel: UILabel = {
let result: UILabel = UILabel()
result.font = .boldSystemFont(ofSize: Values.smallFontSize)
result.themeTextColor = .textPrimary
return result
}()
private lazy var sessionIDLabel: UILabel = {
let result: UILabel = UILabel()
result.font = .systemFont(ofSize: Values.verySmallFontSize)
result.themeTextColor = .textPrimary
result.numberOfLines = 0
result.lineBreakMode = .byCharWrapping
return result
}()
// MARK: - Lifecycle
init(cellViewModel: MessageViewModel, dismissAction: @escaping () -> Void) {
self.cellViewModel = cellViewModel
self.dismissAction = dismissAction
super.init(frame: CGRect.zero)
self.accessibilityLabel = "Message info"
setUpViewHierarchy()
}
override init(frame: CGRect) {
preconditionFailure("Use init(cellViewModel:dismiss:) instead.")
}
required init?(coder: NSCoder) {
preconditionFailure("Use init(cellViewModel:dismiss:) instead.")
}
private func setUpViewHierarchy() {
addSubview(dismissButton)
dismissButton.pin(.top, to: .top, of: self, withInset: Values.smallSpacing)
dismissButton.pin(.leading, to: .leading, of: self)
let backgroundView: UIView = UIView()
backgroundView.clipsToBounds = true
backgroundView.themeBackgroundColor = .contextMenu_background
backgroundView.layer.cornerRadius = Self.cornerRadius
addSubview(backgroundView)
backgroundView.pin([ UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top, UIView.VerticalEdge.bottom ], to: self)
backgroundView.pin(.leading, to: .trailing, of: dismissButton)
let stackView: UIStackView = UIStackView()
stackView.axis = .vertical
stackView.spacing = Values.smallSpacing
backgroundView.addSubview(stackView)
stackView.pin(to: backgroundView, withInset: Values.mediumSpacing)
messageSentDateLabel.text = "MESSAGE_INFO_SENT".localized() + ":\n" + cellViewModel.dateForUI.fromattedForMessageInfo
stackView.addArrangedSubview(messageSentDateLabel)
messageReceivedDateLabel.text = "MESSAGE_INFO_RECEIVED".localized() + ":\n" + cellViewModel.receivedDateForUI.fromattedForMessageInfo
stackView.addArrangedSubview(messageReceivedDateLabel)
let senderTitleLabel: UILabel = {
let result: UILabel = UILabel()
result.font = .systemFont(ofSize: Values.smallFontSize)
result.themeTextColor = .textPrimary
result.text = "MESSAGE_INFO_FROM".localized() + ":"
return result
}()
displayNameLabel.text = cellViewModel.authorName
sessionIDLabel.text = cellViewModel.authorId
profilePictureView.update(
publicKey: cellViewModel.authorId,
profile: cellViewModel.profile,
threadVariant: cellViewModel.threadVariant
)
let profileContainerView: UIView = UIView()
profileContainerView.addSubview(senderTitleLabel)
senderTitleLabel.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top ], to: profileContainerView)
profileContainerView.addSubview(profilePictureView)
profilePictureView.pin(.leading, to: .leading, of: profileContainerView)
profilePictureView.pin(.top, to: .bottom, of: senderTitleLabel, withInset: Values.mediumSpacing)
profilePictureView.pin(.bottom, to: .bottom, of: profileContainerView, withInset: -Values.verySmallSpacing)
let infoContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ displayNameLabel, sessionIDLabel ])
infoContainerStackView.axis = .vertical
profileContainerView.addSubview(infoContainerStackView)
infoContainerStackView.pin(.leading, to: .trailing, of: profilePictureView, withInset: Values.mediumSpacing)
infoContainerStackView.pin(.trailing, to: .trailing, of: profileContainerView)
infoContainerStackView.pin(.bottom, to: .bottom, of: profileContainerView)
infoContainerStackView.set(.width, to: 240)
stackView.addArrangedSubview(profileContainerView)
}
// MARK: - Interaction
@objc private func dismiss() {
dismissAction()
}
}
}

@ -59,18 +59,6 @@ final class ContextMenuVC: UIViewController {
return result
}()
private lazy var messageInfoView: MessageInfoView = {
let result: MessageInfoView = MessageInfoView(cellViewModel: self.cellViewModel, dismissAction: hideMessageInfo)
result.themeShadowColor = .black
result.layer.shadowOffset = CGSize.zero
result.layer.shadowOpacity = 0.4
result.layer.shadowRadius = 4
result.alpha = 0
result.set(.width, to: 340)
return result
}()
private lazy var timestampLabel: UILabel = {
let result: UILabel = UILabel()
result.font = .systemFont(ofSize: Values.verySmallFontSize)
@ -177,10 +165,7 @@ final class ContextMenuVC: UIViewController {
arrangedSubviews: actions
.filter { !$0.isEmojiAction && !$0.isEmojiPlus && !$0.isDismissAction }
.map { action -> ActionView in
ActionView(
for: action,
dismiss: action.shouldDismissAfterAction ? snDismiss : {}
)
ActionView(for: action, dismiss: snDismiss)
}
)
menuStackView.axis = .vertical
@ -188,9 +173,6 @@ final class ContextMenuVC: UIViewController {
menuStackView.pin(to: menuBackgroundView)
view.addSubview(menuView)
// MessageInfo
view.addSubview(messageInfoView)
// Timestamp
view.addSubview(timestampLabel)
timestampLabel.center(.vertical, in: snapshot)
@ -235,22 +217,18 @@ final class ContextMenuVC: UIViewController {
snapshot.frame = self.frame
emojiBar.pin(.bottom, to: .top, of: view, withInset: targetFrame.minY - spacing)
menuView.pin(.top, to: .top, of: view, withInset: targetFrame.maxY + spacing)
messageInfoView.pin(.top, to: .top, of: view, withInset: targetFrame.maxY + spacing)
switch cellViewModel.variant {
case .standardOutgoing:
menuView.pin(.right, to: .right, of: view, withInset: -(UIScreen.main.bounds.width - targetFrame.maxX))
messageInfoView.pin(.right, to: .right, of: view, withInset: -(UIScreen.main.bounds.width - targetFrame.maxX))
emojiBar.pin(.right, to: .right, of: view, withInset: -(UIScreen.main.bounds.width - targetFrame.maxX))
case .standardIncoming, .standardIncomingDeleted:
menuView.pin(.left, to: .left, of: view, withInset: targetFrame.minX)
messageInfoView.pin(.left, to: .left, of: view, withInset: targetFrame.minX)
emojiBar.pin(.left, to: .left, of: view, withInset: targetFrame.minX)
default: // Should generally only be the 'delete' action
menuView.pin(.left, to: .left, of: view, withInset: targetFrame.minX)
messageInfoView.pin(.left, to: .left, of: view, withInset: targetFrame.minX)
}
// Tap gesture
@ -364,22 +342,6 @@ final class ContextMenuVC: UIViewController {
// MARK: - Interaction
func showMessageInfo() {
UIView.animate(withDuration: 0.2) { [weak self] in
self?.emojiBar.alpha = 0
self?.menuView.alpha = 0
self?.messageInfoView.alpha = 1
}
}
func hideMessageInfo() {
UIView.animate(withDuration: 0.2) { [weak self] in
self?.emojiBar.alpha = 1
self?.menuView.alpha = 1
self?.messageInfoView.alpha = 0
}
}
@objc private func handleTap() {
snDismiss()
}

Loading…
Cancel
Save