7
7
//
8
8
9
9
#define kTweetCell_PadingLeft kPaddingLeftWidth
10
- #define kTweetCell_PadingTop (60 + 15 )
10
+ #define kTweetCell_PadingTop (65 + 15 )
11
11
12
12
#define kTweetCell_PadingBottom 10.0
13
13
#define kTweetCell_ContentWidth (kScreen_Width -kTweetCell_PadingLeft - kPaddingLeftWidth )
31
31
#import " MJPhotoBrowser.h"
32
32
#import " UICustomCollectionView.h"
33
33
#import " CodingShareView.h"
34
+ #import " TweetSendLocationDetailViewController.h"
34
35
35
36
@interface TweetCell ()
36
37
@property (strong , nonatomic ) Tweet *tweet;
@@ -46,7 +47,7 @@ @interface TweetCell ()
46
47
@property (strong , nonatomic ) UICustomCollectionView *mediaView;
47
48
@property (strong , nonatomic ) UICollectionView *likeUsersView;
48
49
@property (strong , nonatomic ) UITableView *commentListView;
49
- @property (strong , nonatomic ) UIImageView *timeClockIconView, *commentOrLikeBeginImgView, *commentOrLikeSplitlineView;
50
+ @property (strong , nonatomic ) UIImageView *timeClockIconView, *commentOrLikeBeginImgView, *commentOrLikeSplitlineView, *fromPhoneIconView ;
50
51
@end
51
52
52
53
@implementation TweetCell
@@ -71,7 +72,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
71
72
}
72
73
73
74
if (!self.ownerImgView ) {
74
- self.ownerImgView = [[UITapImageView alloc ] initWithFrame: CGRectMake (kPaddingLeftWidth , 15 + CGRectGetMaxY (_topView.frame), 33 , 33 )];
75
+ self.ownerImgView = [[UITapImageView alloc ] initWithFrame: CGRectMake (kPaddingLeftWidth , 15 + CGRectGetMaxY (_topView.frame), 35 , 35 )];
75
76
[self .ownerImgView doCircleFrame ];
76
77
[self .contentView addSubview: self .ownerImgView];
77
78
}
@@ -142,13 +143,14 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
142
143
[self .locaitonBtn addTarget: self action: @selector (locationBtnClicked: ) forControlEvents: UIControlEventTouchUpInside];
143
144
[self .contentView addSubview: self .locaitonBtn];
144
145
}
145
-
146
+ if (!self.fromPhoneIconView ) {
147
+ self.fromPhoneIconView = [[UIImageView alloc ] initWithFrame: CGRectMake (kPaddingLeftWidth , 0 , 15 , 15 )];
148
+ self.fromPhoneIconView .image = [UIImage imageNamed: @" little_phone_icon" ];
149
+ [self .contentView addSubview: self .fromPhoneIconView];
150
+ }
146
151
if (!self.fromLabel ) {
147
- self.fromLabel = [[UILabel alloc ] initWithFrame: CGRectMake (kTweetCell_PadingLeft , 0 , 100 , 15 )];
152
+ self.fromLabel = [[UILabel alloc ] initWithFrame: CGRectMake (CGRectGetMaxX ( self .fromPhoneIconView.frame) + 5 , 0 , kScreen_Width / 2 , 15 )];
148
153
self.fromLabel .font = kTweet_TimtFont ;
149
- self.fromLabel .minimumScaleFactor = 0.50 ;
150
- self.fromLabel .adjustsFontSizeToFitWidth = YES ;
151
- self.fromLabel .textAlignment = NSTextAlignmentLeft;
152
154
self.fromLabel .textColor = [UIColor colorWithHexString: @" 0x999999" ];
153
155
[self .contentView addSubview: self .fromLabel];
154
156
}
@@ -224,6 +226,8 @@ - (void)layoutSubviews{
224
226
if (!_tweet) {
225
227
return ;
226
228
}
229
+ BOOL isMineTweet = [_tweet.owner.global_key isEqualToString: [Login curLoginUser ].global_key];
230
+
227
231
self.topView .hidden = !_needTopView;
228
232
// owner头像
229
233
__weak __typeof (self)weakSelf = self;
@@ -238,8 +242,7 @@ - (void)layoutSubviews{
238
242
[self .timeLabel setX: timeLabelX];
239
243
[self .timeClockIconView setX: timeLabelX-15 ];
240
244
241
-
242
- CGFloat centerY = 15 + 15 + 33.0 /2 ;
245
+ CGFloat centerY = 15 + 15 + CGRectGetHeight (_ownerImgView.frame )/2 ;
243
246
CGFloat curBottomY = _needTopView? 0 : -15 ;
244
247
centerY += curBottomY;
245
248
@@ -252,9 +255,6 @@ - (void)layoutSubviews{
252
255
curBottomY += kTweetCell_PadingTop ;
253
256
254
257
// owner冒泡text内容
255
- // [self.contentLabel setWidth:kTweetCell_ContentWidth];
256
- // self.contentLabel.text = _tweet.content;
257
- // [self.contentLabel sizeToFit];
258
258
[self .contentLabel setY: curBottomY];
259
259
[self .contentLabel setLongString: _tweet.content withFitWidth: kTweetCell_ContentWidth maxHeight: kTweet_ContentMaxHeight ];
260
260
for (HtmlMediaItem *item in _tweet.htmlMedia .mediaItems ) {
@@ -277,40 +277,32 @@ - (void)layoutSubviews{
277
277
}
278
278
}
279
279
280
- BOOL isMineTweet = [_tweet.owner.global_key isEqualToString: [Login curLoginUser ].global_key];
281
-
282
280
// 地址&设备小尾巴
283
281
if (_tweet.location .length > 0 || _tweet.device .length > 0 ) {
284
- CGFloat curX = kPaddingLeftWidth ;
285
282
if (_tweet.location .length > 0 ) {
286
283
[self .locaitonBtn setTitle: _tweet.location forState: UIControlStateNormal];
287
- CGFloat titleWidth = [self .locaitonBtn.titleLabel.text getWidthWithFont: self .locaitonBtn.titleLabel.font constrainedToSize: CGSizeMake (kScreen_Width , 15 )];
288
- self.locaitonBtn .frame = CGRectMake (curX, curBottomY, titleWidth, 15 );
289
- curX += titleWidth +5 ;
284
+ [self .locaitonBtn setY: curBottomY];
285
+ curBottomY += _tweet.device .length > 0 ? 20 : 15 ;
290
286
}
291
- if (_tweet.device .length > 0 ) {
287
+ if (_tweet.device .length > 0 ) {
292
288
self.fromLabel .text = [NSString stringWithFormat: @" 来自 %@ " , _tweet.device];
293
- CGFloat titleWidth = [self .fromLabel.text getWidthWithFont: self .fromLabel.font constrainedToSize: CGSizeMake ( kScreen_Width , 15 ) ];
294
- titleWidth = MIN (titleWidth, kScreen_Width - kPaddingLeftWidth - curX) ;
295
- self. fromLabel . frame = CGRectMake (curX, curBottomY, titleWidth, 15 ) ;
289
+ [self .fromLabel setY: curBottomY ];
290
+ [ self .fromPhoneIconView setCenterY: self .fromLabel.centerY] ;
291
+ curBottomY += 15 ;
296
292
}
297
- curBottomY += 30 ;
293
+ curBottomY += 15 ;
298
294
}
299
295
self.locaitonBtn .hidden = _tweet.location .length <= 0 ;
300
- self.fromLabel .hidden = _tweet.device .length <= 0 ;
296
+ self.fromLabel .hidden = self. fromPhoneIconView . hidden = _tweet.device .length <= 0 ;
301
297
302
298
// 喜欢&评论 按钮
303
299
[self .likeBtn setImage: [UIImage imageNamed: (_tweet.liked.boolValue? @" tweet_btn_liked" :@" tweet_btn_like" )] forState: UIControlStateNormal];
304
300
[self .likeBtn setY: curBottomY];
305
301
[self .commentBtn setY: curBottomY];
306
302
[self .shareBtn setY: curBottomY];
307
303
308
- if (isMineTweet) {
309
- [self .deleteBtn setY: curBottomY];
310
- self.deleteBtn .hidden = NO ;
311
- }else {
312
- self.deleteBtn .hidden = YES ;
313
- }
304
+ [self .deleteBtn setY: curBottomY];
305
+ self.deleteBtn .hidden = !isMineTweet;
314
306
315
307
curBottomY += kTweetCell_LikeComment_Height ;
316
308
curBottomY += [TweetCell likeCommentBtn_BottomPadingWithTweet: _tweet];
@@ -364,7 +356,7 @@ + (CGFloat)cellHeightWithObj:(id)obj needTopView:(BOOL)needTopView{
364
356
cellHeight += kTweetCell_PadingTop ;
365
357
cellHeight += [self contentLabelHeightWithTweet: tweet];
366
358
cellHeight += [self contentMediaHeightWithTweet: tweet];
367
- cellHeight += [self locationHeightWithTweet : tweet];
359
+ cellHeight += [self locationAndDeviceHeightWithTweet : tweet];
368
360
cellHeight += kTweetCell_LikeComment_Height ;
369
361
cellHeight += [TweetCell likeCommentBtn_BottomPadingWithTweet: tweet];
370
362
cellHeight += [TweetCell likeUsersHeightWithTweet: tweet];
@@ -405,14 +397,18 @@ + (CGFloat)likeCommentBtn_BottomPadingWithTweet:(Tweet *)tweet{
405
397
}
406
398
}
407
399
408
- + (CGFloat )locationHeightWithTweet : (Tweet *)tweet {
409
- CGFloat ocationHeight = 0 ;
400
+ + (CGFloat )locationAndDeviceHeightWithTweet : (Tweet *)tweet {
401
+ CGFloat height = 0 ;
410
402
if (tweet.location .length > 0 || tweet.device .length > 0 ) {
411
- ocationHeight = 15 + 15 ;
412
- }else {
413
- ocationHeight = 0 ;
403
+ if (tweet.location .length > 0 ) {
404
+ height += tweet.device .length > 0 ? 20 : 15 ;
405
+ }
406
+ if (tweet.device .length > 0 ) {
407
+ height += 15 ;
408
+ }
409
+ height += 15 ;
414
410
}
415
- return ocationHeight ;
411
+ return height ;
416
412
}
417
413
418
414
@@ -658,8 +654,11 @@ - (void)userBtnClicked{
658
654
}
659
655
}
660
656
- (void )locationBtnClicked : (id )sender {
661
- if (_locationClickedBlock) {
662
- _locationClickedBlock (_tweet);
657
+ TweetSendLocationDetailViewController *vc = [[TweetSendLocationDetailViewController alloc ]init];
658
+ vc.tweet = _tweet;
659
+ if (vc.tweet .coord .length > 0 ) {
660
+ [[BaseViewController presentingVC ].navigationController pushViewController: vc animated: YES ];
661
+
663
662
}
664
663
}
665
664
- (void )shareBtnClicked : (id )sender {
0 commit comments