diff --git a/ChattoAdditions/Source/Chat Items/BaseMessage/BaseMessageModel.swift b/ChattoAdditions/Source/Chat Items/BaseMessage/BaseMessageModel.swift index bda6583..b58ea5e 100644 --- a/ChattoAdditions/Source/Chat Items/BaseMessage/BaseMessageModel.swift +++ b/ChattoAdditions/Source/Chat Items/BaseMessage/BaseMessageModel.swift @@ -35,7 +35,7 @@ public protocol MessageModelProtocol: ChatItemProtocol { var senderId: String { get } var isIncoming: Bool { get } var date: NSDate { get } - var status: MessageStatus { get set } + var status: MessageStatus { get } } public protocol DecoratedMessageModelProtocol: MessageModelProtocol { @@ -64,12 +64,7 @@ public extension DecoratedMessageModelProtocol { } var status: MessageStatus { - get { - return self.messageModel.status - } - set { - self.messageModel.status = newValue - } + return self.messageModel.status } } diff --git a/ChattoAdditions/Source/Chat Items/BaseMessage/BaseMessageViewModel.swift b/ChattoAdditions/Source/Chat Items/BaseMessage/BaseMessageViewModel.swift index ce3480e..05ce7fe 100644 --- a/ChattoAdditions/Source/Chat Items/BaseMessage/BaseMessageViewModel.swift +++ b/ChattoAdditions/Source/Chat Items/BaseMessage/BaseMessageViewModel.swift @@ -49,7 +49,6 @@ public protocol MessageViewModelProtocol: class { // why class? https://gist.git var showsFailedIcon: Bool { get } var date: String { get } var status: MessageViewModelStatus { get } - var messageModel: MessageModelProtocol { get } } public protocol DecoratedMessageViewModelProtocol: MessageViewModelProtocol { @@ -79,10 +78,6 @@ extension DecoratedMessageViewModelProtocol { public var showsFailedIcon: Bool { return self.messageViewModel.showsFailedIcon } - - public var messageModel: MessageModelProtocol { - return self.messageViewModel.messageModel - } } public class MessageViewModel: MessageViewModelProtocol { diff --git a/ChattoAdditions/Source/Chat Items/PhotoMessages/PhotoMessageModel.swift b/ChattoAdditions/Source/Chat Items/PhotoMessages/PhotoMessageModel.swift index 36821f2..bf2bb73 100644 --- a/ChattoAdditions/Source/Chat Items/PhotoMessages/PhotoMessageModel.swift +++ b/ChattoAdditions/Source/Chat Items/PhotoMessages/PhotoMessageModel.swift @@ -29,12 +29,15 @@ public protocol PhotoMessageModelProtocol: DecoratedMessageModelProtocol { var imageSize: CGSize { get } } -public class PhotoMessageModel: PhotoMessageModelProtocol { - public let messageModel: MessageModelProtocol - public let image: UIImage // fixme: URL +public class PhotoMessageModel: PhotoMessageModelProtocol { + public var messageModel: MessageModelProtocol { + return self._messageModel + } + public let _messageModel: MessageModelT // Can't make messasgeModel: MessageModelT: https://gist.github.com/diegosanchezr/5a66c7af862e1117b556 + public let image: UIImage public let imageSize: CGSize - public init(messageModel: MessageModelProtocol, imageSize: CGSize, image: UIImage) { - self.messageModel = messageModel + public init(messageModel: MessageModelT, imageSize: CGSize, image: UIImage) { + self._messageModel = messageModel self.imageSize = imageSize self.image = image } diff --git a/ChattoAdditions/Source/Chat Items/PhotoMessages/PhotoMessageViewModel.swift b/ChattoAdditions/Source/Chat Items/PhotoMessages/PhotoMessageViewModel.swift index e6f1860..881f43a 100644 --- a/ChattoAdditions/Source/Chat Items/PhotoMessages/PhotoMessageViewModel.swift +++ b/ChattoAdditions/Source/Chat Items/PhotoMessages/PhotoMessageViewModel.swift @@ -51,8 +51,11 @@ public extension PhotoMessageViewModelProtocol { func wasHidden() {} } -public class PhotoMessageViewModel: PhotoMessageViewModelProtocol { - public var photoMessage: PhotoMessageModelProtocol +public class PhotoMessageViewModel: PhotoMessageViewModelProtocol { + public var photoMessage: PhotoMessageModelProtocol { + return self._photoMessage + } + public let _photoMessage: PhotoMessageModelT // Can't make photoMessage: PhotoMessageModelT: https://gist.github.com/diegosanchezr/5a66c7af862e1117b556 public var transferStatus: Observable = Observable(.Idle) public var transferProgress: Observable = Observable(0) public var transferDirection: Observable = Observable(.Download) @@ -65,8 +68,8 @@ public class PhotoMessageViewModel: PhotoMessageViewModelProtocol { return self.messageViewModel.showsFailedIcon || self.transferStatus.value == .Failed } - public init(photoMessage: PhotoMessageModelProtocol, messageViewModel: MessageViewModelProtocol) { - self.photoMessage = photoMessage + public init(photoMessage: PhotoMessageModelT, messageViewModel: MessageViewModelProtocol) { + self._photoMessage = photoMessage self.image = Observable(photoMessage.image) self.messageViewModel = messageViewModel } @@ -80,18 +83,18 @@ public class PhotoMessageViewModel: PhotoMessageViewModelProtocol { } } -public class PhotoMessageViewModelDefaultBuilder: ViewModelBuilderProtocol { +public class PhotoMessageViewModelDefaultBuilder: ViewModelBuilderProtocol { public init() { } let messageViewModelBuilder = MessageViewModelDefaultBuilder() - public func createViewModel(model: ModelT) -> PhotoMessageViewModel { + public func createViewModel(model: PhotoMessageModelT) -> PhotoMessageViewModel { let messageViewModel = self.messageViewModelBuilder.createMessageViewModel(model) let photoMessageViewModel = PhotoMessageViewModel(photoMessage: model, messageViewModel: messageViewModel) return photoMessageViewModel } public func canCreateViewModel(fromModel model: Any) -> Bool { - return model is ModelT + return model is PhotoMessageModelT } } diff --git a/ChattoAdditions/Source/Chat Items/TextMessages/TextMessageModel.swift b/ChattoAdditions/Source/Chat Items/TextMessages/TextMessageModel.swift index c2f2392..785fb13 100644 --- a/ChattoAdditions/Source/Chat Items/TextMessages/TextMessageModel.swift +++ b/ChattoAdditions/Source/Chat Items/TextMessages/TextMessageModel.swift @@ -28,11 +28,14 @@ public protocol TextMessageModelProtocol: DecoratedMessageModelProtocol { var text: String { get } } -public class TextMessageModel: TextMessageModelProtocol { - public let messageModel: MessageModelProtocol +public class TextMessageModel: TextMessageModelProtocol { + public var messageModel: MessageModelProtocol { + return self._messageModel + } + public let _messageModel: MessageModelT // Can't make messasgeModel: MessageModelT: https://gist.github.com/diegosanchezr/5a66c7af862e1117b556 public let text: String - public init(messageModel: MessageModelProtocol, text: String) { - self.messageModel = messageModel + public init(messageModel: MessageModelT, text: String) { + self._messageModel = messageModel self.text = text } // This should be covered by DecoratedMessageModelProtocol, but compiler crashes without this (Xcode 7.1) diff --git a/ChattoAdditions/Source/Chat Items/TextMessages/TextMessageViewModel.swift b/ChattoAdditions/Source/Chat Items/TextMessages/TextMessageViewModel.swift index bbb39d1..f558aa5 100644 --- a/ChattoAdditions/Source/Chat Items/TextMessages/TextMessageViewModel.swift +++ b/ChattoAdditions/Source/Chat Items/TextMessages/TextMessageViewModel.swift @@ -28,29 +28,31 @@ public protocol TextMessageViewModelProtocol: DecoratedMessageViewModelProtocol var text: String { get } } -public class TextMessageViewModel: TextMessageViewModelProtocol { - public let text: String +public class TextMessageViewModel: TextMessageViewModelProtocol { + public var text: String { + return self.textMessage.text + } + public let textMessage: TextMessageModelT public let messageViewModel: MessageViewModelProtocol - public init(text: String, messageViewModel: MessageViewModelProtocol) { - self.text = text + public init(textMessage: TextMessageModelT, messageViewModel: MessageViewModelProtocol) { + self.textMessage = textMessage self.messageViewModel = messageViewModel } } -public class TextMessageViewModelDefaultBuilder: ViewModelBuilderProtocol { +public class TextMessageViewModelDefaultBuilder: ViewModelBuilderProtocol { public init() { } let messageViewModelBuilder = MessageViewModelDefaultBuilder() - public func createViewModel(model: ModelT) -> TextMessageViewModel { - let messageViewModel = self.messageViewModelBuilder.createMessageViewModel(model) - let textMessageViewModel = TextMessageViewModel(text: model.text, messageViewModel: messageViewModel) + public func createViewModel(textMessage: TextMessageModelT) -> TextMessageViewModel { + let messageViewModel = self.messageViewModelBuilder.createMessageViewModel(textMessage) + let textMessageViewModel = TextMessageViewModel(textMessage: textMessage, messageViewModel: messageViewModel) return textMessageViewModel - } public func canCreateViewModel(fromModel model: Any) -> Bool { - return model is ModelT + return model is TextMessageModelT } } diff --git a/ChattoAdditions/Tests/Chat Items/BaseMessage/BaseMessagePresenterTests.swift b/ChattoAdditions/Tests/Chat Items/BaseMessage/BaseMessagePresenterTests.swift index 2aa8ddd..f0a82f3 100644 --- a/ChattoAdditions/Tests/Chat Items/BaseMessage/BaseMessagePresenterTests.swift +++ b/ChattoAdditions/Tests/Chat Items/BaseMessage/BaseMessagePresenterTests.swift @@ -29,11 +29,11 @@ import Chatto class BaseMessagePresenterTests: XCTestCase { // BaseMessagePresenter is generic, let's use the photo one for instance - var presenter: PhotoMessagePresenter, PhotoMessageTestHandler>! + var presenter: PhotoMessagePresenter>, PhotoMessageTestHandler>! let decorationAttributes = ChatItemDecorationAttributes(bottomMargin: 0, showsTail: false) var interactionHandler: PhotoMessageTestHandler! override func setUp() { - let viewModelBuilder = PhotoMessageViewModelDefaultBuilder() + let viewModelBuilder = PhotoMessageViewModelDefaultBuilder>() let sizingCell = PhotoMessageCollectionViewCell.sizingCell() let photoStyle = PhotoMessageCollectionViewCellDefaultStyle() let baseStyle = BaseMessageCollectionViewCellDefaultSyle() diff --git a/ChattoAdditions/Tests/Chat Items/PhotoMessages/PhotoMessagePresenterBuilderTests.swift b/ChattoAdditions/Tests/Chat Items/PhotoMessages/PhotoMessagePresenterBuilderTests.swift index 36b0b15..a3b36e6 100644 --- a/ChattoAdditions/Tests/Chat Items/PhotoMessages/PhotoMessagePresenterBuilderTests.swift +++ b/ChattoAdditions/Tests/Chat Items/PhotoMessages/PhotoMessagePresenterBuilderTests.swift @@ -30,7 +30,7 @@ class PhotoMessagePresenterBuilderTests: XCTestCase { func testThat_CreatesPresenter() { let messageModel = MessageModel(uid: "uid", senderId: "senderId", type: "photo-message", isIncoming: true, date: NSDate(), status: .Success) let photoMessageModel = PhotoMessageModel(messageModel: messageModel, imageSize: CGSize(width: 30, height: 30), image: UIImage()) - let builder = PhotoMessagePresenterBuilder(viewModelBuilder: PhotoMessageViewModelDefaultBuilder(), interactionHandler: PhotoMessageTestHandler()) + let builder = PhotoMessagePresenterBuilder(viewModelBuilder: PhotoMessageViewModelDefaultBuilder>(), interactionHandler: PhotoMessageTestHandler()) XCTAssertNotNil(builder.createPresenterWithChatItem(photoMessageModel)) } } diff --git a/ChattoAdditions/Tests/Chat Items/PhotoMessages/PhotoMessagePresenterTests.swift b/ChattoAdditions/Tests/Chat Items/PhotoMessages/PhotoMessagePresenterTests.swift index 3f08da6..286ff0f 100644 --- a/ChattoAdditions/Tests/Chat Items/PhotoMessages/PhotoMessagePresenterTests.swift +++ b/ChattoAdditions/Tests/Chat Items/PhotoMessages/PhotoMessagePresenterTests.swift @@ -27,11 +27,11 @@ import XCTest class PhotoMessagePresenterTests: XCTestCase, UICollectionViewDataSource { - var presenter: PhotoMessagePresenter, PhotoMessageTestHandler>! + var presenter: PhotoMessagePresenter>, PhotoMessageTestHandler>! let decorationAttributes = ChatItemDecorationAttributes(bottomMargin: 0, showsTail: false) let testImage = UIImage() override func setUp() { - let viewModelBuilder = PhotoMessageViewModelDefaultBuilder() + let viewModelBuilder = PhotoMessageViewModelDefaultBuilder>() let sizingCell = PhotoMessageCollectionViewCell.sizingCell() let photoStyle = PhotoMessageCollectionViewCellDefaultStyle() let baseStyle = BaseMessageCollectionViewCellDefaultSyle() @@ -57,7 +57,7 @@ class PhotoMessagePresenterTests: XCTestCase, UICollectionViewDataSource { func testThat_RegistersAndDequeuesCells() { let collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: UICollectionViewFlowLayout()) - PhotoMessagePresenter, PhotoMessageTestHandler>.registerCells(collectionView) + PhotoMessagePresenter>, PhotoMessageTestHandler>.registerCells(collectionView) collectionView.dataSource = self collectionView.reloadData() XCTAssertNotNil(self.presenter.dequeueCell(collectionView: collectionView, indexPath: NSIndexPath(forItem: 0, inSection: 0))) @@ -76,7 +76,7 @@ class PhotoMessagePresenterTests: XCTestCase, UICollectionViewDataSource { } class PhotoMessageTestHandler: BaseMessageInteractionHandlerProtocol { - typealias ViewModelT = PhotoMessageViewModel + typealias ViewModelT = PhotoMessageViewModel> var didHandleTapOnFailIcon = false func userDidTapOnFailIcon(viewModel viewModel: ViewModelT) { diff --git a/ChattoAdditions/Tests/Chat Items/TextMessages/TextMessagePresenterBuilderTests.swift b/ChattoAdditions/Tests/Chat Items/TextMessages/TextMessagePresenterBuilderTests.swift index 4ea0641..fbf66bc 100644 --- a/ChattoAdditions/Tests/Chat Items/TextMessages/TextMessagePresenterBuilderTests.swift +++ b/ChattoAdditions/Tests/Chat Items/TextMessages/TextMessagePresenterBuilderTests.swift @@ -30,7 +30,7 @@ class TextMessagePresenterBuilderTests: XCTestCase { func testThat_CreatesPresenter() { let messageModel = MessageModel(uid: "uid", senderId: "senderId", type: "text-message", isIncoming: true, date: NSDate(), status: .Success) let textMessageModel = TextMessageModel(messageModel: messageModel, text: "Some text") - let builder = TextMessagePresenterBuilder(viewModelBuilder: TextMessageViewModelDefaultBuilder(), interactionHandler: TextMessageTestHandler()) + let builder = TextMessagePresenterBuilder(viewModelBuilder: TextMessageViewModelDefaultBuilder>(), interactionHandler: TextMessageTestHandler()) XCTAssertNotNil(builder.createPresenterWithChatItem(textMessageModel)) } } diff --git a/ChattoAdditions/Tests/Chat Items/TextMessages/TextMessagePresenterTests.swift b/ChattoAdditions/Tests/Chat Items/TextMessages/TextMessagePresenterTests.swift index 314d17b..6aaf3a4 100644 --- a/ChattoAdditions/Tests/Chat Items/TextMessages/TextMessagePresenterTests.swift +++ b/ChattoAdditions/Tests/Chat Items/TextMessages/TextMessagePresenterTests.swift @@ -28,10 +28,10 @@ import Chatto class TextMessagePresenterTests: XCTestCase, UICollectionViewDataSource { - var presenter: TextMessagePresenter, TextMessageTestHandler>! + var presenter: TextMessagePresenter>, TextMessageTestHandler>! let decorationAttributes = ChatItemDecorationAttributes(bottomMargin: 0, showsTail: false) override func setUp() { - let viewModelBuilder = TextMessageViewModelDefaultBuilder() + let viewModelBuilder = TextMessageViewModelDefaultBuilder>() let sizingCell = TextMessageCollectionViewCell.sizingCell() let textStyle = TextMessageCollectionViewCellDefaultStyle() let baseStyle = BaseMessageCollectionViewCellDefaultSyle() @@ -43,7 +43,7 @@ class TextMessagePresenterTests: XCTestCase, UICollectionViewDataSource { func testThat_RegistersAndDequeuesCells() { let collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: UICollectionViewFlowLayout()) - TextMessagePresenter, TextMessageTestHandler>.registerCells(collectionView) + TextMessagePresenter>, TextMessageTestHandler>.registerCells(collectionView) collectionView.dataSource = self collectionView.reloadData() XCTAssertNotNil(self.presenter.dequeueCell(collectionView: collectionView, indexPath: NSIndexPath(forItem: 0, inSection: 0))) @@ -87,7 +87,7 @@ class TextMessagePresenterTests: XCTestCase, UICollectionViewDataSource { } class TextMessageTestHandler: BaseMessageInteractionHandlerProtocol { - typealias ViewModelT = TextMessageViewModel + typealias ViewModelT = TextMessageViewModel> func userDidTapOnFailIcon(viewModel viewModel: ViewModelT) { diff --git a/ChattoApp/ChattoApp.xcodeproj/project.pbxproj b/ChattoApp/ChattoApp.xcodeproj/project.pbxproj index 9da37bb..12cb858 100644 --- a/ChattoApp/ChattoApp.xcodeproj/project.pbxproj +++ b/ChattoApp/ChattoApp.xcodeproj/project.pbxproj @@ -8,24 +8,29 @@ /* Begin PBXBuildFile section */ 1CB21D193EF017E5E1C63755 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 623390018DA74FF277EE2626 /* Pods.framework */; }; - C30C6EBB1BDE9BDC00D4C879 /* FakeMessageFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = C30C6EBA1BDE9BDC00D4C879 /* FakeMessageFactory.swift */; }; - C31E291A1BF38F8A00EF5B2F /* FakeMessageSender.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31E29191BF38F8A00EF5B2F /* FakeMessageSender.swift */; }; - C31E291C1BF39DE600EF5B2F /* FakePhotoMessageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31E291B1BF39DE600EF5B2F /* FakePhotoMessageViewModel.swift */; }; - C326C9AE1BF6424900EC4607 /* UserActionHandlers.swift in Sources */ = {isa = PBXBuildFile; fileRef = C326C9AD1BF6424900EC4607 /* UserActionHandlers.swift */; }; - C33FBFA91BDE441C008E3545 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C33FBFA81BDE441C008E3545 /* AppDelegate.swift */; }; - C33FBFAB1BDE441C008E3545 /* DemoChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C33FBFAA1BDE441C008E3545 /* DemoChatViewController.swift */; }; C33FBFAE1BDE441C008E3545 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C33FBFAC1BDE441C008E3545 /* Main.storyboard */; }; C33FBFB01BDE441C008E3545 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C33FBFAF1BDE441C008E3545 /* Assets.xcassets */; }; C33FBFB31BDE441C008E3545 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C33FBFB11BDE441C008E3545 /* LaunchScreen.storyboard */; }; C33FBFC91BDE441C008E3545 /* ChattoAppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C33FBFC81BDE441C008E3545 /* ChattoAppUITests.swift */; }; - C35A6F4D1BF807C10085CA19 /* SlidingDatasSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35A6F4C1BF807C10085CA19 /* SlidingDatasSource.swift */; }; C35A6F4F1BF807EC0085CA19 /* SlidingDataSourceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35A6F4E1BF807EC0085CA19 /* SlidingDataSourceTests.swift */; }; - C35A6F511BF8089C0085CA19 /* FakeDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35A6F501BF8089C0085CA19 /* FakeDataSource.swift */; }; - C396D98F1BF8C64900F10439 /* ConversationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C396D98E1BF8C64900F10439 /* ConversationsViewController.swift */; }; - C3B0D35B1BF3C55E006CF725 /* SendingStatusPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B0D35A1BF3C55E006CF725 /* SendingStatusPresenter.swift */; }; - C3B0D35D1BF3C627006CF725 /* SendingStatusCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B0D35C1BF3C627006CF725 /* SendingStatusCollectionViewCell.swift */; }; - C3B0D35F1BF3C63C006CF725 /* SendingStatusCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C3B0D35E1BF3C63C006CF725 /* SendingStatusCollectionViewCell.xib */; }; - C3B0D3611BF3C928006CF725 /* ChatItemsDemoDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B0D3601BF3C928006CF725 /* ChatItemsDemoDecorator.swift */; }; + C3F91DB61C75EF9E00D461D2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DA01C75EF9E00D461D2 /* AppDelegate.swift */; }; + C3F91DB71C75EF9E00D461D2 /* ChatItemsDemoDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DA11C75EF9E00D461D2 /* ChatItemsDemoDecorator.swift */; }; + C3F91DB81C75EF9E00D461D2 /* ConversationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DA21C75EF9E00D461D2 /* ConversationsViewController.swift */; }; + C3F91DBC1C75EF9E00D461D2 /* DemoChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DA81C75EF9E00D461D2 /* DemoChatViewController.swift */; }; + C3F91DBD1C75EF9E00D461D2 /* FakeDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DA91C75EF9E00D461D2 /* FakeDataSource.swift */; }; + C3F91DBE1C75EF9E00D461D2 /* FakeMessageFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DAA1C75EF9E00D461D2 /* FakeMessageFactory.swift */; }; + C3F91DBF1C75EF9E00D461D2 /* FakeMessageSender.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DAB1C75EF9E00D461D2 /* FakeMessageSender.swift */; }; + C3F91DC01C75EF9E00D461D2 /* DemoPhotoMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DAD1C75EF9E00D461D2 /* DemoPhotoMessageHandler.swift */; }; + C3F91DC11C75EF9E00D461D2 /* DemoPhotoMessageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DAE1C75EF9E00D461D2 /* DemoPhotoMessageModel.swift */; }; + C3F91DC21C75EF9E00D461D2 /* DemoPhotoMessageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DAF1C75EF9E00D461D2 /* DemoPhotoMessageViewModel.swift */; }; + C3F91DC31C75EF9E00D461D2 /* SlidingDatasSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DB01C75EF9E00D461D2 /* SlidingDatasSource.swift */; }; + C3F91DC41C75EF9E00D461D2 /* DemoTextMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DB21C75EF9E00D461D2 /* DemoTextMessageHandler.swift */; }; + C3F91DC51C75EF9E00D461D2 /* DemoTextMessageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DB31C75EF9E00D461D2 /* DemoTextMessageModel.swift */; }; + C3F91DC61C75EF9E00D461D2 /* DemoTextMessageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DB41C75EF9E00D461D2 /* DemoTextMessageViewModel.swift */; }; + C3F91DC71C75EF9E00D461D2 /* BaseMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DB51C75EF9E00D461D2 /* BaseMessageHandler.swift */; }; + C3F91DCC1C75EFE300D461D2 /* SendingStatusCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DC91C75EFE300D461D2 /* SendingStatusCollectionViewCell.swift */; }; + C3F91DCD1C75EFE300D461D2 /* SendingStatusCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C3F91DCA1C75EFE300D461D2 /* SendingStatusCollectionViewCell.xib */; }; + C3F91DCE1C75EFE300D461D2 /* SendingStatusPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F91DCB1C75EFE300D461D2 /* SendingStatusPresenter.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -62,13 +67,7 @@ 623390018DA74FF277EE2626 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BC1B7FD95E9FA5D84A5E756D /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; C103E6161174A5DF650D22E6 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; - C30C6EBA1BDE9BDC00D4C879 /* FakeMessageFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FakeMessageFactory.swift; path = Source/FakeMessageFactory.swift; sourceTree = ""; }; - C31E29191BF38F8A00EF5B2F /* FakeMessageSender.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FakeMessageSender.swift; sourceTree = ""; }; - C31E291B1BF39DE600EF5B2F /* FakePhotoMessageViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FakePhotoMessageViewModel.swift; sourceTree = ""; }; - C326C9AD1BF6424900EC4607 /* UserActionHandlers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserActionHandlers.swift; sourceTree = ""; }; C33FBFA51BDE441C008E3545 /* ChattoApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChattoApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; - C33FBFA81BDE441C008E3545 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - C33FBFAA1BDE441C008E3545 /* DemoChatViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoChatViewController.swift; sourceTree = ""; }; C33FBFAD1BDE441C008E3545 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; C33FBFAF1BDE441C008E3545 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; C33FBFB21BDE441C008E3545 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -78,14 +77,25 @@ C33FBFC41BDE441C008E3545 /* ChattoAppUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ChattoAppUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; C33FBFC81BDE441C008E3545 /* ChattoAppUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChattoAppUITests.swift; sourceTree = ""; }; C33FBFCA1BDE441C008E3545 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - C35A6F4C1BF807C10085CA19 /* SlidingDatasSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SlidingDatasSource.swift; sourceTree = ""; }; C35A6F4E1BF807EC0085CA19 /* SlidingDataSourceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SlidingDataSourceTests.swift; sourceTree = ""; }; - C35A6F501BF8089C0085CA19 /* FakeDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FakeDataSource.swift; sourceTree = ""; }; - C396D98E1BF8C64900F10439 /* ConversationsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConversationsViewController.swift; sourceTree = ""; }; - C3B0D35A1BF3C55E006CF725 /* SendingStatusPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SendingStatusPresenter.swift; sourceTree = ""; }; - C3B0D35C1BF3C627006CF725 /* SendingStatusCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SendingStatusCollectionViewCell.swift; sourceTree = ""; }; - C3B0D35E1BF3C63C006CF725 /* SendingStatusCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SendingStatusCollectionViewCell.xib; sourceTree = ""; }; - C3B0D3601BF3C928006CF725 /* ChatItemsDemoDecorator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatItemsDemoDecorator.swift; sourceTree = ""; }; + C3F91DA01C75EF9E00D461D2 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + C3F91DA11C75EF9E00D461D2 /* ChatItemsDemoDecorator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatItemsDemoDecorator.swift; sourceTree = ""; }; + C3F91DA21C75EF9E00D461D2 /* ConversationsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConversationsViewController.swift; sourceTree = ""; }; + C3F91DA81C75EF9E00D461D2 /* DemoChatViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoChatViewController.swift; sourceTree = ""; }; + C3F91DA91C75EF9E00D461D2 /* FakeDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FakeDataSource.swift; sourceTree = ""; }; + C3F91DAA1C75EF9E00D461D2 /* FakeMessageFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FakeMessageFactory.swift; sourceTree = ""; }; + C3F91DAB1C75EF9E00D461D2 /* FakeMessageSender.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FakeMessageSender.swift; sourceTree = ""; }; + C3F91DAD1C75EF9E00D461D2 /* DemoPhotoMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoPhotoMessageHandler.swift; sourceTree = ""; }; + C3F91DAE1C75EF9E00D461D2 /* DemoPhotoMessageModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoPhotoMessageModel.swift; sourceTree = ""; }; + C3F91DAF1C75EF9E00D461D2 /* DemoPhotoMessageViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoPhotoMessageViewModel.swift; sourceTree = ""; }; + C3F91DB01C75EF9E00D461D2 /* SlidingDatasSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SlidingDatasSource.swift; sourceTree = ""; }; + C3F91DB21C75EF9E00D461D2 /* DemoTextMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoTextMessageHandler.swift; sourceTree = ""; }; + C3F91DB31C75EF9E00D461D2 /* DemoTextMessageModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoTextMessageModel.swift; sourceTree = ""; }; + C3F91DB41C75EF9E00D461D2 /* DemoTextMessageViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoTextMessageViewModel.swift; sourceTree = ""; }; + C3F91DB51C75EF9E00D461D2 /* BaseMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseMessageHandler.swift; sourceTree = ""; }; + C3F91DC91C75EFE300D461D2 /* SendingStatusCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SendingStatusCollectionViewCell.swift; sourceTree = ""; }; + C3F91DCA1C75EFE300D461D2 /* SendingStatusCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SendingStatusCollectionViewCell.xib; sourceTree = ""; }; + C3F91DCB1C75EFE300D461D2 /* SendingStatusPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SendingStatusPresenter.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -131,23 +141,6 @@ name = Pods; sourceTree = ""; }; - C30C6EBD1BDE9BE200D4C879 /* Source */ = { - isa = PBXGroup; - children = ( - C3B0D3601BF3C928006CF725 /* ChatItemsDemoDecorator.swift */, - C396D98E1BF8C64900F10439 /* ConversationsViewController.swift */, - C33FBFAA1BDE441C008E3545 /* DemoChatViewController.swift */, - C30C6EBA1BDE9BDC00D4C879 /* FakeMessageFactory.swift */, - C35A6F501BF8089C0085CA19 /* FakeDataSource.swift */, - C31E29191BF38F8A00EF5B2F /* FakeMessageSender.swift */, - C31E291B1BF39DE600EF5B2F /* FakePhotoMessageViewModel.swift */, - C35A6F4C1BF807C10085CA19 /* SlidingDatasSource.swift */, - C326C9AD1BF6424900EC4607 /* UserActionHandlers.swift */, - C3B0D3581BF3C54F006CF725 /* Custom items */, - ); - name = Source; - sourceTree = ""; - }; C33FBF9C1BDE441C008E3545 = { isa = PBXGroup; children = ( @@ -173,8 +166,7 @@ C33FBFA71BDE441C008E3545 /* ChattoApp */ = { isa = PBXGroup; children = ( - C30C6EBD1BDE9BE200D4C879 /* Source */, - C33FBFA81BDE441C008E3545 /* AppDelegate.swift */, + C3F91D9F1C75EF9E00D461D2 /* Source */, C33FBFAC1BDE441C008E3545 /* Main.storyboard */, C33FBFAF1BDE441C008E3545 /* Assets.xcassets */, C33FBFB11BDE441C008E3545 /* LaunchScreen.storyboard */, @@ -201,21 +193,51 @@ path = ChattoAppUITests; sourceTree = ""; }; - C3B0D3581BF3C54F006CF725 /* Custom items */ = { + C3F91D9F1C75EF9E00D461D2 /* Source */ = { isa = PBXGroup; children = ( - C3B0D3591BF3C54F006CF725 /* Sending status */, + C3F91DA01C75EF9E00D461D2 /* AppDelegate.swift */, + C3F91DA11C75EF9E00D461D2 /* ChatItemsDemoDecorator.swift */, + C3F91DA21C75EF9E00D461D2 /* ConversationsViewController.swift */, + C3F91DA81C75EF9E00D461D2 /* DemoChatViewController.swift */, + C3F91DA91C75EF9E00D461D2 /* FakeDataSource.swift */, + C3F91DAA1C75EF9E00D461D2 /* FakeMessageFactory.swift */, + C3F91DAB1C75EF9E00D461D2 /* FakeMessageSender.swift */, + C3F91DB01C75EF9E00D461D2 /* SlidingDatasSource.swift */, + C3F91DB51C75EF9E00D461D2 /* BaseMessageHandler.swift */, + C3F91DAC1C75EF9E00D461D2 /* Photo Messages */, + C3F91DC81C75EFE300D461D2 /* Sending status */, + C3F91DB11C75EF9E00D461D2 /* Text Messages */, ); - name = "Custom items"; - path = "Source/Custom items"; + path = Source; sourceTree = ""; }; - C3B0D3591BF3C54F006CF725 /* Sending status */ = { + C3F91DAC1C75EF9E00D461D2 /* Photo Messages */ = { isa = PBXGroup; children = ( - C3B0D35A1BF3C55E006CF725 /* SendingStatusPresenter.swift */, - C3B0D35C1BF3C627006CF725 /* SendingStatusCollectionViewCell.swift */, - C3B0D35E1BF3C63C006CF725 /* SendingStatusCollectionViewCell.xib */, + C3F91DAD1C75EF9E00D461D2 /* DemoPhotoMessageHandler.swift */, + C3F91DAE1C75EF9E00D461D2 /* DemoPhotoMessageModel.swift */, + C3F91DAF1C75EF9E00D461D2 /* DemoPhotoMessageViewModel.swift */, + ); + path = "Photo Messages"; + sourceTree = ""; + }; + C3F91DB11C75EF9E00D461D2 /* Text Messages */ = { + isa = PBXGroup; + children = ( + C3F91DB21C75EF9E00D461D2 /* DemoTextMessageHandler.swift */, + C3F91DB31C75EF9E00D461D2 /* DemoTextMessageModel.swift */, + C3F91DB41C75EF9E00D461D2 /* DemoTextMessageViewModel.swift */, + ); + path = "Text Messages"; + sourceTree = ""; + }; + C3F91DC81C75EFE300D461D2 /* Sending status */ = { + isa = PBXGroup; + children = ( + C3F91DC91C75EFE300D461D2 /* SendingStatusCollectionViewCell.swift */, + C3F91DCA1C75EFE300D461D2 /* SendingStatusCollectionViewCell.xib */, + C3F91DCB1C75EFE300D461D2 /* SendingStatusPresenter.swift */, ); path = "Sending status"; sourceTree = ""; @@ -329,8 +351,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - C3B0D35F1BF3C63C006CF725 /* SendingStatusCollectionViewCell.xib in Resources */, C33FBFB31BDE441C008E3545 /* LaunchScreen.storyboard in Resources */, + C3F91DCD1C75EFE300D461D2 /* SendingStatusCollectionViewCell.xib in Resources */, C33FBFB01BDE441C008E3545 /* Assets.xcassets in Resources */, C33FBFAE1BDE441C008E3545 /* Main.storyboard in Resources */, ); @@ -418,18 +440,23 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C31E291C1BF39DE600EF5B2F /* FakePhotoMessageViewModel.swift in Sources */, - C3B0D3611BF3C928006CF725 /* ChatItemsDemoDecorator.swift in Sources */, - C33FBFAB1BDE441C008E3545 /* DemoChatViewController.swift in Sources */, - C396D98F1BF8C64900F10439 /* ConversationsViewController.swift in Sources */, - C3B0D35B1BF3C55E006CF725 /* SendingStatusPresenter.swift in Sources */, - C3B0D35D1BF3C627006CF725 /* SendingStatusCollectionViewCell.swift in Sources */, - C30C6EBB1BDE9BDC00D4C879 /* FakeMessageFactory.swift in Sources */, - C31E291A1BF38F8A00EF5B2F /* FakeMessageSender.swift in Sources */, - C35A6F511BF8089C0085CA19 /* FakeDataSource.swift in Sources */, - C35A6F4D1BF807C10085CA19 /* SlidingDatasSource.swift in Sources */, - C33FBFA91BDE441C008E3545 /* AppDelegate.swift in Sources */, - C326C9AE1BF6424900EC4607 /* UserActionHandlers.swift in Sources */, + C3F91DBF1C75EF9E00D461D2 /* FakeMessageSender.swift in Sources */, + C3F91DB81C75EF9E00D461D2 /* ConversationsViewController.swift in Sources */, + C3F91DC41C75EF9E00D461D2 /* DemoTextMessageHandler.swift in Sources */, + C3F91DC31C75EF9E00D461D2 /* SlidingDatasSource.swift in Sources */, + C3F91DC71C75EF9E00D461D2 /* BaseMessageHandler.swift in Sources */, + C3F91DC61C75EF9E00D461D2 /* DemoTextMessageViewModel.swift in Sources */, + C3F91DC01C75EF9E00D461D2 /* DemoPhotoMessageHandler.swift in Sources */, + C3F91DBC1C75EF9E00D461D2 /* DemoChatViewController.swift in Sources */, + C3F91DBD1C75EF9E00D461D2 /* FakeDataSource.swift in Sources */, + C3F91DB61C75EF9E00D461D2 /* AppDelegate.swift in Sources */, + C3F91DCE1C75EFE300D461D2 /* SendingStatusPresenter.swift in Sources */, + C3F91DC51C75EF9E00D461D2 /* DemoTextMessageModel.swift in Sources */, + C3F91DCC1C75EFE300D461D2 /* SendingStatusCollectionViewCell.swift in Sources */, + C3F91DB71C75EF9E00D461D2 /* ChatItemsDemoDecorator.swift in Sources */, + C3F91DC11C75EF9E00D461D2 /* DemoPhotoMessageModel.swift in Sources */, + C3F91DC21C75EF9E00D461D2 /* DemoPhotoMessageViewModel.swift in Sources */, + C3F91DBE1C75EF9E00D461D2 /* FakeMessageFactory.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ChattoApp/ChattoApp/AppDelegate.swift b/ChattoApp/ChattoApp/Source/AppDelegate.swift similarity index 100% rename from ChattoApp/ChattoApp/AppDelegate.swift rename to ChattoApp/ChattoApp/Source/AppDelegate.swift diff --git a/ChattoApp/ChattoApp/Source/BaseMessageHandler.swift b/ChattoApp/ChattoApp/Source/BaseMessageHandler.swift new file mode 100644 index 0000000..6fd3d74 --- /dev/null +++ b/ChattoApp/ChattoApp/Source/BaseMessageHandler.swift @@ -0,0 +1,52 @@ +/* + The MIT License (MIT) + + Copyright (c) 2015-present Badoo Trading Limited. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +import Foundation +import Chatto +import ChattoAdditions + +public protocol DemoMessageViewModelProtocol { + var messageModel: DemoMessageModelProtocol { get } +} + +class BaseMessageHandler { + + private let messageSender: FakeMessageSender + init (messageSender: FakeMessageSender) { + self.messageSender = messageSender + } + func userDidTapOnFailIcon(viewModel viewModel: DemoMessageViewModelProtocol) { + print("userDidTapOnFailIcon") + self.messageSender.sendMessage(viewModel.messageModel) + } + + func userDidTapOnBubble(viewModel viewModel: DemoMessageViewModelProtocol) { + print("userDidTapOnBubble") + + } + + func userDidLongPressOnBubble(viewModel viewModel: DemoMessageViewModelProtocol) { + print("userDidLongPressOnBubble") + } +} diff --git a/ChattoApp/ChattoApp/ChatItemsDemoDecorator.swift b/ChattoApp/ChattoApp/Source/ChatItemsDemoDecorator.swift similarity index 100% rename from ChattoApp/ChattoApp/ChatItemsDemoDecorator.swift rename to ChattoApp/ChattoApp/Source/ChatItemsDemoDecorator.swift diff --git a/ChattoApp/ChattoApp/ConversationsViewController.swift b/ChattoApp/ChattoApp/Source/ConversationsViewController.swift similarity index 100% rename from ChattoApp/ChattoApp/ConversationsViewController.swift rename to ChattoApp/ChattoApp/Source/ConversationsViewController.swift diff --git a/ChattoApp/ChattoApp/DemoChatViewController.swift b/ChattoApp/ChattoApp/Source/DemoChatViewController.swift similarity index 90% rename from ChattoApp/ChattoApp/DemoChatViewController.swift rename to ChattoApp/ChattoApp/Source/DemoChatViewController.swift index 2c52c54..3c3c500 100644 --- a/ChattoApp/ChattoApp/DemoChatViewController.swift +++ b/ChattoApp/ChattoApp/Source/DemoChatViewController.swift @@ -69,16 +69,16 @@ class DemoChatViewController: BaseChatViewController { override func createPresenterBuilders() -> [ChatItemType: [ChatItemPresenterBuilderProtocol]] { return [ - TextMessageModel.chatItemType: [ + DemoTextMessageModel.chatItemType: [ TextMessagePresenterBuilder( - viewModelBuilder: TextMessageViewModelDefaultBuilder(), - interactionHandler: TextMessageHandler(baseHandler: self.baseMessageHandler) + viewModelBuilder: DemoTextMessageViewModelBuilder(), + interactionHandler: DemoTextMessageHandler(baseHandler: self.baseMessageHandler) ) ], - PhotoMessageModel.chatItemType: [ + DemoPhotoMessageModel.chatItemType: [ PhotoMessagePresenterBuilder( - viewModelBuilder: FakePhotoMessageViewModelBuilder(), - interactionHandler: PhotoMessageHandler(baseHandler: self.baseMessageHandler) + viewModelBuilder: DemoPhotoMessageViewModelBuilder(), + interactionHandler: DemoPhotoMessageHandler(baseHandler: self.baseMessageHandler) ) ], SendingStatusModel.chatItemType: [SendingStatusPresenterBuilder()] diff --git a/ChattoApp/ChattoApp/FakeDataSource.swift b/ChattoApp/ChattoApp/Source/FakeDataSource.swift similarity index 100% rename from ChattoApp/ChattoApp/FakeDataSource.swift rename to ChattoApp/ChattoApp/Source/FakeDataSource.swift diff --git a/ChattoApp/ChattoApp/Source/FakeMessageFactory.swift b/ChattoApp/ChattoApp/Source/FakeMessageFactory.swift index b03da2c..2850d53 100644 --- a/ChattoApp/ChattoApp/Source/FakeMessageFactory.swift +++ b/ChattoApp/ChattoApp/Source/FakeMessageFactory.swift @@ -33,9 +33,9 @@ extension Array { } } -func createTextMessageModel(uid: String, text: String, isIncoming: Bool) -> TextMessageModel { - let messageModel = createMessageModel(uid, isIncoming: isIncoming, type: TextMessageModel.chatItemType) - let textMessageModel = TextMessageModel(messageModel: messageModel, text: text) +func createTextMessageModel(uid: String, text: String, isIncoming: Bool) -> DemoTextMessageModel { + let messageModel = createMessageModel(uid, isIncoming: isIncoming, type: TextMessageModel.chatItemType) + let textMessageModel = DemoTextMessageModel(messageModel: messageModel, text: text) return textMessageModel } @@ -46,9 +46,9 @@ func createMessageModel(uid: String, isIncoming: Bool, type: String) -> MessageM return messageModel } -func createPhotoMessageModel(uid: String, image: UIImage, size: CGSize, isIncoming: Bool) -> PhotoMessageModel { - let messageModel = createMessageModel(uid, isIncoming: isIncoming, type: PhotoMessageModel.chatItemType) - let photoMessageModel = PhotoMessageModel(messageModel: messageModel, imageSize:size, image: image) +func createPhotoMessageModel(uid: String, image: UIImage, size: CGSize, isIncoming: Bool) -> DemoPhotoMessageModel { + let messageModel = createMessageModel(uid, isIncoming: isIncoming, type: PhotoMessageModel.chatItemType) + let photoMessageModel = DemoPhotoMessageModel(messageModel: messageModel, imageSize:size, image: image) return photoMessageModel } @@ -70,7 +70,7 @@ class FakeMessageFactory { } } - class func createTextMessageModel(uid: String, isIncoming: Bool) -> TextMessageModel { + class func createTextMessageModel(uid: String, isIncoming: Bool) -> DemoTextMessageModel { let incomingText: String = isIncoming ? "incoming" : "outgoing" let maxText = self.demoTexts.randomItem() let length: Int = 10 + Int(arc4random_uniform(300)) @@ -78,7 +78,7 @@ class FakeMessageFactory { return ChattoApp.createTextMessageModel(uid, text: text, isIncoming: isIncoming) } - class func createPhotoMessageModel(uid: String, isIncoming: Bool) -> PhotoMessageModel { + class func createPhotoMessageModel(uid: String, isIncoming: Bool) -> DemoPhotoMessageModel { var imageSize = CGSize.zero switch arc4random_uniform(100) % 3 { case 0: diff --git a/ChattoApp/ChattoApp/FakeMessageSender.swift b/ChattoApp/ChattoApp/Source/FakeMessageSender.swift similarity index 81% rename from ChattoApp/ChattoApp/FakeMessageSender.swift rename to ChattoApp/ChattoApp/Source/FakeMessageSender.swift index 8117693..456a54a 100644 --- a/ChattoApp/ChattoApp/FakeMessageSender.swift +++ b/ChattoApp/ChattoApp/Source/FakeMessageSender.swift @@ -26,21 +26,25 @@ import Foundation import Chatto import ChattoAdditions +public protocol DemoMessageModelProtocol: MessageModelProtocol { + var status: MessageStatus { get set } +} + public class FakeMessageSender { - public var onMessageChanged: ((message: MessageModelProtocol) -> Void)? + public var onMessageChanged: ((message: DemoMessageModelProtocol) -> Void)? - public func sendMessages(messages: [MessageModelProtocol]) { + public func sendMessages(messages: [DemoMessageModelProtocol]) { for message in messages { self.fakeMessageStatus(message) } } - public func sendMessage(message: MessageModelProtocol) { + public func sendMessage(message: DemoMessageModelProtocol) { self.fakeMessageStatus(message) } - private func fakeMessageStatus(message: MessageModelProtocol) { + private func fakeMessageStatus(message: DemoMessageModelProtocol) { switch message.status { case .Success: break @@ -65,14 +69,14 @@ public class FakeMessageSender { } } - private func updateMessage(message: MessageModelProtocol, status: MessageStatus) { + private func updateMessage(message: DemoMessageModelProtocol, status: MessageStatus) { if message.status != status { message.status = status self.notifyMessageChanged(message) } } - private func notifyMessageChanged(message: MessageModelProtocol) { + private func notifyMessageChanged(message: DemoMessageModelProtocol) { self.onMessageChanged?(message: message) } } diff --git a/ChattoApp/ChattoApp/Source/Photo Messages/DemoPhotoMessageHandler.swift b/ChattoApp/ChattoApp/Source/Photo Messages/DemoPhotoMessageHandler.swift new file mode 100644 index 0000000..3245618 --- /dev/null +++ b/ChattoApp/ChattoApp/Source/Photo Messages/DemoPhotoMessageHandler.swift @@ -0,0 +1,45 @@ +/* + The MIT License (MIT) + + Copyright (c) 2015-present Badoo Trading Limited. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +import Foundation +import ChattoAdditions + +class DemoPhotoMessageHandler: BaseMessageInteractionHandlerProtocol { + private let baseHandler: BaseMessageHandler + init (baseHandler: BaseMessageHandler) { + self.baseHandler = baseHandler + } + + func userDidTapOnFailIcon(viewModel viewModel: DemoPhotoMessageViewModel) { + self.baseHandler.userDidTapOnFailIcon(viewModel: viewModel) + } + + func userDidTapOnBubble(viewModel viewModel: DemoPhotoMessageViewModel) { + self.baseHandler.userDidTapOnBubble(viewModel: viewModel) + } + + func userDidLongPressOnBubble(viewModel viewModel: DemoPhotoMessageViewModel) { + self.baseHandler.userDidLongPressOnBubble(viewModel: viewModel) + } +} diff --git a/ChattoApp/ChattoApp/Source/Photo Messages/DemoPhotoMessageModel.swift b/ChattoApp/ChattoApp/Source/Photo Messages/DemoPhotoMessageModel.swift new file mode 100644 index 0000000..60fc4c7 --- /dev/null +++ b/ChattoApp/ChattoApp/Source/Photo Messages/DemoPhotoMessageModel.swift @@ -0,0 +1,41 @@ +/* + The MIT License (MIT) + + Copyright (c) 2015-present Badoo Trading Limited. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +import Foundation +import ChattoAdditions + +public class DemoPhotoMessageModel: PhotoMessageModel, DemoMessageModelProtocol { + public override init(messageModel: MessageModel, imageSize: CGSize, image: UIImage) { + super.init(messageModel: messageModel, imageSize: imageSize, image: image) + } + + public var status: MessageStatus { + get { + return self._messageModel.status + } + set { + self._messageModel.status = newValue + } + } +} diff --git a/ChattoApp/ChattoApp/FakePhotoMessageViewModel.swift b/ChattoApp/ChattoApp/Source/Photo Messages/DemoPhotoMessageViewModel.swift similarity index 80% rename from ChattoApp/ChattoApp/FakePhotoMessageViewModel.swift rename to ChattoApp/ChattoApp/Source/Photo Messages/DemoPhotoMessageViewModel.swift index 7429f15..24efd3e 100644 --- a/ChattoApp/ChattoApp/FakePhotoMessageViewModel.swift +++ b/ChattoApp/ChattoApp/Source/Photo Messages/DemoPhotoMessageViewModel.swift @@ -25,10 +25,10 @@ import Foundation import ChattoAdditions -class FakePhotoMessageViewModel: PhotoMessageViewModel { +class DemoPhotoMessageViewModel: PhotoMessageViewModel { let fakeImage: UIImage - override init(photoMessage: PhotoMessageModelProtocol, messageViewModel: MessageViewModelProtocol) { + override init(photoMessage: DemoPhotoMessageModel, messageViewModel: MessageViewModelProtocol) { self.fakeImage = photoMessage.image super.init(photoMessage: photoMessage, messageViewModel: messageViewModel) if photoMessage.isIncoming { @@ -65,17 +65,23 @@ class FakePhotoMessageViewModel: PhotoMessageViewModel { } } -public class FakePhotoMessageViewModelBuilder: ViewModelBuilderProtocol { +extension DemoPhotoMessageViewModel: DemoMessageViewModelProtocol { + var messageModel: DemoMessageModelProtocol { + return self._photoMessage + } +} + +class DemoPhotoMessageViewModelBuilder: ViewModelBuilderProtocol { let messageViewModelBuilder = MessageViewModelDefaultBuilder() - public func createViewModel(model: PhotoMessageModel) -> PhotoMessageViewModel { + func createViewModel(model: DemoPhotoMessageModel) -> DemoPhotoMessageViewModel { let messageViewModel = self.messageViewModelBuilder.createMessageViewModel(model) - let photoMessageViewModel = FakePhotoMessageViewModel(photoMessage: model, messageViewModel: messageViewModel) + let photoMessageViewModel = DemoPhotoMessageViewModel(photoMessage: model, messageViewModel: messageViewModel) return photoMessageViewModel } - public func canCreateViewModel(fromModel model: Any) -> Bool { - return model is PhotoMessageModel + func canCreateViewModel(fromModel model: Any) -> Bool { + return model is DemoPhotoMessageModel } } diff --git a/ChattoApp/ChattoApp/Source/Custom items/Sending status/SendingStatusCollectionViewCell.swift b/ChattoApp/ChattoApp/Source/Sending status/SendingStatusCollectionViewCell.swift similarity index 100% rename from ChattoApp/ChattoApp/Source/Custom items/Sending status/SendingStatusCollectionViewCell.swift rename to ChattoApp/ChattoApp/Source/Sending status/SendingStatusCollectionViewCell.swift diff --git a/ChattoApp/ChattoApp/Source/Custom items/Sending status/SendingStatusCollectionViewCell.xib b/ChattoApp/ChattoApp/Source/Sending status/SendingStatusCollectionViewCell.xib similarity index 100% rename from ChattoApp/ChattoApp/Source/Custom items/Sending status/SendingStatusCollectionViewCell.xib rename to ChattoApp/ChattoApp/Source/Sending status/SendingStatusCollectionViewCell.xib diff --git a/ChattoApp/ChattoApp/Source/Custom items/Sending status/SendingStatusPresenter.swift b/ChattoApp/ChattoApp/Source/Sending status/SendingStatusPresenter.swift similarity index 100% rename from ChattoApp/ChattoApp/Source/Custom items/Sending status/SendingStatusPresenter.swift rename to ChattoApp/ChattoApp/Source/Sending status/SendingStatusPresenter.swift diff --git a/ChattoApp/ChattoApp/SlidingDatasSource.swift b/ChattoApp/ChattoApp/Source/SlidingDatasSource.swift similarity index 100% rename from ChattoApp/ChattoApp/SlidingDatasSource.swift rename to ChattoApp/ChattoApp/Source/SlidingDatasSource.swift diff --git a/ChattoApp/ChattoApp/Source/Text Messages/DemoTextMessageHandler.swift b/ChattoApp/ChattoApp/Source/Text Messages/DemoTextMessageHandler.swift new file mode 100644 index 0000000..c488a63 --- /dev/null +++ b/ChattoApp/ChattoApp/Source/Text Messages/DemoTextMessageHandler.swift @@ -0,0 +1,44 @@ +/* + The MIT License (MIT) + + Copyright (c) 2015-present Badoo Trading Limited. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +import Foundation +import ChattoAdditions + +class DemoTextMessageHandler: BaseMessageInteractionHandlerProtocol { + private let baseHandler: BaseMessageHandler + init (baseHandler: BaseMessageHandler) { + self.baseHandler = baseHandler + } + func userDidTapOnFailIcon(viewModel viewModel: DemoTextMessageViewModel) { + self.baseHandler.userDidTapOnFailIcon(viewModel: viewModel) + } + + func userDidTapOnBubble(viewModel viewModel: DemoTextMessageViewModel) { + self.baseHandler.userDidTapOnBubble(viewModel: viewModel) + } + + func userDidLongPressOnBubble(viewModel viewModel: DemoTextMessageViewModel) { + self.baseHandler.userDidLongPressOnBubble(viewModel: viewModel) + } +} diff --git a/ChattoApp/ChattoApp/Source/Text Messages/DemoTextMessageModel.swift b/ChattoApp/ChattoApp/Source/Text Messages/DemoTextMessageModel.swift new file mode 100644 index 0000000..ab5a6aa --- /dev/null +++ b/ChattoApp/ChattoApp/Source/Text Messages/DemoTextMessageModel.swift @@ -0,0 +1,41 @@ +/* + The MIT License (MIT) + + Copyright (c) 2015-present Badoo Trading Limited. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +import Foundation +import ChattoAdditions + +public class DemoTextMessageModel: TextMessageModel, DemoMessageModelProtocol { + public override init(messageModel: MessageModel, text: String) { + super.init(messageModel: messageModel, text: text) + } + + public var status: MessageStatus { + get { + return self._messageModel.status + } + set { + self._messageModel.status = newValue + } + } +} diff --git a/ChattoApp/ChattoApp/Source/Text Messages/DemoTextMessageViewModel.swift b/ChattoApp/ChattoApp/Source/Text Messages/DemoTextMessageViewModel.swift new file mode 100644 index 0000000..e7eea4f --- /dev/null +++ b/ChattoApp/ChattoApp/Source/Text Messages/DemoTextMessageViewModel.swift @@ -0,0 +1,53 @@ +/* + The MIT License (MIT) + + Copyright (c) 2015-present Badoo Trading Limited. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +import Foundation +import ChattoAdditions + +public class DemoTextMessageViewModel: TextMessageViewModel, DemoMessageViewModelProtocol { + + public override init(textMessage: DemoTextMessageModel, messageViewModel: MessageViewModelProtocol) { + super.init(textMessage: textMessage, messageViewModel: messageViewModel) + } + + public var messageModel: DemoMessageModelProtocol { + return self.textMessage + } +} + +public class DemoTextMessageViewModelBuilder: ViewModelBuilderProtocol { + public init() { } + + let messageViewModelBuilder = MessageViewModelDefaultBuilder() + + public func createViewModel(textMessage: DemoTextMessageModel) -> DemoTextMessageViewModel { + let messageViewModel = self.messageViewModelBuilder.createMessageViewModel(textMessage) + let textMessageViewModel = DemoTextMessageViewModel(textMessage: textMessage, messageViewModel: messageViewModel) + return textMessageViewModel + } + + public func canCreateViewModel(fromModel model: Any) -> Bool { + return model is DemoTextMessageModel + } +} diff --git a/ChattoApp/ChattoApp/UserActionHandlers.swift b/ChattoApp/ChattoApp/UserActionHandlers.swift deleted file mode 100644 index c6c2f88..0000000 --- a/ChattoApp/ChattoApp/UserActionHandlers.swift +++ /dev/null @@ -1,85 +0,0 @@ -/* - The MIT License (MIT) - - Copyright (c) 2015-present Badoo Trading Limited. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -import Foundation -import Chatto -import ChattoAdditions - -class TextMessageHandler: BaseMessageInteractionHandlerProtocol { - private let baseHandler: BaseMessageHandler - init (baseHandler: BaseMessageHandler) { - self.baseHandler = baseHandler - } - func userDidTapOnFailIcon(viewModel viewModel: TextMessageViewModel) { - self.baseHandler.userDidTapOnFailIcon(viewModel: viewModel) - } - - func userDidTapOnBubble(viewModel viewModel: TextMessageViewModel) { - self.baseHandler.userDidTapOnBubble(viewModel: viewModel) - } - - func userDidLongPressOnBubble(viewModel viewModel: TextMessageViewModel) { - self.baseHandler.userDidLongPressOnBubble(viewModel: viewModel) - } -} - -class PhotoMessageHandler: BaseMessageInteractionHandlerProtocol { - private let baseHandler: BaseMessageHandler - init (baseHandler: BaseMessageHandler) { - self.baseHandler = baseHandler - } - - func userDidTapOnFailIcon(viewModel viewModel: PhotoMessageViewModel) { - self.baseHandler.userDidTapOnFailIcon(viewModel: viewModel) - } - - func userDidTapOnBubble(viewModel viewModel: PhotoMessageViewModel) { - self.baseHandler.userDidTapOnBubble(viewModel: viewModel) - } - - func userDidLongPressOnBubble(viewModel viewModel: PhotoMessageViewModel) { - self.baseHandler.userDidLongPressOnBubble(viewModel: viewModel) - } -} - -class BaseMessageHandler { - - private let messageSender: FakeMessageSender - init (messageSender: FakeMessageSender) { - self.messageSender = messageSender - } - func userDidTapOnFailIcon(viewModel viewModel: MessageViewModelProtocol) { - NSLog("userDidTapOnFailIcon") - self.messageSender.sendMessage(viewModel.messageModel) - } - - func userDidTapOnBubble(viewModel viewModel: MessageViewModelProtocol) { - NSLog("userDidTapOnBubble") - - } - - func userDidLongPressOnBubble(viewModel viewModel: MessageViewModelProtocol) { - NSLog("userDidLongPressOnBubble") - } -}