-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #515 from pennlabs/anli/03-17-subletting-enhancements
Tweak external link and form component behavior
- Loading branch information
Showing
5 changed files
with
65 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// SafariView.swift | ||
// PennMobile | ||
// | ||
// Created by Anthony Li on 3/17/24. | ||
// Copyright © 2024 PennLabs. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import SafariServices | ||
|
||
struct SafariView: UIViewControllerRepresentable { | ||
let url: URL | ||
|
||
func makeUIViewController(context: Context) -> SFSafariViewController { | ||
SFSafariViewController(url: url) | ||
} | ||
|
||
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {} | ||
} | ||
|
||
struct SafariModifier: ViewModifier { | ||
@Binding var isPresented: Bool | ||
var url: URL? | ||
|
||
func body(content: Content) -> some View { | ||
if let url { | ||
AnyView(content.sheet(isPresented: $isPresented) { | ||
SafariView(url: url) | ||
.ignoresSafeArea() | ||
}) | ||
} else { | ||
AnyView(content) | ||
} | ||
} | ||
} | ||
|
||
extension View { | ||
func safari(isPresented: Binding<Bool>, url: URL?) -> some View { | ||
modifier(SafariModifier(isPresented: isPresented, url: url)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters