Skip to content

Commit

Permalink
Merge pull request #420 from salemove/fix/MOB-1645-survey-bottom-padding
Browse files Browse the repository at this point in the history
Fixed bottom padding on Survey screen
  • Loading branch information
EgorovEI authored Nov 23, 2022
2 parents 6fe61c6 + bd5604d commit f320970
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 62 deletions.
8 changes: 5 additions & 3 deletions GliaWidgets/Component/Bubble/BubbleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ class BubbleView: UIView {

var isVisitorOnHold: Bool = false {
didSet {
isVisitorOnHold
? showOnHoldView()
: hideOnHoldView()
if isVisitorOnHold {
showOnHoldView()
} else {
hideOnHoldView()
}

setAccessibilityIdentifier()
}
Expand Down
2 changes: 2 additions & 0 deletions GliaWidgets/Component/Connect/ConnectView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ConnectView: UIView {
fatalError("init(coder:) has not been implemented")
}

// swiftlint:disable function_body_length
func setState(_ state: State, animated: Bool) {
self.state = state

Expand Down Expand Up @@ -100,6 +101,7 @@ class ConnectView: UIView {
show(animated: animated)
}
}
// swiftlint:enable function_body_length

private func show(animated: Bool) {
guard !isShowing else { return }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ class ConnectOperatorView: UIView {

var isVisitorOnHold: Bool = false {
didSet {
isVisitorOnHold
? showOnHoldView()
: hideOnHoldView()
if isVisitorOnHold {
showOnHoldView()
} else {
hideOnHoldView()
}
}
}

Expand Down
46 changes: 29 additions & 17 deletions GliaWidgets/Coordinator/Call/CallCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ class CallCoordinator: SubFlowCoordinator, FlowCoordinator {
)
return viewController
}
}

// MARK: - Private

private func makeCallViewController(
private extension CallCoordinator {
func makeCallViewController(
call: Call,
startAction: CallViewModel.StartAction
) -> CallViewController {
Expand Down Expand Up @@ -82,30 +86,38 @@ class CallCoordinator: SubFlowCoordinator, FlowCoordinator {
startWith: startAction
)
viewModel.engagementDelegate = { [weak self] event in
switch event {
case .back:
self?.delegate?(.back)
case .engaged(operatorImageUrl: let url):
self?.delegate?(.engaged(operatorImageUrl: url))
case .finished:
self?.delegate?(.finished)
}
self?.handleEngagementViewModelEvent(event)
}
viewModel.delegate = { [weak self] event in
switch event {
case .chat:
self?.delegate?(.chat)
case .minimize:
self?.delegate?(.minimize)
case .visitorOnHoldUpdated(let isOnHold):
self?.delegate?(.visitorOnHoldUpdated(isOnHold: isOnHold))
}
self?.handleCallViewModelEvent(event)
}
return CallViewController(
viewModel: viewModel,
viewFactory: viewFactory
)
}

func handleEngagementViewModelEvent(_ event: EngagementViewModel.DelegateEvent) {
switch event {
case .back:
delegate?(.back)
case .engaged(let url):
delegate?(.engaged(operatorImageUrl: url))
case .finished:
delegate?(.finished)
}
}

func handleCallViewModelEvent(_ event: CallViewModel.DelegateEvent) {
switch event {
case .chat:
delegate?(.chat)
case .minimize:
delegate?(.minimize)
case .visitorOnHoldUpdated(let isOnHold):
delegate?(.visitorOnHoldUpdated(isOnHold: isOnHold))
}
}
}

extension CallCoordinator {
Expand Down
4 changes: 4 additions & 0 deletions GliaWidgets/Coordinator/RootCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class RootCoordinator: SubFlowCoordinator, FlowCoordinator {
navigationController.isNavigationBarHidden = true
}

// swiftlint:disable function_body_length
func start() {
switch engagementKind {
case .none:
Expand Down Expand Up @@ -117,13 +118,15 @@ class RootCoordinator: SubFlowCoordinator, FlowCoordinator {
event(.maximized)
delegate?(.started)
}
// swiftlint:enable function_body_length

deinit {
print("\(Self.self) is deallocated.")
}
}

extension RootCoordinator {
// swiftlint:disable function_body_length
func end() {
defer {
// For now it is required that message history is cleared when engagement ends
Expand Down Expand Up @@ -196,6 +199,7 @@ extension RootCoordinator {
presentSurvey(engagement.id, survey)
}
}
// swiftlint:enable function_body_length

private func startChat(
withAction startAction: ChatViewModel.StartAction,
Expand Down
4 changes: 2 additions & 2 deletions GliaWidgets/CoreSDKClient/CoreSDKClient.Mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ extension CoreSdkClient {

static func mock(
onHold: CoreSdkClient.StreamableOnHoldHandler? = nil,
muteFunc: @escaping () -> Void = {} ,
muteFunc: @escaping () -> Void = {},
unmuteFunc: @escaping () -> Void = {},
getIsMutedFunc: @escaping () -> Bool = { false },
setIsMutedFunc: @escaping (Bool) -> Void = { _ in },
Expand Down Expand Up @@ -266,7 +266,7 @@ extension CoreSdkClient {
onHold: CoreSdkClient.StreamableOnHoldHandler? = nil,
getStreamViewFunc: @escaping () -> CoreSdkClient.StreamView = { .init() },
playVideoFunc: @escaping () -> Void = {},
pauseFunc: @escaping () -> Void = {} ,
pauseFunc: @escaping () -> Void = {},
resumeFunc: @escaping () -> Void = {},
stopFunc: @escaping () -> Void = {},
getIsPausedFunc: @escaping () -> Bool = { false },
Expand Down
4 changes: 2 additions & 2 deletions GliaWidgets/FoundationBased.Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ enum FoundationBased {
_ inDomainMask: Foundation.FileManager.SearchPathDomainMask
) -> [URL]

var fileExistsAtPath:(_ atPath: String) -> Bool
var fileExistsAtPath: (_ atPath: String) -> Bool

var createDirectoryAtUrlWithIntermediateDirectories:(
var createDirectoryAtUrlWithIntermediateDirectories: (
_ atURL: URL,
_ withIntermediateDirectories: Bool,
_ attributes: [FileAttributeKey: Any]?
Expand Down
2 changes: 0 additions & 2 deletions GliaWidgets/Glia.Deprecated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ extension Glia {
}

/// Deprecated.
// swiftlint: disable line_length
@available(*, deprecated, message: "Use start(_:configuration:queueID:visitorContext:theme:features:sceneProvider:) with Optional<VisitorContext> instead.")
// swiftlint: enable line_length
public func start(
_ engagementKind: EngagementKind,
configuration: Configuration,
Expand Down
30 changes: 17 additions & 13 deletions GliaWidgets/Glia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,27 @@ public class Glia {
)
)
rootCoordinator?.delegate = { [weak self] event in
switch event {
case .started:
self?.onEvent?(.started)
case .engagementChanged(let engagementKind):
self?.onEvent?(.engagementChanged(engagementKind))
case .ended:
self?.rootCoordinator = nil
self?.onEvent?(.ended)
case .minimized:
self?.onEvent?(.minimized)
case .maximized:
self?.onEvent?(.maximized)
}
self?.handleCoordinatorEvent(event)
}
rootCoordinator?.start()
}

private func handleCoordinatorEvent(_ event: RootCoordinator.DelegateEvent) {
switch event {
case .started:
onEvent?(.started)
case .engagementChanged(let engagementKind):
onEvent?(.engagementChanged(engagementKind))
case .ended:
rootCoordinator = nil
onEvent?(.ended)
case .minimized:
onEvent?(.minimized)
case .maximized:
onEvent?(.maximized)
}
}

/// Clear visitor session
public func clearVisitorSession() {
environment.coreSdk.clearSession()
Expand Down
4 changes: 4 additions & 0 deletions GliaWidgets/View/Call/CallView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class CallView: EngagementView {
adjustLocalVideoFrameAfterLayout()
}

// swiftlint:disable function_body_length
override func setup() {
accessibilityIdentifier = "call_root_view"

Expand Down Expand Up @@ -190,6 +191,7 @@ class CallView: EngagementView {
header.backButton.accessibilityLabel = style.header.backButton.accessibility.label
header.backButton.accessibilityHint = style.header.backButton.accessibility.hint
}
// swiftlint:enable function_body_length

func switchTo(_ mode: Mode) {
self.mode = mode
Expand Down Expand Up @@ -253,6 +255,7 @@ class CallView: EngagementView {
}
}

// swiftlint:disable function_body_length
private func layout() {
let effect = UIBlurEffect(style: .dark)
let effectView = UIVisualEffectView(effect: effect)
Expand Down Expand Up @@ -316,6 +319,7 @@ class CallView: EngagementView {
adjustForCurrentOrientation()
switchTo(mode)
}
// swiftlint:enable function_body_length

private func adjustForCurrentOrientation() {
if currentOrientation.isLandscape {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ final class ChoiceCardView: OperatorChatMessageView {
}
}

// swiftlint:disable function_body_length
private func contentView(for choiceCard: ChoiceCard) -> UIView {
let containerView = UIView()

Expand Down Expand Up @@ -101,6 +102,7 @@ final class ChoiceCardView: OperatorChatMessageView {

return containerView
}
// swiftlint:enable function_body_length
}

extension ChoiceCardView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ class ChatFileDownloadContentView: ChatFileContentView {
}
accessibilityLabel = sharedProperties.label
}
// swiftlint:enable function_body_length

private func stateText(for downloadState: FileDownload.State) -> NSAttributedString? {
switch downloadState {
Expand Down Expand Up @@ -232,4 +231,5 @@ class ChatFileDownloadContentView: ChatFileContentView {
return string
}
}
// swiftlint:enable function_body_length
}
2 changes: 2 additions & 0 deletions GliaWidgets/ViewController/Call/CallViewController.Mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ extension CallViewController {
return viewController
}

// swiftlint:disable function_body_length
static func mockAudioCallConnectedState() throws -> CallViewController {
let conf = try CoreSdkClient.Salemove.Configuration.mock()
let queueId = UUID.mock.uuidString
Expand Down Expand Up @@ -143,6 +144,7 @@ extension CallViewController {
viewModel.action?(.connected(name: "Blob The Operator", imageUrl: nil))
return viewController
}
// swiftlint:enable function_body_length

static func mockVideoCallConnectingState() throws -> CallViewController {
let conf = try CoreSdkClient.Salemove.Configuration.mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extension Survey {
buttonContainer.leadingAnchor.constraint(equalTo: leadingAnchor),
buttonContainer.trailingAnchor.constraint(equalTo: trailingAnchor),

buttonStackView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor, constant: 0),
buttonStackView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor, constant: -Self.contentPadding),
buttonStackView.topAnchor.constraint(equalTo: buttonContainer.topAnchor, constant: Self.contentPadding),
buttonStackView.leadingAnchor.constraint(equalTo: buttonContainer.leadingAnchor, constant: Self.contentPadding),
buttonStackView.trailingAnchor.constraint(equalTo: buttonContainer.trailingAnchor, constant: -Self.contentPadding),
Expand Down
6 changes: 5 additions & 1 deletion GliaWidgets/ViewController/Survey/SurveyViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ extension Survey {
func render() {
contentView.header.text = props.header
contentView.header.accessibilityLabel = props.header
props.questionsProps.count == contentView.surveyItemsStack.arrangedSubviews.count ? updateProps() : reloadProps()
if props.questionsProps.count == contentView.surveyItemsStack.arrangedSubviews.count {
updateProps()
} else {
reloadProps()
}
contentView.updateUi(theme: theme)
contentView.endEditing = props.endEditing
}
Expand Down
4 changes: 4 additions & 0 deletions GliaWidgets/ViewModel/Chat/ChatViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ChatViewModel: EngagementViewModel, ViewModel {
private var pendingMessages: [OutgoingMessage] = []
private var isViewLoaded: Bool = false

// swiftlint:disable function_body_length
init(
interactor: Interactor,
alertConfiguration: AlertConfiguration,
Expand Down Expand Up @@ -108,6 +109,7 @@ class ChatViewModel: EngagementViewModel, ViewModel {
self?.action?(.pickMediaButtonEnabled(!limitReached))
}
}
// swiftlint:enable function_body_length

func event(_ event: Event) {
switch event {
Expand Down Expand Up @@ -168,6 +170,7 @@ class ChatViewModel: EngagementViewModel, ViewModel {
}
}

// swiftlint:disable function_body_length
override func update(for state: InteractorState) {
super.update(for: state)

Expand Down Expand Up @@ -233,6 +236,7 @@ class ChatViewModel: EngagementViewModel, ViewModel {
break
}
}
// swiftlint:enable function_body_length

override func interactorEvent(_ event: InteractorEvent) {
super.interactorEvent(event)
Expand Down
4 changes: 2 additions & 2 deletions SnapshotTests/AlertViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AlertViewControllerTests: SnapshotTestCase {
))
assertSnapshot(
matching: alert,
as: .accessibilityImage(precision: SnapshotTestCase.possiblePrecision),
as: .accessibilityImage,
named: nameForDevice()
)
}
Expand All @@ -50,7 +50,7 @@ class AlertViewControllerTests: SnapshotTestCase {
))
assertSnapshot(
matching: alert,
as: .accessibilityImage(precision: SnapshotTestCase.possiblePrecision),
as: .accessibilityImage,
named: nameForDevice()
)
}
Expand Down
Loading

0 comments on commit f320970

Please sign in to comment.