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.xcodeproj/project.pbxproj | 10 +++--- 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 +++++++++------- 7 files changed, 55 insertions(+), 84 deletions(-) delete mode 100644 Juick/Views/BubbleMessageCell.h delete mode 100644 Juick/Views/BubbleMessageCell.m create mode 100644 Juick/Views/BubbleMessageCell.swift diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index 1d00963..391edd6 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -24,7 +24,6 @@ 773E639A204BCE6D008B8F8D /* DialogsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 773E6399204BCE6D008B8F8D /* DialogsViewController.m */; }; 773E639D204BD0F2008B8F8D /* Chat.m in Sources */ = {isa = PBXBuildFile; fileRef = 773E639C204BD0F2008B8F8D /* Chat.m */; }; 773E63A0204BDF16008B8F8D /* ChatViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 773E639F204BDF16008B8F8D /* ChatViewController.m */; }; - 773E63A3204BE036008B8F8D /* BubbleMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 773E63A2204BE036008B8F8D /* BubbleMessageCell.m */; }; 773F231C1F76DD0B00B5B0DF /* SerpentineBoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 773F231B1F76DD0B00B5B0DF /* SerpentineBoldItalic.ttf */; }; 773F23331F76ECAC00B5B0DF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 773F23321F76ECAC00B5B0DF /* LaunchScreen.storyboard */; }; 773F23371F76ED5E00B5B0DF /* Splash.png in Resources */ = {isa = PBXBuildFile; fileRef = 773F23341F76ED5D00B5B0DF /* Splash.png */; }; @@ -44,6 +43,7 @@ 776D4EE32A0FD1A300C8BD91 /* ContentLoadingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 776D4EE22A0FD1A300C8BD91 /* ContentLoadingCell.swift */; }; 776D4EE52A0FD4B500C8BD91 /* ConversationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 776D4EE42A0FD4B500C8BD91 /* ConversationCell.swift */; }; 776D4EE72A0FD96C00C8BD91 /* MessageInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 776D4EE62A0FD96C00C8BD91 /* MessageInputView.swift */; }; + 776D4EE92A0FDF5D00C8BD91 /* BubbleMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 776D4EE82A0FDF5D00C8BD91 /* BubbleMessageCell.swift */; }; 778560602343D24E00BB37A2 /* NSData+Hex.m in Sources */ = {isa = PBXBuildFile; fileRef = 7785605F2343D24E00BB37A2 /* NSData+Hex.m */; }; 778560632344CF6F00BB37A2 /* JuickNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 778560622344CF6F00BB37A2 /* JuickNavigationController.m */; }; 77975A1D182B6E9A00410C2B /* NewPostViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77975A1C182B6E9A00410C2B /* NewPostViewController.m */; }; @@ -129,8 +129,6 @@ 773E639C204BD0F2008B8F8D /* Chat.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Chat.m; sourceTree = ""; }; 773E639E204BDF16008B8F8D /* ChatViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChatViewController.h; sourceTree = ""; }; 773E639F204BDF16008B8F8D /* ChatViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChatViewController.m; sourceTree = ""; }; - 773E63A1204BE036008B8F8D /* BubbleMessageCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BubbleMessageCell.h; sourceTree = ""; }; - 773E63A2204BE036008B8F8D /* BubbleMessageCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BubbleMessageCell.m; sourceTree = ""; }; 773F231B1F76DD0B00B5B0DF /* SerpentineBoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = SerpentineBoldItalic.ttf; sourceTree = ""; }; 773F23321F76ECAC00B5B0DF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; 773F23341F76ED5D00B5B0DF /* Splash.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Splash.png; sourceTree = ""; }; @@ -161,6 +159,7 @@ 776D4EE22A0FD1A300C8BD91 /* ContentLoadingCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentLoadingCell.swift; sourceTree = ""; }; 776D4EE42A0FD4B500C8BD91 /* ConversationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationCell.swift; sourceTree = ""; }; 776D4EE62A0FD96C00C8BD91 /* MessageInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageInputView.swift; sourceTree = ""; }; + 776D4EE82A0FDF5D00C8BD91 /* BubbleMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BubbleMessageCell.swift; sourceTree = ""; }; 7785605E2343D24E00BB37A2 /* NSData+Hex.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSData+Hex.h"; sourceTree = ""; }; 7785605F2343D24E00BB37A2 /* NSData+Hex.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+Hex.m"; sourceTree = ""; }; 778560612344CF6F00BB37A2 /* JuickNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JuickNavigationController.h; sourceTree = ""; }; @@ -411,8 +410,7 @@ 77FFC0151D5FD13C003BD81A /* Views */ = { isa = PBXGroup; children = ( - 773E63A1204BE036008B8F8D /* BubbleMessageCell.h */, - 773E63A2204BE036008B8F8D /* BubbleMessageCell.m */, + 776D4EE82A0FDF5D00C8BD91 /* BubbleMessageCell.swift */, 773E6391204BCAD6008B8F8D /* BubbleMessageCell.xib */, 776D4EE42A0FD4B500C8BD91 /* ConversationCell.swift */, 773E6392204BCAD6008B8F8D /* ConversationCell.xib */, @@ -602,12 +600,12 @@ 773E639D204BD0F2008B8F8D /* Chat.m in Sources */, 77B8DCD62093FC03000DBB04 /* BlogViewController.m in Sources */, 773E639A204BCE6D008B8F8D /* DialogsViewController.m in Sources */, + 776D4EE92A0FDF5D00C8BD91 /* BubbleMessageCell.swift in Sources */, 772B4E6C2199811E0029706E /* Entity.m in Sources */, 77B09994189D0B9900A84F59 /* UIImage+Utils.m in Sources */, 77317BC2181BBE8500D60005 /* MessagesViewController.m in Sources */, 77B099A6189D57F000A84F59 /* User.m in Sources */, 77C6ADE41F7717BC000AEA8C /* ThreadViewController.m in Sources */, - 773E63A3204BE036008B8F8D /* BubbleMessageCell.m in Sources */, 77975A1D182B6E9A00410C2B /* NewPostViewController.m in Sources */, 774746AD239F82A10001C7F9 /* NSDate+TimeAgo.m in Sources */, 776D4EE72A0FD96C00C8BD91 /* MessageInputView.swift in Sources */, 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