@@ -25,6 +25,7 @@ class MainViewController: UIViewController, UIScrollViewDelegate {
2525 @IBOutlet private weak var resetDidButton : UIButton !
2626 @IBOutlet private weak var showStoriesButton : UIButton !
2727 @IBOutlet private weak var showSnackBarButton : UIButton !
28+ private var showTestPopupButton : UIButton !
2829
2930 public var waitIndicator : SdkActivityIndicator !
3031
@@ -188,6 +189,48 @@ class MainViewController: UIViewController, UIScrollViewDelegate {
188189 storiesCollectionView. showStories ( )
189190 }
190191
192+ @objc
193+ private func showTestPopup( ) {
194+ guard let sdk = globalSDK else {
195+ return
196+ }
197+
198+ let componentsDict : [ String : Any ] = [
199+ " header " : " Test Popup " ,
200+ " text " : " This is a test popup for iOS SDK "
201+ ]
202+
203+ let componentsJSON : String
204+ if let componentsData = try ? JSONSerialization . data ( withJSONObject: componentsDict) ,
205+ let componentsString = String ( data: componentsData, encoding: . utf8) {
206+ componentsJSON = componentsString
207+ } else {
208+ componentsJSON = " {} "
209+ }
210+
211+ let testPopupData : [ String : Any ] = [
212+ " id " : 999 ,
213+ " channels " : [ " email " ] ,
214+ " position " : " centered " ,
215+ " delay " : 0 ,
216+ " html " : """
217+ <div class= " popup-title " >Test Popup</div>
218+ <p class= " popup-999__intro " >This is a test popup for iOS SDK</p>
219+ """ ,
220+ " components " : componentsJSON,
221+ " web_push_system " : false ,
222+ " popup_actions " : " {} "
223+ ]
224+
225+ let testPopup = Popup ( json: testPopupData)
226+
227+ sdk. popupPresenter. dismissCurrentPopup ( )
228+
229+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.1 ) {
230+ sdk. popupPresenter. presentPopup ( testPopup)
231+ }
232+ }
233+
191234 func setupSdkDemoAppViews( ) {
192235 navigationController? . navigationBar. isHidden = true
193236 scrollView. contentSize = CGSize ( width: UIScreen . main. bounds. size. width, height: 2000 )
@@ -199,6 +242,8 @@ class MainViewController: UIViewController, UIScrollViewDelegate {
199242 resetDidButton. addTarget ( self , action: #selector( didTapReset) , for: . touchUpInside)
200243 showStoriesButton. addTarget ( self , action: #selector( showStories) , for: . touchUpInside)
201244
245+ setupTestPopupButton ( )
246+
202247 fontInterPreload ( )
203248 DispatchQueue . main. asyncAfter ( deadline: . now( ) + 2.0 ) {
204249 self . setupSdkLabels ( )
@@ -231,6 +276,24 @@ class MainViewController: UIViewController, UIScrollViewDelegate {
231276 self . waitIndicator. hideIndicatorWhenStopped = true
232277 }
233278
279+ func setupTestPopupButton( ) {
280+ showTestPopupButton = DemoShopButton ( type: . system)
281+ showTestPopupButton. setTitle ( " Show Test Popup " , for: . normal)
282+ showTestPopupButton. setTitleColor ( . white, for: . normal)
283+ showTestPopupButton. translatesAutoresizingMaskIntoConstraints = false
284+ scrollView. addSubview ( showTestPopupButton)
285+
286+ // Размещаем кнопку рядом с другими тестовыми кнопками
287+ NSLayoutConstraint . activate ( [
288+ showTestPopupButton. topAnchor. constraint ( equalTo: showStoriesButton. bottomAnchor, constant: 10 ) ,
289+ showTestPopupButton. leadingAnchor. constraint ( equalTo: showStoriesButton. leadingAnchor) ,
290+ showTestPopupButton. widthAnchor. constraint ( equalTo: showStoriesButton. widthAnchor) ,
291+ showTestPopupButton. heightAnchor. constraint ( equalTo: showStoriesButton. heightAnchor)
292+ ] )
293+
294+ showTestPopupButton. addTarget ( self , action: #selector( showTestPopup) , for: . touchUpInside)
295+ }
296+
234297 func fontInterPreload( ) {
235298 fcmTokenLabel. font = SdkDynamicFont . dynamicFont ( textStyle: . headline, weight: . bold)
236299 pushTokenLabel . font = SdkDynamicFont . dynamicFont ( textStyle: . headline, weight: . bold)
0 commit comments