<commit_before>import UIKit

@objc(WMFArticleRightAlignedImageCollectionViewCell)
open class ArticleRightAlignedImageCollectionViewCell: ArticleCollectionViewCell {
    
    override open func setup() {
        imageView.cornerRadius = 3
        super.setup()
    }
    
    open override func reset() {
        super.reset()
        titleFontFamily = .system
        titleTextStyle = .body
        updateFonts(with: traitCollection)
    }
    
    override open func sizeThatFits(_ size: CGSize, apply: Bool) -> CGSize {
        let isRTL = articleSemanticContentAttribute == .forceRightToLeft
        var widthMinusMargins = size.width - margins.left - margins.right
        let heightMinusMargins = size.height - margins.top - margins.bottom

        if !isImageViewHidden {
            if (apply) {
                let imageViewY = margins.top + round(0.5*heightMinusMargins - 0.5*imageViewDimension)
                var x = margins.right
                if !isRTL {
                    x = size.width - x - imageViewDimension
                }
                imageView.frame = CGRect(x: x, y: imageViewY, width: imageViewDimension, height: imageViewDimension)
            }
            widthMinusMargins = widthMinusMargins - margins.right - imageViewDimension
        }
        
        var x = margins.left
        if isRTL {
            x = size.width - x - widthMinusMargins
        }
        var origin = CGPoint(x: x, y: margins.top)
        
        let titleLabelFrame = titleLabel.wmf_preferredFrame(at: origin, fitting: widthMinusMargins, alignedBy: articleSemanticContentAttribute, apply: apply)
        origin.y += titleLabelFrame.layoutHeight(with: spacing)
        
        let descriptionLabelFrame = descriptionLabel.wmf_preferredFrame(at: origin, fitting: widthMinusMargins, alignedBy: articleSemanticContentAttribute, apply: apply)
        origin.y += descriptionLabelFrame.layoutHeight(with: spacing)

        if !isSaveButtonHidden {
            origin.y += saveButtonTopSpacing
            let saveButtonFrame = saveButton.wmf_preferredFrame(at: origin, fitting: widthMinusMargins, alignedBy: articleSemanticContentAttribute, apply: apply)
            origin.y += saveButtonFrame.height
        }
        origin.y += margins.bottom
        let height = isImageViewHidden ? origin.y : max(origin.y, imageViewDimension + margins.top + margins.bottom)
        return CGSize(width: size.width, height: height)
    }
}
<commit_msg>add separator to right aligned image cell<commit_after>import UIKit

@objc(WMFArticleRightAlignedImageCollectionViewCell)
open class ArticleRightAlignedImageCollectionViewCell: ArticleCollectionViewCell {
    let separator = UIView()
    
    override open func setup() {
        imageView.cornerRadius = 3
        separator.isOpaque = true
        addSubview(separator)
        super.setup()
    }
    
    open override func reset() {
        super.reset()
        separator.isHidden = true
        titleFontFamily = .system
        titleTextStyle = .body
        updateFonts(with: traitCollection)
    }
    
    override open func sizeThatFits(_ size: CGSize, apply: Bool) -> CGSize {
        let isRTL = articleSemanticContentAttribute == .forceRightToLeft
        var widthMinusMargins = size.width - margins.left - margins.right
        let heightMinusMargins = size.height - margins.top - margins.bottom

        if !isImageViewHidden {
            if (apply) {
                let imageViewY = margins.top + round(0.5*heightMinusMargins - 0.5*imageViewDimension)
                var x = margins.right
                if !isRTL {
                    x = size.width - x - imageViewDimension
                }
                imageView.frame = CGRect(x: x, y: imageViewY, width: imageViewDimension, height: imageViewDimension)
            }
            widthMinusMargins = widthMinusMargins - margins.right - imageViewDimension
        }
        
        var x = margins.left
        if isRTL {
            x = size.width - x - widthMinusMargins
        }
        var origin = CGPoint(x: x, y: margins.top)
        
        let titleLabelFrame = titleLabel.wmf_preferredFrame(at: origin, fitting: widthMinusMargins, alignedBy: articleSemanticContentAttribute, apply: apply)
        origin.y += titleLabelFrame.layoutHeight(with: spacing)
        
        let descriptionLabelFrame = descriptionLabel.wmf_preferredFrame(at: origin, fitting: widthMinusMargins, alignedBy: articleSemanticContentAttribute, apply: apply)
        origin.y += descriptionLabelFrame.layoutHeight(with: spacing)

        if !isSaveButtonHidden {
            origin.y += saveButtonTopSpacing
            let saveButtonFrame = saveButton.wmf_preferredFrame(at: origin, fitting: widthMinusMargins, alignedBy: articleSemanticContentAttribute, apply: apply)
            origin.y += saveButtonFrame.height
        }
        origin.y += margins.bottom
        
        if (apply) {
            separator.frame = CGRect(x: 0, y: origin.y - 0.5, width: size.width, height: 0.5)
        }
        
        let height = isImageViewHidden ? origin.y : max(origin.y, imageViewDimension + margins.top + margins.bottom)
        return CGSize(width: size.width, height: height)
    }
}

{'fraction_non_alphanumeric': 0.07936202920830131, 'fraction_numerical': 0.0028823981552651805, 'mean_word_length': 2.406413612565445, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2652069', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1407, 'n_words': 328}