mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-24 06:38:08 +00:00
Fix Message View
This commit is contained in:
parent
194ddcabf8
commit
07489f68f9
1 changed files with 238 additions and 0 deletions
238
Classes/Swift/Util/ContentMessageView.swift
Normal file
238
Classes/Swift/Util/ContentMessageView.swift
Normal file
|
|
@ -0,0 +1,238 @@
|
|||
//
|
||||
// TopBarNavigationView.swift
|
||||
// linphone
|
||||
//
|
||||
// Created by Benoît Martins on 18/07/2023.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class ContentMessageView: UIViewController {
|
||||
let top_bar_height = 66.0
|
||||
|
||||
let contentView = UIView()
|
||||
let isComposingView = UIView()
|
||||
let isComposingTextView = StyledLabel(VoipTheme.chat_conversation_is_composing_text)
|
||||
let replyLabelTextView = StyledLabel(VoipTheme.chat_conversation_reply_label)
|
||||
let replyContentTextView = StyledLabel(VoipTheme.chat_conversation_reply_content)
|
||||
let replyContentTextSpacing = UIView()
|
||||
let replyContentForMeetingTextView = StyledLabel(VoipTheme.chat_conversation_reply_content)
|
||||
let replyDeleteButton = CallControlButton(width: 22, height: 22, buttonTheme:VoipTheme.nav_black_button("reply_cancel"))
|
||||
let replyMeetingSchedule = UIImageView()
|
||||
let recordingView = UIView()
|
||||
let recordingDeleteButton = CallControlButton(width: 40, height: 40, buttonTheme:VoipTheme.nav_button("delete_default"))
|
||||
let recordingPlayButton = CallControlButton(width: 40, height: 40, buttonTheme:VoipTheme.nav_button("vr_play"))
|
||||
let recordingStopButton = CallControlButton(width: 40, height: 40, buttonTheme:VoipTheme.nav_button("vr_stop"))
|
||||
var recordingWaveView = UIProgressView()
|
||||
let recordingDurationTextView = StyledLabel(VoipTheme.chat_conversation_recording_duration)
|
||||
let recordingWaveImage = UIImageView(image: UIImage(named: "vr_wave.png"))
|
||||
let recordingWaveImageMask = UIView()
|
||||
|
||||
let recordingPlayerImage = UIView()
|
||||
|
||||
let messageView = MessageView()
|
||||
let mediaSelector = UIView()
|
||||
let mediaSelectorReply = UIView()
|
||||
var replyBubble = UIView()
|
||||
var backgroundReplyColor = UIView()
|
||||
|
||||
var isSecure : Bool = false
|
||||
let floatingButton = CallControlButton(buttonTheme:VoipTheme.nav_button(""))
|
||||
var constraintFloatingButton : NSLayoutConstraint? = nil
|
||||
var constraintLandscapeFloatingButton : NSLayoutConstraint? = nil
|
||||
|
||||
var stackView = UIStackView()
|
||||
var stackViewReply = UIStackView()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
stackView.axis = .vertical;
|
||||
stackView.distribution = .fill;
|
||||
stackView.alignment = .center;
|
||||
stackView.spacing = 1;
|
||||
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(stackView)
|
||||
|
||||
//stackView.alignParentTop().alignParentBottom().matchParentSideBorders().done()
|
||||
stackView.alignParentTop().alignParentBottom().done()
|
||||
stackView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true
|
||||
stackView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor).isActive = true
|
||||
|
||||
stackView.addArrangedSubview(contentView)
|
||||
contentView.alignParentTop(withMargin: top_bar_height).matchParentSideBorders().done()
|
||||
|
||||
stackView.addArrangedSubview(isComposingView)
|
||||
isComposingView.height(top_bar_height/2).matchParentSideBorders().done()
|
||||
isComposingView.isHidden = true
|
||||
|
||||
isComposingView.addSubview(isComposingTextView)
|
||||
isComposingTextView.alignParentLeft(withMargin: 10).alignParentRight(withMargin: 10).alignParentTop(withMargin: 10).matchParentHeight().done()
|
||||
isComposingView.backgroundColor = VoipTheme.backgroundWhiteBlack.get()
|
||||
|
||||
stackView.addArrangedSubview(replyBubble)
|
||||
replyBubble.matchParentSideBorders().maxHeight(top_bar_height*3).done()
|
||||
replyBubble.translatesAutoresizingMaskIntoConstraints = false
|
||||
replyBubble.backgroundColor = VoipTheme.voipToolbarBackgroundColor.get()
|
||||
replyBubble.isHidden = true
|
||||
|
||||
replyBubble.addSubview(backgroundReplyColor)
|
||||
backgroundReplyColor.matchParentSideBorders().matchParentHeight().done()
|
||||
|
||||
stackViewReply.axis = .vertical;
|
||||
stackViewReply.distribution = .fill;
|
||||
stackViewReply.alignment = .leading;
|
||||
|
||||
replyBubble.addSubview(stackViewReply)
|
||||
stackViewReply.alignParentLeft(withMargin: 10).alignParentRight(withMargin: 50).alignParentBottom(withMargin: 10).matchParentHeight().wrapContentY().done()
|
||||
stackViewReply.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
stackViewReply.addArrangedSubview(replyLabelTextView)
|
||||
replyLabelTextView.height(30).done()
|
||||
|
||||
stackViewReply.addArrangedSubview(replyMeetingSchedule)
|
||||
replyMeetingSchedule.size(w: 100, h: 40).wrapContentY().done()
|
||||
replyMeetingSchedule.contentMode = .scaleAspectFit
|
||||
replyMeetingSchedule.isHidden = true
|
||||
|
||||
stackViewReply.addArrangedSubview(replyContentForMeetingTextView)
|
||||
replyContentForMeetingTextView.width(100).wrapContentY().done()
|
||||
replyContentForMeetingTextView.textAlignment = .center
|
||||
replyContentForMeetingTextView.numberOfLines = 5
|
||||
replyContentForMeetingTextView.isHidden = true
|
||||
|
||||
stackViewReply.addArrangedSubview(mediaSelectorReply)
|
||||
mediaSelectorReply.height(top_bar_height).wrapContentY().alignParentRight(withMargin: 50).done()
|
||||
mediaSelectorReply.isHidden = true
|
||||
|
||||
stackViewReply.addArrangedSubview(replyContentTextSpacing)
|
||||
replyContentTextSpacing.height(8 ).wrapContentY().done()
|
||||
replyContentTextSpacing.isHidden = true
|
||||
|
||||
stackViewReply.addArrangedSubview(replyContentTextView)
|
||||
replyContentTextView.wrapContentY().done()
|
||||
replyContentTextView.numberOfLines = 5
|
||||
|
||||
replyBubble.addSubview(replyDeleteButton)
|
||||
replyDeleteButton.alignParentRight(withMargin: 15).centerY().done()
|
||||
|
||||
stackView.addArrangedSubview(recordingView)
|
||||
recordingView.height(top_bar_height).wrapContentY().matchParentSideBorders().done()
|
||||
recordingView.backgroundColor = VoipTheme.voipToolbarBackgroundColor.get()
|
||||
recordingView.isHidden = true
|
||||
|
||||
resetRecordingProgressBar()
|
||||
|
||||
stackView.addArrangedSubview(mediaSelector)
|
||||
mediaSelector.height(top_bar_height*2).matchParentSideBorders().done()
|
||||
mediaSelector.backgroundColor = VoipTheme.voipToolbarBackgroundColor.get()
|
||||
mediaSelector.isHidden = true
|
||||
|
||||
stackView.addArrangedSubview(messageView)
|
||||
messageView.alignParentBottom().height(66).matchParentSideBorders().done()
|
||||
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false;
|
||||
view.addSubview(stackView)
|
||||
|
||||
view.addSubview(floatingButton)
|
||||
constraintFloatingButton = floatingButton.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: 3)
|
||||
constraintLandscapeFloatingButton = floatingButton.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: -56)
|
||||
if UIDevice.current.orientation.isLandscape {
|
||||
constraintLandscapeFloatingButton!.isActive = true
|
||||
} else {
|
||||
constraintFloatingButton!.isActive = true
|
||||
}
|
||||
constraintFloatingButton!.isActive = true
|
||||
floatingButton.topAnchor.constraint(equalTo: self.view.layoutMarginsGuide.topAnchor, constant: top_bar_height).isActive = true
|
||||
floatingButton.setImage(UIImage(named:"security_alert_indicator.png"), for: .normal)
|
||||
floatingButton.imageEdgeInsets = UIEdgeInsets(top: 42, left: 42, bottom: 42, right: 42)
|
||||
|
||||
stackView.centerXAnchor.constraint(equalTo:self.view.centerXAnchor).isActive = true
|
||||
stackView.centerYAnchor.constraint(equalTo:self.view.centerYAnchor).isActive = true
|
||||
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.changeSizeOfTextView), name: Notification.Name("LinphoneTextViewSize"), object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.resetSizeOfTextView), name: Notification.Name("LinphoneResetTextViewSize"), object: nil)
|
||||
|
||||
UIDeviceBridge.displayModeSwitched.readCurrentAndObserve { _ in
|
||||
self.replyBubble.backgroundColor = VoipTheme.voipToolbarBackgroundColor.get()
|
||||
self.recordingView.backgroundColor = VoipTheme.voipToolbarBackgroundColor.get()
|
||||
self.mediaSelector.backgroundColor = VoipTheme.voipToolbarBackgroundColor.get()
|
||||
self.isComposingView.backgroundColor = VoipTheme.backgroundWhiteBlack.get()
|
||||
self.recordingWaveView.backgroundColor = VoipTheme.backgroundWhiteBlack.get()
|
||||
self.recordingWaveImageMask.backgroundColor = VoipTheme.backgroundWhiteBlack.get()
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
func resetRecordingProgressBar(){
|
||||
recordingView.addSubview(recordingDeleteButton)
|
||||
recordingDeleteButton.alignParentLeft(withMargin: 10).matchParentHeight().done()
|
||||
|
||||
recordingView.addSubview(recordingPlayButton)
|
||||
recordingPlayButton.alignParentRight(withMargin: 10).matchParentHeight().done()
|
||||
recordingPlayButton.isHidden = true
|
||||
|
||||
recordingView.addSubview(recordingStopButton)
|
||||
recordingStopButton.alignParentRight(withMargin: 10).matchParentHeight().done()
|
||||
|
||||
let newRecordingWaveView = UIProgressView()
|
||||
recordingWaveView = newRecordingWaveView
|
||||
|
||||
recordingView.addSubview(recordingWaveView)
|
||||
recordingWaveView.toRightOf(recordingDeleteButton, withLeftMargin: 10).toLeftOf(recordingStopButton, withRightMargin: 10).alignParentTop(withMargin: 10).alignParentBottom(withMargin: 10).done()
|
||||
recordingWaveView.progressViewStyle = .bar
|
||||
recordingWaveView.layer.cornerRadius = 5
|
||||
recordingWaveView.backgroundColor = VoipTheme.backgroundWhiteBlack.get()
|
||||
recordingWaveView.progressImage = UIImage.withColor(UIColor("L"))
|
||||
recordingWaveView.clipsToBounds = true
|
||||
|
||||
recordingWaveView.addSubview(recordingDurationTextView)
|
||||
recordingDurationTextView.alignParentRight(withMargin: 10).matchParentHeight().done()
|
||||
|
||||
recordingWaveView.addSubview(recordingWaveImage)
|
||||
recordingWaveImage.alignParentTop(withMargin: 10).alignParentBottom(withMargin: 10).alignParentLeft(withMargin: 10).alignParentRight(withMargin: 65).done()
|
||||
|
||||
recordingWaveView.addSubview(recordingWaveImageMask)
|
||||
recordingWaveImageMask.alignParentTop(withMargin: 5).alignParentBottom(withMargin: 5).alignParentLeft(withMargin: 10).alignParentRight(withMargin: 65).done()
|
||||
recordingWaveImageMask.backgroundColor = VoipTheme.backgroundWhiteBlack.get()
|
||||
}
|
||||
|
||||
@objc func rotated() {
|
||||
if UIDevice.current.orientation.isLandscape {
|
||||
constraintLandscapeFloatingButton!.isActive = true
|
||||
constraintFloatingButton!.isActive = false
|
||||
} else {
|
||||
constraintLandscapeFloatingButton!.isActive = false
|
||||
constraintFloatingButton!.isActive = true
|
||||
}
|
||||
}
|
||||
|
||||
@objc func changeSizeOfTextView(){
|
||||
let numLines = (messageView.messageText.contentSize.height / messageView.messageText.font!.lineHeight)
|
||||
if numLines >= 3 && numLines <= 6 {
|
||||
messageView.setHeight(33*numLines - 33)
|
||||
} else if numLines < 3 {
|
||||
messageView.setHeight(66)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func resetSizeOfTextView(){
|
||||
messageView.setHeight(66)
|
||||
}
|
||||
|
||||
|
||||
func changeSecureLevel(secureLevel: Bool, imageBadge: UIImage?){
|
||||
isSecure = secureLevel
|
||||
if(isSecure){
|
||||
floatingButton.isHidden = false
|
||||
floatingButton.setImage(imageBadge, for: .normal)
|
||||
}else{
|
||||
floatingButton.isHidden = true
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue