YMMineViewController.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. //
  2. // YMMineViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/4.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMMineViewController.h"
  9. #import "YMMineViewModel.h"
  10. #import "YMMineInfoView.h"
  11. #import "YMMineOpenMembershipView.h"
  12. #import "YMMineWealthView.h"
  13. #import "YMMineCommonFunctionsOneView.h"
  14. #import "YMMineCommonFunctionsTwoView.h"
  15. @interface YMMineViewController ()<UIScrollViewDelegate>
  16. /// 我的VM
  17. @property (nonatomic, strong) YMMineViewModel *viewModel;
  18. /// 背景图片视图
  19. @property (nonatomic, strong) UIImageView *backgroundImageView;
  20. /// 内容滚动视图
  21. @property (nonatomic, strong) UIScrollView *contentScrollView;
  22. /// 容器视图
  23. @property (nonatomic, strong) UIView *contentView;
  24. /// 信息视图
  25. @property (nonatomic, strong) YMMineInfoView *infoView;
  26. /// 开通会员视图
  27. @property (nonatomic, strong) YMMineOpenMembershipView *openMembershipView;
  28. /// 财富视图
  29. @property (nonatomic, strong) YMMineWealthView *wealthView;
  30. /// 常用功能一视图
  31. @property (nonatomic, strong) YMMineCommonFunctionsOneView *commonFunctionsOneView;
  32. /// 常用功能二视图
  33. @property (nonatomic, strong) YMMineCommonFunctionsTwoView *commonFunctionsTwoView;
  34. @end
  35. @implementation YMMineViewController
  36. @dynamic viewModel;
  37. - (void)viewDidLoad {
  38. [super viewDidLoad];
  39. [self setNavHidden:YES];
  40. self.view.backgroundColor = HexColorFromRGB(0xF3F4F6);
  41. }
  42. - (void)viewDidAppear:(BOOL)animated{
  43. [super viewDidAppear:animated];
  44. [self.viewModel getMineInfoData];
  45. }
  46. - (UIStatusBarStyle)preferredStatusBarStyle {
  47. return UIStatusBarStyleLightContent;
  48. }
  49. - (void)ym_setupViews{
  50. //[self.view addSubview:self.backgroundImageView];
  51. [self.view addSubview:self.contentScrollView];
  52. [self.contentScrollView addSubview:self.contentView];
  53. [self.contentView addSubview:self.infoView];
  54. [self.contentView addSubview:self.openMembershipView];
  55. [self.contentView addSubview:self.wealthView];
  56. [self.contentView addSubview:self.commonFunctionsOneView];
  57. [self.contentView addSubview:self.commonFunctionsTwoView];
  58. [self.view setNeedsUpdateConstraints];
  59. [self.view updateConstraintsIfNeeded];
  60. }
  61. - (void)updateViewConstraints{
  62. // [self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  63. // make.top.equalTo(self.view);
  64. // make.left.equalTo(self.view);
  65. // make.right.equalTo(self.view);
  66. // make.height.mas_greaterThanOrEqualTo(adapt(306));
  67. // }];
  68. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.top.equalTo(self.view);
  70. make.left.equalTo(self.view);
  71. make.right.equalTo(self.view);
  72. make.bottom.equalTo(self.view).offset(-TabbarHeight);
  73. }];
  74. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.edges.equalTo(self.contentScrollView);
  76. make.width.equalTo(self.contentScrollView.mas_width);
  77. }];
  78. [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.top.equalTo(self.contentView);
  80. make.left.equalTo(self.contentView);
  81. make.right.equalTo(self.contentView);
  82. }];
  83. [self.openMembershipView mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.top.equalTo(self.infoView.mas_bottom).offset(adapt(0));
  85. make.left.equalTo(self.contentView);
  86. make.right.equalTo(self.contentView);
  87. }];
  88. [self.wealthView mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.top.equalTo(self.openMembershipView.mas_bottom);
  90. make.left.equalTo(self.contentView);
  91. make.right.equalTo(self.contentView);
  92. }];
  93. [self.commonFunctionsOneView mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.top.equalTo(self.wealthView.mas_bottom);
  95. make.left.equalTo(self.contentView);
  96. make.right.equalTo(self.contentView);
  97. }];
  98. [self.commonFunctionsTwoView mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.top.equalTo(self.commonFunctionsOneView.mas_bottom);
  100. make.left.equalTo(self.contentView);
  101. make.right.equalTo(self.contentView);
  102. make.bottom.equalTo(self.contentView);
  103. }];
  104. [super updateViewConstraints];
  105. }
  106. - (void)ym_bindViewModel{
  107. [self.infoView ym_bindViewModel:self.viewModel];
  108. [self.openMembershipView ym_bindViewModel:self.viewModel];
  109. [self.wealthView ym_bindViewModel:self.viewModel];
  110. [self.commonFunctionsOneView ym_bindViewModel:self.viewModel];
  111. [self.commonFunctionsTwoView ym_bindViewModel:self.viewModel];
  112. [self.viewModel getMineInfoData];
  113. }
  114. - (UIImageView *)backgroundImageView{
  115. if (!_backgroundImageView) {
  116. _backgroundImageView = [[UIImageView alloc]init];
  117. _backgroundImageView.image = ImageByName(@"mine_bg");
  118. }
  119. return _backgroundImageView;
  120. }
  121. - (UIScrollView *)contentScrollView{
  122. if (!_contentScrollView) {
  123. _contentScrollView = [[UIScrollView alloc] init];
  124. _contentScrollView.delegate = self;
  125. _contentScrollView.alwaysBounceVertical = YES;
  126. _contentScrollView.showsVerticalScrollIndicator = NO;
  127. _contentScrollView.showsHorizontalScrollIndicator = NO;
  128. _contentScrollView.backgroundColor = UIColor.clearColor;
  129. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  130. }
  131. return _contentScrollView;
  132. }
  133. - (UIView *)contentView{
  134. if (!_contentView) {
  135. _contentView = [[UIView alloc]init];
  136. }
  137. return _contentView;
  138. }
  139. - (YMMineInfoView *)infoView{
  140. if (!_infoView) {
  141. _infoView = [[YMMineInfoView alloc]init];
  142. }
  143. return _infoView;
  144. }
  145. - (YMMineOpenMembershipView *)openMembershipView{
  146. if (!_openMembershipView) {
  147. _openMembershipView = [[YMMineOpenMembershipView alloc] init];
  148. _openMembershipView.backgroundColor = UIColor.clearColor;
  149. }
  150. return _openMembershipView;
  151. }
  152. - (YMMineWealthView *)wealthView{
  153. if (!_wealthView) {
  154. _wealthView = [[YMMineWealthView alloc]init];
  155. _wealthView.backgroundColor = UIColor.clearColor;
  156. }
  157. return _wealthView;
  158. }
  159. - (YMMineCommonFunctionsOneView *)commonFunctionsOneView{
  160. if (!_commonFunctionsOneView) {
  161. _commonFunctionsOneView = [[YMMineCommonFunctionsOneView alloc]init];
  162. //_commonFunctionsOneView.layer.shadowColor = HexColorFromRGBA(0x000000,0.06).CGColor;
  163. //_commonFunctionsOneView.layer.shadowOffset = CGSizeMake(0,2);
  164. //_commonFunctionsOneView.layer.shadowOpacity = 1;
  165. //_commonFunctionsOneView.layer.shadowRadius = 4;
  166. [_commonFunctionsOneView addRectCorner:(UIRectCornerTopLeft | UIRectCornerTopRight) radius:20];
  167. }
  168. return _commonFunctionsOneView;
  169. }
  170. - (YMMineCommonFunctionsTwoView *)commonFunctionsTwoView{
  171. if (!_commonFunctionsTwoView) {
  172. _commonFunctionsTwoView = [[YMMineCommonFunctionsTwoView alloc]init];
  173. _commonFunctionsTwoView.layer.shadowColor = HexColorFromRGBA(0x000000,0.06).CGColor;
  174. _commonFunctionsTwoView.layer.shadowOffset = CGSizeMake(0,2);
  175. _commonFunctionsTwoView.layer.shadowOpacity = 1;
  176. _commonFunctionsTwoView.layer.shadowRadius = 4;
  177. }
  178. return _commonFunctionsTwoView;
  179. }
  180. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  181. if (scrollView.contentOffset.y < 0) {
  182. scrollView.contentOffset = CGPointZero;
  183. }
  184. }
  185. @end