fix: app preview disabled in release builds

This commit is contained in:
Stefan Hausotte 2026-02-28 23:01:59 +01:00
parent 47a3b59968
commit 1ab005edff
32 changed files with 64 additions and 0 deletions

View file

@ -94,7 +94,9 @@ struct ContentView: View {
}
}
#if DEBUG
#Preview {
ContentView()
.modelContainer(for: ForgejoInstance.self, inMemory: true)
}
#endif

View file

@ -66,6 +66,8 @@ struct CommentSheet: View {
}
}
#if DEBUG
#Preview {
CommentSheet(users: [.preview, .previewBot]) { _ in }
}
#endif

View file

@ -107,6 +107,7 @@ private struct CommentEditSheet: View {
}
}
#if DEBUG
#Preview {
List {
CommentView(
@ -116,3 +117,4 @@ private struct CommentEditSheet: View {
)
}
}
#endif

View file

@ -93,6 +93,7 @@ struct CommitDetailView: View {
}
}
#if DEBUG
#Preview {
NavigationStack {
CommitDetailView(
@ -102,3 +103,4 @@ struct CommitDetailView: View {
)
}
}
#endif

View file

@ -209,6 +209,7 @@ struct CommitRow: View {
}
}
#if DEBUG
#Preview {
NavigationStack {
CommitHistoryView(
@ -218,3 +219,4 @@ struct CommitRow: View {
)
}
}
#endif

View file

@ -143,9 +143,11 @@ private struct InlineCommentBubble: View {
}
}
#if DEBUG
#Preview {
List {
DiffView(diff: .preview)
.listRowInsets(EdgeInsets())
}
}
#endif

View file

@ -45,6 +45,7 @@ struct AssigneesDisplaySection: View {
}
}
#if DEBUG
#Preview("Milestone") {
List {
MilestoneDisplaySection(milestone: .preview)
@ -56,3 +57,4 @@ struct AssigneesDisplaySection: View {
AssigneesDisplaySection(assignees: [.preview, .previewBot])
}
}
#endif

View file

@ -282,6 +282,7 @@ struct CommitSheetView: View {
}
}
#if DEBUG
#Preview("Markdown") {
NavigationStack {
FileViewerView(
@ -335,3 +336,4 @@ struct CommitSheetView: View {
)
}
}
#endif

View file

@ -175,6 +175,8 @@ struct SettingsTabView: View {
}
}
#if DEBUG
#Preview {
HomeView(authService: .previewDefault)
}
#endif

View file

@ -256,6 +256,7 @@ struct InstanceFormView: View {
}
}
#if DEBUG
#Preview("Add") {
InstanceFormView(authService: .previewDefault, mode: .add)
.modelContainer(for: ForgejoInstance.self, inMemory: true)
@ -265,3 +266,4 @@ struct InstanceFormView: View {
InstanceFormView(authService: .previewDefault, mode: .edit(.preview))
.modelContainer(for: ForgejoInstance.self, inMemory: true)
}
#endif

View file

@ -175,7 +175,9 @@ struct InstanceListView: View {
}
}
#if DEBUG
#Preview {
InstanceListView(authService: .previewDefault)
.modelContainer(for: ForgejoInstance.self, inMemory: true)
}
#endif

View file

@ -146,6 +146,7 @@ struct IssueCreateView: View {
#endif
}
#if DEBUG
#Preview {
NavigationStack {
IssueCreateView(
@ -158,3 +159,4 @@ struct IssueCreateView: View {
)
}
}
#endif

View file

@ -286,6 +286,7 @@ struct IssueDetailView: View {
#endif
}
#if DEBUG
#Preview {
NavigationStack {
IssueDetailView(
@ -298,3 +299,4 @@ struct IssueDetailView: View {
)
}
}
#endif

View file

@ -156,6 +156,7 @@ struct IssueEditView: View {
#endif
}
#if DEBUG
#Preview {
IssueEditView(
preview: (),
@ -167,3 +168,4 @@ struct IssueEditView: View {
availableAssignees: [.preview, .previewBot],
)
}
#endif

View file

