Commit 36a42789 authored by hl's avatar hl

update

parent 0dc8be8a
//
// CheckView.h
// PhotoEdit3
//
// Created by 甘瑞文 on 2019/9/19.
// Copyright © 2019 甘瑞文. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface CheckView : UIView
@property (nonatomic, strong) NSMutableArray<NSMutableDictionary *> *data;
- (instancetype)initWithFrame:(CGRect)frame data:(NSMutableArray<NSMutableDictionary *> *)data;
@end
NS_ASSUME_NONNULL_END
//
// CheckView.m
// PhotoEdit3
//
// Created by 甘瑞文 on 2019/9/19.
// Copyright © 2019 甘瑞文. All rights reserved.
//
#import "CheckView.h"
#import "Utils.h"
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define RGB(r,g,b,a) [UIColor colorWithRed:(double)r/255.0f green:(double)g/255.0f blue:(double)b/255.0f alpha:a]
@interface CheckView ()
{
NSInteger _index;
}
@property (nonatomic, strong) UIView *correctView;
@property (nonatomic, strong) UIScrollView *questionView;
@property (nonatomic, strong) NSMutableArray<UIButton *> *correctButtons;
@property (nonatomic, strong) NSMutableArray<UIButton *> *questionButtons;
@end
@implementation CheckView
- (instancetype)init
{
self = [super init];
if (self) {
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame data:(NSMutableArray<NSMutableDictionary *> *)data
{
self = [super initWithFrame:frame];
if (self) {
_data = data;
// self.data = [Utils dictionaryWithJsonString:@"{\"images\":[{\"origImage\":\"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1568953445781&di=f58fdbbabd748ddafbdbdcbd58167b36&imgtype=0&src=http%3A%2F%2Foss.aliyuncs.com%2Fmsimage%2FUpload%2Fwww.kashangwl.com%2FCooperationLink%2F9ccc1233-d045-4fb1-9892-5f70a6a48abf.png\",\"editedImage\":\"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1568953445781&di=f58fdbbabd748ddafbdbdcbd58167b36&imgtype=0&src=http%3A%2F%2Foss.aliyuncs.com%2Fmsimage%2FUpload%2Fwww.kashangwl.com%2FCooperationLink%2F9ccc1233-d045-4fb1-9892-5f70a6a48abf.png\"},{\"origImage\":\"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1568953445781&di=f58fdbbabd748ddafbdbdcbd58167b36&imgtype=0&src=http%3A%2F%2Foss.aliyuncs.com%2Fmsimage%2FUpload%2Fwww.kashangwl.com%2FCooperationLink%2F9ccc1233-d045-4fb1-9892-5f70a6a48abf.png\",\"editedImage\":\"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1568953445781&di=f58fdbbabd748ddafbdbdcbd58167b36&imgtype=0&src=http%3A%2F%2Foss.aliyuncs.com%2Fmsimage%2FUpload%2Fwww.kashangwl.com%2FCooperationLink%2F9ccc1233-d045-4fb1-9892-5f70a6a48abf.png\"}],\"questions\":[{\"name\":\"1\",\"status\":0},{\"name\":\"2\",\"status\":0},{\"name\":\"3\",\"status\":0},{\"name\":\"4\",\"status\":0},{\"name\":\"5\",\"status\":0}]}"][@"questions"];
self.backgroundColor = [UIColor blackColor];
self.alpha = 0.7;
[self configUI];
}
return self;
}
- (void)configUI
{
[self setupCorrectView];
[self setupQuestionView];
}
- (void)setupCorrectView
{
self.correctView.frame = CGRectMake(0, 20, self.frame.size.width, 60);
NSArray *normalImages = @[@"正确-未选中.png", @"半对-未选中.png", @"错误-未选中.png"];
NSArray *selectImages = @[@"正确-选中.png", @"半对-选中.png", @"错误-选中.png"];
for (int i = 0; i < normalImages.count; i ++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.bounds = CGRectMake(0, 0, 40, 40);
[btn setImage:[UIImage imageNamed:normalImages[i]] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:selectImages[i]] forState:UIControlStateSelected];
btn.center = CGPointMake((SCREEN_WIDTH / 3) / 2 + (SCREEN_WIDTH / 3) * i, 30);
// int status = [self.data[i][@"status"] intValue];
// btn.tag = 10 + status;
if (i == 0) {
btn.tag = 100 + 10;
}
if (i == 1) {
btn.tag = 60 + 10;
}
if (i == 2) {
btn.tag = -1 + 10;
}
[btn addTarget:self action:@selector(check:) forControlEvents:UIControlEventTouchUpInside];
// [self chooseCorrect:status];
[self.correctView addSubview:btn];
[self.correctButtons addObject:btn];
}
[self addSubview:self.correctView];
}
- (void)setupQuestionView
{
self.questionView.frame = CGRectMake(0, 150 - 40, SCREEN_WIDTH, 40);
for (int i = 0; i < self.data.count; i ++) {
NSMutableDictionary *dic = self.data[i];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setTitle:dic[@"name"] forState:UIControlStateNormal];
btn.titleLabel.font = [UIFont systemFontOfSize:11];
if (i == 0) {
btn.titleLabel.font = [UIFont boldSystemFontOfSize:15];
}
btn.tag = 20 + i;
btn.bounds = CGRectMake(0, 0, 60, 40);
btn.center = CGPointMake(i * 60 + 30, 20);
[btn addTarget:self action:@selector(chooseQuestion:) forControlEvents:UIControlEventTouchUpInside];
[self chooseCorrectBtn:btn status:[dic[@"status"] intValue]];
if (i < self.data.count - 1) {
UIView *line = [[UIView alloc] init];
line.backgroundColor = [UIColor whiteColor];
line.bounds = CGRectMake(0, 0, 1, 15);
line.center = CGPointMake(i * 60 + 60, 20);
[self.questionView addSubview:line];
}
[self.questionView addSubview:btn];
[self.questionButtons addObject:btn];
}
self.questionView.contentSize = CGSizeMake(60 * self.data.count, 40);
[self addSubview:self.questionView];
}
- (void)chooseCorrectBtn:(UIButton *)btn status:(NSInteger )status
{
switch (status) {
case 100:
//全对
[btn setTitleColor:RGB(142, 195, 31, 1) forState:UIControlStateNormal];
break;
case 60:
//半对
[btn setTitleColor:RGB(171, 115, 37, 1) forState:UIControlStateNormal];
break;
case -1:
//错误
[btn setTitleColor:RGB(169, 88, 89, 1) forState:UIControlStateNormal];
break;
case 0:
//未编辑
break;
default:
break;
}
}
- (void)selectQuestion:(NSInteger)status
{
for (UIButton *btn in self.correctButtons) {
[btn setSelected:NO];
}
switch (status) {
case 100:
//全对
[self.correctButtons[0] setSelected:YES];
break;
case 60:
//半对
[self.correctButtons[1] setSelected:YES];
break;
case -1:
//错误
[self.correctButtons[2] setSelected:YES];
break;
case 0:
//未编辑
break;
default:
break;
}
}
#pragma mark - action
- (void)check:(UIButton *)sender
{
for (UIButton *btn in self.correctButtons) {
[btn setSelected:NO];
}
[self.data[_index] setObject:@(sender.tag - 10) forKey:@"status"];
[self chooseCorrectBtn:self.questionButtons[_index] status:sender.tag - 10];
[sender setSelected:YES];
//选择后要跳到下一题
if (_index == self.questionButtons.count - 1) {
return;
}
[self chooseQuestion:self.questionButtons[_index + 1]];
}
- (void)chooseQuestion:(UIButton *)sender
{
_index = sender.tag - 20;
for (UIButton *btn in self.questionButtons) {
[UIView animateWithDuration:0.5 animations:^{
btn.titleLabel.font = [UIFont systemFontOfSize:11];
}];
}
sender.titleLabel.font = [UIFont boldSystemFontOfSize:15];
[self selectQuestion:[self.data[_index][@"status"] integerValue]];
}
#pragma mark - setter
- (void)setData:(NSMutableDictionary *)data
{
_data = data;
}
#pragma mark - getter
- (UIView *)correctView
{
if (!_correctView) {
_correctView = [[UIView alloc] init];
}
return _correctView;
}
- (UIScrollView *)questionView
{
if (!_questionView) {
_questionView = [[UIScrollView alloc] init];
_questionView.showsVerticalScrollIndicator = NO;
_questionView.showsHorizontalScrollIndicator = NO;
}
return _questionView;
}
- (NSMutableArray *)correctButtons
{
if (!_correctButtons) {
_correctButtons = [[NSMutableArray alloc] init];
}
return _correctButtons;
}
- (NSMutableArray *)questionButtons
{
if (!_questionButtons) {
_questionButtons = [[NSMutableArray alloc] init];
}
return _questionButtons;
}
@end
...@@ -78,6 +78,11 @@ Pod::Spec.new do |s| ...@@ -78,6 +78,11 @@ Pod::Spec.new do |s|
ss.public_header_files = 'LFMediaEditingController/class/vendors/LFMediaDisplayView/*.h','LFMediaEditingController/class/vendors/LFMediaDisplayView/**/*.h' ss.public_header_files = 'LFMediaEditingController/class/vendors/LFMediaDisplayView/*.h','LFMediaEditingController/class/vendors/LFMediaDisplayView/**/*.h'
end end
s.subspec 'CheckView' do |ss|
ss.source_files = 'CheckView/*.{h,m}','CheckView/**/*.{h,m}'
ss.resources = 'CheckView/images/*.{png, xib}'
end
end end
\ No newline at end of file
...@@ -246,6 +246,14 @@ ...@@ -246,6 +246,14 @@
70AA07CC2428965200913FEB /* YJBezierPath.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YJBezierPath.h; sourceTree = "<group>"; }; 70AA07CC2428965200913FEB /* YJBezierPath.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YJBezierPath.h; sourceTree = "<group>"; };
70AA07CD2428965200913FEB /* LFDataFilterImageView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LFDataFilterImageView.h; sourceTree = "<group>"; }; 70AA07CD2428965200913FEB /* LFDataFilterImageView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LFDataFilterImageView.h; sourceTree = "<group>"; };
70AA07CE2428965200913FEB /* LFSplashView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LFSplashView.m; sourceTree = "<group>"; }; 70AA07CE2428965200913FEB /* LFSplashView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LFSplashView.m; sourceTree = "<group>"; };
70AA07E42428C82A00913FEB /* CheckView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CheckView.m; sourceTree = "<group>"; };
70AA07E62428C82A00913FEB /* 错误-未选中.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "错误-未选中.png"; sourceTree = "<group>"; };
70AA07E72428C82A00913FEB /* 半对-未选中.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "半对-未选中.png"; sourceTree = "<group>"; };
70AA07E82428C82A00913FEB /* 正确-未选中.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "正确-未选中.png"; sourceTree = "<group>"; };
70AA07E92428C82A00913FEB /* 正确-选中.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "正确-选中.png"; sourceTree = "<group>"; };
70AA07EA2428C82A00913FEB /* 错误-选中.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "错误-选中.png"; sourceTree = "<group>"; };
70AA07EB2428C82A00913FEB /* 半对-选中.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "半对-选中.png"; sourceTree = "<group>"; };
70AA07EC2428C82A00913FEB /* CheckView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CheckView.h; sourceTree = "<group>"; };
96C07757F20464F4AC5B060A /* Pods-RNGeekImageEditor.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNGeekImageEditor.debug.xcconfig"; path = "Target Support Files/Pods-RNGeekImageEditor/Pods-RNGeekImageEditor.debug.xcconfig"; sourceTree = "<group>"; }; 96C07757F20464F4AC5B060A /* Pods-RNGeekImageEditor.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNGeekImageEditor.debug.xcconfig"; path = "Target Support Files/Pods-RNGeekImageEditor/Pods-RNGeekImageEditor.debug.xcconfig"; sourceTree = "<group>"; };
B2E39BAE03E14EB914ABA09D /* Pods-RNGeekImageEditor.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNGeekImageEditor.release.xcconfig"; path = "Target Support Files/Pods-RNGeekImageEditor/Pods-RNGeekImageEditor.release.xcconfig"; sourceTree = "<group>"; }; B2E39BAE03E14EB914ABA09D /* Pods-RNGeekImageEditor.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNGeekImageEditor.release.xcconfig"; path = "Target Support Files/Pods-RNGeekImageEditor/Pods-RNGeekImageEditor.release.xcconfig"; sourceTree = "<group>"; };
DC88F9BF241A328E0074E2BD /* ImageEditorModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageEditorModel.h; sourceTree = "<group>"; }; DC88F9BF241A328E0074E2BD /* ImageEditorModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageEditorModel.h; sourceTree = "<group>"; };
...@@ -295,6 +303,7 @@ ...@@ -295,6 +303,7 @@
DC88F9C1241A328E0074E2BD /* ImageEditorModel.m */, DC88F9C1241A328E0074E2BD /* ImageEditorModel.m */,
70AA071A2428964500913FEB /* Utils.h */, 70AA071A2428964500913FEB /* Utils.h */,
70AA071B2428964500913FEB /* Utils.m */, 70AA071B2428964500913FEB /* Utils.m */,
70AA07E32428C82A00913FEB /* CheckView */,
70AA071D2428965200913FEB /* LFMediaEditingController */, 70AA071D2428965200913FEB /* LFMediaEditingController */,
70AA070F2428963900913FEB /* YYImage */, 70AA070F2428963900913FEB /* YYImage */,
70AA06C72428963400913FEB /* YBImageBrowser */, 70AA06C72428963400913FEB /* YBImageBrowser */,
...@@ -892,13 +901,35 @@ ...@@ -892,13 +901,35 @@
path = subView; path = subView;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
70AA07E32428C82A00913FEB /* CheckView */ = {
isa = PBXGroup;
children = (
70AA07E42428C82A00913FEB /* CheckView.m */,
70AA07E52428C82A00913FEB /* Images */,
70AA07EC2428C82A00913FEB /* CheckView.h */,
);
path = CheckView;
sourceTree = "<group>";
};
70AA07E52428C82A00913FEB /* Images */ = {
isa = PBXGroup;
children = (
70AA07E62428C82A00913FEB /* 错误-未选中.png */,
70AA07E72428C82A00913FEB /* 半对-未选中.png */,
70AA07E82428C82A00913FEB /* 正确-未选中.png */,
70AA07E92428C82A00913FEB /* 正确-选中.png */,
70AA07EA2428C82A00913FEB /* 错误-选中.png */,
70AA07EB2428C82A00913FEB /* 半对-选中.png */,
);
path = Images;
sourceTree = "<group>";
};
D02055EC85C82592ED91D4AF /* Pods */ = { D02055EC85C82592ED91D4AF /* Pods */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96C07757F20464F4AC5B060A /* Pods-RNGeekImageEditor.debug.xcconfig */, 96C07757F20464F4AC5B060A /* Pods-RNGeekImageEditor.debug.xcconfig */,
B2E39BAE03E14EB914ABA09D /* Pods-RNGeekImageEditor.release.xcconfig */, B2E39BAE03E14EB914ABA09D /* Pods-RNGeekImageEditor.release.xcconfig */,
); );
name = Pods;
path = Pods; path = Pods;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment