Skip to content

Commit 08eae47

Browse files
committed
打赏 - UI
1 parent e85892b commit 08eae47

11 files changed

Lines changed: 269 additions & 3 deletions

File tree

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@
210210
4E5D13101C0ECB3400985AEB /* tweet_btn_reward@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E5D13061C0ECB3400985AEB /* tweet_btn_reward@3x.png */; };
211211
4E5D13111C0ECB3400985AEB /* tweet_btn_rewarded@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E5D13071C0ECB3400985AEB /* tweet_btn_rewarded@2x.png */; };
212212
4E5D13121C0ECB3400985AEB /* tweet_btn_rewarded@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E5D13081C0ECB3400985AEB /* tweet_btn_rewarded@3x.png */; };
213+
4E5D13151C0EDFE700985AEB /* SendRewardManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5D13141C0EDFE700985AEB /* SendRewardManager.m */; };
214+
4E5D13181C0EF48200985AEB /* button_close@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E5D13161C0EF48200985AEB /* button_close@2x.png */; };
215+
4E5D13191C0EF48200985AEB /* button_close@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E5D13171C0EF48200985AEB /* button_close@3x.png */; };
213216
4E5F39021AC951060010515D /* TaskCommentCCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5F39011AC951060010515D /* TaskCommentCCell.m */; };
214217
4E5F39051ACA958C0010515D /* TopicCommentCCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5F39041ACA958C0010515D /* TopicCommentCCell.m */; };
215218
4E5F39071ACBFDCD0010515D /* keyboard_photo@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E5F39061ACBFDCD0010515D /* keyboard_photo@2x.png */; };
@@ -1245,6 +1248,10 @@
12451248
4E5D13061C0ECB3400985AEB /* tweet_btn_reward@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tweet_btn_reward@3x.png"; sourceTree = "<group>"; };
12461249
4E5D13071C0ECB3400985AEB /* tweet_btn_rewarded@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tweet_btn_rewarded@2x.png"; sourceTree = "<group>"; };
12471250
4E5D13081C0ECB3400985AEB /* tweet_btn_rewarded@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tweet_btn_rewarded@3x.png"; sourceTree = "<group>"; };
1251+
4E5D13131C0EDFE700985AEB /* SendRewardManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SendRewardManager.h; sourceTree = "<group>"; };
1252+
4E5D13141C0EDFE700985AEB /* SendRewardManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SendRewardManager.m; sourceTree = "<group>"; };
1253+
4E5D13161C0EF48200985AEB /* button_close@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "button_close@2x.png"; sourceTree = "<group>"; };
1254+
4E5D13171C0EF48200985AEB /* button_close@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "button_close@3x.png"; sourceTree = "<group>"; };
12481255
4E5F39001AC951060010515D /* TaskCommentCCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskCommentCCell.h; sourceTree = "<group>"; };
12491256
4E5F39011AC951060010515D /* TaskCommentCCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TaskCommentCCell.m; sourceTree = "<group>"; };
12501257
4E5F39031ACA958C0010515D /* TopicCommentCCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopicCommentCCell.h; sourceTree = "<group>"; };
@@ -3328,6 +3335,8 @@
33283335
4EC461AC1B39084100D08970 /* FunctionTipsManager.m */,
33293336
4E00229E1B7360B1005308DE /* FunctionIntroManager.h */,
33303337
4E00229F1B7360B1005308DE /* FunctionIntroManager.m */,
3338+
4E5D13131C0EDFE700985AEB /* SendRewardManager.h */,
3339+
4E5D13141C0EDFE700985AEB /* SendRewardManager.m */,
33313340
);
33323341
path = Manager;
33333342
sourceTree = "<group>";
@@ -4110,6 +4119,8 @@
41104119
4EAE068F1B784E9200179F4B /* store_icon@2x.png */,
41114120
4EAE06911B7880BA00179F4B /* me_info_arrow_left@2x.png */,
41124121
4EAC8B691BA01F190060B0FC /* little_phone_icon@2x.png */,
4122+
4E5D13161C0EF48200985AEB /* button_close@2x.png */,
4123+
4E5D13171C0EF48200985AEB /* button_close@3x.png */,
41134124
);
41144125
path = Images;
41154126
sourceTree = "<group>";
@@ -4940,6 +4951,7 @@
49404951
4E6384011B33C18700D98648 /* task_activity_icon_update_priority@2x.png in Resources */,
49414952
7E335D9F1B6F5E94003D0F3D /* keyboard_voice@2x.png in Resources */,
49424953
4E90F89B1AF709C100B44F03 /* bubble.html in Resources */,
4954+
4E5D13191C0EF48200985AEB /* button_close@3x.png in Resources */,
49434955
8E8F7B2D19EF6306006BA8BD /* btn_followed_not@2x.png in Resources */,
49444956
4EF17EE11B3C3112003CDD2D /* intro_tip_2@3x.png in Resources */,
49454957
4E6383DC1B3266C200D98648 /* mrpr_icon_fileChange@2x.png in Resources */,
@@ -5074,6 +5086,7 @@
50745086
8EA6D1A119E240C40076D59C /* tipIcon_UserFollow@2x.png in Resources */,
50755087
4E095A7F1B6B1E40008DC439 /* calendar_0xF5A523@2x.png in Resources */,
50765088
8EA6D18319E240C40076D59C /* me_normal@2x.png in Resources */,
5089+
4E5D13181C0EF48200985AEB /* button_close@2x.png in Resources */,
50775090
4EF17EDC1B3C3112003CDD2D /* intro_tip_0@2x.png in Resources */,
50785091
8EA6D19719E240C40076D59C /* tipIcon_Project@2x.png in Resources */,
50795092
4EF17ED31B3C3112003CDD2D /* intro_icon_2@2x.png in Resources */,
@@ -5333,6 +5346,7 @@
53335346
8EA6D13B19E240C40076D59C /* RootTabViewController.m in Sources */,
53345347
4E4ABBEA1A653027004760D9 /* WebViewController.m in Sources */,
53355348
4E6FB0551B5799B100B0A17B /* ProjectTag.m in Sources */,
5349+
4E5D13151C0EDFE700985AEB /* SendRewardManager.m in Sources */,
53365350
4E6BA2E51A1EE6AF005FD721 /* UIImageView+AFNetworking.m in Sources */,
53375351
8EA6D1B919E240C40076D59C /* ProjectMember.m in Sources */,
53385352
4E996BCD1ABA773800C704F1 /* UserInfoViewController.m in Sources */,

