12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- //
- // SPSBOpenPopupManager.m
- // 我的社保
- //
- // Created by shanp on 2021/4/26.
- //
- #import "SPSBOpenPopupManager.h"
- #import <JXHMacro.h>
- #import <JXHGeneralTools.h>
- #import "SPSBGeneralManager.h"
- #import "SPSBPopupViewController.h"
- static NSMutableArray<SPSBOpenPopupModel *> *_spsb_popupArray = nil;
- static bool _spsb_canPopup = true;
- static bool _spsb_beginPoput = false;
- @implementation SPSBOpenPopupModel @end
- @implementation SPSBOpenPopupManager
- + (void)insertPopupAtFirst:(SPSBOpenPopupModel *)popup {
- if (!_spsb_popupArray) {
- _spsb_popupArray = NSMutableArray.new;
- }
- [_spsb_popupArray insertObject:popup atIndex:0];
- [self check];
- }
- + (void)insertPopup:(SPSBOpenPopupModel *)popup {
- if (!_spsb_popupArray) {
- _spsb_popupArray = NSMutableArray.new;
- }
- [_spsb_popupArray addObject:popup];
- [self check];
- }
- + (void)beginPopup {
- _spsb_beginPoput = true;
- [self check];
- }
- + (void)check {
- if (!_spsb_beginPoput) return;
- dispatch_main_async_safe(^{
- if (!_spsb_canPopup || _spsb_popupArray.count == 0) return;
- _spsb_canPopup = false;
- [self pop];
- });
- }
- + (void)pop {
- SPSBOpenPopupModel *model = _spsb_popupArray[0];
- [_spsb_popupArray removeObjectAtIndex:0];
- [jxh_findPresentedViewControllerStartingFrom(spsb_keyWindow().rootViewController) presentViewController:model.spsb_popup animated:false completion:^{
- if (!model.spsb_stopPopup) {
- _spsb_canPopup = true;
- [self check];
- }
- }];
- }
- @end
|