66 lines
2.1 KiB
Swift
66 lines
2.1 KiB
Swift
// MARK: - Visual Effect View
|
|
import SwiftUI
|
|
|
|
struct VisualEffectView: UIViewRepresentable {
|
|
var effect: UIVisualEffect?
|
|
|
|
func makeUIView(context: Context) -> UIVisualEffectView {
|
|
let view = UIVisualEffectView(effect: nil)
|
|
|
|
// Use a simpler approach without animator
|
|
let blurEffect = UIBlurEffect(style: .systemUltraThinMaterialLight)
|
|
|
|
// Create a custom blur effect with reduced intensity
|
|
let blurView = UIVisualEffectView(effect: blurEffect)
|
|
blurView.alpha = 0.3 // Reduce intensity
|
|
|
|
// Add a white background with low opacity for better frosted effect
|
|
let backgroundView = UIView()
|
|
backgroundView.backgroundColor = UIColor.white.withAlphaComponent(0.1)
|
|
backgroundView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
|
|
view.contentView.addSubview(backgroundView)
|
|
view.contentView.addSubview(blurView)
|
|
blurView.frame = view.bounds
|
|
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
|
|
return view
|
|
}
|
|
|
|
func updateUIView(_ uiView: UIVisualEffectView, context: Context) {
|
|
// No need to update the effect
|
|
}
|
|
}
|
|
|
|
// MARK: - AV Player Controller
|
|
import AVKit
|
|
|
|
struct AVPlayerController: UIViewControllerRepresentable {
|
|
@Binding var player: AVPlayer?
|
|
|
|
func makeUIViewController(context: Context) -> AVPlayerViewController {
|
|
let controller = AVPlayerViewController()
|
|
controller.player = player
|
|
controller.showsPlaybackControls = false
|
|
controller.videoGravity = .resizeAspect
|
|
controller.view.backgroundColor = .clear
|
|
return controller
|
|
}
|
|
|
|
func updateUIViewController(_ uiViewController: AVPlayerViewController, context: Context) {
|
|
uiViewController.player = player
|
|
}
|
|
}
|
|
|
|
// MARK: - Transparent Video Player
|
|
struct TransparentVideoPlayer: UIViewRepresentable {
|
|
func makeUIView(context: Context) -> UIView {
|
|
let view = UIView()
|
|
view.backgroundColor = .clear
|
|
view.isOpaque = false
|
|
return view
|
|
}
|
|
|
|
func updateUIView(_ uiView: UIView, context: Context) {}
|
|
}
|