Files
e-party-iOS/yana/Views/Components/WebView.swift
edwinQQQ de4428e8a1 feat: 新增设置页面及相关功能实现
- 创建SettingPage视图,包含用户信息管理、头像设置、昵称编辑等功能。
- 实现SettingViewModel,处理设置页面的业务逻辑,包括头像上传、昵称更新等。
- 添加相机和相册选择功能,支持头像更换。
- 更新MainPage和MainViewModel,添加导航逻辑以支持设置页面的访问。
- 完善本地化支持,确保多语言兼容性。
- 新增相关测试建议,确保功能完整性和用户体验。
2025-08-06 18:51:37 +08:00

56 lines
1.7 KiB
Swift

import SwiftUI
import SafariServices
// MARK: - Web View Component
struct WebView: UIViewControllerRepresentable {
let url: URL
func makeUIViewController(context: Context) -> SFSafariViewController {
let config = SFSafariViewController.Configuration()
config.entersReaderIfAvailable = false
config.barCollapsingEnabled = true
let safariViewController = SFSafariViewController(url: url, configuration: config)
safariViewController.preferredBarTintColor = UIColor.systemBackground
safariViewController.preferredControlTintColor = UIColor.systemBlue
return safariViewController
}
func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) {
// Safari View Controller
}
}
// MARK: - Web View Modifier
extension View {
/// Web
/// - Parameters:
/// - isPresented:
/// - url: URL
/// - Returns:
func webView(isPresented: Binding<Bool>, url: URL?) -> some View {
self.sheet(isPresented: isPresented) {
if let url = url {
WebView(url: url)
} else {
Text(LocalizedString("web_view.load_failed", comment: ""))
.foregroundColor(.red)
.padding()
}
}
}
}
//#Preview {
// VStack {
// Button(LocalizedString("web_view.open_webpage", comment: "")) {
// //
// }
// }
// .webView(
// isPresented: .constant(true),
// url: URL(string: "https://www.apple.com")
// )
//}