feat(Widget): Implement MultiFollowersCountWidget for medium size
This commit is contained in:
parent
9eb26d4ed8
commit
15b6b9fb93
|
@ -56,7 +56,7 @@ struct MultiFollowersCountEntry: TimelineEntry {
|
||||||
|
|
||||||
struct MultiFollowersCountWidget: Widget {
|
struct MultiFollowersCountWidget: Widget {
|
||||||
private var availableFamilies: [WidgetFamily] {
|
private var availableFamilies: [WidgetFamily] {
|
||||||
return [.systemSmall]
|
return [.systemSmall, .systemMedium]
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some WidgetConfiguration {
|
var body: some WidgetConfiguration {
|
||||||
|
|
|
@ -13,7 +13,9 @@ struct MultiFollowersCountWidgetView: View {
|
||||||
if let accounts = entry.accounts {
|
if let accounts = entry.accounts {
|
||||||
switch family {
|
switch family {
|
||||||
case .systemSmall:
|
case .systemSmall:
|
||||||
viewForSmallWidgetNoChart(accounts)
|
viewForSmallWidget(accounts)
|
||||||
|
case .systemMedium:
|
||||||
|
viewForMediumWidget(accounts)
|
||||||
default:
|
default:
|
||||||
Text("Sorry but this Widget family is unsupported.")
|
Text("Sorry but this Widget family is unsupported.")
|
||||||
}
|
}
|
||||||
|
@ -25,7 +27,7 @@ struct MultiFollowersCountWidgetView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func viewForSmallWidgetNoChart(_ accounts: [FollowersEntryAccountable]) -> some View {
|
private func viewForSmallWidget(_ accounts: [FollowersEntryAccountable]) -> some View {
|
||||||
VStack(alignment: .leading, spacing: 0) {
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
ForEach(accounts, id: \.acct) { account in
|
ForEach(accounts, id: \.acct) { account in
|
||||||
HStack {
|
HStack {
|
||||||
|
@ -55,4 +57,40 @@ struct MultiFollowersCountWidgetView: View {
|
||||||
}
|
}
|
||||||
.padding(.vertical, 16)
|
.padding(.vertical, 16)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func viewForMediumWidget(_ accounts: [FollowersEntryAccountable]) -> some View {
|
||||||
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
|
LazyVGrid(columns: [
|
||||||
|
GridItem(.flexible()),
|
||||||
|
GridItem(.flexible())
|
||||||
|
]) {
|
||||||
|
ForEach(accounts, id: \.acct) { account in
|
||||||
|
HStack {
|
||||||
|
if let avatarImage = account.avatarImage {
|
||||||
|
Image(uiImage: avatarImage)
|
||||||
|
.resizable()
|
||||||
|
.frame(width: 32, height: 32)
|
||||||
|
.cornerRadius(5)
|
||||||
|
}
|
||||||
|
VStack(alignment: .leading) {
|
||||||
|
Text(account.followersCount.asAbbreviatedCountString())
|
||||||
|
.font(.title2)
|
||||||
|
.lineLimit(1)
|
||||||
|
.truncationMode(.tail)
|
||||||
|
|
||||||
|
Text("@\(account.acct)")
|
||||||
|
.font(.caption2)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
.lineLimit(1)
|
||||||
|
.truncationMode(.tail)
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding(.leading, 20)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding(.vertical, 16)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue