pEpForiOS/UI/EmailDisplay/MessageContentCell.swift
author Dirk Zimmermann <dirk@pep-project.org>
Thu, 01 Feb 2018 11:29:01 +0100
changeset 3866 b5901734830a
parent 2891 dac02e368793
child 4194 c9f7aea506a1
permissions -rw-r--r--
IOS-915 logging to pinpoint the problem
yves@1362
     1
//
yves@1362
     2
//  MessageContentCell.swift
yves@1362
     3
//
yves@1362
     4
//  Created by Yves Landert on 20.12.16.
yves@1362
     5
//  Copyright © 2016 appculture AG. All rights reserved.
yves@1362
     6
//
yves@1362
     7
yves@1362
     8
import Foundation
yves@1362
     9
import UIKit
yves@1362
    10
import WebKit
yves@1362
    11
import MessageModel
yves@1362
    12
dirk@1956
    13
open class MessageContentCell: MessageCell {
dirk@1987
    14
    @IBOutlet weak var contentLabel: UILabel!
dirk@1956
    15
dirk@1956
    16
    public override func updateCell(model: ComposeFieldModel, message: Message,
dirk@1956
    17
                                    indexPath: IndexPath) {
dirk@1956
    18
        super.updateCell(model: model, message: message, indexPath: indexPath)
xavier@2831
    19
xavier@2890
    20
        let finalText = NSMutableAttributedString()
xavier@2831
    21
        if message.underAttack {
xavier@2831
    22
            let status = String.pEpRatingTranslation(pEpRating: PEP_rating_under_attack)
xavier@2890
    23
            finalText.bold("\n" + status.title + "\n\n" + status.explanation + "\n\n" + status.suggestion
xavier@2891
    24
                + "\n\n" + NSLocalizedString("Attachments are disabled.", comment: "Disabled attachments") + "\n\n")
xavier@2890
    25
            //if there will be attachmetns show warning
xavier@2831
    26
        }
xavier@2831
    27
xavier@2831
    28
        if let longmessage = message.longMessage?.trimmedWhiteSpace() {
xavier@2890
    29
            finalText.normal(longmessage)
dirk@2866
    30
        } else {
dirk@2866
    31
            if let text = message.longMessageFormatted?.attributedStringHtmlToMarkdown() {
xavier@2890
    32
                finalText.normal(text)
dirk@2866
    33
            }
xavier@2831
    34
        }
xavier@2890
    35
        contentLabel.attributedText = finalText
dirk@1956
    36
    }
yves@1362
    37
}