diff --git a/Packages/Account/Sources/Account/AccountsList/AccountsListView.swift b/Packages/Account/Sources/Account/AccountsList/AccountsListView.swift index 98aa6ced..e1673ea3 100644 --- a/Packages/Account/Sources/Account/AccountsList/AccountsListView.swift +++ b/Packages/Account/Sources/Account/AccountsList/AccountsListView.swift @@ -153,3 +153,13 @@ public struct AccountsListView: View { } } } + +#Preview { + List { + AccountsListRow(viewModel: .init(account: .placeholder(), + relationShip: .placeholder())) + } + .listStyle(.plain) + .withPreviewsEnv() + .environment(Theme.shared) +} diff --git a/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift b/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift index d37594f1..12f96bd8 100644 --- a/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift +++ b/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift @@ -48,7 +48,7 @@ public struct ConversationsListView: View { Divider() } } else if conversations.isEmpty, !viewModel.isLoadingFirstPage, !viewModel.isError { - EmptyView(iconName: "tray", + PlaceholderView(iconName: "tray", title: "conversations.empty.title", message: "conversations.empty.message") } else if viewModel.isError { diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/EmptyView.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/EmptyView.swift deleted file mode 100644 index 7a5a7e25..00000000 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/EmptyView.swift +++ /dev/null @@ -1,32 +0,0 @@ -import SwiftUI - -public struct EmptyView: View { - public let iconName: String - public let title: LocalizedStringKey - public let message: LocalizedStringKey - - public init(iconName: String, title: LocalizedStringKey, message: LocalizedStringKey) { - self.iconName = iconName - self.title = title - self.message = message - } - - public var body: some View { - VStack { - Image(systemName: iconName) - .resizable() - .aspectRatio(contentMode: .fit) - .frame(maxHeight: 50) - Text(title) - .font(.scaledTitle) - .padding(.top, 16) - Text(message) - .font(.scaledSubheadline) - .multilineTextAlignment(.center) - .foregroundStyle(.secondary) - } - .padding(.top, 100) - .padding(.layoutPadding) - .fixedSize(horizontal: false, vertical: true) - } -} diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/ErrorView.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/ErrorView.swift index ef423d3a..ff55bea0 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/ErrorView.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/ErrorView.swift @@ -42,3 +42,11 @@ public struct ErrorView: View { } } } + +#Preview { + ErrorView(title: "Error", + message: "Error loading. Please try again", + buttonTitle: "Retry") { + + } +} diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/NextPageView.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/NextPageView.swift index 04bb593f..95437537 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/NextPageView.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/NextPageView.swift @@ -50,3 +50,14 @@ public struct NextPageView: View { } } } + + +#Preview { + List { + Text("Item 1") + NextPageView { + + } + } + .listStyle(.plain) +} diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/PlaceholderView.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/PlaceholderView.swift new file mode 100644 index 00000000..35488b2e --- /dev/null +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/PlaceholderView.swift @@ -0,0 +1,25 @@ +import SwiftUI + +public struct PlaceholderView: View { + public let iconName: String + public let title: LocalizedStringKey + public let message: LocalizedStringKey + + public init(iconName: String, title: LocalizedStringKey, message: LocalizedStringKey) { + self.iconName = iconName + self.title = title + self.message = message + } + + public var body: some View { + ContentUnavailableView(title, + systemImage: iconName, + description: Text(message)) + } +} + +#Preview { + PlaceholderView(iconName: "square.and.arrow.up.trianglebadge.exclamationmark", + title: "Nothing to see", + message: "This is a preview. Please try again.") +} diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/ScrollToView.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/ScrollToView.swift index 81ec6ca1..93d506d7 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/ScrollToView.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/ScrollToView.swift @@ -11,7 +11,7 @@ public struct ScrollToView: View { public init() {} public var body: some View { - HStack { SwiftUI.EmptyView() } + HStack { EmptyView() } .listRowBackground(Color.clear) .listRowSeparator(.hidden) .listRowInsets(.init()) diff --git a/Packages/Env/Sources/Env/PreviewEnv.swift b/Packages/Env/Sources/Env/PreviewEnv.swift new file mode 100644 index 00000000..e2790ee5 --- /dev/null +++ b/Packages/Env/Sources/Env/PreviewEnv.swift @@ -0,0 +1,15 @@ +import SwiftUI +import Network + +@MainActor +public extension View { + func withPreviewsEnv() -> some View{ + environment(RouterPath()) + .environment(Client(server: "")) + .environment(CurrentAccount.shared) + .environment(UserPreferences.shared) + .environment(CurrentInstance.shared) + .environment(PushNotificationsService.shared) + .environment(QuickLook.shared) + } +} diff --git a/Packages/Explore/Sources/Explore/ExploreView.swift b/Packages/Explore/Sources/Explore/ExploreView.swift index 0fa237c3..d8ad859c 100644 --- a/Packages/Explore/Sources/Explore/ExploreView.swift +++ b/Packages/Explore/Sources/Explore/ExploreView.swift @@ -32,7 +32,7 @@ public struct ExploreView: View { } else if !viewModel.searchQuery.isEmpty { if let results = viewModel.results[viewModel.searchQuery] { if results.isEmpty, !viewModel.isSearching { - EmptyView(iconName: "magnifyingglass", + PlaceholderView(iconName: "magnifyingglass", title: "explore.search.empty.title", message: "explore.search.empty.message") .listRowBackground(theme.secondaryBackgroundColor) @@ -53,7 +53,7 @@ public struct ExploreView: View { .id(UUID()) } } else if viewModel.allSectionsEmpty { - EmptyView(iconName: "magnifyingglass", + PlaceholderView(iconName: "magnifyingglass", title: "explore.search.title", message: "explore.search.message-\(client.server)") #if !os(visionOS) diff --git a/Packages/Notifications/Sources/Notifications/NotificationsListView.swift b/Packages/Notifications/Sources/Notifications/NotificationsListView.swift index e63afb37..f9aaf729 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationsListView.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationsListView.swift @@ -153,7 +153,7 @@ public struct NotificationsListView: View { case let .display(notifications, nextPageState): if notifications.isEmpty { - EmptyView(iconName: "bell.slash", + PlaceholderView(iconName: "bell.slash", title: "notifications.empty.title", message: "notifications.empty.message") #if !os(visionOS) diff --git a/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift b/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift index 6c45b54d..791b541e 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift @@ -350,13 +350,8 @@ public struct StatusRowView: View { client: .init(server: ""), routerPath: RouterPath()), context: .timeline) - }.listStyle(.plain) - .environment(RouterPath()) - .environment(Client(server: "")) - .environment(CurrentAccount.shared) - .environment(UserPreferences.shared) - .environment(CurrentInstance.shared) - .environment(Theme.shared) - .environment(PushNotificationsService.shared) - .environment(QuickLook.shared) + } + .listStyle(.plain) + .withPreviewsEnv() + .environment(Theme.shared) }