From b0f5efae593eacb4a6f686ef4c359fd9a06b29cb Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Thu, 18 Aug 2022 08:54:51 +0200 Subject: [PATCH] Conference scheduling graphical fixes : - mandatory indicator icon truncated - text entry colors (hint/text) - Send via option moved inside scheduling form - mandatory indicator placement - conference summary cosmetics --- .../ConferenceSchedulingSummaryView.swift | 13 +++++---- .../Views/ConferenceSchedulingView.swift | 28 +++++++++++-------- Classes/Swift/Voip/Theme/TextStyle.swift | 4 +-- .../Swift/Voip/Widgets/StyledTextView.swift | 20 ++++++++++--- 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/Classes/Swift/Conference/Views/ConferenceSchedulingSummaryView.swift b/Classes/Swift/Conference/Views/ConferenceSchedulingSummaryView.swift index e99e45909..0028a78bd 100644 --- a/Classes/Swift/Conference/Views/ConferenceSchedulingSummaryView.swift +++ b/Classes/Swift/Conference/Views/ConferenceSchedulingSummaryView.swift @@ -84,7 +84,7 @@ import SVProgressHUD // Left column (Date & Time) let leftColumn = UIView() scheduleForm.addSubview(leftColumn) - leftColumn.matchParentWidthDividedBy(2.2).alignParentLeft(withMargin: form_margin).alignParentTop(withMargin: form_margin).done() + leftColumn.matchParentWidthDividedBy(2.2).alignParentLeft().alignParentTop(withMargin: form_margin).done() let dateLabel = StyledLabel(VoipTheme.conference_scheduling_font, VoipTexts.conference_schedule_date) leftColumn.addSubview(dateLabel) @@ -106,7 +106,7 @@ import SVProgressHUD // Right column (Duration & Timezone) let rightColumn = UIView() scheduleForm.addSubview(rightColumn) - rightColumn.matchParentWidthDividedBy(2.2).alignParentRight(withMargin: form_margin).alignParentTop().done() + rightColumn.matchParentWidthDividedBy(2.2).alignParentRight().alignParentTop().done() let durationLabel = StyledLabel(VoipTheme.conference_scheduling_font, VoipTexts.conference_schedule_duration) rightColumn.addSubview(durationLabel) @@ -127,12 +127,12 @@ import SVProgressHUD // Description let descriptionLabel = StyledLabel(VoipTheme.conference_scheduling_font, VoipTexts.conference_schedule_description_title) scheduleForm.addSubview(descriptionLabel) - descriptionLabel.alignUnder(view: leftColumn,withMargin: form_margin).alignUnder(view: rightColumn,withMargin: form_margin).matchParentSideBorders(insetedByDx: form_margin).done() + descriptionLabel.alignUnder(view: leftColumn,withMargin: form_margin).alignUnder(view: rightColumn,withMargin: form_margin).matchParentSideBorders().done() descriptionInput.textContainer.maximumNumberOfLines = 5 descriptionInput.textContainer.lineBreakMode = .byWordWrapping scheduleForm.addSubview(descriptionInput) - descriptionInput.alignUnder(view: descriptionLabel,withMargin: form_margin).matchParentSideBorders(insetedByDx: form_margin).height(description_height).alignParentBottom(withMargin: form_margin*2).done() + descriptionInput.alignUnder(view: descriptionLabel,withMargin: form_margin).matchParentSideBorders().height(description_height).alignParentBottom(withMargin: form_margin*2).done() scheduleForm.wrapContentY().done() @@ -140,16 +140,17 @@ import SVProgressHUD let viaChatLabel = StyledLabel(VoipTheme.conference_scheduling_font, VoipTexts.conference_schedule_send_invite_chat_summary) contentView.addSubview(viaChatLabel) viaChatLabel.matchParentSideBorders(insetedByDx: form_margin).alignUnder(view: schedulingStack,withMargin: 2*form_margin).done() + viaChatLabel.numberOfLines = 2 ConferenceSchedulingViewModel.shared.sendInviteViaChat.readCurrentAndObserve { (sendChat) in viaChatLabel.isHidden = sendChat != true || ConferenceSchedulingViewModel.shared.scheduleForLater.value != true } // Participants - let participantsLabel = StyledLabel(VoipTheme.conference_scheduling_font, VoipTexts.conference_schedule_participants_list) + let participantsLabel = StyledLabel(VoipTheme.conference_scheduling_font, " "+VoipTexts.conference_schedule_participants_list) participantsLabel.backgroundColor = VoipTheme.voipFormBackgroundColor.get() contentView.addSubview(participantsLabel) participantsLabel.matchParentSideBorders().height(form_input_height).alignUnder(view: viaChatLabel,withMargin: form_margin*2).done() - participantsLabel.textAlignment = .center + participantsLabel.textAlignment = .left contentView.addSubview(participantsListTableView) diff --git a/Classes/Swift/Conference/Views/ConferenceSchedulingView.swift b/Classes/Swift/Conference/Views/ConferenceSchedulingView.swift index 9801487b5..f7249b77a 100644 --- a/Classes/Swift/Conference/Views/ConferenceSchedulingView.swift +++ b/Classes/Swift/Conference/Views/ConferenceSchedulingView.swift @@ -133,19 +133,22 @@ import IQKeyboardManager descriptionInput.textContainer.maximumNumberOfLines = 5 descriptionInput.textContainer.lineBreakMode = .byWordWrapping scheduleForm.addSubview(descriptionInput) - descriptionInput.alignUnder(view: descriptionLabel,withMargin: form_margin).matchParentSideBorders(insetedByDx: form_margin).height(description_height).alignParentBottom(withMargin: form_margin*2).done() - - scheduleForm.wrapContentY().done() + descriptionInput.alignUnder(view: descriptionLabel,withMargin: 2*form_margin).matchParentSideBorders(insetedByDx: form_margin).height(description_height).done() // Sending methods + + let viaChatView = UIView() + scheduleForm.addSubview(viaChatView) + viaChatView.alignUnder(view: descriptionInput,withMargin: form_margin).matchParentSideBorders(insetedByDx: form_margin).alignParentBottom(withMargin: form_margin*4).done() + let viaChatSwitch = StyledCheckBox(liveValue: ConferenceSchedulingViewModel.shared.sendInviteViaChat) - contentView.addSubview(viaChatSwitch) - viaChatSwitch.alignParentLeft(withMargin: form_margin).alignUnder(view: schedulingStack,withMargin: 2*form_margin).done() + viaChatView.addSubview(viaChatSwitch) + viaChatSwitch.alignParentLeft().done() let viaChatLabel = StyledLabel(VoipTheme.conference_scheduling_font, VoipTexts.conference_schedule_send_invite_chat) - contentView.addSubview(viaChatLabel) - viaChatLabel.toRightOf(viaChatSwitch,withLeftMargin: form_margin).alignUnder(view: schedulingStack,withMargin: 2*form_margin).alignHorizontalCenterWith(viaChatSwitch).done() - + viaChatView.addSubview(viaChatLabel) + viaChatLabel.toRightOf(viaChatSwitch,withLeftMargin: form_margin).alignHorizontalCenterWith(viaChatSwitch).done() + /* Hidden as in Android 9.6.2022 let viaMailSwitch = StyledCheckBox(liveValue: ConferenceSchedulingViewModel.shared.sendInviteViaEmail) @@ -184,17 +187,18 @@ import IQKeyboardManager let mandatoryLabel = StyledLabel(VoipTheme.conference_scheduling_font, VoipTexts.conference_schedule_mandatory_field) mandatoryLabel.addIndicatorIcon(iconName: "voip_mandatory", trailing: false) contentView.addSubview(mandatoryLabel) - mandatoryLabel.alignUnder(view: viaChatSwitch,withMargin: 2*form_margin).centerX().matchParentSideBorders().done() mandatoryLabel.textAlignment = .center - mandatoryLabel.alignParentBottom().done() + let lastView = UIView() + contentView.addSubview(lastView) + lastView.alignUnder(view: mandatoryLabel).alignParentBottom().done() // Schedule for later observer ConferenceSchedulingViewModel.shared.scheduleForLater.readCurrentAndObserve { (forLater) in scheduleForm.isHidden = forLater != true super.titleLabel.text = forLater == true ? VoipTexts.conference_schedule_title : VoipTexts.conference_group_call_title - viaChatSwitch.isHidden = forLater != true - viaChatLabel.isHidden = forLater != true + mandatoryLabel.removeConstraints().done() + mandatoryLabel.alignUnder(view: forLater == true ? scheduleForm : scheduleForLater,withMargin: 2*self.form_margin).centerX().matchParentSideBorders().done() } diff --git a/Classes/Swift/Voip/Theme/TextStyle.swift b/Classes/Swift/Voip/Theme/TextStyle.swift index 5e242ae43..51fed4484 100644 --- a/Classes/Swift/Voip/Theme/TextStyle.swift +++ b/Classes/Swift/Voip/Theme/TextStyle.swift @@ -50,9 +50,9 @@ extension UILabel { func addIndicatorIcon(iconName:String, padding:CGFloat = 5.0, y:CGFloat = 4.0, trailing: Bool = true) { let imageAttachment = NSTextAttachment() imageAttachment.image = UIImage(named:iconName) - imageAttachment.bounds = CGRect(x: 5.0, y: y , width: font.lineHeight - 2*padding, height: font.lineHeight - 2*padding) + imageAttachment.bounds = CGRect(x: 0.0, y: y , width: font.lineHeight - 2*padding, height: font.lineHeight - 2*padding) let iconString = NSMutableAttributedString(attachment: imageAttachment) - let textXtring = NSMutableAttributedString(string: text != nil ? text! : "") + let textXtring = NSMutableAttributedString(string: text != nil ? (!trailing ? " " : "") + text! + (trailing ? " " : "") : "") if (trailing) { textXtring.append(iconString) self.text = nil diff --git a/Classes/Swift/Voip/Widgets/StyledTextView.swift b/Classes/Swift/Voip/Widgets/StyledTextView.swift index 6e2f54984..9c7ce1f39 100644 --- a/Classes/Swift/Voip/Widgets/StyledTextView.swift +++ b/Classes/Swift/Voip/Widgets/StyledTextView.swift @@ -25,12 +25,22 @@ class StyledTextView: UITextView, UITextViewDelegate { var style:TextStyle? var liveValue: MutableLiveData? = nil var maxLines:Int - + var isEditing = false + required init?(coder: NSCoder) { maxLines = 0 super.init(coder: coder) } + override var text: String?{ + didSet{ + textColor = text?.count ?? 0 > 0 && text != placeholder ? style?.fgColor.get().withAlphaComponent(1.0) : style?.fgColor.get().withAlphaComponent(0.5) + if !isEditing && text == "" { + showPlaceHolder() + } + } + } + init (_ style:TextStyle, placeHolder:String? = nil, liveValue: MutableLiveData, readOnly:Bool = false, maxLines:Int = 999) { self.maxLines = maxLines self.style = style @@ -54,17 +64,19 @@ class StyledTextView: UITextView, UITextViewDelegate { textColor = textColor?.withAlphaComponent(0.5) } isUserInteractionEnabled = !readOnly - } - + } + func textViewDidBeginEditing(_ textView: UITextView) { + isEditing = true if text == placeholder { placeholder = textView.text text = "" textColor = style?.fgColor.get().withAlphaComponent(1.0) } } - + func textViewDidEndEditing(_ textView: UITextView) { + isEditing = false if text == "" { showPlaceHolder() }