Skip to content

Commit

Permalink
Toggle SC bottom banner visibility based on view model
Browse files Browse the repository at this point in the history
Add toggling of SC bottom banner visibility based view model.

MOB-3719
  • Loading branch information
igorkravchenko committed Nov 1, 2024
1 parent 90ad427 commit 9b2e7c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
22 changes: 10 additions & 12 deletions GliaWidgets/Sources/View/Chat/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ class ChatView: EngagementView {
addKeyboardDismissalTapGesture()
typingIndicatorView.accessibilityIdentifier = "chat_typingIndicator"
typingIndicatorContainer.isHidden = true
// TODO: remove this call with implementation of MOB-3739
renderBanners()
// Hide secure conversation bottom banner unavailability banner initially.
setSecureMessagingBottomBannerHidden(true)
setSendingMessageUnavailabilityBannerHidden(true)
}

override func defineLayout() {
Expand Down Expand Up @@ -189,16 +190,6 @@ class ChatView: EngagementView {
equalTo: messageEntryView.topAnchor, constant: kUnreadMessageIndicatorInset
)
}

func renderBanners() {
secureMessagingBottomBannerView.props = .init(
style: style.secureMessagingBottomBannerStyle,
isHidden: true // Logic to show/hide SC bottom banner is to be added with MOB-3634
)

// Hide send message unavailability banner initially.
setSendingMessageUnavailabilityBannerHidden(true)
}
}

extension ChatView {
Expand All @@ -209,6 +200,13 @@ extension ChatView {
)
}

func setSecureMessagingBottomBannerHidden(_ isHidden: Bool) {
secureMessagingBottomBannerView.props = .init(
style: style.secureMessagingBottomBannerStyle,
isHidden: isHidden
)
}

func setOperatorTypingIndicatorIsHidden(to isHidden: Bool) {
typingIndicatorContainer.isHidden = isHidden
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,17 @@ final class ChatViewController: EngagementViewController, PopoverPresenter {
switch type {
case .chat:
chatView.props = .init(header: props.chat)
// For regular chat engagement bottom banner is hidden.
chatView.setSecureMessagingBottomBannerHidden(true)
case let .secureTranscript(needsTextInputEnabled):
chatView.props = .init(header: props.secureTranscript)
// Instead of hiding text input, we need to disable it and corresponding buttons.
// TODO: Currently there is no 'disabled' styles for text entry, so we need to confirm with Android
// if introduction of such styles is required.
chatView.messageEntryView.isEnabled = needsTextInputEnabled
chatView.setSendingMessageUnavailabilityBannerHidden(viewModel.isSecureConversationsAvailable)
// For secure messaging bottom banner is visible.
chatView.setSecureMessagingBottomBannerHidden(false)
}
}

Expand All @@ -283,7 +287,7 @@ extension ChatViewController {
// Swap existing engagement transcript model
// (though it is technically not for engagement)
// with engagement chat model in superclass EngagementViewController.
swapAndBindEgagementViewModel(viewModel.engagementModel)
swapAndBindEngagementViewModel(viewModel.engagementModel)
// Bind chat model to chat view for sending actions
// and receiving events.
bind(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class EngagementViewController: UIViewController {
}
}

func swapAndBindEgagementViewModel(_ engagementModel: CommonEngagementModel) {
func swapAndBindEngagementViewModel(_ engagementModel: CommonEngagementModel) {
self.viewModel = engagementModel
bind(engagementViewModel: engagementModel)
}
Expand Down

0 comments on commit 9b2e7c1

Please sign in to comment.