widget design

Revises design to give articles more vertical space
This commit is contained in:
Stuart Breckenridge 2020-11-23 10:35:25 +08:00
parent 92c3cd52aa
commit 348abb3f18
No known key found for this signature in database
GPG Key ID: 1F11FD62007DC331
6 changed files with 90 additions and 92 deletions

View File

@ -56,5 +56,21 @@
<string>+ %u more recent unread articles</string>
</dict>
</dict>
<key>LocalizedCount</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@localized_count@</string>
<key>localized_count</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>u</string>
<key>zero</key>
<string>0</string>
<key>other</key>
<string>%u</string>
</dict>
</dict>
</dict>
</plist>

View File

@ -10,6 +10,10 @@ import Foundation
// swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
internal enum L10n {
/// Plural format key: "%#@localized_count@"
internal static func localizedCount(_ p1: Int) -> String {
return L10n.tr("Localizable", "LocalizedCount", p1)
}
/// Your smart feeds, summarized.
internal static let smartFeedSummaryWidgetDescription = L10n.tr("Localizable", "SmartFeedSummary_Widget_Description")
/// Your Smart Feed Summary

View File

@ -44,7 +44,7 @@ struct ArticleItemView: View {
}
}
})
}).padding(.bottom, 4)
})
}
func thumbnail(_ data: Data?) -> UIImage {

View File

@ -20,28 +20,36 @@ struct StarredWidgetView : View {
inboxZero
}
else {
VStack(alignment: .leading) {
HStack(alignment: .top, spacing: 8) {
VStack {
GeometryReader { metrics in
HStack(alignment: .top, spacing: 4) {
VStack(alignment: .leading) {
starredImage
Spacer()
nnwImage
Text(L10n.localizedCount(entry.widgetData.currentStarredCount)).bold().font(Font.system(.footnote, design: .rounded))
Text(L10n.starred.lowercased()).bold().font(Font.system(.footnote).lowercaseSmallCaps()).minimumScaleFactor(0.5).lineLimit(1)
}
VStack(alignment:.leading, spacing: 2) {
.frame(width: metrics.size.width * 0.15)
.padding(.trailing, 4)
Divider()
VStack(alignment:.leading, spacing: 0) {
ForEach(0..<maxCount(), content: { i in
ArticleItemView(article: entry.widgetData.starredArticles[i],
deepLink: WidgetDeepLink.starredArticle(id: entry.widgetData.starredArticles[i].id).url)
if i != 0 {
ArticleItemView(article: entry.widgetData.starredArticles[i],
deepLink: WidgetDeepLink.starredArticle(id: entry.widgetData.todayArticles[i].id).url)
.padding(.vertical, 4)
} else {
ArticleItemView(article: entry.widgetData.unreadArticles[i],
deepLink: WidgetDeepLink.starredArticle(id: entry.widgetData.starredArticles[i].id).url)
.padding(.bottom, 4)
}
})
Spacer()
HStack {
Spacer()
countText
}
}
}
}.padding(.leading, 4)
}.padding()
}
.padding()
.widgetURL(WidgetDeepLink.starred.url)
}
}
@ -61,21 +69,6 @@ struct StarredWidgetView : View {
.cornerRadius(4)
}
var countText: some View {
var count = entry.widgetData.currentStarredCount
if family == .systemLarge {
count = count - 8
} else {
count = count - 3
}
if count < 0 { count = 0 }
let str = L10n.starredCount(count)
return Text(str)
.font(.caption2)
.bold()
.foregroundColor(.accentColor)
}
func maxCount() -> Int {
if family == .systemLarge {
return entry.widgetData.currentStarredCount > 8 ? 8 : entry.widgetData.currentStarredCount

View File

@ -20,29 +20,36 @@ struct TodayWidgetView : View {
inboxZero
}
else {
VStack(alignment: .leading) {
HStack(alignment: .top, spacing: 8) {
VStack {
GeometryReader { metrics in
HStack(alignment: .top, spacing: 4) {
VStack(alignment: .leading) {
todayImage
Spacer()
nnwImage
Text(L10n.localizedCount(entry.widgetData.currentTodayCount)).bold().font(Font.system(.footnote, design: .rounded))
Text(L10n.today.lowercased()).bold().font(Font.system(.footnote).lowercaseSmallCaps()).minimumScaleFactor(0.5).lineLimit(1)
}
VStack(alignment:.leading, spacing: 2) {
.frame(width: metrics.size.width * 0.15)
.padding(.trailing, 4)
Divider()
VStack(alignment:.leading, spacing: 0) {
ForEach(0..<maxCount(), content: { i in
ArticleItemView(article: entry.widgetData.todayArticles[i],
deepLink: WidgetDeepLink.todayArticle(id: entry.widgetData.todayArticles[i].id).url)
if i != 0 {
ArticleItemView(article: entry.widgetData.todayArticles[i],
deepLink: WidgetDeepLink.todayArticle(id: entry.widgetData.todayArticles[i].id).url)
.padding(.vertical, 4)
} else {
ArticleItemView(article: entry.widgetData.unreadArticles[i],
deepLink: WidgetDeepLink.todayArticle(id: entry.widgetData.todayArticles[i].id).url)
.padding(.bottom, 4)
}
})
Spacer()
HStack {
Spacer()
countText
}
}
}
}.padding(.leading, 4)
}.padding()
}
.padding()
.widgetURL(WidgetDeepLink.today.url)
}
}
@ -61,21 +68,6 @@ struct TodayWidgetView : View {
.cornerRadius(4)
}
var countText: some View {
var count = entry.widgetData.currentTodayCount
if family == .systemLarge {
count = count - 8
} else {
count = count - 3
}
if count < 0 { count = 0 }
let str = L10n.todayCount(count)
return Text(str)
.font(.caption2)
.bold()
.foregroundColor(.accentColor)
}
func maxCount() -> Int {
if family == .systemLarge {
return entry.widgetData.todayArticles.count > 8 ? 8 : entry.widgetData.todayArticles.count

View File

@ -20,28 +20,36 @@ struct UnreadWidgetView : View {
inboxZero
}
else {
VStack(alignment: .leading) {
HStack(alignment: .top, spacing: 8) {
VStack {
GeometryReader { metrics in
HStack(alignment: .top, spacing: 4) {
VStack(alignment: .leading) {
unreadImage
Spacer()
nnwImage
Text(L10n.localizedCount(entry.widgetData.currentUnreadCount)).bold().font(Font.system(.footnote, design: .rounded))
Text(L10n.unread.lowercased()).bold().font(Font.system(.footnote).lowercaseSmallCaps()).minimumScaleFactor(0.5).lineLimit(1)
}
VStack(alignment:.leading, spacing: 2) {
.frame(width: metrics.size.width * 0.15)
.padding(.trailing, 4)
Divider()
VStack(alignment:.leading, spacing: 0) {
ForEach(0..<maxCount(), content: { i in
ArticleItemView(article: entry.widgetData.unreadArticles[i],
deepLink: WidgetDeepLink.unreadArticle(id: entry.widgetData.unreadArticles[i].id).url)
if i != 0 {
ArticleItemView(article: entry.widgetData.unreadArticles[i],
deepLink: WidgetDeepLink.unreadArticle(id: entry.widgetData.unreadArticles[i].id).url)
.padding(.vertical, 4)
} else {
ArticleItemView(article: entry.widgetData.unreadArticles[i],
deepLink: WidgetDeepLink.unreadArticle(id: entry.widgetData.unreadArticles[i].id).url)
.padding(.bottom, 4)
}
})
Spacer()
HStack {
Spacer()
countText
}
}
}
}.padding(.leading, 4)
}.padding()
}
.padding()
.widgetURL(WidgetDeepLink.unread.url)
}
}
@ -60,21 +68,6 @@ struct UnreadWidgetView : View {
.cornerRadius(4)
}
var countText: some View {
var count = entry.widgetData.currentUnreadCount
if family == .systemLarge {
count = count - 8
} else {
count = count - 3
}
if count < 0 { count = 0 }
let str = L10n.unreadCount(count)
return Text(str)
.font(.caption2)
.bold()
.foregroundColor(.accentColor)
}
func maxCount() -> Int {
if family == .systemLarge {
return entry.widgetData.unreadArticles.count > 8 ? 8 : entry.widgetData.unreadArticles.count