diff --git a/GigyaSwift/Gigya/GigyaCore.swift b/GigyaSwift/Gigya/GigyaCore.swift index 122745b9..c77f4ef2 100644 --- a/GigyaSwift/Gigya/GigyaCore.swift +++ b/GigyaSwift/Gigya/GigyaCore.swift @@ -444,11 +444,11 @@ public final class GigyaCore: GigyaInstanceProtocol { - Parameter completion: Plugin completion `GigyaPluginEvent`. */ - public func showScreenSet(with name: String, viewController: UIViewController, params: [String: Any] = [:], completion: @escaping (GigyaPluginEvent) -> Void) { + public func showScreenSet(with name: String, viewController: UIViewController, params: [String: Any] = [:], isModal: Bool = true, completion: @escaping (GigyaPluginEvent) -> Void) { let webBridge = createWebBridge() pluginViewWrapper = PluginViewWrapper(config: config, persistenceService: persistenceService, sessionService: sessionService, businessApiService: businessApiService, webBridge: webBridge, plugin: "accounts.screenSet", params: params, completion: completion) - pluginViewWrapper?.presentPluginController(viewController: viewController, dataType: T.self, screenSet: name) + pluginViewWrapper?.presentPluginController(viewController: viewController, dataType: T.self, screenSet: name, isModal: isModal) } // MARK: - Interruptions diff --git a/GigyaSwift/Global/Plugins/PluginViewWrapper.swift b/GigyaSwift/Global/Plugins/PluginViewWrapper.swift index bc2824ee..a69ba3c0 100644 --- a/GigyaSwift/Global/Plugins/PluginViewWrapper.swift +++ b/GigyaSwift/Global/Plugins/PluginViewWrapper.swift @@ -9,7 +9,7 @@ import UIKit protocol PluginViewWrapperProtocol { - func presentPluginController(viewController: UIViewController, dataType: T.Type, screenSet: String?) + func presentPluginController(viewController: UIViewController, dataType: T.Type, screenSet: String?, isModal: Bool) } class PluginViewWrapper: PluginViewWrapperProtocol { @@ -51,7 +51,7 @@ class PluginViewWrapper: PluginViewWrapperProtocol { - Parameter dataType: Account schema. - Parameter screenSet: Requested screen set. */ - func presentPluginController(viewController: UIViewController, dataType: C.Type, screenSet: String? = nil) { + func presentPluginController(viewController: UIViewController, dataType: C.Type, screenSet: String? = nil, isModal: Bool) { if let screenSet = screenSet { params["screenSet"] = screenSet } @@ -79,9 +79,22 @@ class PluginViewWrapper: PluginViewWrapperProtocol { pluginViewController = PluginViewController(webBridge: webBridge, pluginEvent: eventHandler!) - let navigationController = UINavigationController(rootViewController: pluginViewController!) - - viewController.present(navigationController, animated: true) { + if(isModal) { + let navigationController = UINavigationController(rootViewController: pluginViewController!) + viewController.present(navigationController, animated: true) { + self.webBridge?.load(html: html) + } + } + else { + viewController.addChild(pluginViewController!); + viewController.view.addSubview(pluginViewController!.view); + + pluginViewController!.view.translatesAutoresizingMaskIntoConstraints = false; + pluginViewController!.view.topAnchor.constraint(equalTo:viewController.view.topAnchor, constant: 0).isActive = true + pluginViewController!.view.bottomAnchor.constraint(equalTo:viewController.view.bottomAnchor, constant: 0).isActive = true + pluginViewController!.view.leadingAnchor.constraint(equalTo:viewController.view.leadingAnchor, constant: 0).isActive = true + pluginViewController!.view.trailingAnchor.constraint(equalTo:viewController.view.trailingAnchor, constant: 0).isActive = true + self.webBridge?.load(html: html) } }