Coding_iOS/Images/.DS_Store

4 KB
Binary file not shown.
415 Bytes
Loading
595 Bytes
Loading

Coding_iOS/Models/User.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@property (readwrite, nonatomic, strong) NSString *avatar, *name, *global_key, *path, *slogan, *company, *tags_str, *tags, *location, *job_str, *job, *email, *birthday, *pinyinName;
1313
@property (readwrite, nonatomic, strong) NSString *curPassword, *resetPassword, *resetPasswordConfirm, *phone, *introduction;
1414

15-
@property (readwrite, nonatomic, strong) NSNumber *id, *sex, *follow, *followed, *fans_count, *follows_count, *tweets_count, *status;
15+
@property (readwrite, nonatomic, strong) NSNumber *id, *sex, *follow, *followed, *fans_count, *follows_count, *tweets_count, *status, *points_left;
1616
@property (readwrite, nonatomic, strong) NSDate *created_at, *last_logined_at, *last_activity_at, *updated_at;
1717

1818
+ (User *)userWithGlobalKey:(NSString *)global_key;

Coding_iOS/Util/Manager/Coding_NetAPIManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ typedef NS_ENUM(NSUInteger, VerifyType){
176176
- (void)request_UserTagArrayWithBlock:(void (^)(id data, NSError *error))block;
177177
- (void)request_UpdateUserInfo_WithObj:(User *)curUser andBlock:(void (^)(id data, NSError *error))block;
178178
- (void)request_PointRecords:(PointRecords *)records andBlock:(void (^)(id data, NSError *error))block;
179+
- (void)request_Preparereward:(NSString *)tweet_id andBlock:(void (^)(id data, NSError *error))block;
180+
179181

180182
//Message
181183
- (void)request_PrivateMessages:(PrivateMessages *)priMsgs andBlock:(void (^)(id data, NSError *error))block;

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,15 @@ - (void)request_PointRecords:(PointRecords *)records andBlock:(void (^)(id data,
17441744
}];
17451745
}
17461746

