From 63fbe777f33a94e04e40abb9f31d307728d45289 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Tue, 13 Jan 2026 20:44:47 +0800 Subject: [PATCH 1/3] Fix 4950: Determine accurate truncation needs --- .../Cells/MainTimelineFeedCell.swift | 74 +++++++++++++++---- .../Cells/MainTimelineIconFeedCell.swift | 74 ++++++++++++++----- 2 files changed, 115 insertions(+), 33 deletions(-) diff --git a/iOS/MainTimeline/Cells/MainTimelineFeedCell.swift b/iOS/MainTimeline/Cells/MainTimelineFeedCell.swift index 1151fc521..d8f8fb601 100644 --- a/iOS/MainTimeline/Cells/MainTimelineFeedCell.swift +++ b/iOS/MainTimeline/Cells/MainTimelineFeedCell.swift @@ -15,6 +15,8 @@ class MainTimelineFeedCell: UITableViewCell { @IBOutlet var articleDate: UILabel! @IBOutlet var metaDataStackView: UIStackView! + private(set) var usedTitleLineCount: Int = 0 + var cellData: MainTimelineCellData! { didSet { configure(cellData) @@ -95,30 +97,69 @@ class MainTimelineFeedCell: UITableViewCell { let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.minimumLineHeight = UIFont.preferredFont(forTextStyle: .headline).pointSize paragraphStyle.maximumLineHeight = UIFont.preferredFont(forTextStyle: .headline).pointSize - paragraphStyle.lineBreakMode = .byTruncatingTail let titleAttributes: [NSAttributedString.Key: Any] = [ .font: UIFont.preferredFont(forTextStyle: .headline), .paragraphStyle: paragraphStyle, .foregroundColor: isSelected ? UIColor.white : UIColor.label ] - let titleWithNewline = cellData.title + (cellData.summary != "" ? "\n" : "" ) - let titleAttributed = NSAttributedString(string: titleWithNewline, attributes: titleAttributes) + let titleAttributed = NSAttributedString(string: cellData.title, attributes: titleAttributes) attributedCellText.append(titleAttributed) } - if cellData.summary != "" { - let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.minimumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize - paragraphStyle.maximumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize - paragraphStyle.lineBreakMode = .byTruncatingTail - let summaryAttributes: [NSAttributedString.Key: Any] = [ - .font: UIFont.preferredFont(forTextStyle: .body), - .paragraphStyle: paragraphStyle, - .foregroundColor: isSelected ? UIColor.white : UIColor.label - ] - let summaryAttributed = NSAttributedString(string: cellData.summary, attributes: summaryAttributes) - attributedCellText.append(summaryAttributed) - } + articleTitle.attributedText = attributedCellText + + if linesUsedForTitleGreaterThanOrEqualToPreference() { + // No need to add cell summary as we're already at maximum. + articleTitle.lineBreakMode = .byTruncatingTail + return + } else { + if cellData.summary != "" { + let paragraphStyle = NSMutableParagraphStyle() + paragraphStyle.minimumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize + paragraphStyle.maximumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize + let summaryAttributes: [NSAttributedString.Key: Any] = [ + .font: UIFont.preferredFont(forTextStyle: .body), + .paragraphStyle: paragraphStyle, + .foregroundColor: isSelected ? UIColor.white : UIColor.label + ] + let summaryAttributed = NSAttributedString(string: "\n" + cellData.summary, attributes: summaryAttributes) + attributedCellText.append(summaryAttributed) + } + articleTitle.attributedText = attributedCellText + if linesUsedForTitleGreaterThanOrEqualToPreference() { + articleTitle.lineBreakMode = .byTruncatingTail + } + } + } + + func linesUsedForTitleGreaterThanOrEqualToPreference() -> Bool { + contentView.layoutIfNeeded() + + let attributed = articleTitle.attributedText ?? NSAttributedString() + let textStorage = NSTextStorage(attributedString: attributed) + let containerSize = CGSize(width: articleTitle.bounds.width, height: .greatestFiniteMagnitude) + let textContainer = NSTextContainer(size: containerSize) + textContainer.lineFragmentPadding = 0 + textContainer.maximumNumberOfLines = articleTitle.numberOfLines // 0 means unlimited + textContainer.lineBreakMode = articleTitle.lineBreakMode + + let layoutManager = NSLayoutManager() + layoutManager.addTextContainer(textContainer) + textStorage.addLayoutManager(layoutManager) + + _ = layoutManager.glyphRange(for: textContainer) + + var lineCount = 0 + var glyphIndex = 0 + let glyphs = layoutManager.numberOfGlyphs + while glyphIndex < glyphs { + var lineRange = NSRange() + _ = layoutManager.lineFragmentRect(forGlyphAt: glyphIndex, effectiveRange: &lineRange) + glyphIndex = NSMaxRange(lineRange) + lineCount += 1 + } + usedTitleLineCount = lineCount + return usedTitleLineCount >= AppDefaults.shared.timelineNumberOfLines } override func updateConfiguration(using state: UICellConfigurationState) { @@ -145,3 +186,4 @@ class MainTimelineFeedCell: UITableViewCell { self.backgroundConfiguration = backgroundConfig } } + diff --git a/iOS/MainTimeline/Cells/MainTimelineIconFeedCell.swift b/iOS/MainTimeline/Cells/MainTimelineIconFeedCell.swift index ff2d45bce..73a3726b2 100644 --- a/iOS/MainTimeline/Cells/MainTimelineIconFeedCell.swift +++ b/iOS/MainTimeline/Cells/MainTimelineIconFeedCell.swift @@ -15,6 +15,8 @@ class MainTimelineIconFeedCell: UITableViewCell { @IBOutlet var indicatorView: IconView! @IBOutlet var articleDate: UILabel! @IBOutlet var metaDataStackView: UIStackView! + + private(set) var usedTitleLineCount: Int = 0 var cellData: MainTimelineCellData! { didSet { @@ -115,36 +117,74 @@ class MainTimelineIconFeedCell: UITableViewCell { private func applyTitleTextWithAttributes(_ state: UICellConfigurationState) { let attributedCellText = NSMutableAttributedString() - let isSelected = state.isSelected || state.isHighlighted || state.isFocused || state.isSwiped if cellData.title != "" { let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.minimumLineHeight = UIFont.preferredFont(forTextStyle: .headline).pointSize paragraphStyle.maximumLineHeight = UIFont.preferredFont(forTextStyle: .headline).pointSize - paragraphStyle.lineBreakMode = .byTruncatingTail let titleAttributes: [NSAttributedString.Key: Any] = [ .font: UIFont.preferredFont(forTextStyle: .headline), .paragraphStyle: paragraphStyle, .foregroundColor: isSelected ? UIColor.white : UIColor.label ] - let titleWithNewline = cellData.title + (cellData.summary != "" ? "\n" : "" ) - let titleAttributed = NSAttributedString(string: titleWithNewline, attributes: titleAttributes) + let titleAttributed = NSAttributedString(string: cellData.title, attributes: titleAttributes) attributedCellText.append(titleAttributed) } - if cellData.summary != "" { - let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.minimumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize - paragraphStyle.maximumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize - paragraphStyle.lineBreakMode = .byTruncatingTail - let summaryAttributes: [NSAttributedString.Key: Any] = [ - .font: UIFont.preferredFont(forTextStyle: .body), - .paragraphStyle: paragraphStyle, - .foregroundColor: isSelected ? UIColor.white : UIColor.label - ] - let summaryAttributed = NSAttributedString(string: cellData.summary, attributes: summaryAttributes) - attributedCellText.append(summaryAttributed) - } + articleTitle.attributedText = attributedCellText + + if linesUsedForTitleGreaterThanOrEqualToPreference() { + // No need to add cell summary as we're already at maximum. + articleTitle.lineBreakMode = .byTruncatingTail + return + } else { + if cellData.summary != "" { + let paragraphStyle = NSMutableParagraphStyle() + paragraphStyle.minimumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize + paragraphStyle.maximumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize + let summaryAttributes: [NSAttributedString.Key: Any] = [ + .font: UIFont.preferredFont(forTextStyle: .body), + .paragraphStyle: paragraphStyle, + .foregroundColor: isSelected ? UIColor.white : UIColor.label + ] + let summaryAttributed = NSAttributedString(string: "\n" + cellData.summary, attributes: summaryAttributes) + attributedCellText.append(summaryAttributed) + } + articleTitle.attributedText = attributedCellText + if linesUsedForTitleGreaterThanOrEqualToPreference() { + articleTitle.lineBreakMode = .byTruncatingTail + } + } + } + + func linesUsedForTitleGreaterThanOrEqualToPreference() -> Bool { + contentView.layoutIfNeeded() + + let attributed = articleTitle.attributedText ?? NSAttributedString() + let textStorage = NSTextStorage(attributedString: attributed) + let containerSize = CGSize(width: articleTitle.bounds.width, height: .greatestFiniteMagnitude) + let textContainer = NSTextContainer(size: containerSize) + textContainer.lineFragmentPadding = 0 + textContainer.maximumNumberOfLines = articleTitle.numberOfLines // 0 means unlimited + textContainer.lineBreakMode = articleTitle.lineBreakMode + + let layoutManager = NSLayoutManager() + layoutManager.addTextContainer(textContainer) + textStorage.addLayoutManager(layoutManager) + + _ = layoutManager.glyphRange(for: textContainer) + + var lineCount = 0 + var glyphIndex = 0 + let glyphs = layoutManager.numberOfGlyphs + while glyphIndex < glyphs { + var lineRange = NSRange() + _ = layoutManager.lineFragmentRect(forGlyphAt: glyphIndex, effectiveRange: &lineRange) + glyphIndex = NSMaxRange(lineRange) + lineCount += 1 + } + usedTitleLineCount = lineCount + return usedTitleLineCount >= AppDefaults.shared.timelineNumberOfLines } override func updateConfiguration(using state: UICellConfigurationState) { From ab26a96cafa58ebc37fdef3b8bf3312fafe2c4e6 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Tue, 13 Jan 2026 21:03:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=92=84=20Make=20timeline=20nav=20subt?= =?UTF-8?q?itle=20same=20font=20as=20feeds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iOS/MainTimeline/MainTimelineViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/MainTimeline/MainTimelineViewController.swift b/iOS/MainTimeline/MainTimelineViewController.swift index fb244501a..6e61db2b6 100644 --- a/iOS/MainTimeline/MainTimelineViewController.swift +++ b/iOS/MainTimeline/MainTimelineViewController.swift @@ -121,7 +121,7 @@ final class MainTimelineViewController: UITableViewController, UndoableCommandRu private var navigationBarSubtitleTitleLabel: UILabel { let label = UILabel() - label.font = UIFont.preferredFont(forTextStyle: .footnote) + label.font = UIFont(name: "Helvetica", size: 12) label.textColor = .systemGray label.textAlignment = .center label.isUserInteractionEnabled = true From 140f5d7a2bf300ff82bf3188f47e0025e579e303 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Tue, 13 Jan 2026 22:22:27 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=9A=91=EF=B8=8F=20Fixes=20widget=20cr?= =?UTF-8?q?ash=20and=20alignment=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Shared/Widget/WidgetData.swift | 7 ++++--- Shared/Widget/WidgetDataDecoder.swift | 4 ++-- Shared/Widget/WidgetDataEncoder.swift | 13 ++++++++---- Widget/TimelineProvider.swift | 2 +- .../LockScreenSummaryWidget.swift | 11 ++++++---- Widget/Widget Views/StarredWidget.swift | 20 +++++++------------ Widget/Widget Views/TodayWidget.swift | 20 +++++++------------ Widget/Widget Views/UnreadWidget.swift | 20 +++++++------------ Widget/WidgetBundle.swift | 12 +++++++---- 9 files changed, 52 insertions(+), 57 deletions(-) diff --git a/Shared/Widget/WidgetData.swift b/Shared/Widget/WidgetData.swift index c12a19df9..d2e8ac0e3 100644 --- a/Shared/Widget/WidgetData.swift +++ b/Shared/Widget/WidgetData.swift @@ -9,9 +9,10 @@ import Foundation struct WidgetData: Codable { - let currentUnreadCount: Int - let currentTodayCount: Int - let currentStarredCount: Int + let totalUnreadCount: Int + let totalTodayCount: Int + let totalTodayUnreadCount: Int + let totalStarredCount: Int let unreadArticles: [LatestArticle] let starredArticles: [LatestArticle] let todayArticles: [LatestArticle] diff --git a/Shared/Widget/WidgetDataDecoder.swift b/Shared/Widget/WidgetDataDecoder.swift index a7f57064e..249d1123b 100644 --- a/Shared/Widget/WidgetDataDecoder.swift +++ b/Shared/Widget/WidgetDataDecoder.swift @@ -18,7 +18,7 @@ struct WidgetDataDecoder { let decodedWidgetData = try JSONDecoder().decode(WidgetData.self, from: Data(contentsOf: dataURL!)) return decodedWidgetData } else { - return WidgetData(currentUnreadCount: 0, currentTodayCount: 0, currentStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date()) + return WidgetData(totalUnreadCount: 0, totalTodayCount: 0, totalTodayUnreadCount: 0, totalStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date()) } } @@ -29,7 +29,7 @@ struct WidgetDataDecoder { let decoded = try JSONDecoder().decode(WidgetData.self, from: data) return decoded } catch { - return WidgetData(currentUnreadCount: 0, currentTodayCount: 0, currentStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date()) + return WidgetData(totalUnreadCount: 0, totalTodayCount: 0, totalTodayUnreadCount: 0, totalStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date()) } } diff --git a/Shared/Widget/WidgetDataEncoder.swift b/Shared/Widget/WidgetDataEncoder.swift index ca320e7f8..c13021dc1 100644 --- a/Shared/Widget/WidgetDataEncoder.swift +++ b/Shared/Widget/WidgetDataEncoder.swift @@ -95,7 +95,7 @@ import Account Self.logger.debug("WidgetDataEncoder: Reloading Unread widget") } - if existingData.todayArticles != newData.todayArticles { + if existingData.todayArticles != newData.todayArticles || existingData.totalTodayUnreadCount != newData.totalTodayUnreadCount { WidgetCenter.shared.reloadTimelines(ofKind: "com.ranchero.NetNewsWire.TodayWidget") shouldRefreshSummary = true Self.logger.debug("WidgetDataEncoder: Reloading Today widget") @@ -126,15 +126,20 @@ import Account let starredArticles = sortedLatestArticles(fetchedStarredArticles) let fetchedTodayArticles = try AccountManager.shared.fetchArticles(.today(fetchLimit)) + let fetchedTodayTotal = try AccountManager.shared.fetchArticles(.today()) + let fetchedTodayTotalCount = fetchedTodayTotal.count + let fetchedTodayUnreadCount = fetchedTodayTotal.filter({ $0.status.read == false }).count let todayArticles = sortedLatestArticles(fetchedTodayArticles) - let latestData = WidgetData(currentUnreadCount: SmartFeedsController.shared.unreadFeed.unreadCount, - currentTodayCount: todayArticles.count, - currentStarredCount: (try? AccountManager.shared.fetchCountForStarredArticles()) ?? 0, + let latestData = WidgetData(totalUnreadCount: SmartFeedsController.shared.unreadFeed.unreadCount, + totalTodayCount: fetchedTodayTotalCount, + totalTodayUnreadCount: fetchedTodayUnreadCount, + totalStarredCount: (try? AccountManager.shared.fetchCountForStarredArticles()) ?? 0, unreadArticles: unreadArticles, starredArticles: starredArticles, todayArticles: todayArticles, lastUpdateTime: Date.now) + return latestData } diff --git a/Widget/TimelineProvider.swift b/Widget/TimelineProvider.swift index 35de0289e..97d9e66ff 100644 --- a/Widget/TimelineProvider.swift +++ b/Widget/TimelineProvider.swift @@ -51,7 +51,7 @@ struct Provider: TimelineProvider { let widgetData = try WidgetDataDecoder.decodeWidgetData() entry = WidgetTimelineEntry(date: date, widgetData: widgetData) } catch { - entry = WidgetTimelineEntry(date: date, widgetData: WidgetData(currentUnreadCount: 0, currentTodayCount: 0, currentStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date.now)) + entry = WidgetTimelineEntry(date: date, widgetData: WidgetData(totalUnreadCount: 0, totalTodayCount: 0, totalTodayUnreadCount: 0, totalStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date.now)) } let fallback = Calendar.current.date(byAdding: .minute, value: 30, to: Date.now)! diff --git a/Widget/Widget Views/LockScreenSummaryWidget.swift b/Widget/Widget Views/LockScreenSummaryWidget.swift index 510177548..70519b713 100644 --- a/Widget/Widget Views/LockScreenSummaryWidget.swift +++ b/Widget/Widget Views/LockScreenSummaryWidget.swift @@ -19,39 +19,42 @@ struct LockScreenSummaryWidgetView: View { unreadImage Text("label.text.unread", comment: "Unread") Spacer() - Text(verbatim: entry.widgetData.currentUnreadCount.formatted()) + Text(verbatim: entry.widgetData.totalUnreadCount.formatted()) .frame(maxWidth: .infinity, alignment: .trailing) } HStack(alignment: .center) { todayImage Text("label.text.today", comment: "Today") Spacer() - Text(verbatim: entry.widgetData.currentTodayCount.formatted()) + Text(verbatim: entry.widgetData.totalTodayCount.formatted()) .frame(maxWidth: .infinity, alignment: .trailing) } HStack(alignment: .center) { starredImage Text("label.text.starred", comment: "Starred") Spacer() - Text(verbatim: entry.widgetData.currentStarredCount.formatted()) + Text(verbatim: entry.widgetData.totalStarredCount.formatted()) .frame(maxWidth: .infinity, alignment: .trailing) } } - .font(.caption) + .font(.subheadline) } var starredImage: some View { Image(systemName: "star.fill") + .resizable() .frame(width: 14, height: 14) } var unreadImage: some View { Image(systemName: "largecircle.fill.circle") + .resizable() .frame(width: 14, height: 14) } var todayImage: some View { Image(systemName: "sun.max.fill") + .resizable() .frame(width: 14, height: 14) } diff --git a/Widget/Widget Views/StarredWidget.swift b/Widget/Widget Views/StarredWidget.swift index 22b476fab..d0570da86 100644 --- a/Widget/Widget Views/StarredWidget.swift +++ b/Widget/Widget Views/StarredWidget.swift @@ -16,7 +16,7 @@ struct StarredWidgetView: View { var entry: Provider.Entry var body: some View { - if entry.widgetData.currentStarredCount == 0 { + if entry.widgetData.starredArticles.count == 0 { inboxZero .widgetURL(WidgetDeepLink.starred.url) } else { @@ -33,8 +33,8 @@ struct StarredWidgetView: View { .layoutPriority(1) Spacer() .layoutPriority(0) - if entry.widgetData.currentStarredCount - maxCount() > 0 { - Text(verbatim: entry.widgetData.currentStarredCount.formatted()) + if entry.widgetData.totalStarredCount - maxCount() > 0 { + Text(verbatim: entry.widgetData.totalStarredCount.formatted()) .font(.caption2) .bold() .foregroundColor(.secondary) @@ -47,14 +47,8 @@ struct StarredWidgetView: View { Divider() if entry.widgetData.starredArticles.count > 0 { ForEach(0..= 7 ? (7 - reduceAccessibilityCount) : entry.widgetData.currentStarredCount + return entry.widgetData.totalStarredCount >= 7 ? (7 - reduceAccessibilityCount) : entry.widgetData.totalStarredCount } - return entry.widgetData.currentStarredCount >= 3 ? (3 - reduceAccessibilityCount) : entry.widgetData.currentStarredCount + return entry.widgetData.totalStarredCount >= 3 ? (3 - reduceAccessibilityCount) : entry.widgetData.totalStarredCount } var inboxZero: some View { diff --git a/Widget/Widget Views/TodayWidget.swift b/Widget/Widget Views/TodayWidget.swift index 0e1a64275..942884618 100644 --- a/Widget/Widget Views/TodayWidget.swift +++ b/Widget/Widget Views/TodayWidget.swift @@ -17,7 +17,7 @@ struct TodayWidgetView: View { var entry: Provider.Entry var body: some View { - if entry.widgetData.currentTodayCount == 0 { + if entry.widgetData.totalTodayCount == 0 { inboxZero .widgetURL(WidgetDeepLink.today.url) } else { @@ -34,8 +34,8 @@ struct TodayWidgetView: View { .layoutPriority(1) Spacer() .layoutPriority(0) - if entry.widgetData.currentTodayCount > 0 { - Text(verbatim: entry.widgetData.currentTodayCount.formatted()) + if entry.widgetData.totalTodayCount > 0 { + Text(verbatim: entry.widgetData.totalTodayUnreadCount > 0 ? "\(entry.widgetData.totalTodayCount.formatted()), \(entry.widgetData.totalTodayUnreadCount.formatted()) unread" : entry.widgetData.totalTodayCount.formatted()) .font(.caption2) .bold() .foregroundColor(.secondary) @@ -48,14 +48,8 @@ struct TodayWidgetView: View { Divider() if entry.widgetData.todayArticles.count > 0 { ForEach(0..= 7 ? (7 - reduceAccessibilityCount) : entry.widgetData.currentTodayCount + return entry.widgetData.totalTodayCount >= 7 ? (7 - reduceAccessibilityCount) : entry.widgetData.totalTodayCount } - return entry.widgetData.todayArticles.count >= 3 ? (3 - reduceAccessibilityCount) : entry.widgetData.currentTodayCount + return entry.widgetData.totalTodayCount >= 3 ? (3 - reduceAccessibilityCount) : entry.widgetData.totalTodayCount } var inboxZero: some View { diff --git a/Widget/Widget Views/UnreadWidget.swift b/Widget/Widget Views/UnreadWidget.swift index fcf25169f..18853017d 100644 --- a/Widget/Widget Views/UnreadWidget.swift +++ b/Widget/Widget Views/UnreadWidget.swift @@ -16,7 +16,7 @@ struct UnreadWidgetView: View { var entry: Provider.Entry var body: some View { - if entry.widgetData.currentUnreadCount == 0 { + if entry.widgetData.totalUnreadCount == 0 { inboxZero .widgetURL(WidgetDeepLink.unread.url) } else { @@ -33,8 +33,8 @@ struct UnreadWidgetView: View { .layoutPriority(1) Spacer() .layoutPriority(0) - if entry.widgetData.currentUnreadCount - maxCount() > 0 { - Text(verbatim: entry.widgetData.currentUnreadCount.formatted()) + if entry.widgetData.totalUnreadCount - maxCount() > 0 { + Text(verbatim: entry.widgetData.totalUnreadCount.formatted()) .font(.caption2) .bold() .foregroundColor(.secondary) @@ -47,14 +47,8 @@ struct UnreadWidgetView: View { Divider() if entry.widgetData.unreadArticles.count > 0 { ForEach(0..= 7 ? (7 - reduceAccessibilityCount) : entry.widgetData.currentUnreadCount + return entry.widgetData.totalUnreadCount >= 7 ? (7 - reduceAccessibilityCount) : entry.widgetData.totalUnreadCount } - return entry.widgetData.currentUnreadCount >= 3 ? (3 - reduceAccessibilityCount) : entry.widgetData.currentUnreadCount + return entry.widgetData.totalUnreadCount >= 3 ? (3 - reduceAccessibilityCount) : entry.widgetData.totalUnreadCount } var inboxZero: some View { diff --git a/Widget/WidgetBundle.swift b/Widget/WidgetBundle.swift index 92342b636..20628dc51 100644 --- a/Widget/WidgetBundle.swift +++ b/Widget/WidgetBundle.swift @@ -18,10 +18,11 @@ struct UnreadWidget: Widget { return StaticConfiguration(kind: kind, provider: Provider(), content: { entry in UnreadWidgetView(entry: entry) - .frame(maxWidth: .infinity, maxHeight: .infinity) + .frame(maxHeight: .infinity, alignment: .top) .containerBackground(for: .widget) { Color.clear } + .clipped() }) .configurationDisplayName(Text("label.text.unread", comment: "Unread")) .description(Text("label.text.unread-widget-description", comment: "A description of the Unread widget.")) @@ -36,10 +37,11 @@ struct TodayWidget: Widget { return StaticConfiguration(kind: kind, provider: Provider(), content: { entry in TodayWidgetView(entry: entry) - .frame(maxWidth: .infinity, maxHeight: .infinity) + .frame(maxHeight: .infinity, alignment: .top) .containerBackground(for: .widget) { Color.clear } + .clipped() }) .configurationDisplayName(Text("label.text.today", comment: "Today")) .description(Text("label.text.today-widget-description", comment: "A description of the Today widget.")) @@ -54,10 +56,11 @@ struct StarredWidget: Widget { return StaticConfiguration(kind: kind, provider: Provider(), content: { entry in StarredWidgetView(entry: entry) - .frame(maxWidth: .infinity, maxHeight: .infinity) + .frame(maxHeight: .infinity, alignment: .top) .containerBackground(for: .widget) { Color.clear } + .clipped() }) .configurationDisplayName(Text("label.text.starred", comment: "Starred")) .description(Text("label.text.starred-widget-description", comment: "A description of the Starred widget.")) @@ -72,10 +75,11 @@ struct LockScreenSummaryWidget: Widget { return StaticConfiguration(kind: kind, provider: Provider(), content: { entry in LockScreenSummaryWidgetView(entry: entry) - .frame(maxWidth: .infinity, maxHeight: .infinity) + .frame(maxHeight: .infinity, alignment: .top) .containerBackground(for: .widget) { Color.clear } + .clipped() }) .configurationDisplayName(Text("label.text.lock-screen-summary", comment: "Summary")) .description(Text("label.text.lock-screen-summary-description", comment: "A description of the Lock Screen Summary widget."))