chore(Widget): Add another mock follower in multi followers widget

This commit is contained in:
Marcus Kida 2023-02-06 13:51:58 +01:00
parent b5dca48cb2
commit c00e797996
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
3 changed files with 20 additions and 8 deletions

View File

@ -52,7 +52,7 @@ struct LatestFollowersEntry: TimelineEntry {
static var unconfigured: Self {
LatestFollowersEntry(
date: .now,
accounts: [],
accounts: nil,
configuration: LatestFollowersIntent()
)
}

View File

@ -23,14 +23,14 @@ struct MultiFollowersCountWidgetProvider: IntentTimelineProvider {
struct MultiFollowersCountEntry: TimelineEntry {
let date: Date
let accounts: [FollowersEntryAccountable]?
let accounts: [MultiFollowersEntryAccountable]?
let configuration: MultiFollowersCountIntent
static var placeholder: Self {
MultiFollowersCountEntry(
date: .now,
accounts: [
FollowersEntryAccount(
MultiFollowersEntryAccount(
followersCount: 99_900,
displayNameWithFallback: "Mastodon",
acct: "mastodon",
@ -45,7 +45,7 @@ struct MultiFollowersCountEntry: TimelineEntry {
static var unconfigured: Self {
MultiFollowersCountEntry(
date: .now,
accounts: [],
accounts: nil,
configuration: MultiFollowersCountIntent()
)
}
@ -93,7 +93,7 @@ private extension MultiFollowersCountWidgetProvider {
return completion(.unconfigured)
}
var accounts = [FollowersEntryAccountable]()
var accounts = [MultiFollowersEntryAccountable]()
for desiredAccount in desiredAccounts {
let resultingAccount = try await WidgetExtension.appContext
@ -105,12 +105,24 @@ private extension MultiFollowersCountWidgetProvider {
let imageData = try await URLSession.shared.data(from: resultingAccount.avatarImageURLWithFallback(domain: authBox.domain)).0
accounts.append(FollowersEntryAccount.from(
accounts.append(MultiFollowersEntryAccount.from(
mastodonAccount: resultingAccount,
domain: authBox.domain,
avatarImage: UIImage(data: imageData) ?? UIImage(named: "missingAvatar")!
))
}
if context.isPreview {
accounts.append(
MultiFollowersEntryAccount(
followersCount: 1_200,
displayNameWithFallback: "Another follower",
acct: "@another@follower.social",
avatarImage: UIImage(named: "missingAvatar")!,
domain: authBox.domain
)
)
}
let entry = MultiFollowersCountEntry(
date: Date(),

View File

@ -28,7 +28,7 @@ struct MultiFollowersCountWidgetView: View {
}
}
private func viewForSmallWidget(_ accounts: [FollowersEntryAccountable]) -> some View {
private func viewForSmallWidget(_ accounts: [MultiFollowersEntryAccountable]) -> some View {
VStack(alignment: .leading, spacing: 0) {
ForEach(accounts, id: \.acct) { account in
HStack {
@ -59,7 +59,7 @@ struct MultiFollowersCountWidgetView: View {
.padding(.vertical, 16)
}
private func viewForMediumWidget(_ accounts: [FollowersEntryAccountable]) -> some View {
private func viewForMediumWidget(_ accounts: [MultiFollowersEntryAccountable]) -> some View {
VStack(alignment: .leading, spacing: 0) {
LazyVGrid(columns: [
GridItem(.flexible()),