1747+
- (void)request_Preparereward:(NSString *)tweet_id andBlock:(void (^)(id data, NSError *error))block{
1748+
NSString *path = [NSString stringWithFormat:@"api/tweet/%@/preparereward", tweet_id];
1749+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path withParams:nil withMethodType:Get autoShowError:NO andBlock:^(id data, NSError *error) {
1750+
if (data) {
1751+
data = data[@"data"];
1752+
}
1753+
block(data, error);
1754+
}];
1755+
}
17471756
#pragma mark Message
17481757
- (void)request_PrivateMessages:(PrivateMessages *)priMsgs andBlock:(void (^)(id data, NSError *error))block{
17491758
priMsgs.isLoading = YES;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// SendRewardManager.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/12/2.
6+
// Copyright © 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "Tweet.h"
11+
12+
@interface SendRewardManager : NSObject
13+
+ (instancetype)handleTweet:(Tweet *)curTweet completion:(void(^)(Tweet *curTweet, BOOL sendSucess))block;
14+
@end
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
//
2+
// SendRewardManager.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/12/2.
6+
// Copyright © 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "SendRewardManager.h"
10+
#import "Coding_NetAPIManager.h"
11+
#import "Login.h"
12+
13+
@interface SendRewardManager ()
14+
@property (strong, nonatomic) Tweet *curTweet;
15+
@property (copy, nonatomic) void(^completion)(Tweet *curTweet, BOOL sendSucess);
16+
@property (strong, nonatomic) NSArray *tipStrList;
17+
18+
19+
@property (strong, nonatomic) UIView *bgView, *contentView, *tipBgView;
20+
@property (strong, nonatomic) UIButton *closeBtn, *submitBtn;
21+
@property (strong, nonatomic) UILabel *titleL, *tipL, *bottomL;
22+
@property (strong, nonatomic) UITextField *passwordF;
23+
@end
24+
25+
@implementation SendRewardManager
26+
+ (instancetype)shareManager{
27+
static SendRewardManager *shared_manager = nil;
28+
static dispatch_once_t pred;
29+
dispatch_once(&pred, ^{
30+
shared_manager = [[self alloc] init];
31+
});
32+
return shared_manager;
33+
}
34+
35+
+ (instancetype)handleTweet:(Tweet *)curTweet completion:(void(^)(Tweet *curTweet, BOOL sendSucess))block{
36+
SendRewardManager *manager = [self shareManager];
37+
if (manager.curTweet) {//有正在处理的冒泡,此次调用无效
38+
return nil;
39+
}
40+
manager.curTweet = curTweet;
41+
manager.completion = block;
42+
[[Coding_NetAPIManager sharedManager] request_Preparereward:curTweet.id.stringValue andBlock:^(id data, NSError *error) {
43+
manager.tipStrList = data;
44+
[manager p_show];
45+
}];
46+
return manager;
47+
}
48+
49+
- (instancetype)init
50+
{
51+
self = [super init];
52+
if (self) {
53+
CGFloat buttonHeight = 44;
54+
55+
//层级关系
56+
_bgView = [UIView new];
57+
_contentView = [UIView new];
58+
_closeBtn = [UIButton new];
59+
_titleL = [UILabel new];
60+
_passwordF = [UITextField new];
61+
_submitBtn = [UIButton buttonWithStyle:StrapSuccessStyle andTitle:@"确认打赏" andFrame:CGRectMake(0, 0, buttonHeight, buttonHeight) target:self action:@selector(submitBtnClicked)];
62+
_bottomL = [UILabel new];
63+
_tipBgView = [UIView new];
64+
_tipL = [UILabel new];
65+
[_contentView addSubview:_closeBtn];
66+
[_contentView addSubview:_titleL];
67+
[_contentView addSubview:_passwordF];
68+
[_contentView addSubview:_submitBtn];
69+
[_contentView addSubview:_bottomL];
70+
[_contentView addSubview:_tipBgView];
71+
[_contentView addSubview:_tipL];
72+
73+
[_bgView addSubview:_contentView];
74+
75+
//属性设置
76+
_contentView.backgroundColor = [UIColor colorWithHexString:@"0xF8F8F8"];
77+
_contentView.layer.masksToBounds = YES;
78+
_contentView.layer.cornerRadius = 6;
79+
[_closeBtn setImage:[UIImage imageNamed:@"button_close"] forState:UIControlStateNormal];
80+
[_closeBtn addTarget:self action:@selector(p_dismiss) forControlEvents:UIControlEventTouchUpInside];
81+
_titleL.font = [UIFont systemFontOfSize:18];
82+
_titleL.textColor = [UIColor colorWithHexString:@"0x222222"];
83+
_titleL.textAlignment = NSTextAlignmentCenter;
84+
_titleL.attributedText = [self p_titleStr];
85+
_passwordF.font = [UIFont systemFontOfSize:15];
86+
_passwordF.textColor = [UIColor colorWithHexString:@"0x222222"];
87+
_passwordF.secureTextEntry = YES;
88+
_passwordF.textAlignment = NSTextAlignmentCenter;
89+
[_passwordF doBorderWidth:1.0 color:[UIColor colorWithHexString:@"0xCCCCCC"] cornerRadius:2.0];
90+
_passwordF.placeholder = @" 请输入密码";
91+
_bottomL.font = [UIFont systemFontOfSize:12];
92+
_bottomL.textColor = [UIColor colorWithHexString:@"0x999999"];
93+
_bottomL.textAlignment = NSTextAlignmentCenter;
94+
_bottomL.attributedText = [self p_bottomStr];
95+
_tipBgView.backgroundColor = [UIColor colorWithHexString:@"0xF2DEDE"];
96+
_tipBgView.layer.masksToBounds = YES;
97+
_tipBgView.layer.cornerRadius = 3;
98+
_tipL.font = [UIFont systemFontOfSize:15];
99+
_tipL.textColor = [UIColor colorWithHexString:@"0xC55351"];
100+
_tipL.textAlignment = NSTextAlignmentCenter;
101+
_tipL.numberOfLines = 0;
102+
103+
//位置大小
104+
[_closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
105+
make.left.top.equalTo(_contentView);
106+
make.width.height.mas_equalTo(buttonHeight);
107+
}];
108+
[_titleL mas_makeConstraints:^(MASConstraintMaker *make) {
109+
make.left.right.equalTo(_contentView);
110+
make.top.equalTo(_contentView).offset(35);
111+
}];
112+
[_passwordF mas_makeConstraints:^(MASConstraintMaker *make) {
113+
make.top.equalTo(_titleL.mas_bottom).offset(20);
114+
make.left.equalTo(_contentView).offset(25);
115+
make.right.equalTo(_contentView).offset(-25);
116+
make.height.mas_equalTo(35);
117+
}];
118+
[_submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
119+
make.top.equalTo(_passwordF.mas_bottom).offset(25);
120+
make.left.equalTo(_contentView).offset(50);
121+
make.right.equalTo(_contentView).offset(-50);
122+
make.height.mas_equalTo(buttonHeight);
123+
}];
124+
[_tipBgView mas_makeConstraints:^(MASConstraintMaker *make) {
125+
make.top.equalTo(_titleL.mas_bottom).offset(20);
126+
make.left.equalTo(_contentView).offset(25);
127+
make.right.equalTo(_contentView).offset(-25);
128+
make.height.mas_equalTo(60);
129+
}];
130+
[_tipL mas_makeConstraints:^(MASConstraintMaker *make) {
131+
make.edges.equalTo(_tipBgView).insets(UIEdgeInsetsMake(10, 15, 10, 15));
132+
}];
133+
// [_bgView bk_whenTapped:^{
134+
// [self p_dismiss];
135+
// }];
136+
137+
138+
[_bottomL mas_makeConstraints:^(MASConstraintMaker *make) {
139+
make.left.right.equalTo(_contentView);
140+
make.bottom.equalTo(_contentView).offset(-15);
141+
make.height.mas_equalTo(15);
142+
}];
143+
144+
145+
//初始状态
146+
_bgView.backgroundColor = [UIColor clearColor];
147+
_contentView.alpha = 0;
148+
}
149+
return self;
150+
}
151+
152+
- (NSAttributedString *)p_titleStr{
153+
NSString *tempStr = @"打赏给该用户 0.01 码币";
154+
NSMutableAttributedString *titleStr = [[NSMutableAttributedString alloc] initWithString:tempStr];
155+
[titleStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"0xF5A623"] range:[tempStr rangeOfString:@"0.01"]];
156+
return titleStr;
157+
}
158+
159+
160+
- (NSAttributedString *)p_bottomStr{
161+
NSString *tempStr = [NSString stringWithFormat:@"我的码币余额:%@ ", [Login curLoginUser].points_left.stringValue];
162+
NSMutableAttributedString *bottomStr = [[NSMutableAttributedString alloc] initWithString:tempStr];
163+
[bottomStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"0xF5A623"] range:[tempStr rangeOfString:[Login curLoginUser].points_left.stringValue]];
164+
return bottomStr;
165+
}
166+
167+
- (void)setTipStrList:(NSArray *)tipStrList{
168+
_tipStrList = tipStrList;
169+
_tipL.text = tipStrList.firstObject;
170+
171+
BOOL hasTip = _tipStrList.count > 0;
172+
CGFloat contentHeight = hasTip? 185: 229;
173+
CGFloat centerYOffset = hasTip? 0: -60;
174+
_passwordF.hidden = hasTip;
175+
_submitBtn.hidden = hasTip;
176+
_tipBgView.hidden = !hasTip;
177+
_tipL.hidden = !hasTip;
178+
179+
[_contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
180+
make.left.equalTo(_bgView).offset(kPaddingLeftWidth);
181+
make.height.mas_equalTo(contentHeight);
182+
make.centerX.equalTo(_bgView);
183+
make.centerY.equalTo(_bgView).offset(centerYOffset);
184+
}];
185+
}
186+
187+
- (void)submitBtnClicked{
188+
#warning submitBtnClicked reward
189+
[NSObject showHudTipStr:@"稍等~"];
190+
}
191+
192+
- (void)p_show{
193+
_bgView.frame = kScreen_Bounds;
194+
[kKeyWindow addSubview:_bgView];
195+
[UIView animateWithDuration:0.3 animations:^{
196+
_bgView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
197+
_contentView.alpha = 1;
198+
} completion:^(BOOL finished) {
199+
if (!_passwordF.hidden) {
200+
[_passwordF becomeFirstResponder];
201+
}
202+
}];
203+
}
204+
205+
- (void)p_dismiss{
206+
_curTweet = nil;
207+
_completion = nil;
208+
209+
[UIView animateWithDuration:0.3 animations:^{
210+
_bgView.backgroundColor = [UIColor clearColor];
211+
_contentView.alpha = 0;
212+
} completion:^(BOOL finished) {
213+
[_bgView removeFromSuperview];
214+
}];
215+
}
216+
217+
@end

Coding_iOS/Views/Cell/TweetCell.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#import "UICustomCollectionView.h"
3333
#import "CodingShareView.h"
3434
#import "TweetSendLocationDetailViewController.h"
35+
#import "SendRewardManager.h"
3536

3637
@interface TweetCell ()
3738
@property (strong, nonatomic) Tweet *tweet;
@@ -683,7 +684,11 @@ - (void)locationBtnClicked:(id)sender{
683684
}
684685
}
685686
- (void)rewardBtnClicked:(id)sender{
686-
#warning rewardBtnClicked
687+
@weakify(self);
688+
[SendRewardManager handleTweet:_tweet completion:^(Tweet *curTweet, BOOL sendSucess) {
689+
@strongify(self);
690+
self.tweet = curTweet;
691+
}];
687692
}
688693
#pragma mark TTTAttributedLabelDelegate
689694
- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithTransitInformation:(NSDictionary *)components{

0 commit comments

Comments
 (0)