~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/old-fella

Old people's social media app

0
1
main
108 lines · 3.5 KB Raw History
#if DEBUG
    import SwiftUI

    #Preview("Account avatar") {
        HStack(spacing: 24) {
            AccountAvatar(account: PreviewContent.account, size: 44)
            AccountAvatar(account: nil, size: 64)
        }
        .padding()
    }

    #Preview("Author avatar") {
        PreviewHost { _ in
            AuthorAvatar(author: PreviewContent.author, size: 64)
                .padding()
        }
    }

    #Preview("Post loading placeholders") {
        PostLoadingPlaceholder(label: "Loading posts", count: 3)
    }

    #Preview("Content row style") {
        List {
            Text("A post uses the shared row spacing.")
                .modifier(ContentListRowStyle())
        }
        .listStyle(.plain)
    }

    #Preview("Screen size reader") {
        PreviewScreenSize()
    }

    private struct PreviewScreenSize: View {
        @State private var size = CGSize.zero
        var body: some View {
            Text("Screen: \(Int(size.width)) × \(Int(size.height))")
                .background { PadScreenSizeReader { size = $0 } }
                .padding()
        }
    }

    #Preview("Content preferences notice without an error") {
        PreviewHost { _ in
            VStack {
                ContentPreferencesRefreshNotice()
                Text("No notice appears when content preferences load.")
                    .foregroundStyle(.secondary)
            }
            .padding()
        }
    }

    #Preview("View metrics panel without test flags") {
        VStack {
            ViewUpdateMetricsPanel()
            Text("The metrics panel appears only with its UI test flags.")
                .foregroundStyle(.secondary)
        }
        .padding()
    }

    #Preview("Notification activity headers") {
        VStack(spacing: 20) {
            NotificationActivityHeader(reason: .like, date: PreviewContent.date, isRead: false) {
                Text("Mae Rivers liked your post")
            }
            NotificationActivityHeader(reason: .repost, date: PreviewContent.date, isRead: true) {
                Text("Alex Kim reposted your post")
            }
            NotificationActivityHeader(reason: .follow, date: PreviewContent.date, isRead: false) {
                Text("Sam Lee followed you")
            }
        }
        .padding()
    }

    #Preview("Notification rows") {
        PreviewHost { _ in
            List {
                ForEach(
                    [FeedNotification.Reason.like, .repost, .follow, .reply, .mention, .quote], id: \.rawValue
                ) { reason in
                    let notification = FeedNotification(
                        id: reason.rawValue, author: PreviewContent.author, reason: reason,
                        indexedAt: PreviewContent.date, isRead: false, postID: PreviewContent.post.id,
                        relatedPost: reason.includesPost ? PreviewContent.post : nil
                    )
                    NotificationRow(
                        state: NotificationGroupState(group: NotificationGroup(notifications: [notification])),
                        openRoute: { _ in }, openComposer: { _, _ in }, showGroup: { _ in }
                    )
                    .listRowInsets(EdgeInsets())
                }
            }
            .listStyle(.plain)
        }
    }

    #Preview("Notification refresh control") {
        List {
            Text("Pull to refresh")
        }
        .refreshable {}
        .background { ScrollRefreshControl(isRefreshing: true, isActive: true) }
    }
#endif