mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 16:54:12 +00:00
More wrapping fixes
This commit is contained in:
2 files changed
+45
-39
No files matched your search
@@ -157,17 +157,17 @@
|
||||
<constraint firstAttribute="width" constant="16" id="uzg-82-FQF"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="PE8-4l-lJ1">
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="PE8-4l-lJ1">
|
||||
<rect key="frame" x="83" y="34.333333333333336" width="299" height="19.666666666666664"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="authorByLine" textAlignment="natural" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WNE-hv-4df">
|
||||
<rect key="frame" x="0.0" y="2.6666666666666652" width="163.66666666666666" height="14.333333333333336"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="authorByLine" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WNE-hv-4df">
|
||||
<rect key="frame" x="0.0" y="2.6666666666666652" width="145.66666666666666" height="14.333333333333336"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="articleDate" textAlignment="right" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pqp-Wg-z4F">
|
||||
<rect key="frame" x="171.66666666666666" y="2.6666666666666652" width="127.33333333333334" height="14.333333333333336"/>
|
||||
<rect key="frame" x="153.66666666666663" y="2.6666666666666652" width="145.33333333333337" height="14.333333333333336"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
@@ -243,17 +243,17 @@
|
||||
<constraint firstAttribute="height" constant="16" id="uiO-JR-Pqq"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="64B-fB-DhA">
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="64B-fB-DhA">
|
||||
<rect key="frame" x="83" y="34.333333333333336" width="299" height="19.666666666666664"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="authorByLine" textAlignment="natural" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wgf-Uh-0Rm">
|
||||
<rect key="frame" x="0.0" y="2.6666666666666652" width="163.66666666666666" height="14.333333333333336"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="authorByLine" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wgf-Uh-0Rm">
|
||||
<rect key="frame" x="0.0" y="2.6666666666666652" width="145.66666666666666" height="14.333333333333336"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="articleDate" textAlignment="right" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VH0-pt-9cP">
|
||||
<rect key="frame" x="171.66666666666666" y="2.6666666666666652" width="127.33333333333334" height="14.333333333333336"/>
|
||||
<rect key="frame" x="153.66666666666663" y="2.6666666666666652" width="145.33333333333337" height="14.333333333333336"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
@@ -321,17 +321,17 @@
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="qD0-Wg-TEh">
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="qD0-Wg-TEh">
|
||||
<rect key="frame" x="39" y="34" width="343" height="20.333333333333329"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="authorByLine" textAlignment="natural" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="71M-o0-zH9">
|
||||
<rect key="frame" x="0.0" y="3.0000000000000009" width="187.66666666666666" height="14.333333333333336"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="authorByLine" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="71M-o0-zH9">
|
||||
<rect key="frame" x="0.0" y="3.0000000000000009" width="171.66666666666666" height="14.333333333333336"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="articleDate" textAlignment="right" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SHF-0g-wAF">
|
||||
<rect key="frame" x="187.66666666666663" y="3.0000000000000009" width="155.33333333333337" height="14.333333333333336"/>
|
||||
<rect key="frame" x="171.66666666666663" y="3.0000000000000009" width="171.33333333333337" height="14.333333333333336"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
@@ -393,17 +393,17 @@
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="qaT-eT-gBl">
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="qaT-eT-gBl">
|
||||
<rect key="frame" x="39" y="34" width="343" height="20.333333333333329"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="authorByLine" textAlignment="natural" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="W9I-Ap-vm6">
|
||||
<rect key="frame" x="0.0" y="3.0000000000000009" width="187.66666666666666" height="14.333333333333336"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="authorByLine" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="W9I-Ap-vm6">
|
||||
<rect key="frame" x="0.0" y="3.0000000000000009" width="171.66666666666666" height="14.333333333333336"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="articleDate" textAlignment="right" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qYY-Tb-I82">
|
||||
<rect key="frame" x="187.66666666666663" y="3.0000000000000009" width="155.33333333333337" height="14.333333333333336"/>
|
||||
<rect key="frame" x="171.66666666666663" y="3.0000000000000009" width="171.33333333333337" height="14.333333333333336"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
|
||||
@@ -17,9 +17,6 @@ class MainTimelineCell: UITableViewCell {
|
||||
@IBOutlet var articleDate: UILabel!
|
||||
@IBOutlet var metaDataStackView: UIStackView!
|
||||
|
||||
private(set) var usedTitleLineCount: Int = 0
|
||||
|
||||
|
||||
var cellData: MainTimelineCellData! {
|
||||
didSet {
|
||||
configure(cellData)
|
||||
@@ -28,12 +25,6 @@ class MainTimelineCell: UITableViewCell {
|
||||
|
||||
var isPreview: Bool = false
|
||||
|
||||
var activeState: Bool {
|
||||
let state = self.configurationState
|
||||
let active = state.isSwiped || state.isSelected
|
||||
return active
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
MainActor.assumeIsolated {
|
||||
super.awakeFromNib()
|
||||
@@ -47,7 +38,6 @@ class MainTimelineCell: UITableViewCell {
|
||||
}
|
||||
|
||||
private func configure(_ cellData: MainTimelineCellData) {
|
||||
updateIndicatorView(cellData)
|
||||
articleContent.numberOfLines = cellData.numberOfLines
|
||||
addArticleContent(configurationState)
|
||||
|
||||
@@ -66,14 +56,14 @@ class MainTimelineCell: UITableViewCell {
|
||||
articleDate.text = cellData.dateString
|
||||
}
|
||||
|
||||
private func updateIndicatorView(_ cellData: MainTimelineCellData) {
|
||||
private func updateIndicatorView(_ state: UICellConfigurationState) {
|
||||
if cellData.read == false {
|
||||
if indicatorView.alpha == 0.0 {
|
||||
indicatorView.alpha = 1.0
|
||||
}
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
self.indicatorView.iconImage = Assets.Images.unreadCellIndicator
|
||||
self.indicatorView.tintColor = self.activeState ? .white : Assets.Colors.secondaryAccent
|
||||
self.indicatorView.tintColor = self.isActive(state) ? .white : Assets.Colors.secondaryAccent
|
||||
}
|
||||
return
|
||||
} else if cellData.starred {
|
||||
@@ -82,7 +72,7 @@ class MainTimelineCell: UITableViewCell {
|
||||
}
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
self.indicatorView.iconImage = Assets.Images.starredFeed
|
||||
self.indicatorView.tintColor = self.activeState ? .white : Assets.Colors.star
|
||||
self.indicatorView.tintColor = self.isActive(state) ? .white : Assets.Colors.star
|
||||
}
|
||||
return
|
||||
} else if indicatorView.alpha == 1.0 {
|
||||
@@ -101,18 +91,25 @@ class MainTimelineCell: UITableViewCell {
|
||||
metaDataStackView.distribution = .fill
|
||||
default:
|
||||
metaDataStackView.axis = .horizontal
|
||||
metaDataStackView.alignment = .center
|
||||
metaDataStackView.distribution = .fill
|
||||
metaDataStackView.alignment = .bottom
|
||||
metaDataStackView.distribution = .fillEqually
|
||||
}
|
||||
}
|
||||
|
||||
private func isActive(_ state: UICellConfigurationState) -> Bool {
|
||||
let active = state.isSwiped || state.isSelected || state.isEditing || state.isHighlighted
|
||||
if cellData.title.contains("Vouchers") {
|
||||
print("Vouchers: \(active)")
|
||||
}
|
||||
return active
|
||||
}
|
||||
|
||||
func setIconImage(_ iconImage: IconImage?) {
|
||||
if feedIcon!.iconImage !== iconImage {
|
||||
feedIcon!.iconImage = iconImage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func addArticleContent(_ state: UICellConfigurationState) {
|
||||
let attributedCellText = NSMutableAttributedString()
|
||||
|
||||
@@ -144,7 +141,7 @@ class MainTimelineCell: UITableViewCell {
|
||||
articleContent.lineBreakMode = .byTruncatingTail
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
attributedCellText.append(titleAttributed)
|
||||
}
|
||||
|
||||
@@ -156,7 +153,7 @@ class MainTimelineCell: UITableViewCell {
|
||||
let paragraphStyle = NSMutableParagraphStyle()
|
||||
paragraphStyle.minimumLineHeight = summaryLineHeight
|
||||
paragraphStyle.maximumLineHeight = summaryLineHeight
|
||||
paragraphStyle.lineBreakMode = .byTruncatingTail
|
||||
paragraphStyle.lineBreakMode = .byWordWrapping
|
||||
paragraphStyle.lineBreakStrategy = []
|
||||
paragraphStyle.hyphenationFactor = 1.0
|
||||
paragraphStyle.allowsDefaultTighteningForTruncation = true
|
||||
@@ -172,11 +169,20 @@ class MainTimelineCell: UITableViewCell {
|
||||
attributedCellText.append(summaryAttributed)
|
||||
}
|
||||
|
||||
let linesUsed = countLines(of: attributedCellText, width: articleContent.bounds.width)
|
||||
if linesUsed >= cellData.numberOfLines {
|
||||
// The title already fills 3 lines, set it and exit
|
||||
articleContent.attributedText = attributedCellText
|
||||
articleContent.lineBreakMode = .byTruncatingTail
|
||||
return
|
||||
}
|
||||
|
||||
articleContent.attributedText = attributedCellText
|
||||
|
||||
}
|
||||
|
||||
func titleTextColor(for state: UICellConfigurationState) -> UIColor {
|
||||
if activeState {
|
||||
if isActive(state) {
|
||||
return .white
|
||||
} else {
|
||||
return .label
|
||||
@@ -210,13 +216,13 @@ class MainTimelineCell: UITableViewCell {
|
||||
super.updateConfiguration(using: state)
|
||||
|
||||
var backgroundConfig = UIBackgroundConfiguration.listCell().updated(for: state)
|
||||
backgroundConfig.cornerRadius = 20
|
||||
backgroundConfig.cornerRadius = traitCollection.userInterfaceIdiom == .pad ? 20 : 0
|
||||
if traitCollection.userInterfaceIdiom == .pad {
|
||||
backgroundConfig.edgesAddingLayoutMarginsToBackgroundInsets = [.leading, .trailing]
|
||||
backgroundConfig.backgroundInsets = NSDirectionalEdgeInsets(top: 0, leading: !isPreview ? -4 : -12, bottom: 0, trailing: !isPreview ? -4 : -12)
|
||||
}
|
||||
|
||||
if self.activeState {
|
||||
|
||||
if isActive(state) {
|
||||
backgroundConfig.backgroundColor = Assets.Colors.primaryAccent
|
||||
articleContent.textColor = titleTextColor(for: state)
|
||||
articleDate.textColor = .lightText
|
||||
@@ -227,7 +233,7 @@ class MainTimelineCell: UITableViewCell {
|
||||
articleByLine.textColor = .secondaryLabel
|
||||
}
|
||||
|
||||
updateIndicatorView(cellData)
|
||||
updateIndicatorView(state)
|
||||
|
||||
self.backgroundConfiguration = backgroundConfig
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user