QuitMultipleModeAlertViewController.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // QuitMultipleModeAlertViewController.m
  3. // sampleSDK
  4. //
  5. // Created by 王昭威 on 2023/1/18.
  6. //
  7. #import "QuitMultipleModeAlertViewController.h"
  8. #import "PCSTools.h"
  9. #import "PCSButton.h"
  10. #import "UIColor+JKAdd.h"
  11. #import <Masonry/Masonry.h>
  12. @interface QuitMultipleModeAlertViewController ()
  13. @property (nonatomic, strong) UIViewPropertyAnimator* animator;
  14. @property (nonatomic, copy) void(^saveBlock)(QuitMultipleModeAlertViewController*);
  15. @property (nonatomic, copy) void(^discardBlock)(QuitMultipleModeAlertViewController*);
  16. @end
  17. @implementation QuitMultipleModeAlertViewController
  18. + (void)show:(UIViewController *)controller withSaveButtonCallBack: (void(^)(QuitMultipleModeAlertViewController* alertController))saveCallBack discardButtonCallBack: (void(^)(QuitMultipleModeAlertViewController* alertController))discardCallBack{
  19. [self show:controller title:nil text:nil leftBtnTitle:nil rightBtnTitle:nil withLeftButtonCallBack:discardCallBack rightButtonCallBack:saveCallBack];
  20. }
  21. + (void)show:(UIViewController *)controller title:(NSString *)title text:(NSString *)text leftBtnTitle:(NSString *)leftBtnTitle rightBtnTitle:(NSString *)rightBtnTitle withLeftButtonCallBack:(void (^)(QuitMultipleModeAlertViewController * _Nonnull))leftBtnCallBack rightButtonCallBack:(void (^)(QuitMultipleModeAlertViewController * _Nonnull))rightBtnCallBack{
  22. QuitMultipleModeAlertViewController* instance = [[QuitMultipleModeAlertViewController alloc] initWithNibName:@"QuitMultipleModeAlertViewController" bundle:[PCSTools sdkBundle]];
  23. if(instance != nil){
  24. __weak typeof(instance) weakIns = instance;
  25. [instance loadView];
  26. instance.saveBlock = rightBtnCallBack;
  27. instance.discardBlock = leftBtnCallBack;
  28. if(title != nil){
  29. instance.title = title;
  30. }
  31. if(text != nil){
  32. instance.textLabel.text = text;
  33. }
  34. if(leftBtnTitle != nil){
  35. [instance.leftButton setTitle:leftBtnTitle forState:UIControlStateNormal];
  36. }
  37. if(rightBtnTitle != nil){
  38. [instance.rightButton setTitle:rightBtnTitle forState:UIControlStateNormal];
  39. }
  40. [instance addline];
  41. instance.contentView.layer.transform = CATransform3DScale(instance.contentView.layer.transform, 0.1, 0.1, 1);
  42. instance.animator = [[UIViewPropertyAnimator alloc] initWithDuration:0.5 dampingRatio:0.3 animations:^{
  43. weakIns.contentView.layer.transform = CATransform3DIdentity;
  44. }];
  45. instance.modalPresentationStyle = UIModalPresentationOverCurrentContext;
  46. [controller presentViewController:instance animated:NO completion:^{
  47. [instance.animator startAnimation];
  48. }];
  49. }
  50. }
  51. - (instancetype)init{
  52. self = [super init];
  53. if(self){
  54. }
  55. return self;
  56. }
  57. -(void)addline{
  58. UIView *line = [[UIView alloc]init];
  59. line.backgroundColor = [UIColor jk_colorWithHexString:@"#e5e5e5"];
  60. [self.leftButton addSubview:line];
  61. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.top.right.bottom.offset(0);
  63. make.width.offset(0.5);
  64. }];
  65. }
  66. - (void)viewDidLoad {
  67. [super viewDidLoad];
  68. // Do any additional setup after loading the view.
  69. }
  70. - (IBAction)saveButtonTouchUpInside:(id)sender{
  71. self.saveBlock(self);
  72. }
  73. - (IBAction)discardButtonTouchUpInside: (id)sender{
  74. self.discardBlock(self);
  75. }
  76. /*
  77. #pragma mark - Navigation
  78. // In a storyboard-based application, you will often want to do a little preparation before navigation
  79. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  80. // Get the new view controller using [segue destinationViewController].
  81. // Pass the selected object to the new view controller.
  82. }
  83. */
  84. @end