<commit_before>//
//  NotificationTableViewCell.swift
//  Tempo
//
//  Created by <NAME> on 2/21/17.
//  Copyright © 2017 CUAppDev. All rights reserved.
//

import UIKit

protocol NotificationCellDelegate {
	func didTapUserImageForNotification(_ user: User)
}

class NotificationTableViewCell: UITableViewCell {
	
	var notification: TempoNotification!
	var user: User!
	var delegate: NotificationCellDelegate?
	
	var avatarImage = UIImageView()
	var usernameLabel = UILabel()
	var messageLabel = UILabel()
	var descriptionLabel = UILabel()
	var timeLabel = UILabel()
	var seenView = UIView()
//	var acceptButton = UIButton()
	var customSeparator = UIView()
	var seen = false
	
	override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
		super.init(style: style, reuseIdentifier: reuseIdentifier)
		
		let width = UIScreen.main.bounds.width
		
		avatarImage.frame = CGRect(x: 16, y: 10, width: notificationCellHeight - 20, height: notificationCellHeight - 20)
		avatarImage.layer.cornerRadius = avatarImage.bounds.size.width / 2
		avatarImage.clipsToBounds = true
		contentView.addSubview(avatarImage)
		let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapAvatarImage(_:)))
		avatarImage.isUserInteractionEnabled = true
		avatarImage.addGestureRecognizer(tapGestureRecognizer)
		
		timeLabel.frame = CGRect(x: width - 40, y: 10, width: 20, height: notificationCellHeight - 20)
		timeLabel.backgroundColor = .clear
		timeLabel.textColor = .cellOffWhite
		timeLabel.font = UIFont(name: "AvenirNext-Regular", size: 13)
		contentView.addSubview(timeLabel)
		
		let x = avatarImage.frame.maxX + 16
		usernameLabel.frame = CGRect(x: x, y: 8, width: 50, height: notificationCellHeight/2 - 8)
		usernameLabel.backgroundColor = .clear
		usernameLabel.textColor = .white
		usernameLabel.font = UIFont(name: "AvenirNext-Medium", size: 15)
		contentView.addSubview(usernameLabel)
		
		messageLabel.frame = CGRect(x: x, y: 8, width: width - (x+50), height: notificationCellHeight/2 - 8)
		messageLabel.backgroundColor = .clear
		messageLabel.textColor = .cellOffWhite
		messageLabel.font = UIFont(name: "AvenirNext-Regular", size: 15)
		contentView.addSubview(messageLabel)
		
		descriptionLabel.frame = CGRect(x: x, y: notificationCellHeight/2, width: width - (x+50), height: notificationCellHeight/2 - 8)
		descriptionLabel.backgroundColor = .clear
		descriptionLabel.textColor = .cellOffWhite
		descriptionLabel.font = UIFont(name: "AvenirNext-Regular", size: 13)
		contentView.addSubview(descriptionLabel)
		
