
- 修改Package.swift以支持iOS 15和macOS 12。 - 更新swift-tca-architecture-guidelines.mdc中的alwaysApply设置为false。 - 注释掉AppDelegate中的NIMSDK导入,移除不再使用的NIMConfigurationManager和NIMSessionManager文件。 - 添加新的API相关文件,包括EMailLoginFeature、IDLoginFeature和相关视图,增强登录功能。 - 更新APIConstants和APIEndpoints以反映新的API路径。 - 添加本地化支持文件,包含英文和中文简体的本地化字符串。 - 新增字体管理和安全工具类,支持AES和DES加密。 - 更新Xcode项目配置,调整版本号和启动画面设置。
55 lines
1.6 KiB
Swift
55 lines
1.6 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("无法加载页面")
|
|
.foregroundColor(.red)
|
|
.padding()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
VStack {
|
|
Button("打开网页") {
|
|
// 预览时不执行任何操作
|
|
}
|
|
}
|
|
.webView(
|
|
isPresented: .constant(true),
|
|
url: URL(string: "https://www.apple.com")
|
|
)
|
|
} |