Skip to content

Commit d994787

Browse files
authored
Fix generated errorview tvos (#1424)
* Updated to use hex.pm for live_view_native and live_view_native_swift_ui for the tutorial * Fix ErrorView generators for tvOS version * Add Restart from Root button fallback
1 parent 49bb69e commit d994787

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

Sources/LiveViewNative/Live/LiveErrorView.swift

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,36 @@ public struct LiveErrorView<Fallback: View>: View {
3939
}
4040
.padding()
4141
#else
42-
SwiftUI.Menu {
43-
SwiftUI.Button {
44-
Task {
45-
await reconnectLiveView(.automatic)
42+
if #available(iOS 14, macOS 11, tvOS 17, visionOS 1, *) {
43+
SwiftUI.Menu {
44+
SwiftUI.Button {
45+
Task {
46+
await reconnectLiveView(.automatic)
47+
}
48+
} label: {
49+
SwiftUI.Label("Reconnect this page", systemImage: "arrow.2.circlepath")
50+
}
51+
SwiftUI.Button {
52+
Task {
53+
await reconnectLiveView(.restart)
54+
}
55+
} label: {
56+
SwiftUI.Label("Restart from root", systemImage: "arrow.circlepath")
4657
}
4758
} label: {
48-
SwiftUI.Label("Reconnect this page", systemImage: "arrow.2.circlepath")
59+
SwiftUI.Label("Reconnect", systemImage: "arrow.2.circlepath")
4960
}
61+
.padding()
62+
} else {
5063
SwiftUI.Button {
5164
Task {
5265
await reconnectLiveView(.restart)
5366
}
5467
} label: {
5568
SwiftUI.Label("Restart from root", systemImage: "arrow.circlepath")
5669
}
57-
} label: {
58-
SwiftUI.Label("Reconnect", systemImage: "arrow.2.circlepath")
70+
.padding()
5971
}
60-
.padding()
6172
#endif
6273
}
6374
} else {

priv/templates/lvn.swiftui.gen/xcodegen/TemplateApp/ErrorView.swift

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,36 @@ struct ErrorView: View {
6767
}
6868
.padding()
6969
#else
70-
Menu {
71-
Button {
72-
Task {
73-
await reconnectLiveView(.automatic)
70+
if #available(iOS 14, macOS 11, tvOS 17, visionOS 1, *) {
71+
Menu {
72+
Button {
73+
Task {
74+
await reconnectLiveView(.automatic)
75+
}
76+
} label: {
77+
Label("Reconnect this page", systemImage: "arrow.2.circlepath")
78+
}
79+
Button {
80+
Task {
81+
await reconnectLiveView(.restart)
82+
}
83+
} label: {
84+
Label("Restart from root", systemImage: "arrow.circlepath")
7485
}
7586
} label: {
76-
Label("Reconnect this page", systemImage: "arrow.2.circlepath")
87+
Label("Reconnect", systemImage: "arrow.2.circlepath")
7788
}
89+
.padding()
90+
} else {
7891
Button {
7992
Task {
8093
await reconnectLiveView(.restart)
8194
}
8295
} label: {
8396
Label("Restart from root", systemImage: "arrow.circlepath")
8497
}
85-
} label: {
86-
Label("Reconnect", systemImage: "arrow.2.circlepath")
98+
.padding()
8799
}
88-
.padding()
89100
#endif
90101
}
91102
}

0 commit comments

Comments
 (0)