//		acceptButton.frame = CGRect(x: UIScreen.main.bounds.width - 100, y: 15, width: 80, height: notificationCellHeight - 30)
//		acceptButton.backgroundColor = UIColor.tempoRed
//		acceptButton.layer.cornerRadius = 4
//		acceptButton.setAttributedTitle(NSAttributedString(string: "Accept", attributes: [NSForegroundColorAttributeName: UIColor.white]), for: .normal)
//		acceptButton.titleLabel?.font = UIFont(name: "AvenirNext-Medium", size: 14)
//		acceptButton.isHidden = true
//		contentView.addSubview(acceptButton)
		
		seenView.frame = CGRect(x: width - 18, y: notificationCellHeight/2 - 5, width: 10, height: 10)
		seenView.layer.cornerRadius = 5
		seenView.backgroundColor = .clear
		contentView.addSubview(seenView)
		
		customSeparator.frame = CGRect(x: 0, y: notificationCellHeight-1, width: UIScreen.main.bounds.width, height: 1)
		customSeparator.backgroundColor = .readCellColor
		contentView.addSubview(customSeparator)
	}
	
	required init?(coder aDecoder: NSCoder) {
		fatalError("init(coder:) has not been implemented")
	}

	func setupCell(notification: TempoNotification) {
		contentView.backgroundColor = .unreadCellColor
		selectionStyle = .none
		
		self.notification = notification
		self.user = notification.user
		self.seen = notification.seen!
		
		avatarImage.hnk_setImageFromURL(user.imageURL)
		
		// Adjust label widths to match text content
		usernameLabel.text = "@\(user.username)"
		let oldFrame = usernameLabel.frame
		usernameLabel.sizeToFit()<commit_msg>Small UI edits in notif cell<commit_after>//
//  NotificationTableViewCell.swift
//  Tempo
//
//  Created by <NAME> on 2/21/17.
//  Copyright © 2017 CUAppDev. All rights reserved.
//

import UIKit

protocol NotificationCellDelegate {
	func didTapUserImageForNotification(_ user: User)
}

class NotificationTableViewCell: UITableViewCell {
	
	var notification: TempoNotification!
	var user: User!
	var delegate: NotificationCellDelegate?
	
	var avatarImage = UIImageView()
	var usernameLabel = UILabel()
	var messageLabel = UILabel()
	var descriptionLabel = UILabel()
	var timeLabel = UILabel()
	var seenView = UIView()
//	var acceptButton = UIButton()
	var customSeparator = UIView()
	var seen = false
	
	override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
		super.init(style: style, reuseIdentifier: reuseIdentifier)
		
		let width = UIScreen.main.bounds.width
		
		avatarImage.frame = CGRect(x: 16, y: 10, width: notificationCellHeight - 20, height: notificationCellHeight - 20)
		avatarImage.layer.cornerRadius = avatarImage.bounds.size.width / 2
		avatarImage.clipsToBounds = true
		contentView.addSubview(avatarImage)
		let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapAvatarImage(_:)))
		avatarImage.isUserInteractionEnabled = true
		avatarImage.addGestureRecognizer(tapGestureRecognizer)
		
		timeLabel.frame = CGRect(x: width - 50, y: 10, width: 30, height: notificationCellHeight - 20)
		timeLabel.backgroundColor = .clear
		timeLabel.textColor = .cellOffWhite
		timeLabel.font = UIFont(name: "AvenirNext-Regular", size: 13)
		timeLabel.textAlignment = .right
		contentView.addSubview(timeLabel)
		
		let x = avatarImage.frame.maxX + 16
		usernameLabel.frame = CGRect(x: x, y: 8, width: 50, height: notificationCellHeight/2 - 8)
		usernameLabel.backgroundColor = .clear
		usernameLabel.textColor = .white
		usernameLabel.font = UIFont(name: "AvenirNext-Medium", size: 14)
		contentView.addSubview(usernameLabel)
		
		messageLabel.frame = CGRect(x: x, y: 8, width: width - (x+50), height: notificationCellHeight/2 - 8)
		messageLabel.backgroundColor = .clear
		messageLabel.textColor = .cellOffWhite
		messageLabel.font = UIFont(name: "AvenirNext-Regular", size: 14)
		contentView.addSubview(messageLabel)
		
		descriptionLabel.frame = CGRect(x: x, y: notificationCellHeight/2, width: width - (x+50), height: notificationCellHeight/2 - 8)
		descriptionLabel.backgroundColor = .clear
		descriptionLabel.textColor = .cellOffWhite
		descriptionLabel.font = UIFont(name: "AvenirNext-Regular", size: 13)
		contentView.addSubview(descriptionLabel)
		
//		acceptButton.frame = CGRect(x: UIScreen.main.bounds.width - 100, y: 15, width: 80, height: notificationCellHeight - 30)
//		acceptButton.backgroundColor = UIColor.tempoRed
//		acceptButton.layer.cornerRadius = 4
//		acceptButton.setAttributedTitle(NSAttributedString(string: "Accept", attributes: [NSForegroundColorAttributeName: UIColor.white]), for: .normal)
//		acceptButton.titleLabel?.font = UIFont(name: "AvenirNext-Medium", size: 14)
//		acceptButton.isHidden = true
//		contentView.addSubview(acceptButton)
		
		seenView.frame = CGRect(x: width - 15, y: notificationCellHeight/2 - 5, width: 10, height: 10)
		seenView.layer.cornerRadius = 5
		seenView.backgroundColor = .clear
		contentView.addSubview(seenView)
		
		customSeparator.frame = CGRect(x: 0, y: notificationCellHeight-1, width: UIScreen.main.bounds.width, height: 1)
		customSeparator.backgroundColor = .readCellColor
		contentView.addSubview(customSeparator)
	}
	
	required init?(coder aDecoder: NSCoder) {
		fatalError("init(coder:) has not been implemented")
	}

	func setupCell(notification: TempoNotification) {
		contentView.backgroundColor = .unreadCellColor
		selectionStyle = .none
		
		self.notification = notification
		self.user = notification.user
		self.seen = notification.seen!
		
		avatarImage.hnk_setImageFromURL(user.imageURL)
		
		// Adjust label widths to match text content
		usernameLabel.text = "@\(user.username)"
		let oldFrame = usernameLabel.frame
		usernameLabel.sizeToFit()
{'fraction_non_alphanumeric': 0.10669456066945607, 'fraction_numerical': 0.018459266551809007, 'mean_word_length': 4.84255930984903, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5384771', 'n_tokens_mistral': 2921, 'n_tokens_neox': 2511, 'n_words': 568}