This commit is contained in:
2026-09-24 16:25:22 +08:00
commit 7428184f01
1198 changed files with 314515 additions and 0 deletions
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyTrackingDomains</key>
<array/>
</dict>
</plist>
@@ -0,0 +1,117 @@
import UIKit
class XdBlur {
///
/// - Parameters:
/// - view:
/// - style: Light, Dark, ExtraLight
/// - intensity: 0-1
/// - backgroundColor:
static func applyBlur(
to view: UIView,
style: UIBlurEffect.Style = .light,
intensity: CGFloat = 0.8,
backgroundColor: UIColor? = nil
) {
//
view.subviews
.filter { $0 is UIVisualEffectView }
.forEach { $0.removeFromSuperview() }
//
let blurEffect = UIBlurEffect(style: style)
let blurView = UIVisualEffectView(effect: blurEffect)
//
if #available(iOS 13.0, *) {
let vibrancyView = UIVisualEffectView(effect:
UIVibrancyEffect(blurEffect: blurEffect, style: .fill)
)
blurView.contentView.addSubview(vibrancyView)
}
// frame
blurView.frame = view.bounds
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
//
blurView.alpha = intensity
//
if let backgroundColor = backgroundColor {
let colorView = UIView(frame: blurView.bounds)
colorView.backgroundColor = backgroundColor
colorView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
blurView.contentView.addSubview(colorView)
}
//
view.insertSubview(blurView, at: 0)
}
///
/// - Parameter view:
static func removeBlur(from view: UIView) {
view.subviews
.filter { $0 is UIVisualEffectView }
.forEach { $0.removeFromSuperview() }
}
///
/// - Parameters:
/// - view:
/// - radius:
/// - tintColor:
static func applyCustomBlur(
to view: UIView,
radius: CGFloat = 10,
tintColor: UIColor? = nil
) {
//
let blurEffect = UIBlurEffect(style: .light)
let blurView = UIVisualEffectView(effect: blurEffect)
//
let vibrancyView = UIVisualEffectView(effect:
UIVibrancyEffect(blurEffect: blurEffect)
)
blurView.frame = view.bounds
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
//
if let tintColor = tintColor {
let colorView = UIView(frame: blurView.bounds)
colorView.backgroundColor = tintColor
colorView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
blurView.contentView.addSubview(colorView)
}
view.insertSubview(blurView, at: 0)
}
static func applyBlurSelf(ele: UIView ,bg:UIView, blur: CGFloat, backgroundColor: UIColor = .clear) {
// Create snapshot of element
UIGraphicsBeginImageContextWithOptions(ele.bounds.size, false, 0)
ele.layer.render(in: UIGraphicsGetCurrentContext()!)
let snapshot = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
// Create blur effect
let effectView = UIVisualEffectView(effect: UIBlurEffect(style: .light))
effectView.frame = bg.bounds
// Create color overlay
let colorView = UIView(frame: bg.bounds)
colorView.backgroundColor = backgroundColor
colorView.alpha = blur
// Add views to background
bg.addSubview(effectView)
bg.addSubview(colorView)
// Set snapshot as background
let imageView = UIImageView(image: snapshot)
imageView.frame = bg.bounds
bg.insertSubview(imageView, at: 0)
}
}
@@ -0,0 +1,3 @@
{
"deploymentTarget": "12"
}
@@ -0,0 +1,103 @@
import { UIViewController, UIView, UIWindow, UIScreen, UIColor, UIBlurEffect } from 'UIKit';
import { CGRect, CGFloat, CGPoint, CGAffineTransform, CGSize } from 'CoreFoundation';
import { CABasicAnimation, CAMediaTimingFillMode, CATransform3DIsIdentity, CATransform3DIdentity, CATransform3DMakeTranslation, CATransform3DRotate, CATransform3DScale } from 'QuartzCore';
import { getRootView } from "./libs/util.uts"
import { Color } from 'SwiftUI';
import { hexToRgb } from '../libs/color.uts'
export class xModalPage {
contentView : UIView | null = null;
rootWin : UIWindow;
constructor() {
let winsize = UIScreen.main.bounds as CGRect;
let mainwidth = new CGRect(x = 0, y = 180, width = 300, height = 200)
// 创建一个新的 UIWindow 实例
let newWindow = new UIWindow(frame = mainwidth)
// newWindow.frame = mainwidth
this.rootWin = newWindow;
}
setView(ele : UniElement | null) {
if (ele == null) return;
let userView = ele!.getIOSView() as UIView | null
if (userView == null) return;
this.contentView = userView!;
class ContentWin extends UIViewController {
userView : UIView | null = null;
setAddView(userViewBox : UIView | null) {
this.userView = userViewBox;
}
override viewDidLoad() {
super.viewDidLoad();
let root = super.view as UIView;
root.backgroundColor = UIColor.black
if (this.userView != null) {
let cview = this.userView! as UIView;
cview.frame = UIScreen.main.bounds
root.addSubview(cview)
}
}
}
if (this.contentView == null) return;
DispatchQueue.main.async(execute = () : void => {
// 创建一个新的 UIViewController 实例作为模态视图控制器
let secondViewController = new ContentWin()
secondViewController.setAddView(this.contentView)
// 将模态视图控制器添加到新窗口中
this.rootWin.rootViewController = secondViewController as UIViewController
})
}
show() {
let pageconroll = this.rootWin.rootViewController;
if (this.contentView == null || pageconroll == null) return;
DispatchQueue.main.async(execute = () : void => {
this.rootWin.makeKeyAndVisible()
let parent = UTSiOS.getCurrentViewController() as UIViewController;
parent.present(pageconroll!, animated = true, completion = nil)
})
}
hide() {
DispatchQueue.main.async(execute = () : void => {
this.rootWin.rootViewController?.dismiss(animated = true, completion = nil)
})
}
destroy() {
}
}
export class xdBlur {
$element : UniNativeViewElement;
targetView : UIView | null = null;
constructor(element : UniNativeViewElement) {
//接收传递过来的UniNativeViewElement
this.$element = element;
this.targetView = new UIView()
this.$element.bindIOSView(this.targetView!);
}
setFilterBg(blur : number, bgcolor : string,ele:UniElement|null = null) {
let colorrgba = hexToRgb(bgcolor)
let br = (blur / 100).toFloat()
let view = this.targetView!
XdBlur.applyBlur(
to = view,
style = UIBlurEffect.Style.light,
intensity = new CGFloat(br),
backgroundColor = UTSiOS.colorWithString(bgcolor)
)
}
public static setFilterSelfBg(ele : UniElement,bg:UniElement, blur : number, bgcolor : string) {
let colorrgba = hexToRgb(bgcolor)
let br = (blur / 100).toFloat()
let view = ele.getIOSView()! as UIView
let viewbg = bg.getIOSView()! as UIView
XdBlur.applyBlurSelf(ele=view,bg = viewbg, blur = new CGFloat(br), backgroundColor = UTSiOS.colorWithString(bgcolor))
}
}
@@ -0,0 +1,10 @@
import { UIViewController, UIView } from 'UIKit';
export function getRootView() : UIView {
let parent = UTSiOS.getCurrentViewController() as UIViewController;
let windUiview = parent.view as UIView
return windUiview;
}
export function getRoot() : UIViewController {
let parent = UTSiOS.getCurrentViewController() as UIViewController;
return parent;
}