<commit_before>//
//  SearchResultCell.swift
//  Cutlines
//
//  Created by John on 2/19/17.
//  Copyright © 2017 Bruce32. All rights reserved.
//

import UIKit

class SearchResultCell: UITableViewCell {
	
	// MARK: Properties
	var resultText: String?
	var resultImage: UIImage?
	
	private let resultLabel = UILabel()
	private let resultImageView = UIImageView()
	
	override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
		super.init(style: .default, reuseIdentifier: "SearchResultCell")
		
		setup()
	}
	
	required init?(coder aDecoder: NSCoder) {
		super.init(coder: aDecoder)
		
		setup()
	}
	
	override func layoutSubviews() {
		super.layoutSubviews()
		
		resultLabel.text = resultText
		resultImageView.image = resultImage
		
		resultImageView.clipsToBounds = true
		resultImageView.contentMode = .scaleAspectFill
		resultImageView.translatesAutoresizingMaskIntoConstraints = false
		resultLabel.translatesAutoresizingMaskIntoConstraints = false
		
		var constraints = [NSLayoutConstraint]()
		
		// tie the image to the superviews leadind and top edges
		constraints.append(resultImageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 5))
		constraints.append(resultImageView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 5))
		
		// make the image a square
		constraints.append(resultImageView.widthAnchor.constraint(equalTo: resultImageView.heightAnchor))
		
		// pad the image from the superview's top and bottom edges
		constraints.append(resultImageView.heightAnchor.constraint(lessThanOrEqualTo: contentView.heightAnchor, constant: -10))
		
		// set a lower priority for this equality so the image grows as large as it can
		let heightConstraint = resultImageView.heightAnchor.constraint(equalTo: contentView.heightAnchor)
		heightConstraint.priority = UILayoutPriorityDefaultHigh
		constraints.append(heightConstraint)
		
		// Center the label vertically and give it some padding between the image
		constraints.append(resultLabel.centerYAnchor.constraint(equalTo: resultImageView.centerYAnchor))
		constraints.append(resultLabel.leadingAnchor.constraint(equalTo: resultImageView.trailingAnchor, constant: 10))
		
		NSLayoutConstraint.activate(constraints)
		
		separatorInset = UIEdgeInsets(top: 0, left: contentView.frame.size.height, bottom: 0, right: 0)
	}
	
	// MARK: Private functions
	private func setup() {
		
		// Using the default textLabel & imageView properties of UITableViewCell
		// results in the cell incorrectly re-laying out its subview when the cell is touched
		// so we just ignore those properties and create our own
		contentView.addSubview(resultLabel)
		contentView.addSubview(resultImageView)
	}
}<commit_msg>fix theme on new resultLabel in the search result cell<commit_after>//
//  SearchResultCell.swift
//  Cutlines
//
//  Created by John on 2/19/17.
//  Copyright © 2017 Bruce32. All rights reserved.
//

import UIKit

class SearchResultCell: UITableViewCell {
	
	// MARK: Properties
	var resultText: String?
	var resultImage: UIImage?
	
	private let resultLabel = UILabel()
	private let resultImageView = UIImageView()
	
	override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
		super.init(style: .default, reuseIdentifier: "SearchResultCell")
		
		setup()
	}
	
	required init?(coder aDecoder: NSCoder) {
		super.init(coder: aDecoder)
		
		setup()
	}
	
	override func layoutSubviews() {
		super.layoutSubviews()
		
		resultLabel.text = resultText
		resultImageView.image = resultImage
		
		resultImageView.clipsToBounds = true
		resultImageView.contentMode = .scaleAspectFill
		resultImageView.translatesAutoresizingMaskIntoConstraints = false
		resultLabel.translatesAutoresizingMaskIntoConstraints = false
		
		var constraints = [NSLayoutConstraint]()
		
		// tie the image to the superviews leadind and top edges
		constraints.append(resultImageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 5))
		constraints.append(resultImageView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 5))
		
		// make the image a square
		constraints.append(resultImageView.widthAnchor.constraint(equalTo: resultImageView.heightAnchor))
		
		// pad the image from the superview's top and bottom edges
		constraints.append(resultImageView.heightAnchor.constraint(lessThanOrEqualTo: contentView.heightAnchor, constant: -10))
		
		// set a lower priority for this equality so the image grows as large as it can
		let heightConstraint = resultImageView.heightAnchor.constraint(equalTo: contentView.heightAnchor)
		heightConstraint.priority = UILayoutPriorityDefaultHigh
		constraints.append(heightConstraint)
		
		// Center the label vertically and give it some padding between the image
		constraints.append(resultLabel.centerYAnchor.constraint(equalTo: resultImageView.centerYAnchor))
		constraints.append(resultLabel.leadingAnchor.constraint(equalTo: resultImageView.trailingAnchor, constant: 10))
		
		NSLayoutConstraint.activate(constraints)
		
		separatorInset = UIEdgeInsets(top: 0, left: contentView.frame.size.height, bottom: 0, right: 0)
	}
	
	override func setTheme(_ theme: Theme) {
		super.setTheme(theme)
		
		resultLabel.textColor = theme.textColor
	}
	
	// MARK: Private functions
	private func setup() {
		
		// Using the default textLabel & imageView properties of UITableViewCell
		// results in the cell incorrectly re-laying out its subview when the cell is touched
		// so we just ignore those properties and create our own
		contentView.addSubview(resultLabel)
		contentView.addSubview(resultImageView)
	}
}
{'fraction_non_alphanumeric': 0.08053811659192825, 'fraction_numerical': 0.007174887892376682, 'mean_word_length': 4.778238341968912, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1054606', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1481, 'n_words': 421}