commit 3a3ed08b574cb51214b6c898042ef73af30d1c11 parent bc2ce27073cf4185cd4c344e84043f0c630e82f3 Author: FIGBERT <figbert@figbert.com> Date: Fri, 30 Sep 2022 20:41:40 -0700 Add support for redirect statuses Diffstat:
M | Shared/CapsuleView.swift | | | 28 | ++++++++++++++++++++++++++++ |
1 file changed, 28 insertions(+), 0 deletions(-)
diff --git a/Shared/CapsuleView.swift b/Shared/CapsuleView.swift @@ -19,6 +19,8 @@ struct CapsuleView: View { InputView() case .Success: SuccessView() + case .TemporaryRedirect, .PermanentRedirect: + RedirectView() default: Text("boop") } @@ -124,6 +126,32 @@ struct InputView: View { } } +struct RedirectView: View { + @EnvironmentObject var data: BrowserData + var body: some View { + VStack { + Text("Redirecting...") + .font(.system(size: 35, weight: .bold)) + if case .Redirect(let url) = data.tab.response?.header { + HStack { + Text(data.tab.url?.absoluteString ?? "") + Image(systemName: "arrow.forward") + Text(url.absoluteString) + } + .font(.system(size: 15)) + .foregroundColor(.gray) + } + } + .onAppear { + if case .Redirect(let url) = data.tab.response?.header { + Task { + await data.openURL(url) + } + } + } + } +} + struct CapsuleView_Previews: PreviewProvider { static var previews: some View { CapsuleView()