77//
88
99#define kTweetCell_PadingLeft kPaddingLeftWidth
10- #define kTweetCell_PadingTop (60 + 15 )
10+ #define kTweetCell_PadingTop (65 + 15 )
1111
1212#define kTweetCell_PadingBottom 10.0
1313#define kTweetCell_ContentWidth (kScreen_Width -kTweetCell_PadingLeft - kPaddingLeftWidth )
3131#import " MJPhotoBrowser.h"
3232#import " UICustomCollectionView.h"
3333#import " CodingShareView.h"
34+ #import " TweetSendLocationDetailViewController.h"
3435
3536@interface TweetCell ()
3637@property (strong , nonatomic ) Tweet *tweet;
@@ -46,7 +47,7 @@ @interface TweetCell ()
4647@property (strong , nonatomic ) UICustomCollectionView *mediaView;
4748@property (strong , nonatomic ) UICollectionView *likeUsersView;
4849@property (strong , nonatomic ) UITableView *commentListView;
49- @property (strong , nonatomic ) UIImageView *timeClockIconView, *commentOrLikeBeginImgView, *commentOrLikeSplitlineView;
50+ @property (strong , nonatomic ) UIImageView *timeClockIconView, *commentOrLikeBeginImgView, *commentOrLikeSplitlineView, *fromPhoneIconView ;
5051@end
5152
5253@implementation TweetCell
@@ -71,7 +72,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
7172 }
7273
7374 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 )];
7576 [self .ownerImgView doCircleFrame ];
7677 [self .contentView addSubview: self .ownerImgView];
7778 }
@@ -142,13 +143,14 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
142143 [self .locaitonBtn addTarget: self action: @selector (locationBtnClicked: ) forControlEvents: UIControlEventTouchUpInside];
143144 [self .contentView addSubview: self .locaitonBtn];
144145 }
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+ }
146151 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 )];
148153 self.fromLabel .font = kTweet_TimtFont ;
149- self.fromLabel .minimumScaleFactor = 0.50 ;
150- self.fromLabel .adjustsFontSizeToFitWidth = YES ;
151- self.fromLabel .textAlignment = NSTextAlignmentLeft;
152154 self.fromLabel .textColor = [UIColor colorWithHexString: @" 0x999999" ];
153155 [self .contentView addSubview: self .fromLabel];
154156 }
@@ -224,6 +226,8 @@ - (void)layoutSubviews{
224226 if (!_tweet) {
225227 return ;
226228 }
229+ BOOL isMineTweet = [_tweet.owner.global_key isEqualToString: [Login curLoginUser ].global_key];
230+
227231 self.topView .hidden = !_needTopView;
228232 // owner头像
229233 __weak __typeof (self)weakSelf = self;
@@ -238,8 +242,7 @@ - (void)layoutSubviews{
238242 [self .timeLabel setX: timeLabelX];
239243 [self .timeClockIconView setX: timeLabelX-15 ];
240244
241-
242- CGFloat centerY = 15 + 15 + 33.0 /2 ;
245+ CGFloat centerY = 15 + 15 + CGRectGetHeight (_ownerImgView.frame )/2 ;
243246 CGFloat curBottomY = _needTopView? 0 : -15 ;
244247 centerY += curBottomY;
245248
@@ -252,9 +255,6 @@ - (void)layoutSubviews{
252255 curBottomY += kTweetCell_PadingTop ;
253256
254257 // owner冒泡text内容
255- // [self.contentLabel setWidth:kTweetCell_ContentWidth];
256- // self.contentLabel.text = _tweet.content;
257- // [self.contentLabel sizeToFit];
258258 [self .contentLabel setY: curBottomY];
259259 [self .contentLabel setLongString: _tweet.content withFitWidth: kTweetCell_ContentWidth maxHeight: kTweet_ContentMaxHeight ];
260260 for (HtmlMediaItem *item in _tweet.htmlMedia .mediaItems ) {
@@ -277,40 +277,32 @@ - (void)layoutSubviews{
277277 }
278278 }
279279
280- BOOL isMineTweet = [_tweet.owner.global_key isEqualToString: [Login curLoginUser ].global_key];
281-
282280 // 地址&设备小尾巴
283281 if (_tweet.location .length > 0 || _tweet.device .length > 0 ) {
284- CGFloat curX = kPaddingLeftWidth ;
285282 if (_tweet.location .length > 0 ) {
286283 [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 ;
290286 }
291- if (_tweet.device .length > 0 ) {
287+ if (_tweet.device .length > 0 ) {
292288 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 ;
296292 }
297- curBottomY += 30 ;
293+ curBottomY += 15 ;
298294 }
299295 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 ;
301297
302298 // 喜欢&评论 按钮
303299 [self .likeBtn setImage: [UIImage imageNamed: (_tweet.liked.boolValue? @" tweet_btn_liked" :@" tweet_btn_like" )] forState: UIControlStateNormal];
304300 [self .likeBtn setY: curBottomY];
305301 [self .commentBtn setY: curBottomY];
306302 [self .shareBtn setY: curBottomY];
307303
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;
314306
315307 curBottomY += kTweetCell_LikeComment_Height ;
316308 curBottomY += [TweetCell likeCommentBtn_BottomPadingWithTweet: _tweet];
@@ -364,7 +356,7 @@ + (CGFloat)cellHeightWithObj:(id)obj needTopView:(BOOL)needTopView{
364356 cellHeight += kTweetCell_PadingTop ;
365357 cellHeight += [self contentLabelHeightWithTweet: tweet];
366358 cellHeight += [self contentMediaHeightWithTweet: tweet];
367- cellHeight += [self locationHeightWithTweet : tweet];
359+ cellHeight += [self locationAndDeviceHeightWithTweet : tweet];
368360 cellHeight += kTweetCell_LikeComment_Height ;
369361 cellHeight += [TweetCell likeCommentBtn_BottomPadingWithTweet: tweet];
370362 cellHeight += [TweetCell likeUsersHeightWithTweet: tweet];
@@ -405,14 +397,18 @@ + (CGFloat)likeCommentBtn_BottomPadingWithTweet:(Tweet *)tweet{
405397 }
406398}
407399
408- + (CGFloat)locationHeightWithTweet : (Tweet *)tweet {
409- CGFloat ocationHeight = 0 ;
400+ + (CGFloat)locationAndDeviceHeightWithTweet : (Tweet *)tweet {
401+ CGFloat height = 0 ;
410402 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 ;
414410 }
415- return ocationHeight ;
411+ return height ;
416412}
417413
418414
@@ -658,8 +654,11 @@ - (void)userBtnClicked{
658654 }
659655}
660656- (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+
663662 }
664663}
665664- (void )shareBtnClicked : (id )sender {
0 commit comments