Text position on widget

Text position on widgets are now in a fixed position.
This commit is contained in:
Stuart Breckenridge 2021-01-29 22:34:31 +08:00
parent bc7341ec80
commit 4414ea6c06
No known key found for this signature in database
GPG Key ID: 1F11FD62007DC331
3 changed files with 131 additions and 75 deletions

View File

@ -23,34 +23,53 @@ struct StarredWidgetView : View {
} }
else { else {
GeometryReader { metrics in GeometryReader { metrics in
HStack(alignment: .top, spacing: 4) { HStack {
VStack(alignment: .leading, spacing: -4) { VStack {
starredImage starredImage
.padding(.vertical, 12)
.padding(.leading, 8)
Spacer() Spacer()
Text(L10n.localizedCount(entry.widgetData.currentStarredCount)).bold().font(.callout).minimumScaleFactor(0.5).lineLimit(1)
Text(L10n.starred.lowercased()).bold().font(Font.system(.footnote).lowercaseSmallCaps()).minimumScaleFactor(0.5).lineLimit(1)
}
.frame(width: metrics.size.width * 0.15)
.padding(.trailing, 4)
VStack(alignment:.leading, spacing: 0) { }
ForEach(0..<maxCount(), content: { i in }
if i != 0 { .frame(width: metrics.size.width * 0.15)
Divider()
ArticleItemView(article: entry.widgetData.starredArticles[i], Spacer()
deepLink: WidgetDeepLink.starredArticle(id: entry.widgetData.starredArticles[i].id).url)
.padding(.top, 8) VStack(alignment:.leading, spacing: 0) {
.padding(.bottom, 4) ForEach(0..<maxCount(), content: { i in
} else { if i != 0 {
ArticleItemView(article: entry.widgetData.starredArticles[i], Divider()
deepLink: WidgetDeepLink.starredArticle(id: entry.widgetData.starredArticles[i].id).url) ArticleItemView(article: entry.widgetData.starredArticles[i],
.padding(.bottom, 4) deepLink: WidgetDeepLink.starredArticle(id: entry.widgetData.starredArticles[i].id).url)
} .padding(.top, 8)
.padding(.bottom, 4)
}) } else {
ArticleItemView(article: entry.widgetData.starredArticles[i],
deepLink: WidgetDeepLink.starredArticle(id: entry.widgetData.starredArticles[i].id).url)
.padding(.bottom, 4)
}
})
Spacer()
}
.padding(.leading, metrics.size.width * 0.175)
.padding([.bottom, .trailing])
.padding(.top, 12)
.overlay(
VStack {
Spacer() Spacer()
}.padding(.leading, 4) HStack {
}.padding() Spacer()
Text(L10n.starredCount(entry.widgetData.currentStarredCount - maxCount()))
.font(.caption2)
.bold()
.foregroundColor(.secondary)
}
}
.padding(.horizontal)
.padding(.bottom, 6)
)
}.widgetURL(WidgetDeepLink.starred.url) }.widgetURL(WidgetDeepLink.starred.url)
} }

View File

@ -23,34 +23,53 @@ struct TodayWidgetView : View {
} }
else { else {
GeometryReader { metrics in GeometryReader { metrics in
HStack(alignment: .top, spacing: 4) { HStack {
VStack(alignment: .leading, spacing: -4) { VStack {
todayImage todayImage
.padding(.vertical, 12)
.padding(.leading, 8)
Spacer() Spacer()
Text(L10n.localizedCount(entry.widgetData.currentTodayCount)).bold().font(.callout).minimumScaleFactor(0.5).lineLimit(1)
Text(L10n.today.lowercased()).bold().font(Font.system(.footnote).lowercaseSmallCaps()).minimumScaleFactor(0.5).lineLimit(1)
}
.frame(width: metrics.size.width * 0.15)
.padding(.trailing, 4)
VStack(alignment:.leading, spacing: 0) { }
ForEach(0..<maxCount(), content: { i in }
if i != 0 { .frame(width: metrics.size.width * 0.15)
Divider()
ArticleItemView(article: entry.widgetData.todayArticles[i], Spacer()
deepLink: WidgetDeepLink.todayArticle(id: entry.widgetData.todayArticles[i].id).url)
.padding(.top, 8) VStack(alignment:.leading, spacing: 0) {
.padding(.bottom, 4) ForEach(0..<maxCount(), content: { i in
} else { if i != 0 {
ArticleItemView(article: entry.widgetData.unreadArticles[i], Divider()
deepLink: WidgetDeepLink.todayArticle(id: entry.widgetData.todayArticles[i].id).url) ArticleItemView(article: entry.widgetData.todayArticles[i],
.padding(.bottom, 4) deepLink: WidgetDeepLink.todayArticle(id: entry.widgetData.todayArticles[i].id).url)
} .padding(.top, 8)
.padding(.bottom, 4)
}) } else {
ArticleItemView(article: entry.widgetData.todayArticles[i],
deepLink: WidgetDeepLink.todayArticle(id: entry.widgetData.todayArticles[i].id).url)
.padding(.bottom, 4)
}
})
Spacer()
}
.padding(.leading, metrics.size.width * 0.175)
.padding([.bottom, .trailing])
.padding(.top, 12)
.overlay(
VStack {
Spacer() Spacer()
}.padding(.leading, 4) HStack {
}.padding() Spacer()
Text(L10n.todayCount(entry.widgetData.currentTodayCount - maxCount()))
.font(.caption2)
.bold()
.foregroundColor(.secondary)
}
}
.padding(.horizontal)
.padding(.bottom, 6)
)
}.widgetURL(WidgetDeepLink.today.url) }.widgetURL(WidgetDeepLink.today.url)
} }
} }

