From 5c9b7627a77153b4b8e501cb5d59484038c8a8ad Mon Sep 17 00:00:00 2001 From: Andrei Sadovnicov Date: Mon, 9 Oct 2023 14:20:19 +0300 Subject: [PATCH 01/22] Add modalPresentationStyle property to NINCoordinator --- .../View/Coordinator/Coordinator.swift | 11 +++++++++-- NinchatSDKSwift/NINChatSession.swift | 12 +++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/NinchatSDKSwift/Implementations/View/Coordinator/Coordinator.swift b/NinchatSDKSwift/Implementations/View/Coordinator/Coordinator.swift index 186d220f..9ededca0 100644 --- a/NinchatSDKSwift/Implementations/View/Coordinator/Coordinator.swift +++ b/NinchatSDKSwift/Implementations/View/Coordinator/Coordinator.swift @@ -11,7 +11,7 @@ import WebRTC import NinchatLowLevelClient protocol Coordinator: AnyObject { - init(with sessionManager: NINChatSessionManager, delegate: NINChatSessionInternalDelegate?, onPresentationCompletion: @escaping () -> Void) + init(with sessionManager: NINChatSessionManager, delegate: NINChatSessionInternalDelegate?, modalPresentationStyle: UIModalPresentationStyle, onPresentationCompletion: @escaping () -> Void) func start(with queue: String?, resume: ResumeMode?, within navigation: UINavigationController?) -> UIViewController? func prepareNINQuestionnaireViewModel(onCompletion: @escaping () -> Void) func deallocate() @@ -39,6 +39,8 @@ final class NINCoordinator: NSObject, Coordinator, UIAdaptivePresentationControl UIStoryboard(name: "Chat", bundle: .SDKBundle) }() + private let modalPresentationStyle: UIModalPresentationStyle + // MARK: - Questionnaire helpers private var hasPreAudienceQuestionnaire: Bool { @@ -142,9 +144,10 @@ final class NINCoordinator: NSObject, Coordinator, UIAdaptivePresentationControl // MARK: - Coordinator - init(with sessionManager: NINChatSessionManager, delegate: NINChatSessionInternalDelegate?, onPresentationCompletion: @escaping () -> Void) { + init(with sessionManager: NINChatSessionManager, delegate: NINChatSessionInternalDelegate?, modalPresentationStyle: UIModalPresentationStyle, onPresentationCompletion: @escaping () -> Void) { self.delegate = delegate self.sessionManager = sessionManager + self.modalPresentationStyle = modalPresentationStyle self.onPresentationCompletion = onPresentationCompletion } @@ -403,4 +406,8 @@ extension NINCoordinator { func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { self.onPresentationCompletion?() } + + func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle { + return modalPresentationStyle + } } diff --git a/NinchatSDKSwift/NINChatSession.swift b/NinchatSDKSwift/NINChatSession.swift index 38692b6c..1b8b9b93 100644 --- a/NinchatSDKSwift/NINChatSession.swift +++ b/NinchatSDKSwift/NINChatSession.swift @@ -25,15 +25,15 @@ public protocol NINChatSessionProtocol { var session: NINResult { get } var delegate: NINChatSessionDelegate? { get set } - init(configKey: String, queueID: String?, environments: [String]?, metadata: NINLowLevelClientProps?, configuration: NINSiteConfiguration?) + init(configKey: String, queueID: String?, environments: [String]?, metadata: NINLowLevelClientProps?, configuration: NINSiteConfiguration?, modalPresentationStyle: UIModalPresentationStyle) func start(completion: @escaping NinchatSessionCompletion) throws func start(credentials: NINSessionCredentials, completion: @escaping NinchatSessionCompletion) throws func chatSession(within navigationController: UINavigationController?) throws -> UIViewController? func deallocate() } extension NINChatSessionProtocol { - init(configKey: String, queueID: String?, environments: [String]?, metadata: NINLowLevelClientProps?) { - self.init(configKey: configKey, queueID: queueID, environments: environments, metadata: metadata, configuration: nil) + init(configKey: String, queueID: String?, environments: [String]?, metadata: NINLowLevelClientProps?, modalPresentationStyle: UIModalPresentationStyle) { + self.init(configKey: configKey, queueID: queueID, environments: environments, metadata: metadata, configuration: nil, modalPresentationStyle: modalPresentationStyle) } } @@ -42,7 +42,7 @@ public final class NINChatSession: NINChatSessionProtocol, NINChatDevHelper { NINChatSessionManagerImpl(session: self, serverAddress: self.defaultServerAddress, audienceMetadata: self.audienceMetadata, configuration: self.configuration) }() private lazy var coordinator: Coordinator? = { - NINCoordinator(with: self.sessionManager, delegate: self) { [weak self] in + NINCoordinator(with: self.sessionManager, delegate: self, modalPresentationStyle: self.modalPresentationStyle) { [weak self] in self?.deallocate() } }() @@ -61,6 +61,7 @@ public final class NINChatSession: NINChatSessionProtocol, NINChatDevHelper { return Constants.kProductionServerAddress.rawValue #endif } + private var modalPresentationStyle: UIModalPresentationStyle // MARK: - NINChatDevHelper @@ -85,12 +86,13 @@ public final class NINChatSession: NINChatSessionProtocol, NINChatDevHelper { get { sessionManager.appDetails } } - public init(configKey: String, queueID: String? = nil, environments: [String]? = nil, metadata: NINLowLevelClientProps? = nil, configuration: NINSiteConfiguration? = nil) { + public init(configKey: String, queueID: String? = nil, environments: [String]? = nil, metadata: NINLowLevelClientProps? = nil, configuration: NINSiteConfiguration? = nil, modalPresentationStyle: UIModalPresentationStyle) { self.configKey = configKey self.queueID = queueID self.environments = environments self.audienceMetadata = metadata self.configuration = configuration + self.modalPresentationStyle = modalPresentationStyle self.serverAddress = Constants.kProductionServerAddress.rawValue } From b53cf9233163b5ed338e96b490bd2b079f8f915a Mon Sep 17 00:00:00 2001 From: Andrei Sadovnicov Date: Mon, 9 Oct 2023 16:06:32 +0300 Subject: [PATCH 02/22] Add setting color for selected text in chat input --- NinchatSDKSwift/Implementations/Constants.swift | 1 + .../View/UIKit/Input Controls/ChatInputControls.swift | 3 +++ 2 files changed, 4 insertions(+) diff --git a/NinchatSDKSwift/Implementations/Constants.swift b/NinchatSDKSwift/Implementations/Constants.swift index 50c613f5..0c38c6e6 100644 --- a/NinchatSDKSwift/Implementations/Constants.swift +++ b/NinchatSDKSwift/Implementations/Constants.swift @@ -54,6 +54,7 @@ public enum ColorConstants { case ninchatColorChatBubbleRightTint case ninchatColorChatBubbleComposeTint case ninchatColorTextareaText + case ninchatColorTextareaSelectedText case ninchatColorTextareaPlaceholder case ninchatColorTextareaSubmitText case ninchatColorChatBubbleLeftLink diff --git a/NinchatSDKSwift/Implementations/View/UIKit/Input Controls/ChatInputControls.swift b/NinchatSDKSwift/Implementations/View/UIKit/Input Controls/ChatInputControls.swift index 0ce34dbd..b74bba6d 100644 --- a/NinchatSDKSwift/Implementations/View/UIKit/Input Controls/ChatInputControls.swift +++ b/NinchatSDKSwift/Implementations/View/UIKit/Input Controls/ChatInputControls.swift @@ -105,6 +105,9 @@ final class ChatInputControls: UIView, ChatInputControlsProtocol { self.textInput.textColor = inputTextColor textColor = inputTextColor } + if let inputSelectedTextColor = self.delegate?.override(colorAsset: .ninchatColorTextareaSelectedText) { + self.textInput.tintColor = inputSelectedTextColor + } if let inputTextLayer = self.delegate?.override(layerAsset: .ninchatColorTextareaTextInput) { self.textInput.layer.apply(inputTextLayer) } From 8beba6d7885cf949aeeebf2e40e9bad5081468b1 Mon Sep 17 00:00:00 2001 From: Andrei Sadovnicov Date: Tue, 10 Oct 2023 08:05:56 +0300 Subject: [PATCH 03/22] Make modalPresentationStyle parameter optional --- NinchatSDKSwift/NINChatSession.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NinchatSDKSwift/NINChatSession.swift b/NinchatSDKSwift/NINChatSession.swift index 1b8b9b93..a97f73f2 100644 --- a/NinchatSDKSwift/NINChatSession.swift +++ b/NinchatSDKSwift/NINChatSession.swift @@ -86,7 +86,7 @@ public final class NINChatSession: NINChatSessionProtocol, NINChatDevHelper { get { sessionManager.appDetails } } - public init(configKey: String, queueID: String? = nil, environments: [String]? = nil, metadata: NINLowLevelClientProps? = nil, configuration: NINSiteConfiguration? = nil, modalPresentationStyle: UIModalPresentationStyle) { + public init(configKey: String, queueID: String? = nil, environments: [String]? = nil, metadata: NINLowLevelClientProps? = nil, configuration: NINSiteConfiguration? = nil, modalPresentationStyle: UIModalPresentationStyle = .fullScreen) { self.configKey = configKey self.queueID = queueID self.environments = environments From b78221c98226dd578a7d27364c63d2adf0ab888f Mon Sep 17 00:00:00 2001 From: Andrei Sadovnicov Date: Wed, 11 Oct 2023 09:18:17 +0300 Subject: [PATCH 04/22] Add logging for setting action --- .../Extensions/NINLowLevelClientProps+Extension.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/NinchatSDKSwift/Implementations/Extensions/NINLowLevelClientProps+Extension.swift b/NinchatSDKSwift/Implementations/Extensions/NINLowLevelClientProps+Extension.swift index 498b2f82..23defabd 100644 --- a/NinchatSDKSwift/Implementations/Extensions/NINLowLevelClientProps+Extension.swift +++ b/NinchatSDKSwift/Implementations/Extensions/NINLowLevelClientProps+Extension.swift @@ -118,6 +118,7 @@ extension NINLowLevelClientProps: NINLowLevelSessionProps { } func setAction(_ action: NINLowLevelClientActions) { + debugger("set action: \(action)") self.set(value: action.rawValue, forKey: "action") } } From efe21de77a90725a04aa03e171b57e109c873dda Mon Sep 17 00:00:00 2001 From: Andrei Sadovnicov Date: Wed, 11 Oct 2023 09:20:43 +0300 Subject: [PATCH 05/22] Fix typo in NINGroupChatViewController --- .../Implementations/View/Chat.storyboard | 57 +++++++++---------- .../NINGroupChatViewController.swift | 2 +- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/NinchatSDKSwift/Implementations/View/Chat.storyboard b/NinchatSDKSwift/Implementations/View/Chat.storyboard index 7b4b919a..603949fc 100644 --- a/NinchatSDKSwift/Implementations/View/Chat.storyboard +++ b/NinchatSDKSwift/Implementations/View/Chat.storyboard @@ -1,9 +1,8 @@ - + - - + @@ -37,7 +36,7 @@ - + @@ -48,7 +47,7 @@ - + Joined audience queue {{name}}, you are next. @@ -73,7 +72,7 @@ you are next. - + @@ -81,7 +80,7 @@ you are next. - + @@ -345,13 +344,13 @@ you are next. - + - + - + @@ -361,16 +360,16 @@ you are next. - + - + - + @@ -387,7 +386,7 @@ you are next.