ASBirthdayTreatViewController.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. //
  2. // ASBirthdayTreatViewController.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/7/1.
  6. //
  7. #import "ASBirthdayTreatViewController.h"
  8. @interface ASBirthdayTreatViewController ()
  9. @property (nonatomic, strong) UIScrollView *scrollV;
  10. @property (nonatomic, strong) UIView *bgV;
  11. @property (nonatomic, strong) UIImageView *bgImgV;
  12. @property (nonatomic, strong) UIImageView *topImgV;
  13. @property (nonatomic, strong) UIImageView *titleImgV;
  14. @property (nonatomic, strong) UILabel * contentLB;
  15. @property (nonatomic, strong) UILabel * codeDesLB;
  16. @property (nonatomic, strong) UIView *btnV;
  17. @property (nonatomic, strong) UIButton *startBt;
  18. @property (nonatomic, strong) UIView *dateV;
  19. @property (nonatomic, strong) UILabel *monthLb;
  20. @property (nonatomic, strong) UILabel *dayLb;
  21. @property (nonatomic, strong) UIImageView *dayBgV;
  22. @property (nonatomic, strong) UILabel *yearLb;
  23. @end
  24. @implementation ASBirthdayTreatViewController
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. // Do any additional setup after loading the view.
  28. self.titleStr = @"Birthday Treat";
  29. [self setNavRightSearch:^{
  30. }];
  31. [self loadSubviews];
  32. [self configSubVs];
  33. }
  34. - (void)viewWillAppear:(BOOL)animated {
  35. [super viewWillAppear:animated];
  36. // KWLoginedUserModel *info = [KWLoginedManager.shareInstance getCurrentLoginedUser];
  37. // if (info.isBirthday) {
  38. // @weakify(self);
  39. // [self.vm getVIPCouponData:^(BOOL flag) {
  40. // if (flag) {
  41. // weak_self.codeDesLB.text = [NSString stringWithFormat: @"USE CODE: %@\nGET DISCOUNT & GIFTPACK", weak_self.vm.code];
  42. // NSString *birthStr = [NSString stringWithFormat: @"Our Gift To You?\n$%@ To Spend On Your\nFavorite Hair.", weak_self.vm.amount];
  43. // weak_self.contentLB.text = birthStr;
  44. // }
  45. //
  46. //
  47. // }];
  48. // }
  49. }
  50. - (void)configSubVs {
  51. self.statusBgV.backgroundColor = _E0FFF5;
  52. self.customNavBar.backgroundColor = _F0FFFA;
  53. self.titleImgV.image = [UIImage imageNamed:self.isBirthday ? @"birth_titleImg_2" : @"birth_titleImg_1"];
  54. self.codeDesLB.hidden = !self.isBirthday;
  55. self.btnV.hidden = !self.isBirthday;
  56. // KWLoginedUserModel *info = [KWLoginedManager.shareInstance getCurrentLoginedUser];
  57. // NSDate *date = [NSDate dateWithString:info.dob format:@"yyyy-MM-dd hh:mm:ss"];
  58. NSDate *date = [NSDate new];
  59. self.dayLb.text = [NSString stringWithFormat:@"%ld" ,date.day];
  60. NSString *monStr = @"JANUARY";
  61. NSInteger mon = date.month;
  62. switch (mon) {
  63. case 1:
  64. monStr = @"JANUARY";
  65. break;
  66. case 2:
  67. monStr = @"FEBRUARY";
  68. break;
  69. case 3:
  70. monStr = @"MARCH";
  71. break;
  72. case 4:
  73. monStr = @"APRIL";
  74. break;
  75. case 5:
  76. monStr = @"MAY";
  77. break;
  78. case 6:
  79. monStr = @"JUNE";
  80. break;
  81. case 7:
  82. monStr = @"JULY";
  83. break;
  84. case 8:
  85. monStr = @"AUGUST";
  86. break;
  87. case 9:
  88. monStr = @"SEPTEMBER";
  89. break;
  90. case 10:
  91. monStr = @"OCTOBER";
  92. break;
  93. case 11:
  94. monStr = @"NOVEMBER";
  95. break;
  96. default:
  97. monStr = @"DECEMBER";
  98. break;
  99. }
  100. self.monthLb.text = monStr;
  101. self.yearLb.text = [NSString stringWithFormat:@"%ld" ,date.year];// @"2000";
  102. NSString *birthStr = @"Our Gift To You?\n$30 To Spend On Your\nFavorite Hair.";
  103. NSString *defualtStr = [NSString stringWithFormat: @"hello,%@ %@\nThanks for giving us the opportunity to celebratingyour birthday with you in the future.You’re going to receive our special birthday treat.\nLook forward to your special day to come.", @"USER", @"NAME"];//info.lastname, info.firstname];
  104. self.contentLB.text = self.isBirthday ? birthStr : defualtStr;
  105. }
  106. - (void)loadSubviews {
  107. [self.view addSubview:self.scrollV];
  108. [self.scrollV addSubview:self.bgV];
  109. [self.scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
  110. make.top.equalTo(self.customNavBar.mas_bottom);
  111. make.right.left.bottom.equalTo(self.view);
  112. }];
  113. [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.edges.equalTo(self.scrollV);
  115. make.width.equalTo(self.view);
  116. make.height.greaterThanOrEqualTo([NSNumber numberWithFloat:SCREEN_HEIGHT - (NavigationBarHeight+StatusHeight)]);
  117. }];
  118. [self.bgV addSubview:self.bgImgV];
  119. [self.bgImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.edges.equalTo(self.bgV);
  121. }];
  122. UIStackView *stackV = [[UIStackView alloc] init];
  123. stackV.axis = UILayoutConstraintAxisVertical;
  124. stackV.distribution = UIStackViewDistributionFill;
  125. stackV.alignment = UIStackViewAlignmentFill;
  126. stackV.spacing = 20;
  127. [self.bgV addSubview:stackV];
  128. [stackV mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.centerX.equalTo(self.bgV);
  130. make.width.equalTo([NSNumber numberWithFloat:SCREEN_WIDTH - 120]);
  131. make.top.equalTo(self.bgV.mas_top).offset(38);
  132. make.bottom.equalTo(self.bgV.mas_bottom).offset(-150);
  133. }];
  134. UIStackView *topSt = [[UIStackView alloc] init];
  135. topSt.axis = UILayoutConstraintAxisVertical;
  136. topSt.distribution = UIStackViewDistributionFill;
  137. topSt.alignment = UIStackViewAlignmentFill;
  138. topSt.spacing = 8;
  139. [topSt addArrangedSubview:self.topImgV];
  140. [self.topImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  141. make.height.equalTo(@102);
  142. }];
  143. [topSt addArrangedSubview:self.titleImgV];
  144. [self.titleImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.height.equalTo(@68);
  146. }];
  147. [stackV addArrangedSubview:topSt];
  148. [stackV addArrangedSubview:self.contentLB];
  149. // [stackV addArrangedSubview:self.lineV];
  150. // [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  151. // make.height.equalTo(@50);
  152. // }];
  153. [stackV addArrangedSubview:self.btnV];
  154. [self.btnV mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.height.equalTo(@45);
  156. }];
  157. [self.btnV addSubview:self.startBt];
  158. [self.startBt mas_makeConstraints:^(MASConstraintMaker *make) {
  159. make.height.equalTo(@45);
  160. make.width.equalTo([NSNumber numberWithFloat:SCREEN_WIDTH-150]);
  161. make.center.equalTo(self.btnV);
  162. }];
  163. [stackV addArrangedSubview:self.codeDesLB];
  164. [self.codeDesLB mas_makeConstraints:^(MASConstraintMaker *make) {
  165. make.height.equalTo(@48);
  166. }];
  167. [stackV addArrangedSubview:self.dateV];
  168. [self.dateV addSubview:self.monthLb];
  169. [self.dateV addSubview:self.dayBgV];
  170. [self.dateV addSubview:self.dayLb];
  171. [self.dateV addSubview:self.yearLb];
  172. [self.monthLb mas_makeConstraints:^(MASConstraintMaker *make) {
  173. make.height.equalTo(@17);
  174. make.centerX.equalTo(self.dateV);
  175. make.top.equalTo(self.dateV).offset(10);
  176. }];
  177. [self.dayBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  178. make.height.equalTo(@45);
  179. make.width.equalTo(@36.5);
  180. make.centerX.equalTo(self.dateV);
  181. make.top.equalTo(self.monthLb.mas_bottom).offset(5);
  182. }];
  183. [self.dayLb mas_makeConstraints:^(MASConstraintMaker *make) {
  184. make.center.equalTo(self.dayBgV);
  185. make.height.equalTo(self.dayBgV);
  186. make.width.equalTo(self.dayBgV);
  187. }];
  188. [self.yearLb mas_makeConstraints:^(MASConstraintMaker *make) {
  189. make.height.equalTo(@17);
  190. make.centerX.equalTo(self.dateV);
  191. make.top.equalTo(self.dayBgV.mas_bottom).offset(5);
  192. make.bottom.equalTo(self.dateV).offset(-10);
  193. }];
  194. dispatch_async(dispatch_get_main_queue(), ^{
  195. [self viewAddLineColorBg:self.bgV colorArr:@[
  196. (id)_E0FFF5.CGColor,
  197. (id)Col_FFF.CGColor
  198. ]];
  199. });
  200. }
  201. - (UIScrollView *)scrollV {
  202. if (!_scrollV) {
  203. UIScrollView *v = [UIScrollView new];
  204. v.showsVerticalScrollIndicator = false;
  205. v.showsHorizontalScrollIndicator = false;
  206. v.backgroundColor = Col_FFF;
  207. _scrollV = v;
  208. }
  209. return _scrollV;
  210. }
  211. - (UIView *)bgV {
  212. if (!_bgV) {
  213. UIView *v = [UIView new];
  214. _bgV = v;
  215. }
  216. return _bgV;
  217. }
  218. - (UIImageView *)bgImgV {
  219. if (!_bgImgV) {
  220. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_bg"]];
  221. v.contentMode = UIViewContentModeScaleToFill;
  222. _bgImgV = v;
  223. }
  224. return _bgImgV;
  225. }
  226. - (UIImageView *)topImgV {
  227. if (!_topImgV) {
  228. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_topImg"]];
  229. v.contentMode = UIViewContentModeScaleAspectFit;
  230. _topImgV = v;
  231. }
  232. return _topImgV;
  233. }
  234. - (UIImageView *)titleImgV {
  235. if (!_titleImgV) {
  236. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_titleImg_1"]];
  237. v.contentMode = UIViewContentModeScaleAspectFit;
  238. _titleImgV = v;
  239. }
  240. return _titleImgV;
  241. }
  242. - (UILabel *)contentLB {
  243. if (!_contentLB) {
  244. UILabel *lb = [[UILabel alloc] init];
  245. lb.numberOfLines = 0;
  246. lb.textAlignment = NSTextAlignmentCenter;
  247. lb.textColor = UIColor.blackColor;
  248. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  249. lb.qmui_lineHeight = 24;
  250. _contentLB = lb;
  251. }
  252. return _contentLB;
  253. }
  254. - (UILabel *)codeDesLB {
  255. if (!_codeDesLB) {
  256. UILabel *lb = [[UILabel alloc] init];
  257. lb.numberOfLines = 0;
  258. lb.textColor = _043632;
  259. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  260. lb.qmui_lineHeight = 24;
  261. lb.textAlignment = NSTextAlignmentCenter;
  262. lb.lineBreakMode = NSLineBreakByWordWrapping;
  263. lb.text = @"USE CODE: BIRTHDAY\nGET DISCOUNT & GIFTPACK";
  264. _codeDesLB = lb;
  265. }
  266. return _codeDesLB;
  267. }
  268. - (UIView *)btnV {
  269. if (!_btnV) {
  270. UIView *v = [UIView new];
  271. v.backgroundColor = UIColor.clearColor;
  272. _btnV = v;
  273. }
  274. return _btnV;
  275. }
  276. - (UIButton *)startBt {
  277. if (!_startBt) {
  278. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  279. bt.backgroundColor = [UIColor blackColor];
  280. bt.layer.cornerRadius = 4;
  281. bt.layer.masksToBounds = true;
  282. [bt setTitle:@"GET THE PARTY STARTED" forState:UIControlStateNormal];
  283. [bt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  284. bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
  285. [bt addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside];
  286. _startBt = bt;
  287. }
  288. return _startBt;
  289. }
  290. - (void)btnAction {
  291. // if (![self.vm.typeId isEqualToString:@""]) {
  292. // KWProductListViewController *vc = [[KWProductListViewController alloc] init];
  293. // vc.titleName = @"HD Lace";
  294. // vc.type = self.vm.typeId;
  295. // [self.navigationController pushViewController:vc animated:YES];
  296. // } else {
  297. // [self.view makeToast:@"Get Birth Products Type Error"];
  298. // }
  299. }
  300. - (UIView *)dateV {
  301. if (!_dateV) {
  302. UIView *v = [UIView new];
  303. v.backgroundColor = UIColor.clearColor;
  304. _dateV = v;
  305. }
  306. return _dateV;
  307. }
  308. - (UILabel *)monthLb {
  309. if (!_monthLb) {
  310. UILabel *lb = [[UILabel alloc] init];
  311. lb.numberOfLines = 0;
  312. lb.textColor = UIColor.blackColor;
  313. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  314. lb.qmui_lineHeight = 20;
  315. _monthLb = lb;
  316. }
  317. return _monthLb;
  318. }
  319. - (UILabel *)dayLb {
  320. if (!_dayLb) {
  321. UILabel *lb = [[UILabel alloc] init];
  322. lb.numberOfLines = 0;
  323. lb.textColor = UIColor.blackColor;
  324. lb.font = [UIFont fontWithName:Rob_Bold size:20];
  325. lb.qmui_lineHeight = 20;
  326. lb.textAlignment = NSTextAlignmentCenter;
  327. _dayLb = lb;
  328. }
  329. return _dayLb;
  330. }
  331. - (UILabel *)yearLb {
  332. if (!_yearLb) {
  333. UILabel *lb = [[UILabel alloc] init];
  334. lb.numberOfLines = 0;
  335. lb.textColor = UIColor.blackColor;
  336. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  337. lb.qmui_lineHeight = 20;
  338. _yearLb = lb;
  339. }
  340. return _yearLb;
  341. }
  342. - (UIImageView *)dayBgV {
  343. if (!_dayBgV) {
  344. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_dayTime_bg"]];
  345. v.contentMode = UIViewContentModeScaleAspectFit;
  346. _dayBgV = v;
  347. }
  348. return _dayBgV;
  349. }
  350. - (void)viewAddLineColorBg:(UIView *)bgV colorArr:(NSArray *)colors {
  351. CAGradientLayer *layer = [[CAGradientLayer alloc] init];
  352. layer.frame = bgV.bounds;
  353. layer.colors = colors;
  354. layer.startPoint = CGPointMake(0.44, 0.2);
  355. layer.endPoint = CGPointMake(0.5, 1);
  356. layer.locations = @[@0,@1.0f];
  357. layer.name = @"colorLayer";
  358. [bgV.layer insertSublayer:layer atIndex:0];
  359. }
  360. @end