diff --git a/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidget.swift b/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidget.swift index 3b75e619c..66c5bd52f 100644 --- a/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidget.swift +++ b/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidget.swift @@ -52,7 +52,7 @@ struct LatestFollowersEntry: TimelineEntry { static var unconfigured: Self { LatestFollowersEntry( date: .now, - accounts: [], + accounts: nil, configuration: LatestFollowersIntent() ) } diff --git a/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidget.swift b/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidget.swift index 518470a79..92bb8b258 100644 --- a/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidget.swift +++ b/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidget.swift @@ -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(), diff --git a/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidgetView.swift b/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidgetView.swift index 836490dd2..bfc0f8495 100644 --- a/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidgetView.swift +++ b/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidgetView.swift @@ -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()),