Skip to content

Commit 78710ed

Browse files
committed
Add a selection background to info list cells and tweak vertical spacing
1 parent 2fca1a1 commit 78710ed

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Authenticator/Source/InfoListViewController.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ class InfoListCell: UITableViewCell {
103103
private static let titleFont = UIFont.systemFont(ofSize: 18, weight: UIFontWeightMedium)
104104
private static let descriptionFont = UIFont.systemFont(ofSize: 15, weight: UIFontWeightLight)
105105
private static let callToActionFont = UIFont.systemFont(ofSize: 15, weight: UIFontWeightSemibold)
106+
private static let paragraphStyle: NSParagraphStyle = {
107+
let paragraphStyle = NSMutableParagraphStyle()
108+
paragraphStyle.lineHeightMultiple = 1.3
109+
return paragraphStyle
110+
}()
106111

107112
let titleLabel = UILabel()
108113
let descriptionLabel = UILabel()
@@ -122,7 +127,6 @@ class InfoListCell: UITableViewCell {
122127

123128
private func configureCell() {
124129
backgroundColor = .otpBackgroundColor
125-
selectionStyle = .none
126130

127131
titleLabel.textColor = .otpForegroundColor
128132
titleLabel.font = InfoListCell.titleFont
@@ -135,6 +139,9 @@ class InfoListCell: UITableViewCell {
135139
descriptionLabel.translatesAutoresizingMaskIntoConstraints = false
136140
contentView.addSubview(descriptionLabel)
137141

142+
selectedBackgroundView = UIView()
143+
selectedBackgroundView?.backgroundColor = UIColor(white: 0, alpha: 0.25)
144+
138145
setNeedsUpdateConstraints()
139146
}
140147

@@ -160,15 +167,11 @@ class InfoListCell: UITableViewCell {
160167
// MARK: Update
161168

162169
func updateWithRowModel(_ rowModel: InfoList.RowModel) {
163-
let paragraphStyle = NSMutableParagraphStyle()
164-
paragraphStyle.lineHeightMultiple = 1.3
165-
166-
let attributedTitle = NSAttributedString(string: rowModel.title,
167-
attributes: [NSParagraphStyleAttributeName: paragraphStyle])
168-
titleLabel.attributedText = attributedTitle
170+
titleLabel.text = rowModel.title
169171

172+
let attributes = [NSParagraphStyleAttributeName: InfoListCell.paragraphStyle]
170173
let attributedDetails = NSMutableAttributedString(string: rowModel.description + " " + rowModel.callToAction,
171-
attributes:[NSParagraphStyleAttributeName: paragraphStyle])
174+
attributes: attributes)
172175
attributedDetails.addAttribute(NSFontAttributeName, value: InfoListCell.callToActionFont,
173176
range: (attributedDetails.string as NSString).range(of: rowModel.callToAction))
174177
descriptionLabel.attributedText = attributedDetails

0 commit comments

Comments
 (0)