View File

@ -23,43 +23,61 @@ struct UnreadWidgetView : View {
} }
else { else {
GeometryReader { metrics in GeometryReader { metrics in
HStack(alignment: .top, spacing: 4) { HStack {
VStack(alignment: .leading, spacing: -4) { VStack {
unreadImage unreadImage
.padding(.vertical, 12)
.padding(.leading, 8)
Spacer() Spacer()
Text(L10n.localizedCount(entry.widgetData.currentUnreadCount)).bold().font(.callout).minimumScaleFactor(0.5).lineLimit(1)
Text(L10n.unread.lowercased()).bold().font(Font.system(.footnote).lowercaseSmallCaps()).minimumScaleFactor(0.5).lineLimit(1)
}
.frame(width: metrics.size.width * 0.15)
.padding(.trailing, 4)
VStack(alignment:.leading, spacing: 0) { }
ForEach(0..<maxCount(), content: { i in }
if i != 0 { .frame(width: metrics.size.width * 0.15)
Divider()
ArticleItemView(article: entry.widgetData.unreadArticles[i], Spacer()
deepLink: WidgetDeepLink.unreadArticle(id: entry.widgetData.unreadArticles[i].id).url)
.padding(.top, 8) VStack(alignment:.leading, spacing: 0) {
.padding(.bottom, 4) ForEach(0..<maxCount(), content: { i in
} else { if i != 0 {
ArticleItemView(article: entry.widgetData.unreadArticles[i], Divider()
deepLink: WidgetDeepLink.unreadArticle(id: entry.widgetData.unreadArticles[i].id).url) ArticleItemView(article: entry.widgetData.unreadArticles[i],
.padding(.bottom, 4) deepLink: WidgetDeepLink.unreadArticle(id: entry.widgetData.unreadArticles[i].id).url)
} .padding(.top, 8)
.padding(.bottom, 4)
}) } else {
ArticleItemView(article: entry.widgetData.unreadArticles[i],
deepLink: WidgetDeepLink.unreadArticle(id: entry.widgetData.unreadArticles[i].id).url)
.padding(.bottom, 4)
}
})
Spacer()
}
.padding(.leading, metrics.size.width * 0.175)
.padding([.bottom, .trailing])
.padding(.top, 12)
.overlay(
VStack {
Spacer() Spacer()
}.padding(.leading, 4) HStack {
}.padding() Spacer()
}.widgetURL(WidgetDeepLink.unread.url) Text(L10n.unreadCount(entry.widgetData.currentUnreadCount - maxCount()))
.font(.caption2)
.bold()
.foregroundColor(.secondary)
}
}
.padding(.horizontal)
.padding(.bottom, 6)
)
}
.widgetURL(WidgetDeepLink.unread.url)
} }
} }
var unreadImage: some View { var unreadImage: some View {
Image(systemName: "largecircle.fill.circle") Image(systemName: "largecircle.fill.circle")
.resizable() .resizable()
.frame(width: 30, height: 30, alignment: .center) .frame(width: 30, height: 30, alignment: .top)
.cornerRadius(4)
.foregroundColor(.accentColor) .foregroundColor(.accentColor)
} }