Commit b6ad8d66 cgx

签到UI

1 个父辈 7fb6c827
正在显示 37 个修改的文件 包含 682 行增加191 行删除
......@@ -76,6 +76,8 @@
D062A0A128183FE000B4F48A /* FeedbackDetailController.m in Sources */ = {isa = PBXBuildFile; fileRef = D062A0A028183FE000B4F48A /* FeedbackDetailController.m */; };
D070509A28071BAF006D72E1 /* DSNetworkTool.m in Sources */ = {isa = PBXBuildFile; fileRef = D070509928071BAF006D72E1 /* DSNetworkTool.m */; };
D07257F0286BE5510080F458 /* GoodSleepHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257EF286BE5510080F458 /* GoodSleepHeadView.m */; };
D07257F3286BF99F0080F458 /* DailyTaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F2286BF99F0080F458 /* DailyTaskView.m */; };
D07257F6286C2F110080F458 /* SignCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F5286C2F110080F458 /* SignCollectionViewCell.m */; };
D07A4B27280E9BAA00BA0EC0 /* AccountController.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B26280E9BAA00BA0EC0 /* AccountController.m */; };
D07A4B2A280EA6B600BA0EC0 /* UserInfoTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B29280EA6B600BA0EC0 /* UserInfoTableView.m */; };
D07A4B2D280EA73B00BA0EC0 /* UserInfoView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B2C280EA73B00BA0EC0 /* UserInfoView.m */; };
......@@ -371,6 +373,10 @@
D070509928071BAF006D72E1 /* DSNetworkTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DSNetworkTool.m; sourceTree = "<group>"; };
D07257EE286BE5510080F458 /* GoodSleepHeadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GoodSleepHeadView.h; sourceTree = "<group>"; };
D07257EF286BE5510080F458 /* GoodSleepHeadView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GoodSleepHeadView.m; sourceTree = "<group>"; };
D07257F1286BF99F0080F458 /* DailyTaskView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DailyTaskView.h; sourceTree = "<group>"; };
D07257F2286BF99F0080F458 /* DailyTaskView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DailyTaskView.m; sourceTree = "<group>"; };
D07257F4286C2F110080F458 /* SignCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SignCollectionViewCell.h; sourceTree = "<group>"; };
D07257F5286C2F110080F458 /* SignCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SignCollectionViewCell.m; sourceTree = "<group>"; };
D07A4B25280E9BAA00BA0EC0 /* AccountController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccountController.h; sourceTree = "<group>"; };
D07A4B26280E9BAA00BA0EC0 /* AccountController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AccountController.m; sourceTree = "<group>"; };
D07A4B28280EA6B600BA0EC0 /* UserInfoTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UserInfoTableView.h; sourceTree = "<group>"; };
......@@ -1084,8 +1090,12 @@
D091E670283F2E6F00D3279E /* ScoreDetailListController.m */,
D037C495284F4A22000F3089 /* SignTaskView.h */,
D037C496284F4A22000F3089 /* SignTaskView.m */,
D07257F4286C2F110080F458 /* SignCollectionViewCell.h */,
D07257F5286C2F110080F458 /* SignCollectionViewCell.m */,
D037C498284F4F0D000F3089 /* DailyTaskCell.h */,
D037C499284F4F0D000F3089 /* DailyTaskCell.m */,
D07257F1286BF99F0080F458 /* DailyTaskView.h */,
D07257F2286BF99F0080F458 /* DailyTaskView.m */,
D0D4107A2844B8DB00009638 /* DailyTaskController.h */,
D0D4107B2844B8DB00009638 /* DailyTaskController.m */,
D0336161285035AB005573CF /* DailyBgView.h */,
......@@ -1951,6 +1961,7 @@
D037C49D284F5DE8000F3089 /* DailyTaskSrollView.m in Sources */,
D09D0E9D280D73B6008DEDAB /* InviteController.m in Sources */,
D043DD58285B25EE0043A4CE /* VersionRequestModel.m in Sources */,
D07257F3286BF99F0080F458 /* DailyTaskView.m in Sources */,
D0534F092835D90400F8892E /* DSNaviBarViewController.m in Sources */,
D04B3D9A27F6D4D90022F8DF /* LeadingController.m in Sources */,
D0031549284DAC0D00CFE94D /* RelaxBodyView.m in Sources */,
......@@ -1992,6 +2003,7 @@
D0506B0C280503A800229278 /* UIButton+Extras.m in Sources */,
D0C50B3F27FD381000DC68F0 /* UIView+Extras.m in Sources */,
D0FAC41E281B817D00D4B859 /* GKPhotoManager.m in Sources */,
D07257F6286C2F110080F458 /* SignCollectionViewCell.m in Sources */,
D00291892816CD4500C0573B /* DsCacheUtils.m in Sources */,
D07DAC902810546A0067A1BF /* DSImagePickerController.m in Sources */,
D0DF90AE2814390000FC0F64 /* BannerModel.m in Sources */,
......
......@@ -45,7 +45,7 @@
UILabel *leftLab = [UILabel dkLabWithText:@"小梦睡眠" font:BoldFont(24.0)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftLab];
/* rightItem */
// rightItem
UIButton *dailyTaskBtn = [UIButton new];
[dailyTaskBtn addTarget:self action:@selector(jumpToDailyTaskPage) forControlEvents:UIControlEventTouchUpInside];
[dailyTaskBtn dk_setImage:DKImagePickerWithNames(@"ic_home_meirirw", @"dk_ic_home_meirirw", @"ic_home_meirirw") forState:UIControlStateNormal];
......
......@@ -6,6 +6,7 @@
//
#import <UIKit/UIKit.h>
#import "ScoreTaskRequestModel.h"
NS_ASSUME_NONNULL_BEGIN
......@@ -14,6 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier indexPath:(NSIndexPath *)indexPath;
- (void)updateSignView:(ScoreTaskRequestModel *)requestModel;
@end
NS_ASSUME_NONNULL_END
......@@ -28,6 +28,10 @@
return self;
}
- (void)updateSignView:(ScoreTaskRequestModel *)requestModel {
[self.signTaskView updateSignView:requestModel];
}
#pragma mark - lazy
- (SignTaskView *)signTaskView {
if (!_signTaskView) {
......
......@@ -7,44 +7,30 @@
#import "DailyTaskController.h"
#import "ScoreTaskRequestModel.h"
#import "DailyTaskSrollView.h"
#import "DailyBgView.h"
#import "DailyTaskCell.h"
#import "DailyTaskView.h"
@interface DailyTaskController () <UIScrollViewDelegate, UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) DailyTaskSrollView *dtSrollView;
@property (nonatomic, strong) UIScrollView *scrollInnerView;
@property (nonatomic, strong) DailyBgView *dailyBgView;
@property (nonatomic, strong) UITableView *taskTableView;
@property (nonatomic, assign) BOOL vccanScroll;
@property (nonatomic, assign) CGFloat bgHeight;
@property (nonatomic, assign) CGFloat coverHeight;
@property (nonatomic, strong) NSMutableArray *taskListArr;
@interface DailyTaskController () <DailyTaskViewDelegate>
@property (nonatomic, strong) DailyTaskView *dailyTaskView;
@end
@implementation DailyTaskController
- (void)loadView {
self.view = self.dailyTaskView;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.vccanScroll = YES;
self.bgHeight = kScreenWidth*300/375.0;
self.coverHeight = 50;
// 模拟数据
for (int i = 0; i < 10; i++) {
[self.taskListArr addObject:@(i+1)];
}
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
self.dailyTaskView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
self.naviBgColor = DSClearColor;
self.naviBarAlpha = 1.0;
[self.backBtn dk_setImage:DKImagePickerWithNames(@"cus_back_icon", @"sys_back_icon", @"sys_back_icon") forState:UIControlStateNormal];
[self.dsNaviBar addSubview:self.backBtn];
[self.view insertSubview:self.dtSrollView belowSubview:self.dsNaviBar];
[ScoreTaskRequestModel queryUserSignListWithCompletion:^(ScoreTaskRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
[self.dailyTaskView updateSignView:requestModel];
}
}];
[ScoreTaskRequestModel queryUserDailyTaskListWithCompletion:^(ScoreTaskRequestModel * _Nonnull requestModel) {
......@@ -54,186 +40,28 @@
}];
}
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat offsetY = scrollView.contentOffset.y;
if (scrollView == self.dtSrollView) {
CGFloat maxOffsetY = self.bgHeight - self.coverHeight;
if (offsetY >= maxOffsetY) {
scrollView.contentOffset = CGPointMake(0, maxOffsetY);
self.vccanScroll = NO;
#pragma mark - DailyTaskViewDelegate
- (void)scrollViewDidScroll:(BOOL)isMax {
if (isMax) {
self.naviTitle = @"每日任务";
self.isNeedUpdateStatusBarStyle = YES;
self.dsNaviBar.dk_backgroundColorPicker = DKColorPickerWithColors(BrandColor, SubNaviDarkColor, BrandColor);
[self.backBtn setImage:[UIImage imageNamed:@"sys_back_icon"] forState:UIControlStateNormal];
} else {
if (self.vccanScroll == NO) {
scrollView.contentOffset = CGPointMake(0, maxOffsetY);
}
}
if (offsetY <= 0) {
self.naviTitle = @"";
self.naviBgColor = DSClearColor;
self.isNeedUpdateStatusBarStyle = NO;
[self.backBtn dk_setImage:DKImagePickerWithNames(@"cus_back_icon", @"sys_back_icon", @"sys_back_icon") forState:UIControlStateNormal];
}
} else if (scrollView == self.taskTableView) {
CGPoint point = [scrollView.panGestureRecognizer translationInView:scrollView];
CGFloat taboffsetY = point.y;
if (offsetY < 0) {
self.vccanScroll = YES;
}
if (taboffsetY < 0) {
if (self.dtSrollView.contentOffset.y < self.bgHeight - self.coverHeight) {
self.taskTableView.contentOffset = CGPointZero;
}
} else {
if (offsetY > 0) {
self.dtSrollView.contentOffset = CGPointMake(0, self.bgHeight - self.coverHeight);
} else if (offsetY < 0) {
if (self.dtSrollView.contentOffset.y > 0 && self.dtSrollView.contentOffset.y < self.bgHeight - self.coverHeight) {
self.taskTableView.contentOffset = CGPointZero;
}
}
}
}
}
#pragma mark - UITableViewDelegate && UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
return 1;
}
return self.taskListArr.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
return 186;
} else {
return 50;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellID = [NSString stringWithFormat:@"DailyTaskCell_%zd", indexPath.section];
DailyTaskCell *signCell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (!signCell) {
signCell = [[DailyTaskCell alloc] initWithReuseIdentifier:cellID indexPath:indexPath];
}
if (indexPath.section == 0) {
} else {
}
return signCell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
// 最后1个单元格圆角设置
if (indexPath.row == self.taskListArr.count - 1) {
[cell setCornerRadiusRect:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadius:24.0];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (section == 0) {
return 0.001;
} else {
return 15.0 + 52;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
if (section == 2) {
return (24 + Bottom_SafeArea_Height);
} else {
return 0.001;
}
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
CGFloat h = section == 0 ? 0.001 : 15.0 + 52;
if (section == 0) {
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, h)];
} else {
// 添加分区头
UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, h)];
headView.backgroundColor = DSClearColor;
UILabel *titleLab = [UILabel labWithText:(section == 1 ? @"每日任务" : @"新手任务") font:BoldFont(16.0) fit:YES];
titleLab.textAlignment = NSTextAlignmentCenter;
titleLab.frame = CGRectMake(0, 15, kScreenWidth - 30, 52);
[titleLab setCornerRadiusRect:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadius:24.0];
titleLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
titleLab.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
[headView addSubview:titleLab];
return headView;
}
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
CGFloat h = section == 2 ? (24 + Bottom_SafeArea_Height) : 0.001;
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, h)];
}
#pragma mark - lazy
- (DailyTaskSrollView *)dtSrollView {
if (!_dtSrollView) {
_dtSrollView = [[DailyTaskSrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
_dtSrollView.contentSize = CGSizeMake(kScreenWidth, self.bgHeight + kScreenHeight - self.coverHeight);
_dtSrollView.showsVerticalScrollIndicator = NO;
_dtSrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
_dtSrollView.delegate = self;
_dtSrollView.bounces = NO;
[_dtSrollView addSubview:self.scrollInnerView];
}
return _dtSrollView;
}
- (UIScrollView *)scrollInnerView {
if (_scrollInnerView == nil) {
_scrollInnerView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight + self.bgHeight - self.coverHeight)];
_scrollInnerView.contentSize = CGSizeMake(kScreenWidth, kScreenHeight + self.bgHeight - self.coverHeight);
_scrollInnerView.showsVerticalScrollIndicator = NO;
_scrollInnerView.delegate = self;
_scrollInnerView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[_scrollInnerView addSubview:self.dailyBgView];
[_scrollInnerView addSubview:self.taskTableView];
}
return _scrollInnerView;
}
- (DailyBgView *)dailyBgView {
if (!_dailyBgView) {
_dailyBgView = [[DailyBgView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, self.bgHeight)];
}
return _dailyBgView;
}
- (UITableView *)taskTableView {
if (!_taskTableView) {
_taskTableView = [[UITableView alloc] initWithFrame:CGRectMake(15, self.bgHeight - self.coverHeight, kScreenWidth - 30, kScreenHeight) style:UITableViewStyleGrouped];
_taskTableView.delegate = self;
_taskTableView.dataSource = self;
_taskTableView.backgroundColor = DSClearColor;
_taskTableView.showsVerticalScrollIndicator = NO;
_taskTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
return _taskTableView;
}
- (NSMutableArray *)taskListArr {
if (!_taskListArr) {
_taskListArr = [NSMutableArray array];
- (DailyTaskView *)dailyTaskView {
if (!_dailyTaskView) {
_dailyTaskView = [[DailyTaskView alloc] initWithDelegate:self];
[_dailyTaskView debugViewShowBorder];
}
return _taskListArr;
return _dailyTaskView;
}
@end
//
// DailyTaskView.h
// DreamSleep
//
// Created by peter on 2022/6/29.
//
#import <UIKit/UIKit.h>
#import "ScoreTaskRequestModel.h"
NS_ASSUME_NONNULL_BEGIN
@protocol DailyTaskViewDelegate <NSObject>
/// 监听scrollview是否滚动到临界值
/// @param isMax isMax
- (void)didScrollToMaxOffsetY:(BOOL)isMax;
@end
/// 每日任务页面自定义主view
@interface DailyTaskView : UIView
@property (nonatomic, weak) id<DailyTaskViewDelegate> delegate;
- (instancetype)initWithDelegate:(id<DailyTaskViewDelegate>)delegate;
- (void)updateSignView:(ScoreTaskRequestModel *)requestModel;
@end
NS_ASSUME_NONNULL_END
//
// DailyTaskView.m
// DreamSleep
//
// Created by peter on 2022/6/29.
//
#import "DailyTaskView.h"
#import "DailyTaskSrollView.h"
#import "DailyBgView.h"
#import "DailyTaskCell.h"
@interface DailyTaskView () <UIScrollViewDelegate, UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) DailyTaskSrollView *dtSrollView;
@property (nonatomic, strong) UIScrollView *scrollInnerView;
@property (nonatomic, strong) DailyBgView *dailyBgView;
@property (nonatomic, strong) UITableView *taskTableView;
@property (nonatomic, assign) BOOL vccanScroll;
@property (nonatomic, assign) CGFloat bgHeight;
@property (nonatomic, assign) CGFloat coverHeight;
@property (nonatomic, strong) NSMutableArray *taskListArr;
@property (nonatomic, strong) ScoreTaskRequestModel *requestModel;
@end
@implementation DailyTaskView
- (instancetype)initWithDelegate:(id<DailyTaskViewDelegate>)delegate {
if (self = [super init]) {
_delegate = delegate;
self.vccanScroll = YES;
self.bgHeight = kScreenWidth*300/375.0;
self.coverHeight = 50;
// 模拟数据
for (int i = 0; i < 10; i++) {
[self.taskListArr addObject:@(i+1)];
}
[self insertSubview:self.dtSrollView atIndex:0];
}
return self;
}
- (void)updateSignView:(ScoreTaskRequestModel *)requestModel {
self.requestModel = requestModel;
[self.taskTableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
}
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat offsetY = scrollView.contentOffset.y;
if (scrollView == self.dtSrollView) {
CGFloat maxOffsetY = self.bgHeight - self.coverHeight;
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.taskTableView) {
CGPoint point = [scrollView.panGestureRecognizer translationInView:scrollView];
CGFloat taboffsetY = point.y;
if (offsetY < 0) {
self.vccanScroll = YES;
}
if (taboffsetY < 0) {
if (self.dtSrollView.contentOffset.y < self.bgHeight - self.coverHeight) {
self.taskTableView.contentOffset = CGPointZero;
}
} else {
if (offsetY > 0) {
self.dtSrollView.contentOffset = CGPointMake(0, self.bgHeight - self.coverHeight);
} else if (offsetY < 0) {
if (self.dtSrollView.contentOffset.y > 0 && self.dtSrollView.contentOffset.y < self.bgHeight - self.coverHeight) {
self.taskTableView.contentOffset = CGPointZero;
}
}
}
}
}
#pragma mark - UITableViewDelegate && UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
return 1;
}
return self.taskListArr.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
return 186;
} else {
return 50;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellID = [NSString stringWithFormat:@"DailyTaskCell_%zd", indexPath.section];
DailyTaskCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (!cell) {
cell = [[DailyTaskCell alloc] initWithReuseIdentifier:cellID indexPath:indexPath];
}
if (indexPath.section == 0) { // 签到cell
[cell updateSignView:self.requestModel];
} else {
}
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
// 最后1个单元格圆角设置
if (indexPath.row == self.taskListArr.count - 1) {
[cell setCornerRadiusRect:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadius:24.0];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (section == 0) {
return 0.001;
} else {
return 15.0 + 52;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
if (section == 2) {
return (24 + Bottom_SafeArea_Height);
} else {
return 0.001;
}
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
CGFloat h = section == 0 ? 0.001 : 15.0 + 52;
if (section == 0) {
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, h)];
} else {
// 添加分区头
UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, h)];
headView.backgroundColor = DSClearColor;
UILabel *titleLab = [UILabel labWithText:(section == 1 ? @"每日任务" : @"新手任务") font:BoldFont(16.0) fit:YES];
titleLab.textAlignment = NSTextAlignmentCenter;
titleLab.frame = CGRectMake(0, 15, kScreenWidth - 30, 52);
[titleLab setCornerRadiusRect:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadius:24.0];
titleLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
titleLab.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
[headView addSubview:titleLab];
return headView;
}
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
CGFloat h = section == 2 ? (24 + Bottom_SafeArea_Height) : 0.001;
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, h)];
}
#pragma mark - lazy
- (DailyTaskSrollView *)dtSrollView {
if (!_dtSrollView) {
_dtSrollView = [[DailyTaskSrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
_dtSrollView.contentSize = CGSizeMake(kScreenWidth, self.bgHeight + kScreenHeight - self.coverHeight);
_dtSrollView.showsVerticalScrollIndicator = NO;
_dtSrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
_dtSrollView.delegate = self;
_dtSrollView.bounces = NO;
[_dtSrollView addSubview:self.scrollInnerView];
}
return _dtSrollView;
}
- (UIScrollView *)scrollInnerView {
if (_scrollInnerView == nil) {
_scrollInnerView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight + self.bgHeight - self.coverHeight)];
_scrollInnerView.contentSize = CGSizeMake(kScreenWidth, kScreenHeight + self.bgHeight - self.coverHeight);
_scrollInnerView.showsVerticalScrollIndicator = NO;
_scrollInnerView.delegate = self;
_scrollInnerView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[_scrollInnerView addSubview:self.dailyBgView];
[_scrollInnerView addSubview:self.taskTableView];
}
return _scrollInnerView;
}
- (DailyBgView *)dailyBgView {
if (!_dailyBgView) {
_dailyBgView = [[DailyBgView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, self.bgHeight)];
}
return _dailyBgView;
}
- (UITableView *)taskTableView {
if (!_taskTableView) {
_taskTableView = [[UITableView alloc] initWithFrame:CGRectMake(15, self.bgHeight - self.coverHeight, kScreenWidth - 30, kScreenHeight) style:UITableViewStyleGrouped];
_taskTableView.delegate = self;
_taskTableView.dataSource = self;
_taskTableView.backgroundColor = DSClearColor;
_taskTableView.showsVerticalScrollIndicator = NO;
_taskTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
return _taskTableView;
}
- (NSMutableArray *)taskListArr {
if (!_taskListArr) {
_taskListArr = [NSMutableArray array];
}
return _taskListArr;
}
@end
//
// SignCollectionViewCell.h
// DreamSleep
//
// Created by peter on 2022/6/29.
//
#import <UIKit/UIKit.h>
#import "SignModel.h"
#import "ScoreTaskRequestModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface SignCollectionViewCell : UICollectionViewCell
- (void)refreshSignView:(ScoreTaskRequestModel *)requestModel indexPath:(NSIndexPath *)indexPath;
@end
NS_ASSUME_NONNULL_END
//
// SignCollectionViewCell.m
// DreamSleep
//
// Created by peter on 2022/6/29.
//
#import "SignCollectionViewCell.h"
@interface SignCollectionViewCell ()
@property (nonatomic, strong) UIView *dayView;
@property (nonatomic, strong) UILabel *scoreLab;
@property (nonatomic, strong) UIImageView *doneIV;
@property (nonatomic, strong) UIImageView *giftIV;
@property (nonatomic, strong) UILabel *dayLab;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UIView *bigDot;
@property (nonatomic, strong) UIView *smallDot;
@end
@implementation SignCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self debugViewShowBorderWithColor:[UIColor greenColor]];
[self.contentView addSubview:self.dayView];
[self.contentView addSubview:self.giftIV];
[self.contentView addSubview:self.scoreLab];
[self.contentView addSubview:self.doneIV];
[self.dayView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.equalTo(self.contentView);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
[self.giftIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.dayView);
}];
[self.doneIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.dayView);
make.bottom.equalTo(self.dayView).offset(-6);
}];
}
return self;
}
- (void)refreshSignView:(ScoreTaskRequestModel *)requestModel indexPath:(NSIndexPath *)indexPath {
SignModel *signModel = requestModel.signList[indexPath.row];
BOOL is_cur_day = requestModel.cur_day == signModel.day;
// 背景小圆背景颜色显示
DKColorPicker day_dk_bg_color = is_cur_day ? DKColorPickerWithColors(ColorFromHex(0xFC7032), ColorFromHex(0xB5552E), DSWhite) : DKColorPickerWithColors(ColorFromHexA(0xFC7032, .1), ColorFromHexA(0xFC7032, .1), DSWhite);
self.dayView.dk_backgroundColorPicker = day_dk_bg_color;
// 礼物图标显示
if (signModel.state == 0) { // 未签到
if (signModel.day == 3) { // 小礼物
self.giftIV.hidden = NO;
self.giftIV.dk_imagePicker = DKImagePickerWithNames(@"ic_rw_jiangli1", @"dk_ic_rw_jiangli1", @"dk_ic_rw_jiangli1");
} else if (signModel.day == 7) { // 大礼物
self.giftIV.hidden = NO;
self.giftIV.dk_imagePicker = DKImagePickerWithNames(@"ic_rw_jiangli2", @"dk_ic_rw_jiangli2", @"dk_ic_rw_jiangli2");
} else {
self.giftIV.hidden = YES;
}
} else { // 已签到不显示礼物图标
self.giftIV.hidden = YES;
}
// 积分显示
if (signModel.state == 0 && (signModel.day == 3 || signModel.day == 7)) {
self.scoreLab.hidden = YES;
} else {
self.scoreLab.hidden = NO;
}
self.scoreLab.text = [NSString stringWithFormat:@"+%d", signModel.point];
self.scoreLab.font = signModel.state == 1 ? SysFont(12.0) : SysFont(14.0);
[self.scoreLab sizeToFit];
[self.scoreLab mas_makeConstraints:^(MASConstraintMaker *make) {
if (signModel.state == 1) {
make.centerX.equalTo(self.dayView);
make.top.equalTo(self.dayView).offset(6);
} else {
make.center.equalTo(self.dayView);
}
}];
DKColorPicker score_dk_text_color = is_cur_day ? DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) : DKColorPickerWithColors(ColorFromHex(0xFC7032), ColorFromHex(0xFC7032), DSWhite);
self.scoreLab.dk_textColorPicker = score_dk_text_color;
// 完成图标显示
self.doneIV.hidden = signModel.state == 0;
}
#pragma mark - lazy
- (UIView *)dayView {
if (!_dayView) {
_dayView = [UIView new];
[_dayView cornerRadius:20.0];
}
return _dayView;
}
- (UIImageView *)giftIV {
if (!_giftIV) {
_giftIV = [UIImageView new];
}
return _giftIV;
}
- (UILabel *)scoreLab {
if (!_scoreLab) {
_scoreLab = [UILabel new];
_scoreLab.textAlignment = NSTextAlignmentCenter;
_scoreLab.backgroundColor = DSClearColor;
}
return _scoreLab;
}
- (UIImageView *)doneIV {
if (!_doneIV) {
_doneIV = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"ic_rw_yiqiandao", @"dk_ic_rw_yiqiandao", @"ic_rw_yiqiandao")];
}
return _doneIV;
}
@end
......@@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) int day;
/// 当日签到积分值
@property (nonatomic, assign) int point;
/// 签到状态 0:未签到 1: 已签到
/// 签到状态 0未签到 1: 已签到
@property (nonatomic, assign) int state;
@end
......
......@@ -6,12 +6,15 @@
//
#import <UIKit/UIKit.h>
#import "ScoreTaskRequestModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 签到任务视图
@interface SignTaskView : UIView
- (void)updateSignView:(ScoreTaskRequestModel *)requestModel;
@end
NS_ASSUME_NONNULL_END
......@@ -6,6 +6,16 @@
//
#import "SignTaskView.h"
#import "SignCollectionViewCell.h"
@interface SignTaskView () <UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UICollectionView *signMainView;
@property (nonatomic, strong) UIButton *signBtn;
/// 签到列表
@property (nonatomic, strong) NSArray *signList;
@property (nonatomic, strong) ScoreTaskRequestModel *requestModel;
@end
@implementation SignTaskView
......@@ -13,8 +23,96 @@
if (self = [super initWithFrame:frame]) {
self.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
[self cornerRadius:24.0];
[self addSubview:self.titleLab];
[self addSubview:self.signMainView];
[self addSubview:self.signBtn];
[self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.equalTo(self).offset(15);
}];
[self.signMainView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.right.equalTo(self).offset(-15);
make.top.equalTo(self.titleLab.mas_bottom).offset(10);
make.bottom.equalTo(self.signBtn.mas_top).offset(-14);
}];
[self.signBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(155, 40));
make.centerX.equalTo(self);
make.bottom.equalTo(self).offset(-15);
}];
}
return self;
}
- (void)signAction {
}
- (void)updateSignView:(ScoreTaskRequestModel *)requestModel {
if (requestModel && requestModel.signList && requestModel.signList.count) {
self.requestModel = requestModel;
self.signList = requestModel.signList;
[self.signMainView reloadData];
}
}
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.signList.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
SignCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([SignCollectionViewCell class]) forIndexPath:indexPath];
[cell refreshSignView:self.requestModel indexPath:indexPath];
return cell;
}
#pragma mark - lazy
- (UILabel *)titleLab {
if (!_titleLab) {
_titleLab = [UILabel labWithText:@"签到领积分,连续签到有额外奖励" font:SysFont(12.0) fit:YES];
_titleLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3));
}
return _titleLab;
}
- (UICollectionView *)signMainView {
if (!_signMainView) {
CGFloat space = (kScreenWidth - 60 - 280) / 6.0;
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
layout.minimumLineSpacing = 0;
layout.itemSize = CGSizeMake(40 + space, 77);
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
_signMainView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_signMainView.backgroundColor = DSClearColor;
_signMainView.scrollEnabled = NO;
[_signMainView registerClass:[SignCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([SignCollectionViewCell class])];
_signMainView.showsHorizontalScrollIndicator = NO;
_signMainView.delegate = self;
_signMainView.dataSource = self;
}
return _signMainView;
}
- (UIButton *)signBtn {
if (!_signBtn) {
_signBtn = [UIButton btnWithTitle:@"签到领积分" font:BoldFont(16)];
[_signBtn dk_setTitleColorPicker:DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) forState:UIControlStateNormal];
[_signBtn dk_setBackgroundColorPicker:DKColorPickerWithColors(ColorFromHex(0xFEA961), ColorFromHex(0xB77C4E), DSWhite)];
[_signBtn addTarget:self action:@selector(signAction) forControlEvents:UIControlEventTouchUpInside];
[_signBtn cornerRadius:20];
}
return _signBtn;
}
- (NSArray *)signList {
if (!_signList) {
_signList = [NSArray array];
}
return _signList;
}
@end
{
"images" : [
{
"filename" : "dk_ic_rw_jiangli1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_rw_jiangli1@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_rw_jiangli1@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_ic_rw_jiangli2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_rw_jiangli2@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_rw_jiangli2@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_ic_rw_yiqiandao.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_rw_yiqiandao@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_rw_yiqiandao@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_rw_jiangli1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_rw_jiangli1@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_rw_jiangli1@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_rw_jiangli2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_rw_jiangli2@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_rw_jiangli2@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_rw_yiqiandao.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_rw_yiqiandao@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_rw_yiqiandao@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!