(
value: GlassEffectType,
options: {
effectType: 'glass' | 'container';
targetView?: UIVisualEffectView;
toGlassStyleFn?: (variant?: GlassEffectVariant) => number;
onCreate?: (effectView: UIVisualEffectView, effect: UIVisualEffect) => void;
onUpdate?: (effectView: UIVisualEffectView, effect: UIVisualEffect, duration: number) => void;
},
)
| 926 | } |
| 927 | |
| 928 | protected _applyGlassEffect( |
| 929 | value: GlassEffectType, |
| 930 | options: { |
| 931 | effectType: 'glass' | 'container'; |
| 932 | targetView?: UIVisualEffectView; |
| 933 | toGlassStyleFn?: (variant?: GlassEffectVariant) => number; |
| 934 | onCreate?: (effectView: UIVisualEffectView, effect: UIVisualEffect) => void; |
| 935 | onUpdate?: (effectView: UIVisualEffectView, effect: UIVisualEffect, duration: number) => void; |
| 936 | }, |
| 937 | ): UIVisualEffectView | undefined { |
| 938 | const config: GlassEffectConfig | null = typeof value !== 'string' ? value : null; |
| 939 | const variant = config ? config.variant : (value as GlassEffectVariant); |
| 940 | const defaultDuration = 0.3; |
| 941 | const duration = config ? (config.animateChangeDuration ?? defaultDuration) : defaultDuration; |
| 942 | const glassSupported = supportsGlass(); |
| 943 | let effect: UIVisualEffect = UIVisualEffect.new(); |
| 944 | |
| 945 | // Create the appropriate effect based on type and variant |
| 946 | if (value && !['identity', 'none'].includes(variant) && glassSupported) { |
| 947 | if (options.effectType === 'glass') { |
| 948 | const styleFn = options.toGlassStyleFn || this.toUIGlassStyle.bind(this); |
| 949 | effect = UIGlassEffect.effectWithStyle(styleFn(variant)); |
| 950 | if (config) { |
| 951 | (effect as UIGlassEffect).interactive = !!config.interactive; |
| 952 | if (config.tint) { |
| 953 | (effect as UIGlassEffect).tintColor = typeof config.tint === 'string' ? new Color(config.tint).ios : config.tint; |
| 954 | } |
| 955 | } |
| 956 | } else if (options.effectType === 'container') { |
| 957 | effect = UIGlassContainerEffect.alloc().init(); |
| 958 | (effect as UIGlassContainerEffect).spacing = config?.spacing ?? 8; |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | // Handle creating new effect view or updating existing one |
| 963 | if (options.targetView) { |
| 964 | // Update existing effect view |
| 965 | if (options.onUpdate) { |
| 966 | options.onUpdate(options.targetView, effect, duration); |
| 967 | } else { |
| 968 | // Default update behavior: animate effect changes |
| 969 | UIView.animateWithDurationAnimations(duration, () => { |
| 970 | options.targetView.effect = effect; |
| 971 | }); |
| 972 | } |
| 973 | return undefined; |
| 974 | } else if (options.onCreate) { |
| 975 | // Create new effect view and let caller handle setup |
| 976 | const effectView = UIVisualEffectView.alloc().initWithEffect(effect); |
| 977 | options.onCreate(effectView, effect); |
| 978 | return effectView; |
| 979 | } |
| 980 | return undefined; |
| 981 | } |
| 982 | [statusBarStyleProperty.getDefault]() { |
| 983 | return this.style.statusBarStyle; |
| 984 | } |
no test coverage detected