YMBaseViewController.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // YMBaseViewController.h
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/4.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "ZCBaseVC.h"
  9. #import "YMBaseViewModel.h"
  10. #import "YMBaseCustomNavView.h"
  11. #import <MJRefresh/MJRefresh.h>
  12. NS_ASSUME_NONNULL_BEGIN
  13. /** 导航栏风格 */
  14. typedef NS_ENUM(NSUInteger, YMBaseNavigationStyle) {
  15. /** 白色*/
  16. YMBaseNavigationStyleWhite = 0,
  17. /** 透明背景白色返回*/
  18. YMBaseNavigationStyleClearBgWhiteBackArrow,
  19. /** 透明背景黑色返回*/
  20. YMBaseNavigationStyleClearBgBlackBackArrow,
  21. /** 渐变*/
  22. YMBaseNavigationStyleGradient,
  23. };
  24. @interface YMBaseViewController : ZCBaseVC
  25. ///导航栏的样式
  26. @property (nonatomic, assign) YMBaseNavigationStyle ym_navigationStyle;
  27. ///自定义导航栏 如果需要自定义导航栏在最上层,把其他视图用sendSubviewToBack降至底层这样就不会被遮罩住无法交互了
  28. @property (nonatomic, strong) YMBaseCustomNavView *ym_customNavView;
  29. ///是否隐藏左item
  30. @property (nonatomic, assign) BOOL isHideLeftItem;
  31. ///隐藏导航条
  32. - (void)setNavHidden:(BOOL)hidden;
  33. /**
  34. 统一使用该方法初始化,子类中直接声明对于的'readonly' 的 'viewModel'属性,
  35. 并在@implementation内部加上关键词 '@dynamic viewModel;'
  36. @dynamic A相当于告诉编译器:“参数A的getter和setter方法并不在此处,
  37. 而在其他地方实现了或者生成了,当你程序运行的时候你就知道了,
  38. 所以别警告我了”这样程序在运行的时候,
  39. 对应参数的getter和setter方法就会在其他地方去寻找,比如父类。
  40. */
  41. - (instancetype)initWithViewModel:(YMBaseViewModel*)viewModel;
  42. @property (nonatomic, strong, readonly) YMBaseViewModel *viewModel;
  43. - (void)ym_setupViews;
  44. - (void)ym_bindViewModel;
  45. /// 下拉刷新头部
  46. @property (nonatomic, strong) MJRefreshNormalHeader *refreshHeader;
  47. /// 上拉加载更多底部,还有更多数据可以加载的状态下使用
  48. @property (nonatomic, strong) MJRefreshAutoNormalFooter *loadMoreFooter;
  49. /// 不会上拉加载更多的底部,没有更多数据可以加载的状态下使用
  50. @property (nonatomic, strong) MJRefreshAutoNormalFooter *noLoadMoreFooter;
  51. /// 下拉刷新回调方法,具体实现代码需要子类实现
  52. - (void)headerRefreshing;
  53. /// 上拉加载回调方法,具体实现代码需要子类实现
  54. - (void)footerRefreshing;
  55. @end
  56. /** 导航按钮*/
  57. @interface YMBaseViewController (YMNavBar)
  58. /** 左Bar按钮+标题*/
  59. - (void)setLeftBarButtonWithTitle:(NSString *)title
  60. block:(void (^)(id sender))block;
  61. /** 右Bar按钮+标题*/
  62. - (void)setRightBarButtonWithTitle:(NSString *)title
  63. block:(void (^)(id sender))block;
  64. /** 左Bar按钮+图片*/
  65. - (void)setLeftBarButtonWithImage:(NSString *)image
  66. block:(void (^)(id sender))block;
  67. /** 右Bar按钮+图片*/
  68. - (void)setRightBarButtonWithImage:(NSString *)image
  69. block:(void (^)(id sender))block;
  70. /** 左Bar多个按钮*/
  71. - (void)setLeftBarButtonWithButtons:(NSArray *)buttons;
  72. /** 右Bar多个按钮*/
  73. - (void)setRightBarButtonWithButtons:(NSArray *)buttons;
  74. /** 左Bar自定义View*/
  75. - (void)setLeftBarButtonWithCustomView:(UIView *)customView;
  76. /** 右Bar自定义View*/
  77. - (void)setRightBarButtonWithCustomView:(UIView *)customView;
  78. @end
  79. NS_ASSUME_NONNULL_END