OrderMessageModel.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // OrderMessageModel.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/3/31.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "OrderMessageModel.h"
  9. #import "NSString+StringSize.h"
  10. #import "SDWebImage/UIButton+WebCache.h"
  11. #import "UIImageView+WebCache.h"
  12. #define __VIEW_WIDTH__ [UIScreen mainScreen].bounds.size.width
  13. #define __SPACE__ 15
  14. #define __TIME_HIGTH__ 25
  15. #define __TEXT_MAXW__ 200
  16. @implementation OrderMessageModel
  17. - (instancetype)initWithDic:(NSDictionary *)subdic
  18. {
  19. self = [super init];
  20. if (self) {
  21. _icon = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"avatar"]];
  22. _text = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"title"]];
  23. _time = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"addtime"]];
  24. _type = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"type"]];
  25. _orderid = minstr([subdic valueForKey:@"orderid"]);
  26. _status = minstr([subdic valueForKey:@"status"]);
  27. _is_commission = minstr([subdic valueForKey:@"is_commission"]);
  28. }
  29. return self;
  30. }
  31. -(void)setMessageFrame:(OrderMessageModel *)upMessage
  32. {
  33. BOOL isEqual = [_time isEqual:upMessage.time];
  34. if (!isEqual) {
  35. _timeR = CGRectMake(0,0,__VIEW_WIDTH__, __TIME_HIGTH__);
  36. }
  37. CGSize textSize = [_text sizeWithFont:__TEXT_FONT__ maxWidth:__TEXT_MAXW__];
  38. CGSize buttonSize = CGSizeMake(textSize.width + __EDGE_W__*3, textSize.height + __EDGE_W__*3);
  39. CGFloat textX;
  40. CGFloat textY = CGRectGetMaxY(_timeR);
  41. CGFloat iconX;
  42. // if ([_type isEqual:@"0"]) {
  43. // textX = __VIEW_WIDTH__ - __ICON_WIDTH__ - __SPACE__ - buttonSize.width;
  44. // iconX = __VIEW_WIDTH__ - __SPACE__ - __ICON_WIDTH__;
  45. // }
  46. // else
  47. // {
  48. textX = __ICON_WIDTH__ + __SPACE__;
  49. iconX = __SPACE__;
  50. // }
  51. _iconR = CGRectMake(iconX, textY, __ICON_WIDTH__, __ICON_WIDTH__);
  52. _textR = CGRectMake(textX, textY, buttonSize.width, buttonSize.height);
  53. _rowH = MAX(CGRectGetMaxY(_textR), CGRectGetMaxY(_iconR))+__SPACE__;
  54. }
  55. +(instancetype)messageWithDic:(NSDictionary *)subdic
  56. {
  57. return [[self alloc] initWithDic:subdic];
  58. }
  59. @end