mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
# Conflicts: # Scripts/LintLocalizableStrings.swift # Session.xcodeproj/project.pbxproj # Session/Calls/Call Management/SessionCall.swift # Session/Calls/Call Management/SessionCallManager.swift # Session/Calls/WebRTC/WebRTCSession+DataChannel.swift # Session/Conversations/ConversationVC+Interaction.swift # Session/Conversations/Message Cells/Content Views/OpenGroupInvitationView.swift # Session/Conversations/Message Cells/Content Views/QuoteView.swift # Session/Conversations/Message Cells/Content Views/SwiftUI/OpenGroupInvitationView_SwiftUI.swift # Session/Conversations/Message Cells/Content Views/SwiftUI/VoiceMessageView_SwiftUI.swift # Session/Conversations/Settings/ThreadSettingsViewModel.swift # Session/Database/Migrations/_001_ThemePreferences.swift # Session/Home/GlobalSearch/GlobalSearchViewController.swift # Session/Home/HomeViewModel.swift # Session/Home/Message Requests/MessageRequestsViewModel.swift # Session/Home/New Conversation/NewMessageScreen.swift # Session/Media Viewing & Editing/GIFs/GiphyAPI.swift # Session/Media Viewing & Editing/GIFs/GiphyDownloader.swift # Session/Media Viewing & Editing/PhotoLibrary.swift # Session/Meta/MainAppContext.swift # Session/Meta/SessionApp.swift # Session/Meta/Translations/remove_unused_strings.swift # Session/Notifications/PushRegistrationManager.swift # Session/Onboarding/Onboarding.swift # Session/Settings/HelpViewModel.swift # Session/Settings/SettingsViewModel.swift # Session/Settings/Views/VersionFooterView.swift # Session/Shared/FullConversationCell.swift # Session/Shared/SessionHostingViewController.swift # Session/Utilities/BackgroundPoller.swift # Session/Utilities/UIContextualAction+Utilities.swift # SessionMessagingKit/Configuration.swift # SessionMessagingKit/Database/Models/Attachment.swift # SessionMessagingKit/Database/Models/ClosedGroup.swift # SessionMessagingKit/Database/Models/Interaction.swift # SessionMessagingKit/Database/Models/RecipientState.swift # SessionMessagingKit/Database/Models/SessionThread.swift # SessionMessagingKit/Jobs/FailedMessageSendsJob.swift # SessionMessagingKit/LibSession/Config Handling/LibSession+Contacts.swift # SessionMessagingKit/LibSession/Config Handling/LibSession+UserGroups.swift # SessionMessagingKit/LibSession/Config Handling/LibSession+UserProfile.swift # SessionMessagingKit/LibSession/LibSession+SessionMessagingKit.swift # SessionMessagingKit/Messages/Message.swift # SessionMessagingKit/Messages/Visible Messages/VisibleMessage.swift # SessionMessagingKit/Sending & Receiving/Attachments/ThumbnailService.swift # SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+MessageRequests.swift # SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+VisibleMessages.swift # SessionMessagingKit/Sending & Receiving/Message Handling/MessageSender+LegacyClosedGroups.swift # SessionMessagingKit/Sending & Receiving/MessageReceiver.swift # SessionMessagingKit/Sending & Receiving/MessageSender.swift # SessionMessagingKit/Sending & Receiving/Notifications/Models/SubscribeRequest.swift # SessionMessagingKit/Sending & Receiving/Notifications/Models/UnsubscribeRequest.swift # SessionMessagingKit/Sending & Receiving/Notifications/PushNotificationAPI.swift # SessionMessagingKit/Sending & Receiving/Pollers/CurrentUserPoller.swift # SessionMessagingKit/Sending & Receiving/Pollers/OpenGroupPoller.swift # SessionMessagingKit/Utilities/OWSAudioPlayer.m # SessionMessagingKit/Utilities/Preferences.swift # SessionMessagingKit/Utilities/ProfileManager.swift # SessionMessagingKitTests/Jobs/MessageSendJobSpec.swift # SessionMessagingKitTests/Open Groups/OpenGroupManagerSpec.swift # SessionNotificationServiceExtension/NSENotificationPresenter.swift # SessionShareExtension/ShareNavController.swift # SessionSnodeKit/LibSession/LibSession+Networking.swift # SessionSnodeKit/Networking/SnodeAPI.swift # SessionSnodeKit/Types/ProxiedContentDownloader.swift # SessionUIKit/Components/ConfirmationModal.swift # SessionUtilitiesKit/Database/Models/Identity.swift # SessionUtilitiesKit/General/AppContext.swift # SessionUtilitiesKit/General/FileSystem.swift # SessionUtilitiesKit/General/NSTimer+Proxying.m # SessionUtilitiesKit/General/SNUserDefaults.swift # SessionUtilitiesKit/General/UIDevice+featureSupport.swift # SessionUtilitiesKit/Media/MediaUtils.swift # SignalUtilitiesKit/Media Viewing & Editing/Image Editing/ImageEditorCropViewController.swift # SignalUtilitiesKit/Media Viewing & Editing/MediaMessageView.swift # SignalUtilitiesKit/Media Viewing & Editing/OWSVideoPlayer.swift # SignalUtilitiesKit/Screen Lock/ScreenLockViewController.swift
92 lines
3.5 KiB
Swift
92 lines
3.5 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import UIKit
|
|
import SessionUIKit
|
|
import SessionMessagingKit
|
|
|
|
final class OpenGroupInvitationView: UIView {
|
|
private static let iconSize: CGFloat = 24
|
|
private static let iconImageViewSize: CGFloat = 48
|
|
|
|
// MARK: - Lifecycle
|
|
|
|
init(name: String, url: String, textColor: ThemeValue, isOutgoing: Bool) {
|
|
super.init(frame: CGRect.zero)
|
|
|
|
setUpViewHierarchy(
|
|
name: name,
|
|
rawUrl: url,
|
|
textColor: textColor,
|
|
isOutgoing: isOutgoing
|
|
)
|
|
}
|
|
|
|
override init(frame: CGRect) {
|
|
preconditionFailure("Use init(name:url:textColor:) instead.")
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
preconditionFailure("Use init(name:url:textColor:) instead.")
|
|
}
|
|
|
|
private func setUpViewHierarchy(name: String, rawUrl: String, textColor: ThemeValue, isOutgoing: Bool) {
|
|
// Title
|
|
let titleLabel = UILabel()
|
|
titleLabel.font = .boldSystemFont(ofSize: Values.largeFontSize)
|
|
titleLabel.text = name
|
|
titleLabel.themeTextColor = textColor
|
|
titleLabel.lineBreakMode = .byTruncatingTail
|
|
|
|
// Subtitle
|
|
let subtitleLabel = UILabel()
|
|
subtitleLabel.font = .systemFont(ofSize: Values.smallFontSize)
|
|
subtitleLabel.text = "communityInvitation".localized()
|
|
subtitleLabel.themeTextColor = textColor
|
|
subtitleLabel.lineBreakMode = .byTruncatingTail
|
|
|
|
// URL
|
|
let urlLabel = UILabel()
|
|
urlLabel.font = .systemFont(ofSize: Values.verySmallFontSize)
|
|
urlLabel.text = {
|
|
if let range = rawUrl.range(of: "?public_key=") { // stringlint:ignore
|
|
return String(rawUrl[..<range.lowerBound])
|
|
}
|
|
|
|
return rawUrl
|
|
}()
|
|
urlLabel.themeTextColor = textColor
|
|
urlLabel.lineBreakMode = .byCharWrapping
|
|
urlLabel.numberOfLines = 0
|
|
|
|
// Label stack
|
|
let labelStackView = UIStackView(arrangedSubviews: [ titleLabel, UIView.vSpacer(2), subtitleLabel, UIView.vSpacer(4), urlLabel ])
|
|
labelStackView.axis = .vertical
|
|
|
|
// Icon
|
|
let iconContainerView: UIView = UIView()
|
|
iconContainerView.layer.cornerRadius = (OpenGroupInvitationView.iconImageViewSize / 2)
|
|
iconContainerView.themeBackgroundColor = (isOutgoing ? .messageBubble_overlay : .primary)
|
|
iconContainerView.set(.width, to: OpenGroupInvitationView.iconImageViewSize)
|
|
iconContainerView.set(.height, to: OpenGroupInvitationView.iconImageViewSize)
|
|
|
|
let iconName = (isOutgoing ? "Globe" : "Plus") // stringlint:ignore
|
|
let iconImageView = UIImageView(
|
|
image: UIImage(named: iconName)?.withRenderingMode(.alwaysTemplate)
|
|
)
|
|
iconImageView.themeTintColor = (isOutgoing ? .messageBubble_outgoingText : .textPrimary)
|
|
iconImageView.contentMode = .scaleAspectFit
|
|
iconImageView.set(.width, to: OpenGroupInvitationView.iconSize)
|
|
iconImageView.set(.height, to: OpenGroupInvitationView.iconSize)
|
|
iconContainerView.addSubview(iconImageView)
|
|
iconImageView.center(in: iconContainerView)
|
|
|
|
// Main stack
|
|
let mainStackView = UIStackView(arrangedSubviews: [ iconContainerView, labelStackView ])
|
|
mainStackView.axis = .horizontal
|
|
mainStackView.spacing = Values.mediumSpacing
|
|
mainStackView.alignment = .center
|
|
addSubview(mainStackView)
|
|
mainStackView.pin(to: self, withInset: Values.mediumSpacing)
|
|
}
|
|
}
|