Skip to content

Commit a0751ed

Browse files
Fix previews environment
1 parent 4f11bfe commit a0751ed

File tree

4 files changed

+8
-23
lines changed

4 files changed

+8
-23
lines changed

Fyreplace/Views/EnvironmentView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ struct EnvironmentView: View {
2424
.environmentObject(eventBus)
2525
}
2626
}
27+
28+
extension EnvironmentValues {
29+
@Entry var isInForeground = true
30+
@Entry var api: APIProtocol = .fake()
31+
}

Fyreplace/Views/MainView.swift

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,3 @@ struct MainView: View, MainViewProtocol {
9696
#Preview {
9797
MainView()
9898
}
99-
100-
struct ForegroundEnvironmentKey: EnvironmentKey {
101-
static let defaultValue = true
102-
}
103-
104-
extension EnvironmentValues {
105-
var isInForeground: Bool {
106-
get { self[ForegroundEnvironmentKey.self] }
107-
set { self[ForegroundEnvironmentKey.self] = newValue }
108-
}
109-
}
110-
111-
struct APIEnvironmentKey: EnvironmentKey {
112-
static let defaultValue: APIProtocol = .fake()
113-
}
114-
115-
extension EnvironmentValues {
116-
var api: APIProtocol {
117-
get { self[APIEnvironmentKey.self] }
118-
set { self[APIEnvironmentKey.self] = newValue }
119-
}
120-
}

Fyreplace/Views/Screens/EmailsScreen.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct EmailsScreen: View, EmailsScreenProtocol {
55
var eventBus: EventBus
66

77
@Environment(\.api)
8-
var api: any APIProtocol
8+
var api
99

1010
@State
1111
var isLoading = false
@@ -136,4 +136,5 @@ struct EmailsScreen: View, EmailsScreenProtocol {
136136
NavigationStack {
137137
EmailsScreen()
138138
}
139+
.environmentObject(EventBus())
139140
}

Fyreplace/Views/Screens/SettingsScreen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ struct SettingsScreen: View, SettingsScreenProtocol {
142142
NavigationStack {
143143
SettingsScreen()
144144
}
145+
.environmentObject(EventBus())
145146
}
146147

147148
private struct DateJoinedText: View {

0 commit comments

Comments
 (0)