Commit ba257b50 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Andreas Traczyk

data transfer: display image

Change-Id: I2b934cfb4a739001298dfc055489493b7491b1d3
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 2b13f8f4
......@@ -2,24 +2,24 @@
#if os(OSX)
import AppKit.NSImage
typealias AssetColorTypeAlias = NSColor
typealias Image = NSImage
internal typealias AssetColorTypeAlias = NSColor
internal typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias AssetColorTypeAlias = UIColor
typealias Image = UIImage
internal typealias AssetColorTypeAlias = UIColor
internal typealias Image = UIImage
#endif
// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
@available(*, deprecated, renamed: "ImageAsset")
typealias AssetType = ImageAsset
internal typealias AssetType = ImageAsset
struct ImageAsset {
fileprivate var name: String
internal struct ImageAsset {
internal fileprivate(set) var name: String
var image: Image {
internal var image: Image {
let bundle = Bundle(for: BundleToken.self)
#if os(iOS) || os(tvOS)
let image = Image(named: name, in: bundle, compatibleWith: nil)
......@@ -33,57 +33,57 @@ struct ImageAsset {
}
}
struct ColorAsset {
fileprivate var name: String
internal struct ColorAsset {
internal fileprivate(set) var name: String
#if swift(>=3.2)
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
var color: AssetColorTypeAlias {
internal var color: AssetColorTypeAlias {
return AssetColorTypeAlias(asset: self)
}
#endif
}
// swiftlint:disable identifier_name line_length nesting type_body_length type_name
enum Asset {
static let accountIcon = ImageAsset(name: "account_icon")
static let addPerson = ImageAsset(name: "add_person")
static let attachmentIcon = ImageAsset(name: "attachment_icon")
static let audioMuted = ImageAsset(name: "audio_muted")
static let audioRunning = ImageAsset(name: "audio_running")
static let backButton = ImageAsset(name: "back_button")
static let backgroundRing = ImageAsset(name: "background_ring")
static let blockIcon = ImageAsset(name: "block_icon")
static let callButton = ImageAsset(name: "call_button")
static let camera = ImageAsset(name: "camera")
static let clearConversation = ImageAsset(name: "clear_conversation")
static let closeIcon = ImageAsset(name: "close_icon")
static let contactRequestIcon = ImageAsset(name: "contact_request_icon")
static let conversationIcon = ImageAsset(name: "conversation_icon")
static let device = ImageAsset(name: "device")
static let disableSpeakerphone = ImageAsset(name: "disable_speakerphone")
static let doneIcon = ImageAsset(name: "done_icon")
static let downloadIcon = ImageAsset(name: "download_icon")
static let enableSpeakerphone = ImageAsset(name: "enable_speakerphone")
static let fallbackAvatar = ImageAsset(name: "fallback_avatar")
static let icContactPicture = ImageAsset(name: "ic_contact_picture")
static let moreSettings = ImageAsset(name: "more_settings")
static let pauseCall = ImageAsset(name: "pause_call")
static let ringIcon = ImageAsset(name: "ringIcon")
static let ringLogo = ImageAsset(name: "ring_logo")
static let sendButton = ImageAsset(name: "send_button")
static let settingsIcon = ImageAsset(name: "settings_icon")
static let shareButton = ImageAsset(name: "share_button")
static let stopCall = ImageAsset(name: "stop_call")
static let switchCamera = ImageAsset(name: "switch_camera")
static let unpauseCall = ImageAsset(name: "unpause_call")
static let videoMuted = ImageAsset(name: "video_muted")
static let videoRunning = ImageAsset(name: "video_running")
internal enum Asset {
internal static let accountIcon = ImageAsset(name: "account_icon")
internal static let addPerson = ImageAsset(name: "add_person")
internal static let attachmentIcon = ImageAsset(name: "attachment_icon")
internal static let audioMuted = ImageAsset(name: "audio_muted")
internal static let audioRunning = ImageAsset(name: "audio_running")
internal static let backButton = ImageAsset(name: "back_button")
internal static let backgroundRing = ImageAsset(name: "background_ring")
internal static let blockIcon = ImageAsset(name: "block_icon")
internal static let callButton = ImageAsset(name: "call_button")
internal static let camera = ImageAsset(name: "camera")
internal static let clearConversation = ImageAsset(name: "clear_conversation")
internal static let closeIcon = ImageAsset(name: "close_icon")
internal static let contactRequestIcon = ImageAsset(name: "contact_request_icon")
internal static let conversationIcon = ImageAsset(name: "conversation_icon")
internal static let device = ImageAsset(name: "device")
internal static let disableSpeakerphone = ImageAsset(name: "disable_speakerphone")
internal static let doneIcon = ImageAsset(name: "done_icon")
internal static let downloadIcon = ImageAsset(name: "download_icon")
internal static let enableSpeakerphone = ImageAsset(name: "enable_speakerphone")
internal static let fallbackAvatar = ImageAsset(name: "fallback_avatar")
internal static let icContactPicture = ImageAsset(name: "ic_contact_picture")
internal static let moreSettings = ImageAsset(name: "more_settings")
internal static let pauseCall = ImageAsset(name: "pause_call")
internal static let ringIcon = ImageAsset(name: "ringIcon")
internal static let ringLogo = ImageAsset(name: "ring_logo")
internal static let sendButton = ImageAsset(name: "send_button")
internal static let settingsIcon = ImageAsset(name: "settings_icon")
internal static let shareButton = ImageAsset(name: "share_button")
internal static let stopCall = ImageAsset(name: "stop_call")
internal static let switchCamera = ImageAsset(name: "switch_camera")
internal static let unpauseCall = ImageAsset(name: "unpause_call")
internal static let videoMuted = ImageAsset(name: "video_muted")
internal static let videoRunning = ImageAsset(name: "video_running")
// swiftlint:disable trailing_comma
static let allColors: [ColorAsset] = [
internal static let allColors: [ColorAsset] = [
]
static let allImages: [ImageAsset] = [
internal static let allImages: [ImageAsset] = [
accountIcon,
addPerson,
attachmentIcon,
......@@ -120,11 +120,11 @@ enum Asset {
]
// swiftlint:enable trailing_comma
@available(*, deprecated, renamed: "allImages")
static let allValues: [AssetType] = allImages
internal static let allValues: [AssetType] = allImages
}
// swiftlint:enable identifier_name line_length nesting type_body_length type_name
extension Image {
internal extension Image {
@available(iOS 1.0, tvOS 1.0, watchOS 1.0, *)
@available(OSX, deprecated,
message: "This initializer is unsafe on macOS, please use the ImageAsset.image property")
......@@ -138,7 +138,7 @@ extension Image {
}
}
extension AssetColorTypeAlias {
internal extension AssetColorTypeAlias {
#if swift(>=3.2)
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
convenience init!(asset: ColorAsset) {
......
......@@ -7,21 +7,21 @@ import UIKit
// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
protocol StoryboardType {
internal protocol StoryboardType {
static var storyboardName: String { get }
}
extension StoryboardType {
internal extension StoryboardType {
static var storyboard: UIStoryboard {
return UIStoryboard(name: self.storyboardName, bundle: Bundle(for: BundleToken.self))
}
}
struct SceneType<T: Any> {
let storyboard: StoryboardType.Type
let identifier: String
internal struct SceneType<T: Any> {
internal let storyboard: StoryboardType.Type
internal let identifier: String
func instantiate() -> T {
internal func instantiate() -> T {
guard let controller = storyboard.storyboard.instantiateViewController(withIdentifier: identifier) as? T else {
fatalError("ViewController '\(identifier)' is not of the expected class \(T.self).")
}
......@@ -29,10 +29,10 @@ struct SceneType<T: Any> {
}
}
struct InitialSceneType<T: Any> {
let storyboard: StoryboardType.Type
internal struct InitialSceneType<T: Any> {
internal let storyboard: StoryboardType.Type
func instantiate() -> T {
internal func instantiate() -> T {
guard let controller = storyboard.storyboard.instantiateInitialViewController() as? T else {
fatalError("ViewController is not of the expected class \(T.self).")
}
......@@ -40,96 +40,96 @@ struct InitialSceneType<T: Any> {
}
}
protocol SegueType: RawRepresentable { }
internal protocol SegueType: RawRepresentable { }
extension UIViewController {
internal extension UIViewController {
func perform<S: SegueType>(segue: S, sender: Any? = nil) where S.RawValue == String {
performSegue(withIdentifier: segue.rawValue, sender: sender)
}
}
// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
enum StoryboardScene {
enum BlockListViewController: StoryboardType {
static let storyboardName = "BlockListViewController"
internal enum StoryboardScene {
internal enum BlockListViewController: StoryboardType {
internal static let storyboardName = "BlockListViewController"
static let initialScene = InitialSceneType<Ring.BlockListViewController>(storyboard: BlockListViewController.self)
internal static let initialScene = InitialSceneType<Ring.BlockListViewController>(storyboard: BlockListViewController.self)
}
enum CallViewController: StoryboardType {
static let storyboardName = "CallViewController"
internal enum CallViewController: StoryboardType {
internal static let storyboardName = "CallViewController"
static let initialScene = InitialSceneType<Ring.CallViewController>(storyboard: CallViewController.self)
internal static let initialScene = InitialSceneType<Ring.CallViewController>(storyboard: CallViewController.self)
}
enum ContactRequestsViewController: StoryboardType {
static let storyboardName = "ContactRequestsViewController"
internal enum ContactRequestsViewController: StoryboardType {
internal static let storyboardName = "ContactRequestsViewController"
static let initialScene = InitialSceneType<Ring.ContactRequestsViewController>(storyboard: ContactRequestsViewController.self)
internal static let initialScene = InitialSceneType<Ring.ContactRequestsViewController>(storyboard: ContactRequestsViewController.self)
}
enum ContactViewController: StoryboardType {
static let storyboardName = "ContactViewController"
internal enum ContactViewController: StoryboardType {
internal static let storyboardName = "ContactViewController"
static let initialScene = InitialSceneType<Ring.ContactViewController>(storyboard: ContactViewController.self)
internal static let initialScene = InitialSceneType<Ring.ContactViewController>(storyboard: ContactViewController.self)
}
enum ConversationViewController: StoryboardType {
static let storyboardName = "ConversationViewController"
internal enum ConversationViewController: StoryboardType {
internal static let storyboardName = "ConversationViewController"
static let initialScene = InitialSceneType<Ring.ConversationViewController>(storyboard: ConversationViewController.self)
internal static let initialScene = InitialSceneType<Ring.ConversationViewController>(storyboard: ConversationViewController.self)
}
enum CreateAccountViewController: StoryboardType {
static let storyboardName = "CreateAccountViewController"
internal enum CreateAccountViewController: StoryboardType {
internal static let storyboardName = "CreateAccountViewController"
static let initialScene = InitialSceneType<Ring.CreateAccountViewController>(storyboard: CreateAccountViewController.self)
internal static let initialScene = InitialSceneType<Ring.CreateAccountViewController>(storyboard: CreateAccountViewController.self)
}
enum CreateProfileViewController: StoryboardType {
static let storyboardName = "CreateProfileViewController"
internal enum CreateProfileViewController: StoryboardType {
internal static let storyboardName = "CreateProfileViewController"
static let initialScene = InitialSceneType<Ring.CreateProfileViewController>(storyboard: CreateProfileViewController.self)
internal static let initialScene = InitialSceneType<Ring.CreateProfileViewController>(storyboard: CreateProfileViewController.self)
}
enum InitialLoadingViewController: StoryboardType {
static let storyboardName = "InitialLoadingViewController"
internal enum InitialLoadingViewController: StoryboardType {
internal static let storyboardName = "InitialLoadingViewController"
static let initialScene = InitialSceneType<Ring.InitialLoadingViewController>(storyboard: InitialLoadingViewController.self)
internal static let initialScene = InitialSceneType<Ring.InitialLoadingViewController>(storyboard: InitialLoadingViewController.self)
static let initialLoadingViewController = SceneType<Ring.InitialLoadingViewController>(storyboard: InitialLoadingViewController.self, identifier: "InitialLoadingViewController")
internal static let initialLoadingViewController = SceneType<Ring.InitialLoadingViewController>(storyboard: InitialLoadingViewController.self, identifier: "InitialLoadingViewController")
}
enum LaunchScreen: StoryboardType {
static let storyboardName = "LaunchScreen"
internal enum LaunchScreen: StoryboardType {
internal static let storyboardName = "LaunchScreen"
static let initialScene = InitialSceneType<UIViewController>(storyboard: LaunchScreen.self)
internal static let initialScene = InitialSceneType<UIViewController>(storyboard: LaunchScreen.self)
}
enum LinkDeviceViewController: StoryboardType {
static let storyboardName = "LinkDeviceViewController"
internal enum LinkDeviceViewController: StoryboardType {
internal static let storyboardName = "LinkDeviceViewController"
static let initialScene = InitialSceneType<Ring.LinkDeviceViewController>(storyboard: LinkDeviceViewController.self)
internal static let initialScene = InitialSceneType<Ring.LinkDeviceViewController>(storyboard: LinkDeviceViewController.self)
}
enum LinkNewDeviceViewController: StoryboardType {
static let storyboardName = "LinkNewDeviceViewController"
internal enum LinkNewDeviceViewController: StoryboardType {
internal static let storyboardName = "LinkNewDeviceViewController"
static let initialScene = InitialSceneType<Ring.LinkNewDeviceViewController>(storyboard: LinkNewDeviceViewController.self)
internal static let initialScene = InitialSceneType<Ring.LinkNewDeviceViewController>(storyboard: LinkNewDeviceViewController.self)
}
enum MeDetailViewController: StoryboardType {
static let storyboardName = "MeDetailViewController"
internal enum MeDetailViewController: StoryboardType {
internal static let storyboardName = "MeDetailViewController"
static let initialScene = InitialSceneType<Ring.MeDetailViewController>(storyboard: MeDetailViewController.self)
internal static let initialScene = InitialSceneType<Ring.MeDetailViewController>(storyboard: MeDetailViewController.self)
}
enum MeViewController: StoryboardType {
static let storyboardName = "MeViewController"
internal enum MeViewController: StoryboardType {
internal static let storyboardName = "MeViewController"
static let initialScene = InitialSceneType<Ring.MeViewController>(storyboard: MeViewController.self)
internal static let initialScene = InitialSceneType<Ring.MeViewController>(storyboard: MeViewController.self)
}
enum SmartlistViewController: StoryboardType {
static let storyboardName = "SmartlistViewController"
internal enum SmartlistViewController: StoryboardType {
internal static let storyboardName = "SmartlistViewController"
static let initialScene = InitialSceneType<Ring.SmartlistViewController>(storyboard: SmartlistViewController.self)
internal static let initialScene = InitialSceneType<Ring.SmartlistViewController>(storyboard: SmartlistViewController.self)
}
enum WelcomeViewController: StoryboardType {
static let storyboardName = "WelcomeViewController"
internal enum WelcomeViewController: StoryboardType {
internal static let storyboardName = "WelcomeViewController"
static let initialScene = InitialSceneType<Ring.WelcomeViewController>(storyboard: WelcomeViewController.self)
internal static let initialScene = InitialSceneType<Ring.WelcomeViewController>(storyboard: WelcomeViewController.self)
}
}
enum StoryboardSegue {
internal enum StoryboardSegue {
}
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name
......
This diff is collapsed.
......@@ -289,6 +289,22 @@ final class InteractionDataHelper {
}
}
func updateInteractionWithID(interactionID: Int64, content: String) -> Bool {
guard let dataBase = RingDB.instance.ringDB else {
return false
}
let query = table.filter(id == interactionID)
do {
if try dataBase.run(query.update(body <- content)) > 0 {
return true
} else {
return false
}
} catch {
return false
}
}
func deleteAllIntercations(convID: Int64) -> Bool {
guard let dataBase = RingDB.instance.ringDB else {
return false
......
......@@ -230,6 +230,20 @@ class DBManager {
}
}
func updateFileName(interactionID: Int64, name: String) -> Completable {
return Completable.create { [unowned self] completable in
let success = self.interactionHepler
.updateInteractionWithID(interactionID: interactionID, content: name)
if success {
completable(.completed)
} else {
completable(.error(DBBridgingError.updateMessageStatusFailed))
}
return Disposables.create { }
}
}
func updateTransferStatus(daemonID: String, withStatus transferStatus: DataTransferStatus) -> Completable {
return Completable.create { [unowned self] completable in
let success = self.interactionHepler
......
//
// UIImage+Helpers.swift
// Ring
//
// Created by Hadrien De Sousa on 17-07-19.
// Copyright © 2017 Savoir-faire Linux. All rights reserved.
//
/*
* Copyright (C) 2017 Savoir-faire Linux Inc.
*
* Author: Hadrien De Sousa <hadrien.desousa@savoirfairelinux.com>
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import Foundation
import UIKit
import CoreImage
extension UIImage {
var circleMasked: UIImage? {
......@@ -36,6 +50,22 @@ extension UIImage {
return result
}
func setRoundCorner(radius: CGFloat, offset: CGFloat) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(self.size, false, 0)
let bounds = CGRect(origin: .zero, size: self.size)
let path = UIBezierPath(roundedRect: bounds.insetBy(dx: offset, dy: offset), cornerRadius: radius)
let context = UIGraphicsGetCurrentContext()
context?.saveGState()
path.addClip()
self.draw(in: bounds)
UIColor.ringMsgBackground.setStroke()
path.lineWidth = offset * 2
path.stroke()
let roundedImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return roundedImage
}
// convenience function in UIImage extension to resize a given image
func convert(toSize size: CGSize, scale: CGFloat) -> UIImage {
let imgRect = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size)
......@@ -62,4 +92,54 @@ extension UIImage {
}
return imageData
}
func resizeIntoRectangle(of size: CGSize) -> UIImage? {
if self.size.width < size.width && self.size.height < size.height {
return self
}
if self.size.height == 0 {
return nil
}
var newWidth = size.width
var newHeight = size.height
let ratio = self.size.width / self.size.height
if ratio > 1 {
newHeight = newWidth / ratio
} else if ratio < 1, ratio != 0 {
newWidth = newHeight * ratio
}
let newSize = CGSize(width: newWidth, height: newHeight)
guard let cgImage = self.cgImage else {return self.resizeImageWith(newSize: newSize)}
let bitsPerComponent = cgImage.bitsPerComponent
let bytesPerRow = cgImage.bytesPerRow
guard let colorSpace = cgImage.colorSpace else {return self.resizeImageWith(newSize: newSize)}
let bitmapInfo = cgImage.bitmapInfo
guard let context = CGContext(data: nil,
width: Int(newWidth),
height: Int(newHeight),
bitsPerComponent: bitsPerComponent,
bytesPerRow: bytesPerRow,
space: colorSpace,
bitmapInfo: bitmapInfo.rawValue) else {return self.resizeImageWith(newSize: newSize)}
context.interpolationQuality = .high
context.draw(cgImage, in: CGRect(origin: .zero, size: CGSize(width: newWidth, height: newHeight)))
let image = context.makeImage().flatMap { UIImage(cgImage: $0) }
if let newImage: UIImage = image {
return newImage
}
return self.resizeImageWith(newSize: newSize)
}
func resizeImageWith(newSize: CGSize) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(newSize, true, 0)
draw(in: CGRect(origin: CGPoint(x: 0, y: 0), size: newSize))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage
}
}
......@@ -40,7 +40,7 @@ class MessageCell: UITableViewCell, NibReusable {
@IBOutlet weak var progressBar: UIProgressView!
@IBOutlet weak var acceptButton: UIButton!
@IBOutlet weak var cancelButton: UIButton!
@IBOutlet weak var buttonsHeightConstraint: NSLayoutConstraint!
@IBOutlet weak var buttonsHeightConstraint: NSLayoutConstraint?
@IBOutlet weak var bottomCorner: UIView!
@IBOutlet weak var topCorner: UIView!
@IBOutlet weak var timeLabel: UILabel!
......@@ -48,6 +48,9 @@ class MessageCell: UITableViewCell, NibReusable {
@IBOutlet weak var rightDivider: UIView!
@IBOutlet weak var sendingIndicator: UIActivityIndicatorView!
@IBOutlet weak var failedStatusLabel: UILabel!
@IBOutlet weak var bubbleViewMask: UIView?
private var transferImageView = UIImageView()
var dataTransferProgressUpdater: Timer?
......@@ -226,28 +229,38 @@ class MessageCell: UITableViewCell, NibReusable {
self.bubbleTopConstraint.constant = item.timeStringShown != nil ? 32 : 1
default: break
}
if item.shouldDisplayTransferedImage {
self.displayTransferedImage(message: item)
}
}
/// swiftlint:disable function_body_length
func configureFromItem(_ conversationViewModel: ConversationViewModel,
_ items: [MessageViewModel]?,
cellForRowAt indexPath: IndexPath) {
self.backgroundColor = UIColor.clear
self.bubbleViewMask?.backgroundColor = UIColor.ringMsgBackground
self.transferImageView.backgroundColor = UIColor.ringMsgBackground
buttonsHeightConstraint?.priority = UILayoutPriority(rawValue: 999.0)
guard let item = items?[indexPath.row] else {
return
}
self.transferImageView.removeFromSuperview()
self.bubbleViewMask?.isHidden = true
// hide/show time label
formatCellTimeLabel(item)
self.formatCellTimeLabel(item)
if item.bubblePosition() == .generated {
self.bubble.backgroundColor = UIColor.ringMsgCellReceived
self.messageLabel.setTextWithLineSpacing(withText: item.content, withLineSpacing: 2)
if indexPath.row == 0 {
messageLabelMarginConstraint.constant = 4
self.messageLabelMarginConstraint.constant = 4
self.bubbleTopConstraint.constant = 36
} else {
messageLabelMarginConstraint.constant = -2
self.messageLabelMarginConstraint.constant = -2
self.bubbleTopConstraint.constant = 32
}
return
......@@ -256,10 +269,10 @@ class MessageCell: UITableViewCell, NibReusable {
let type = item.bubblePosition()
self.bubble.backgroundColor = type == .received ? UIColor.ringMsgCellReceived : UIColor(hex: 0xcfebf5, alpha: 1.0)
if indexPath.row == 0 {
messageLabelMarginConstraint.constant = 4
self.messageLabelMarginConstraint.constant = 4
self.bubbleTopConstraint.constant = 36
} else {
messageLabelMarginConstraint.constant = -2
self.messageLabelMarginConstraint.constant = -2
self.bubbleTopConstraint.constant = 32
}
if item.bubblePosition() == .received {
......@@ -273,11 +286,11 @@ class MessageCell: UITableViewCell, NibReusable {
}
// bubble grouping for cell
applyBubbleStyleToCell(items, cellForRowAt: indexPath)
self.applyBubbleStyleToCell(items, cellForRowAt: indexPath)
// special cases where top/bottom margins should be larger
if indexPath.row == 0 {
messageLabelMarginConstraint.constant = 4
self.messageLabelMarginConstraint.constant = 4
self.bubbleTopConstraint.constant = 36
} else if items?.count == indexPath.row + 1 {
self.bubbleBottomConstraint.constant = 16
......@@ -316,12 +329,31 @@ class MessageCell: UITableViewCell, NibReusable {
return
})
.disposed(by: self.disposeBag)
}
}
// swiftlint:enable function_body_length
func displayTransferedImage(message: MessageViewModel) {
let maxDimsion: CGFloat = 250
if let image = message.getTransferedImage(maxSize: maxDimsion ) {
self.transferImageView.image = image
self.transferImageView.contentMode = .center
buttonsHeightConstraint?.priority = UILayoutPriority(rawValue: 250.0)
self.bubble.addSubview(self.transferImageView)
self.bubbleViewMask?.isHidden = false
self.bottomCorner.isHidden = true
self.topCorner.isHidden = true
self.transferImageView.translatesAutoresizingMaskIntoConstraints = false
if message.bubblePosition() == .sent {
self.transferImageView.trailingAnchor.constraint(equalTo: self.bubble.trailingAnchor, constant: 0).isActive = true
} else if message.bubblePosition() == .received {
self.transferImageView.leadingAnchor.constraint(equalTo: self.bubble.leadingAnchor, constant: 0).isActive = true
}
self.transferImageView.topAnchor.constraint(equalTo: self.bubble.topAnchor, constant: 0).isActive = true
self.transferImageView.bottomAnchor.constraint(equalTo: self.bubble.bottomAnchor, constant: 0).isActive = true
}
}
// swiftlint:enable cyclomatic_complexity
}
......@@ -7,6 +7,7 @@
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Unknown constraint types" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
......@@ -20,7 +21,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PUF-dd-SHE" userLabel="Avatar View">
<rect key="frame" x="16" y="67.5" width="32" height="32"/>
<rect key="frame" x="16" y="67" width="32" height="32"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="2Sx-kt-bxB"/>
......@@ -28,7 +29,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Mcd-XM-6nW" userLabel="Top Corner">
<rect key="frame" x="64" y="8" width="17" height="17"/>
<rect key="frame" x="64" y="8.5" width="17" height="17"/>
<color key="backgroundColor" red="1" green="0.0" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="17" id="ByW-4A-Bl3"/>
......@@ -44,7 +45,7 @@
</constraints>
</view>
<view clipsSubviews="YES" contentMode="scaleToFill" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="k7r-gv-wn2" customClass="MessageBubble" customModule="Ring" customModuleProvider="target">
<rect key="frame" x="64" y="8" width="382" height="93.5"/>
<rect key="frame" x="64" y="8.5" width="382" height="93"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="attachment_icon" translatesAutoresizingMaskIntoConstraints="NO" id="Vif-9c-Vza" userLabel="File Icon">
<rect key="frame" x="14" y="7" width="24" height="24"/>
......@@ -103,21 +104,27 @@
</button>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="24" id="On9-4Y-HIE"/>
<constraint firstAttribute="height" priority="999" constant="24" id="On9-4Y-HIE"/>
</constraints>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LoC-UA-VKl">
<rect key="frame" x="0.0" y="0.0" width="382" height="93"/>
</view>
</subviews>
<color key="backgroundColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="dFz-uY-Lik" firstAttribute="top" secondItem="tc3-3o-eIM" secondAttribute="bottom" constant="4" id="6EE-zr-Tk1"/>
<constraint firstAttribute="trailing" secondItem="LoC-UA-VKl" secondAttribute="trailing" id="6eD-bM-gZr"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="34" id="Csz-kZ-sEb"/>
<constraint firstItem="ZGC-d7-MmV" firstAttribute="top" secondItem="GOj-xs-tfd" secondAttribute="bottom" constant="8.5" id="ERj-sO-0Et"/>
<constraint firstItem="LoC-UA-VKl" firstAttribute="top" secondItem="k7r-gv-wn2" secondAttribute="top" id="EcP-ub-ZL3"/>