From 312afec3c4fd7f0f51c82c6dc067bc5c89a4c453 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 13 May 2023 18:17:06 +0300 Subject: BubbleMessageCell conversion --- Juick/Supporting Files/Juick-Bridging-Header.h | 1 + Juick/ViewControllers/ChatViewController.m | 1 - Juick/Views/BubbleMessageCell.h | 20 ------------ Juick/Views/BubbleMessageCell.m | 45 -------------------------- Juick/Views/BubbleMessageCell.swift | 35 ++++++++++++++++++++ Juick/Views/BubbleMessageCell.xib | 27 +++++++++------- 6 files changed, 51 insertions(+), 78 deletions(-) delete mode 100644 Juick/Views/BubbleMessageCell.h delete mode 100644 Juick/Views/BubbleMessageCell.m create mode 100644 Juick/Views/BubbleMessageCell.swift (limited to 'Juick') diff --git a/Juick/Supporting Files/Juick-Bridging-Header.h b/Juick/Supporting Files/Juick-Bridging-Header.h index 954d628..f1dc47d 100644 --- a/Juick/Supporting Files/Juick-Bridging-Header.h +++ b/Juick/Supporting Files/Juick-Bridging-Header.h @@ -3,5 +3,6 @@ // #import "UIView+Shimmer.h" #import "Chat.h" +#import "Message.h" #import #import "AppDelegate.h" diff --git a/Juick/ViewControllers/ChatViewController.m b/Juick/ViewControllers/ChatViewController.m index 86d7b2f..76635f2 100644 --- a/Juick/ViewControllers/ChatViewController.m +++ b/Juick/ViewControllers/ChatViewController.m @@ -7,7 +7,6 @@ // #import "ChatViewController.h" -#import "BubbleMessageCell.h" #import "Juick-Swift.h" diff --git a/Juick/Views/BubbleMessageCell.h b/Juick/Views/BubbleMessageCell.h deleted file mode 100644 index bad2fc4..0000000 --- a/Juick/Views/BubbleMessageCell.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// BubbleMessageCell.h -// Juick -// -// Created by Vitaly Takmazov on 04/03/2018. -// Copyright © 2018 com.juick. All rights reserved. -// - -#import -#import "Message.h" - -@interface BubbleMessageCell : UITableViewCell -@property (strong, nonatomic) IBOutlet UIImageView *avatarView; -@property (strong, nonatomic) IBOutlet UILabel *unreadMarker; -@property (strong, nonatomic) IBOutlet UILabel *name; -@property (strong, nonatomic) IBOutlet UITextView *message; - --(void) configureWithMessage:(Message *) message isMe:(BOOL)isMe; - -@end diff --git a/Juick/Views/BubbleMessageCell.m b/Juick/Views/BubbleMessageCell.m deleted file mode 100644 index 1c923c7..0000000 --- a/Juick/Views/BubbleMessageCell.m +++ /dev/null @@ -1,45 +0,0 @@ -// -// BubbleMessageCell.m -// Juick -// -// Created by Vitaly Takmazov on 04/03/2018. -// Copyright © 2018 com.juick. All rights reserved. -// - -#import "BubbleMessageCell.h" - -@implementation BubbleMessageCell - -- (void)awakeFromNib { - [super awakeFromNib]; - // Initialization code -} - -- (void)setSelected:(BOOL)selected animated:(BOOL)animated { - [super setSelected:selected animated:animated]; - - // Configure the view for the selected state -} - --(void) configureWithMessage:(Message *)message isMe:(BOOL)isMe { - self.selectionStyle = UITableViewCellSelectionStyleNone; - self.message.backgroundColor = isMe ? [UIColor colorNamed:@"Title"] : [UIColor colorNamed:@"Chat"]; - self.message.textColor = isMe ? [UIColor whiteColor] : [UIColor colorNamed:@"Text"]; - self.message.dataDetectorTypes = UIDataDetectorTypeAll; - self.message.tintColor = isMe? [UIColor whiteColor] : [UIColor colorNamed:@"Title"]; - self.name.text = message.user.uname; - self.message.text = message.text; - self.unreadMarker.text = @""; - __weak UIImageView *weakAvatar = self.avatarView; - [[AppDelegate shared].api fetchImageWithURL:[NSURL URLWithString:message.user.avatar] callback:^(NSData *data) { - [UIView transitionWithView:weakAvatar - duration:0.3 - options:UIViewAnimationOptionTransitionCrossDissolve - animations:^{ - weakAvatar.image = [UIImage imageWithData:data]; - } - completion:nil]; - }]; -} - -@end diff --git a/Juick/Views/BubbleMessageCell.swift b/Juick/Views/BubbleMessageCell.swift new file mode 100644 index 0000000..fcd9381 --- /dev/null +++ b/Juick/Views/BubbleMessageCell.swift @@ -0,0 +1,35 @@ +// +// BubbleMessageCell.swift +// Juick +// +// Created by Vitaly Takmazov on 13.05.2023. +// Copyright © 2023 com.juick. All rights reserved. +// + +import UIKit + +@objc +class BubbleMessageCell: UITableViewCell { + @IBOutlet weak var avatarView: UIImageView! + @IBOutlet weak var unreadMarker: UILabel! + @IBOutlet weak var name: UILabel! + @IBOutlet weak var message: UITextView! + + @objc + func configure(message: Message, isMe: Bool) { + self.message.backgroundColor = isMe ? UIColor(named: "Title") : UIColor(named: "Chat") + self.message.textColor = isMe ? UIColor.white : UIColor(named: "Text") + self.message.dataDetectorTypes = .all + self.message.tintColor = isMe ? UIColor.white : UIColor(named: "Title") + self.name.text = message.user.uname + self.message.text = message.text + self.unreadMarker.text = "" + AppDelegate.shared().api.fetchImage(with: URL(string: message.user.avatar)) { data in + if let imageData = data { + UIView.transition(with: self.avatarView, duration: 0.3, options: .transitionCrossDissolve, animations: { + self.avatarView.image = UIImage(data: imageData) + }) + } + } + } +} diff --git a/Juick/Views/BubbleMessageCell.xib b/Juick/Views/BubbleMessageCell.xib index 75afe92..0ad0ea7 100644 --- a/Juick/Views/BubbleMessageCell.xib +++ b/Juick/Views/BubbleMessageCell.xib @@ -1,28 +1,26 @@ - - - - + + - + - + - + - + - + @@ -43,16 +41,16 @@ - + - + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. @@ -82,4 +80,9 @@ + + + + + -- cgit v1.2.3