MORedPacketHistoryView.m 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // MORedPacketHistoryView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/6/13.
  6. //
  7. #import "MORedPacketHistoryView.h"
  8. #import "JXCategoryTitleBackgroundView.h"
  9. #import "MORedPacketHistoryTableView.h"
  10. @interface MORedPacketHistoryView ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
  11. @property (weak, nonatomic) IBOutlet UILabel *titleLab;
  12. @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
  13. @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
  14. @end
  15. @implementation MORedPacketHistoryView
  16. + (instancetype)moRedPacketHistoryView{
  17. return [[[NSBundle mainBundle] loadNibNamed:@"MORedPacketHistoryView" owner:self options:nil] firstObject];
  18. }
  19. - (void)awakeFromNib{
  20. [super awakeFromNib];
  21. self.titleLab.text = NSLocalString(@"mimo_red_packet_history_title");
  22. self.titleLab.font = [MOTextTools getTheFontWithSize:18 AndFontName:kNormalContentFontStr];
  23. self.titleLab.textColor = [MOTools colorWithHexString:@"#333333"];
  24. self.layer.cornerRadius = 16.0;
  25. self.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
  26. self.titleCategoryView.titles = @[NSLocalString(@"mimo_red_packet_history_received"),NSLocalString(@"mimo_red_packet_history_issued")];
  27. CGFloat totalItemWidth = 280.0;
  28. self.titleCategoryView.layer.cornerRadius = 30.0 / 2.0;
  29. self.titleCategoryView.layer.masksToBounds = YES;
  30. self.titleCategoryView.cellSpacing = 0;
  31. self.titleCategoryView.cellWidth = totalItemWidth / self.titleCategoryView.titles.count;
  32. self.titleCategoryView.titleColor = [MOTools colorWithHexString:@"#FFFFFF" alpha:1.0];
  33. self.titleCategoryView.titleSelectedColor = [MOTools colorWithHexString:@"#6B2800" alpha:1.0];
  34. self.titleCategoryView.titleFont = [MOTextTools getTheFontWithSize:13.0 AndFontName:kNormalContentFontStr];
  35. self.titleCategoryView.titleSelectedFont = [MOTextTools getTheFontWithSize:13.0 AndFontName:kNormalContentBlodFontStr];
  36. self.titleCategoryView.backgroundColor = [MOTools colorWithHexString:@"#C3BDB9"];
  37. self.titleCategoryView.layer.borderColor = [MOTools colorWithHexString:@"#FFBB95" alpha:0.5].CGColor;
  38. self.titleCategoryView.layer.borderWidth = 1;
  39. JXCategoryIndicatorBackgroundView *backgroundTwoView = [[JXCategoryIndicatorBackgroundView alloc] init];
  40. backgroundTwoView.indicatorHeight = 30.0;
  41. backgroundTwoView.indicatorWidthIncrement = 0;
  42. backgroundTwoView.indicatorColor = [MOTools colorWithHexString:@"#FFEC85" alpha:1.0];
  43. NSArray *colorTwoArr = @[[MOTools colorWithHexString:@"#FAEFA7"],[MOTools colorWithHexString:@"#FFB54C"]];
  44. UIImage *imageTwo = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, 142.0, 30.0) Colors:colorTwoArr GradientType:0];
  45. UIImageView *imgTwoBgView = [[UIImageView alloc] init];
  46. imgTwoBgView.contentMode = UIViewContentModeScaleToFill;
  47. [imgTwoBgView setImage:imageTwo];
  48. [backgroundTwoView addSubview:imgTwoBgView];
  49. [imgTwoBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.edges.equalTo(backgroundTwoView);
  51. }];
  52. imgTwoBgView.layer.cornerRadius = 15;
  53. imgTwoBgView.layer.masksToBounds = YES;
  54. imgTwoBgView.layer.borderColor = [MOTools colorWithHexString:@"#FFBB95"].CGColor;
  55. imgTwoBgView.layer.borderWidth = 1;
  56. self.titleCategoryView.indicators = @[backgroundTwoView];
  57. [self addSubview:self.titleCategoryView];
  58. [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.equalTo(self).offset(60.0);
  60. make.centerX.equalTo(self);
  61. make.width.equalTo(@(totalItemWidth));
  62. make.height.equalTo(@30.0);
  63. }];
  64. [self addSubview:self.listContainerView];
  65. [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.top.equalTo(self).offset(108.0);
  67. make.left.right.bottom.equalTo(self);
  68. }];
  69. self.titleCategoryView.listContainer = self.listContainerView;
  70. }
  71. - (IBAction)closeBtnClick:(id)sender {
  72. [self dismissRedPacketHistoryView];
  73. }
  74. // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
  75. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
  76. MOLogV(@"变换了");
  77. }
  78. #pragma mark - JXCategoryListContainerViewDelegate
  79. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
  80. return self.titleCategoryView.titles.count;
  81. }
  82. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
  83. MORedPacketHistoryTableView *view = [[MORedPacketHistoryTableView alloc] init];
  84. view.viewType = index;
  85. return view;
  86. }
  87. - (void)showRedPacketHistoryView{
  88. [UIView animateWithDuration:0.3 animations:^{
  89. self.transform = CGAffineTransformMakeTranslation(0, -self.height);
  90. [self layoutIfNeeded];
  91. }];
  92. }
  93. - (void)dismissRedPacketHistoryView{
  94. [UIView animateWithDuration:0.3 animations:^{
  95. self.transform = CGAffineTransformIdentity;
  96. [self layoutIfNeeded];
  97. }];
  98. }
  99. #pragma mark - Lazy
  100. - (JXCategoryTitleView *)titleCategoryView {
  101. if(!_titleCategoryView){
  102. _titleCategoryView = [[JXCategoryTitleView alloc] init];
  103. _titleCategoryView.delegate = self;
  104. }
  105. return _titleCategoryView;
  106. }
  107. - (JXCategoryListContainerView *)listContainerView{
  108. if(!_listContainerView){
  109. _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
  110. }
  111. return _listContainerView;
  112. }
  113. @end