@ -49,6 +49,7 @@ extension Color {
}
}
#if DEBUG
#Preview {
HStack {
ForEach(IssueLabel.previewList) { label in
@ -57,3 +58,4 @@ extension Color {
}
.padding()
}
#endif

View file

@ -143,6 +143,7 @@ struct IssueListView: View {
#endif
}
#if DEBUG
#Preview {
NavigationStack {
IssueListView(
@ -153,6 +154,7 @@ struct IssueListView: View {
)
}
}
#endif
struct IssueRow: View {
let issue: Issue

View file

@ -48,6 +48,7 @@ struct IssuesOverviewView: View {
#endif
}
#if DEBUG
#Preview {
NavigationStack {
IssuesOverviewView(
@ -57,3 +58,4 @@ struct IssuesOverviewView: View {
)
}
}
#endif

View file

@ -205,6 +205,7 @@ struct MermaidDiagramView: View {
}
}
#if DEBUG
#Preview("Editor") {
@Previewable @State var text = "# Hello\n\nThis is **bold** and *italic* text.\n\n- Item 1\n- Item 2"
@Previewable @State var tab: EditPreviewTab = .edit
@ -216,3 +217,4 @@ struct MermaidDiagramView: View {
MarkdownPreview(text: "# Hello\n\nThis is **bold** and *italic* text.\n\n```swift\nlet x = 42\n```")
.padding()
}
#endif

View file

@ -76,6 +76,7 @@ struct MentionableEditorField: View {
}
}
#if DEBUG
#Preview {
@Previewable @State var text = "Hello @"
@Previewable @State var tab: EditPreviewTab = .edit
@ -86,3 +87,4 @@ struct MentionableEditorField: View {
)
.padding()
}
#endif

View file

@ -283,6 +283,7 @@ struct UserPickerSection: View {
}
}
#if DEBUG
#Preview("Description") {
@Previewable @State var text = "Some **markdown** description"
NavigationStack {
@ -328,3 +329,4 @@ struct UserPickerSection: View {
}
}
}
#endif

View file

@ -261,6 +261,7 @@ private struct NotificationRow: View {
}
}
#if DEBUG
#Preview {
NavigationStack {
NotificationsOverviewView(
@ -270,3 +271,4 @@ private struct NotificationRow: View {
)
}
}
#endif

View file

@ -234,6 +234,7 @@ struct PullRequestCreateView: View {
#endif
}
#if DEBUG
#Preview {
NavigationStack {
PullRequestCreateView(
@ -248,3 +249,4 @@ struct PullRequestCreateView: View {
)
}
}
#endif

View file

@ -590,6 +590,7 @@ struct PullRequestDetailView: View {
#endif
}
#if DEBUG
#Preview {
NavigationStack {
PullRequestDetailView(
@ -603,3 +604,4 @@ struct PullRequestDetailView: View {
)
}
}
#endif

View file

@ -203,6 +203,7 @@ struct PullRequestEditView: View {
#endif
}
#if DEBUG
#Preview {
PullRequestEditView(
preview: (),
@ -214,3 +215,4 @@ struct PullRequestEditView: View {
availableAssignees: [.preview, .previewBot],
)
}
#endif

View file

@ -143,6 +143,7 @@ struct PullRequestListView: View {
#endif
}
#if DEBUG
#Preview {
NavigationStack {
PullRequestListView(
@ -153,6 +154,7 @@ struct PullRequestListView: View {
)
}
}
#endif
struct PullRequestRow: View {
let pullRequest: PullRequest

View file

@ -102,6 +102,7 @@ struct PullRequestMergeView: View {
}
}
#if DEBUG
#Preview {
PullRequestMergeView(
repository: .preview,
@ -109,3 +110,4 @@ struct PullRequestMergeView: View {
authService: .previewDefault,
) {}
}
#endif

View file

@ -235,6 +235,7 @@ private struct AddInlineCommentSheet: View {
}
}
#if DEBUG
#Preview {
PullRequestReviewSheet(
preview: (),
@ -244,3 +245,4 @@ private struct AddInlineCommentSheet: View {
parsedDiff: .preview,
)
}
#endif

View file

@ -96,6 +96,7 @@ struct PullRequestOverviewRow: View {
}
}
#if DEBUG
#Preview {
NavigationStack {
PullRequestsOverviewView(
@ -105,3 +106,4 @@ struct PullRequestOverviewRow: View {
)
}
}
#endif

View file

@ -559,8 +559,10 @@ struct ContentRow: View {
}
}
#if DEBUG
#Preview {
NavigationStack {
RepositoryDetailView(repository: .preview, authService: .previewDefault)
}
}
#endif

View file

@ -329,6 +329,8 @@ struct RepositoryRow: View {
}
}
#if DEBUG
#Preview {
RepositoryListView(authService: .previewDefault)
}
#endif

View file

@ -176,8 +176,10 @@ private struct RepositoryPickerRow: View {
}
}
#if DEBUG
#Preview {
RepositoryPickerView(preview: (), authService: .previewDefault, repositories: [.preview]) { repo in
Text(repo.fullName)
}
}
#endif

View file

@ -75,6 +75,7 @@ struct ReviewSummaryView: View {
}
}
#if DEBUG
#Preview {
List {
ReviewSummaryView(
@ -83,3 +84,4 @@ struct ReviewSummaryView: View {
)
}
}
#endif