Commit 6cf3b825 cgx

搭建我的积分页面UI框架

1 个父辈 9896fcfd
...@@ -28,7 +28,12 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -28,7 +28,12 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithDelegate:(id<DailyTaskViewDelegate>)delegate; - (instancetype)initWithDelegate:(id<DailyTaskViewDelegate>)delegate;
/// 更新签到视图
/// @param requestModel requestModel
- (void)updateSignView:(ScoreTaskRequestModel *)requestModel; - (void)updateSignView:(ScoreTaskRequestModel *)requestModel;
/// 更新任务视图
/// @param requestModel requestModel
- (void)updateTaskView:(ScoreTaskRequestModel *)requestModel; - (void)updateTaskView:(ScoreTaskRequestModel *)requestModel;
@end @end
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
// //
#import "DailyTaskView.h" #import "DailyTaskView.h"
#import "DailyTaskSrollView.h" #import "TaskPointSrollView.h"
#import "DailyBgView.h" #import "DailyBgView.h"
#import "SignTaskView.h" #import "SignTaskView.h"
#import "DailyTaskCell.h" #import "DailyTaskCell.h"
#import "TaskGroupModel.h" #import "TaskGroupModel.h"
@interface DailyTaskView () <UIScrollViewDelegate, UITableViewDelegate, UITableViewDataSource, DailyTaskCellDelegate> @interface DailyTaskView () <UIScrollViewDelegate, UITableViewDelegate, UITableViewDataSource, DailyTaskCellDelegate>
@property (nonatomic, strong) DailyTaskSrollView *dtSrollView; @property (nonatomic, strong) TaskPointSrollView *dtSrollView;
@property (nonatomic, strong) UIScrollView *scrollInnerView; @property (nonatomic, strong) UIScrollView *scrollInnerView;
@property (nonatomic, strong) DailyBgView *dailyBgView; @property (nonatomic, strong) DailyBgView *dailyBgView;
@property (nonatomic, strong) UITableView *taskTableView; @property (nonatomic, strong) UITableView *taskTableView;
...@@ -187,9 +187,9 @@ ...@@ -187,9 +187,9 @@
} }
#pragma mark - lazy #pragma mark - lazy
- (DailyTaskSrollView *)dtSrollView { - (TaskPointSrollView *)dtSrollView {
if (!_dtSrollView) { if (!_dtSrollView) {
_dtSrollView = [[DailyTaskSrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)]; _dtSrollView = [[TaskPointSrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
_dtSrollView.contentSize = CGSizeMake(kScreenWidth, self.bgHeight + kScreenHeight - self.coverHeight); _dtSrollView.contentSize = CGSizeMake(kScreenWidth, self.bgHeight + kScreenHeight - self.coverHeight);
_dtSrollView.showsVerticalScrollIndicator = NO; _dtSrollView.showsVerticalScrollIndicator = NO;
_dtSrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; _dtSrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
......
...@@ -8,29 +8,30 @@ ...@@ -8,29 +8,30 @@
#import "MyPointController.h" #import "MyPointController.h"
#import "ScoreTaskRequestModel.h" #import "ScoreTaskRequestModel.h"
#import "ScoreDetailController.h" #import "ScoreDetailController.h"
#import "MyPointView.h"
@interface MyPointController () @interface MyPointController () <MyPointViewDelegate>
@property (nonatomic, strong) UIImageView *headBgIV; @property (nonatomic, strong) MyPointView *myPointView;
@property (nonatomic, strong) UIButton *scoreDetailBtn; @property (nonatomic, strong) UIButton *scoreDetailBtn;
@end @end
@implementation MyPointController @implementation MyPointController
- (void)loadView {
self.view = self.myPointView;
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = DSWhite; self.myPointView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
self.naviBgColor = DSClearColor; self.naviBgColor = DSClearColor;
self.naviTitle = @"我的积分";
self.naviBarAlpha = 1.0; self.naviBarAlpha = 1.0;
self.naviTitle = @"我的积分";
self.titleLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, DkTitleColor, DSWhite); self.titleLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, DkTitleColor, DSWhite);
[self.backBtn dk_setImage:DKImagePickerWithNames(@"cus_back_icon", @"sys_back_icon", @"sys_back_icon") forState:UIControlStateNormal];
[self.dsNaviBar addSubview:self.backBtn]; [self.dsNaviBar addSubview:self.backBtn];
[self.view insertSubview:self.headBgIV atIndex:0];
[self.headBgIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self.view);
}];
[self.dsNaviBar addSubview:self.scoreDetailBtn]; [self.dsNaviBar addSubview:self.scoreDetailBtn];
[self.scoreDetailBtn mas_makeConstraints:^(MASConstraintMaker *make) { [self.scoreDetailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.dsNaviBar); make.right.equalTo(self.dsNaviBar);
...@@ -57,14 +58,25 @@ ...@@ -57,14 +58,25 @@
[self.navigationController pushViewController:detailVC animated:YES]; [self.navigationController pushViewController:detailVC animated:YES];
} }
#pragma mark - lazy #pragma mark - MyPointViewDelegate
- (UIImageView *)headBgIV { - (void)didScrollToMaxOffsetY:(BOOL)isMax {
if (!_headBgIV) { if (isMax) {
_headBgIV = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"bj_jf_dingbu", @"dk_bj_jf_dingbu", @"dk_bj_jf_dingbu")]; self.isNeedUpdateStatusBarStyle = YES;
self.dsNaviBar.dk_backgroundColorPicker = DKColorPickerWithColors(BrandColor, SubNaviDarkColor, BrandColor);
[self.backBtn setImage:[UIImage imageNamed:@"sys_back_icon"] forState:UIControlStateNormal];
self.titleLab.textColor = DSWhite;
[self.scoreDetailBtn setTitleColor:DSWhite forState:UIControlStateNormal];
} else {
self.naviBgColor = DSClearColor;
self.isNeedUpdateStatusBarStyle = NO;
[self.backBtn dk_setImage:DKImagePickerWithNames(@"cus_back_icon", @"sys_back_icon", @"sys_back_icon") forState:UIControlStateNormal];
self.titleLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, DkTitleColor, DSWhite);
[self.scoreDetailBtn dk_setTitleColorPicker:DKColorPickerWithKey(Dk_TITLE) forState:UIControlStateNormal];
} }
return _headBgIV; self.scoreDetailBtn.layer.borderColor = self.scoreDetailBtn.titleLabel.textColor.CGColor;
} }
#pragma mark - lazy
- (UIButton *)scoreDetailBtn { - (UIButton *)scoreDetailBtn {
if (!_scoreDetailBtn) { if (!_scoreDetailBtn) {
_scoreDetailBtn = [UIButton btnWithTitle:@"积分明细" font:SysFont(12.0)]; _scoreDetailBtn = [UIButton btnWithTitle:@"积分明细" font:SysFont(12.0)];
...@@ -78,4 +90,11 @@ ...@@ -78,4 +90,11 @@
return _scoreDetailBtn; return _scoreDetailBtn;
} }
- (MyPointView *)myPointView {
if (!_myPointView) {
_myPointView = [[MyPointView alloc] initWithDelegate:self];
}
return _myPointView;
}
@end @end
//
// MyPointView.h
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol MyPointViewDelegate <NSObject>
/// 监听scrollview是否滚动到临界值
/// @param isMax isMax
- (void)didScrollToMaxOffsetY:(BOOL)isMax;
@end
/// 自定义我的积分主视图
@interface MyPointView : UIView
@property (nonatomic, weak) id<MyPointViewDelegate> delegate;
- (instancetype)initWithDelegate:(id<MyPointViewDelegate>)delegate;
@end
NS_ASSUME_NONNULL_END
//
// MyPointView.m
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import "MyPointView.h"
#import "TaskPointSrollView.h"
#import "ScoreLevelView.h"
#import "RankHeadView.h"
#import "RankViewCell.h"
@interface MyPointView () <UIScrollViewDelegate, UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) TaskPointSrollView *pointSrollView;
@property (nonatomic, strong) UIScrollView *scrollInnerView;
@property (nonatomic, strong) UIImageView *headBgIV;
@property (nonatomic, strong) ScoreLevelView *scoreLevelView;
@property (nonatomic, strong) UITableView *rankTableView;
@property (nonatomic, strong) RankHeadView *rankHeadView;
@property (nonatomic, assign) BOOL vccanScroll;
@property (nonatomic, assign) CGFloat bgHeight;
@property (nonatomic, strong) NSArray *rankListArr;
@end
@implementation MyPointView
- (instancetype)initWithDelegate:(id<MyPointViewDelegate>)delegate {
if (self = [super init]) {
_delegate = delegate;
self.vccanScroll = YES;
self.bgHeight = 277;
self.rankListArr = @[@1, @2, @3, @4, @5, @6, @7, @8, @9];
[self addSubview:self.headBgIV];
[self.headBgIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self);
}];
[self addSubview:self.pointSrollView];
}
return self;
}
#pragma mark - UITableViewDelegate && UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.rankListArr.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 70;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
RankViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([RankViewCell class]) forIndexPath:indexPath];
cell.textLabel.text = [NSString stringWithFormat:@"%ld", indexPath.row + 1];
return cell;
}
#pragma mark - lazy
- (TaskPointSrollView *)pointSrollView {
if (!_pointSrollView) {
_pointSrollView = [[TaskPointSrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
_pointSrollView.contentSize = CGSizeMake(kScreenWidth, self.bgHeight + kScreenHeight);
_pointSrollView.showsVerticalScrollIndicator = NO;
_pointSrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
_pointSrollView.delegate = self;
_pointSrollView.bounces = NO;
_pointSrollView.backgroundColor = DSClearColor;
[_pointSrollView addSubview:self.scrollInnerView];
}
return _pointSrollView;
}
- (UIScrollView *)scrollInnerView {
if (_scrollInnerView == nil) {
_scrollInnerView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight + self.bgHeight)];
_scrollInnerView.contentSize = CGSizeMake(kScreenWidth, kScreenHeight + self.bgHeight);
_scrollInnerView.showsVerticalScrollIndicator = NO;
_scrollInnerView.delegate = self;
_scrollInnerView.backgroundColor = DSClearColor;
[_scrollInnerView addSubview:self.scoreLevelView];
[_scrollInnerView addSubview:self.rankTableView];
}
return _scrollInnerView;
}
- (UIImageView *)headBgIV {
if (!_headBgIV) {
_headBgIV = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"bj_jf_dingbu", @"dk_bj_jf_dingbu", @"dk_bj_jf_dingbu")];
}
return _headBgIV;
}
- (ScoreLevelView *)scoreLevelView {
if (!_scoreLevelView) {
_scoreLevelView = [[ScoreLevelView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, self.bgHeight)];
[_scoreLevelView debugViewShowBorder];
}
return _scoreLevelView;
}
- (UITableView *)rankTableView {
if (!_rankTableView) {
_rankTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.bgHeight, kScreenWidth, kScreenHeight) style:UITableViewStyleGrouped];
_rankTableView.delegate = self;
_rankTableView.dataSource = self;
_rankTableView.backgroundColor = DSClearColor;
_rankTableView.showsVerticalScrollIndicator = NO;
_rankTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_rankTableView.tableHeaderView = self.rankHeadView;
[_rankTableView registerClass:[RankViewCell class] forCellReuseIdentifier:NSStringFromClass([RankViewCell class])];
}
return _rankTableView;
}
- (RankHeadView *)rankHeadView {
if (!_rankHeadView) {
_rankHeadView = [[RankHeadView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 186)];
}
return _rankHeadView;
}
- (NSArray *)rankListArr {
if (!_rankListArr) {
_rankListArr = [NSArray array];
}
return _rankListArr;
}
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat offsetY = scrollView.contentOffset.y;
if (scrollView == self.pointSrollView) {
CGFloat maxOffsetY = self.bgHeight;
if (offsetY >= maxOffsetY) {
scrollView.contentOffset = CGPointMake(0, maxOffsetY);
self.vccanScroll = NO;
if (self.delegate && [self.delegate respondsToSelector:@selector(didScrollToMaxOffsetY:)]) {
[self.delegate didScrollToMaxOffsetY:YES];
}
} else {
if (self.vccanScroll == NO) {
scrollView.contentOffset = CGPointMake(0, maxOffsetY);
}
}
if (offsetY <= 0) {
if (self.delegate && [self.delegate respondsToSelector:@selector(didScrollToMaxOffsetY:)]) {
[self.delegate didScrollToMaxOffsetY:NO];
}
}
} else if (scrollView == self.rankTableView) {
CGPoint point = [scrollView.panGestureRecognizer translationInView:scrollView];
CGFloat taboffsetY = point.y;
if (offsetY < 0) {
self.vccanScroll = YES;
}
if (taboffsetY < 0) {
if (self.pointSrollView.contentOffset.y < self.bgHeight) {
self.rankTableView.contentOffset = CGPointZero;
}
} else {
if (offsetY > 0) {
self.pointSrollView.contentOffset = CGPointMake(0, self.bgHeight);
} else if (offsetY < 0) {
if (self.pointSrollView.contentOffset.y > 0 && self.pointSrollView.contentOffset.y < self.bgHeight) {
self.rankTableView.contentOffset = CGPointZero;
}
}
}
}
}
@end
//
// RankHeadView.h
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 自定义等级头部视图
@interface RankHeadView : UIView
@end
NS_ASSUME_NONNULL_END
//
// RankHeadView.m
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import "RankHeadView.h"
@interface RankHeadView ()
@end
@implementation RankHeadView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor greenColor];
}
return self;
}
@end
//
// RankViewCell.h
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 排名cell
@interface RankViewCell : UITableViewCell
@end
NS_ASSUME_NONNULL_END
//
// RankViewCell.m
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import "RankViewCell.h"
@interface RankViewCell ()
@end
@implementation RankViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
}
return self;
}
@end
//
// ScoreLevelView.h
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 当前用户积分级别视图
@interface ScoreLevelView : UIView
@end
NS_ASSUME_NONNULL_END
//
// ScoreLevelView.m
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import "ScoreLevelView.h"
@implementation ScoreLevelView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
}
return self;
}
@end
// //
// DailyTaskSrollView.h // TaskPointSrollView.h
// DreamSleep // DreamSleep
// //
// Created by peter on 2022/6/7. // Created by peter on 2022/6/7.
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface DailyTaskSrollView : UIScrollView /// 任务积分自定义滚动视图
@interface TaskPointSrollView : UIScrollView
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
// //
// DailyTaskSrollView.m // TaskPointSrollView.m
// DreamSleep // DreamSleep
// //
// Created by peter on 2022/6/7. // Created by peter on 2022/6/7.
// //
#import "DailyTaskSrollView.h" #import "TaskPointSrollView.h"
@implementation DailyTaskSrollView @implementation TaskPointSrollView
//返回YES,则可以多个手势一起触发方法,返回NO则为互斥(比如外层UIScrollView名为mainScroll内嵌的UIScrollView名为subScroll,当我们拖动subScroll时,mainScroll是不会响应手势的(多个手势默认是互斥的),当下面这个代理返回YES时,subScroll和mainScroll就能同时响应手势,同时滚动,这符合我们这里的需求) //返回YES,则可以多个手势一起触发方法,返回NO则为互斥(比如外层UIScrollView名为mainScroll内嵌的UIScrollView名为subScroll,当我们拖动subScroll时,mainScroll是不会响应手势的(多个手势默认是互斥的),当下面这个代理返回YES时,subScroll和mainScroll就能同时响应手势,同时滚动,这符合我们这里的需求)
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!