@sbaiahmed1/react-native-blur 3.1.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +319 -308
- package/ReactNativeBlur.podspec +1 -1
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeBlurViewManagerDelegate.java +18 -3
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeBlurViewManagerInterface.java +6 -1
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassEffectContainerManagerDelegate.java +53 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassEffectContainerManagerInterface.java +25 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassViewManagerDelegate.java +38 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassViewManagerInterface.java +20 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.cpp +1 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.h +1 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.cpp +1 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.h +7 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/Props.cpp +21 -2
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/Props.h +70 -2
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.cpp +1 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.h +11 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/States.h +12 -0
- package/android/build.gradle +2 -3
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt +62 -269
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurViewManager.kt +13 -8
- package/ios/Helpers/BlurStyleHelpers.swift +1 -1
- package/ios/Helpers/ReactNativeBlurViewHelper.swift +8 -32
- package/ios/Helpers/ReactNativeLiquidGlassViewHelper.swift +44 -0
- package/ios/ReactNativeBlurView.mm +28 -74
- package/ios/{ReactNativeBlurViewManager.m → ReactNativeBlurViewManager.mm} +15 -39
- package/ios/ReactNativeLiquidGlassView.h +14 -0
- package/ios/ReactNativeLiquidGlassView.mm +284 -0
- package/ios/ReactNativeLiquidGlassViewManager.h +6 -0
- package/ios/ReactNativeLiquidGlassViewManager.mm +20 -0
- package/ios/Views/AdvancedBlurView.swift +6 -34
- package/ios/Views/BasicColoredView.swift +37 -44
- package/ios/Views/LiquidGlassContainerView.swift +173 -0
- package/lib/module/BlurView.js +17 -31
- package/lib/module/BlurView.js.map +1 -1
- package/lib/module/LiquidGlassView.js +75 -0
- package/lib/module/LiquidGlassView.js.map +1 -0
- package/lib/module/ReactNativeBlurViewNativeComponent.ts +1 -7
- package/lib/module/ReactNativeLiquidGlassViewNativeComponent.ts +57 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/BlurView.d.ts +19 -39
- package/lib/typescript/src/BlurView.d.ts.map +1 -1
- package/lib/typescript/src/LiquidGlassView.d.ts +85 -0
- package/lib/typescript/src/LiquidGlassView.d.ts.map +1 -0
- package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts +1 -6
- package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/ReactNativeLiquidGlassViewNativeComponent.d.ts +44 -0
- package/lib/typescript/src/ReactNativeLiquidGlassViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/BlurView.tsx +37 -68
- package/src/LiquidGlassView.tsx +138 -0
- package/src/ReactNativeBlurViewNativeComponent.ts +1 -7
- package/src/ReactNativeLiquidGlassViewNativeComponent.ts +57 -0
- package/src/index.tsx +6 -0
|
@@ -1,59 +1,35 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
|
-
// MARK: - UIKit Wrapper
|
|
4
|
+
// MARK: - UIKit Wrapper for Blur
|
|
5
5
|
|
|
6
6
|
@objc public class AdvancedBlurView: UIView {
|
|
7
7
|
|
|
8
8
|
private var hostingController: UIHostingController<BasicColoredView>?
|
|
9
9
|
|
|
10
|
-
@objc public var glassTintColor: UIColor = .clear {
|
|
11
|
-
didSet {
|
|
12
|
-
updateView()
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@objc public var glassOpacity: Double = 1.0 {
|
|
17
|
-
didSet {
|
|
18
|
-
updateView()
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
10
|
@objc public var blurAmount: Double = 10.0 {
|
|
23
11
|
didSet {
|
|
24
12
|
updateView()
|
|
25
13
|
}
|
|
26
14
|
}
|
|
27
15
|
|
|
28
|
-
@objc public var type: String = "blur" {
|
|
29
|
-
didSet {
|
|
30
|
-
updateView()
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
16
|
@objc public var blurTypeString: String = "xlight" {
|
|
35
17
|
didSet {
|
|
36
18
|
updateView()
|
|
37
19
|
}
|
|
38
20
|
}
|
|
39
21
|
|
|
40
|
-
@objc public var glassType: String = "clear" {
|
|
41
|
-
didSet {
|
|
42
|
-
updateView()
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
22
|
@objc public var reducedTransparencyFallbackColor: UIColor = .white {
|
|
47
23
|
didSet {
|
|
48
24
|
updateView()
|
|
49
25
|
}
|
|
50
26
|
}
|
|
51
27
|
|
|
52
|
-
@objc public var
|
|
28
|
+
@objc public var ignoreSafeArea: Bool = false {
|
|
53
29
|
didSet {
|
|
54
30
|
updateView()
|
|
55
31
|
}
|
|
56
|
-
|
|
32
|
+
}
|
|
57
33
|
|
|
58
34
|
public override init(frame: CGRect) {
|
|
59
35
|
super.init(frame: frame)
|
|
@@ -82,14 +58,10 @@ import UIKit
|
|
|
82
58
|
|
|
83
59
|
let blurStyle = blurStyleFromString(blurTypeString)
|
|
84
60
|
let swiftUIView = BasicColoredView(
|
|
85
|
-
glassTintColor: glassTintColor,
|
|
86
|
-
glassOpacity: glassOpacity,
|
|
87
61
|
blurAmount: blurAmount,
|
|
88
62
|
blurStyle: blurStyle,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
reducedTransparencyFallbackColor: reducedTransparencyFallbackColor,
|
|
92
|
-
isInteractive: isInteractive
|
|
63
|
+
ignoreSafeArea: ignoreSafeArea,
|
|
64
|
+
reducedTransparencyFallbackColor: reducedTransparencyFallbackColor
|
|
93
65
|
)
|
|
94
66
|
|
|
95
67
|
let hosting = UIHostingController(rootView: swiftUIView)
|
|
@@ -117,7 +89,7 @@ import UIKit
|
|
|
117
89
|
setupHostingController()
|
|
118
90
|
}
|
|
119
91
|
}
|
|
120
|
-
|
|
92
|
+
|
|
121
93
|
public override func didMoveToWindow() {
|
|
122
94
|
super.didMoveToWindow()
|
|
123
95
|
if window != nil {
|
|
@@ -3,56 +3,49 @@
|
|
|
3
3
|
import SwiftUI
|
|
4
4
|
import UIKit
|
|
5
5
|
|
|
6
|
-
// MARK: - SwiftUI View Component
|
|
6
|
+
// MARK: - SwiftUI View Component for Blur
|
|
7
7
|
|
|
8
8
|
struct BasicColoredView: View {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var glassType: String
|
|
15
|
-
var reducedTransparencyFallbackColor: UIColor
|
|
16
|
-
var isInteractive: Bool
|
|
9
|
+
let blurAmount: Double
|
|
10
|
+
let blurStyle: UIBlurEffect.Style
|
|
11
|
+
let reducedTransparencyFallbackColor: UIColor
|
|
12
|
+
let blurIntensity: Double
|
|
13
|
+
let ignoreSafeArea: Bool
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
let isReducedTransparencyEnabled = UIAccessibility.isReduceTransparencyEnabled
|
|
16
|
+
|
|
17
|
+
init(blurAmount: Double,
|
|
18
|
+
blurStyle: UIBlurEffect.Style,
|
|
19
|
+
ignoreSafeArea: Bool,
|
|
20
|
+
reducedTransparencyFallbackColor: UIColor) {
|
|
21
|
+
self.blurAmount = blurAmount
|
|
22
|
+
self.blurStyle = blurStyle
|
|
23
|
+
self.ignoreSafeArea = ignoreSafeArea
|
|
24
|
+
self.reducedTransparencyFallbackColor = reducedTransparencyFallbackColor
|
|
25
|
+
self.blurIntensity = mapBlurAmountToIntensity(blurAmount)
|
|
26
|
+
}
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
var body: some View {
|
|
29
|
+
content
|
|
30
|
+
.ignoresSafeArea(ignoreSafeArea ? .all : [])
|
|
31
|
+
}
|
|
23
32
|
|
|
33
|
+
private var content: some View {
|
|
24
34
|
if isReducedTransparencyEnabled {
|
|
25
|
-
|
|
26
|
-
Rectangle()
|
|
27
|
-
.fill(Color(reducedTransparencyFallbackColor))
|
|
28
|
-
} else {
|
|
29
|
-
if (type == "liquidGlass"){
|
|
30
|
-
if #available(iOS 26.0, *) {
|
|
31
|
-
let baseGlassEffect = glassEffectFromString(glassType)
|
|
32
|
-
Rectangle()
|
|
33
|
-
.glassEffect(
|
|
34
|
-
baseGlassEffect
|
|
35
|
-
.tint(Color(glassTintColor)
|
|
36
|
-
.opacity(glassOpacity))
|
|
37
|
-
.interactive(isInteractive)
|
|
38
|
-
, in: .rect)
|
|
39
|
-
|
|
40
|
-
} else {
|
|
41
|
-
// Use proper blur intensity control for liquid glass fallback
|
|
42
|
-
Rectangle()
|
|
43
|
-
.fill(Color(.clear))
|
|
44
|
-
.background(Blur(style: blurStyle, intensity: blurIntensity))
|
|
45
|
-
.overlay(
|
|
46
|
-
Color(glassTintColor)
|
|
47
|
-
.opacity(glassOpacity)
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
}else {
|
|
51
|
-
// Use proper blur intensity control for regular blur
|
|
35
|
+
AnyView(
|
|
52
36
|
Rectangle()
|
|
53
|
-
.fill(Color(
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
.fill(Color(reducedTransparencyFallbackColor))
|
|
38
|
+
)
|
|
39
|
+
} else {
|
|
40
|
+
AnyView(regularBlurView)
|
|
56
41
|
}
|
|
57
42
|
}
|
|
58
|
-
|
|
43
|
+
|
|
44
|
+
private var regularBlurView: some View {
|
|
45
|
+
// Use proper blur intensity control for regular blur
|
|
46
|
+
Rectangle()
|
|
47
|
+
.fill(Color(.clear))
|
|
48
|
+
.background(Blur(style: blurStyle, intensity: blurIntensity))
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
// MARK: - UIKit-only Wrapper for Liquid Glass (following Expo's approach)
|
|
4
|
+
|
|
5
|
+
@objc public class LiquidGlassContainerView: UIView {
|
|
6
|
+
private var glassEffectView: UIVisualEffectView?
|
|
7
|
+
private var glassEffect: Any?
|
|
8
|
+
private var currentGlassStyle: String = "clear" // Track current style
|
|
9
|
+
|
|
10
|
+
@objc public var glassTintColor: UIColor = .clear {
|
|
11
|
+
didSet {
|
|
12
|
+
updateEffect()
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@objc public var glassOpacity: Double = 1.0 {
|
|
17
|
+
didSet {
|
|
18
|
+
updateEffect()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@objc public var glassType: String = "clear" {
|
|
23
|
+
didSet {
|
|
24
|
+
updateEffect()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@objc public var reducedTransparencyFallbackColor: UIColor = .white {
|
|
29
|
+
didSet {
|
|
30
|
+
updateFallback()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@objc public var isInteractive: Bool = true {
|
|
35
|
+
didSet {
|
|
36
|
+
updateEffect()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@objc public var ignoreSafeArea: Bool = false {
|
|
41
|
+
didSet {
|
|
42
|
+
// Not used in UIKit approach
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Border radius storage for React Native's style system
|
|
47
|
+
private var topLeftRadius: CGFloat = 0
|
|
48
|
+
private var topRightRadius: CGFloat = 0
|
|
49
|
+
private var bottomLeftRadius: CGFloat = 0
|
|
50
|
+
private var bottomRightRadius: CGFloat = 0
|
|
51
|
+
private var allBorderRadius: CGFloat = 0
|
|
52
|
+
|
|
53
|
+
public override init(frame: CGRect) {
|
|
54
|
+
super.init(frame: frame)
|
|
55
|
+
setupView()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
required init?(coder: NSCoder) {
|
|
59
|
+
super.init(coder: coder)
|
|
60
|
+
setupView()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private func setupView() {
|
|
64
|
+
let effectView = UIVisualEffectView()
|
|
65
|
+
effectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
66
|
+
effectView.frame = bounds
|
|
67
|
+
addSubview(effectView)
|
|
68
|
+
self.glassEffectView = effectView
|
|
69
|
+
|
|
70
|
+
updateEffect()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// MARK: - Border Radius Methods (called by React Native's style system)
|
|
74
|
+
|
|
75
|
+
@objc public func setBorderRadius(_ radius: CGFloat) {
|
|
76
|
+
allBorderRadius = radius
|
|
77
|
+
topLeftRadius = radius
|
|
78
|
+
topRightRadius = radius
|
|
79
|
+
bottomLeftRadius = radius
|
|
80
|
+
bottomRightRadius = radius
|
|
81
|
+
updateBorderRadius()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@objc public func setBorderTopLeftRadius(_ radius: CGFloat) {
|
|
85
|
+
topLeftRadius = radius
|
|
86
|
+
updateBorderRadius()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@objc public func setBorderTopRightRadius(_ radius: CGFloat) {
|
|
90
|
+
topRightRadius = radius
|
|
91
|
+
updateBorderRadius()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@objc public func setBorderBottomLeftRadius(_ radius: CGFloat) {
|
|
95
|
+
bottomLeftRadius = radius
|
|
96
|
+
updateBorderRadius()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@objc public func setBorderBottomRightRadius(_ radius: CGFloat) {
|
|
100
|
+
bottomRightRadius = radius
|
|
101
|
+
updateBorderRadius()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private func updateEffect() {
|
|
105
|
+
if #available(iOS 26.0, *) {
|
|
106
|
+
#if compiler(>=6.2)
|
|
107
|
+
let style: UIGlassEffect.Style = glassType == "regular" ? .regular : .clear
|
|
108
|
+
|
|
109
|
+
// Always create a new effect to ensure proper rendering
|
|
110
|
+
let effect = UIGlassEffect(style: style)
|
|
111
|
+
effect.tintColor = glassTintColor.withAlphaComponent(glassOpacity)
|
|
112
|
+
effect.isInteractive = isInteractive
|
|
113
|
+
|
|
114
|
+
glassEffectView?.effect = effect
|
|
115
|
+
glassEffect = effect
|
|
116
|
+
currentGlassStyle = glassType
|
|
117
|
+
|
|
118
|
+
updateBorderRadius()
|
|
119
|
+
#endif
|
|
120
|
+
} else {
|
|
121
|
+
// Fallback for iOS < 26
|
|
122
|
+
updateFallback()
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private func updateFallback() {
|
|
127
|
+
if #available(iOS 26.0, *) {
|
|
128
|
+
// Do nothing if iOS 26+
|
|
129
|
+
} else {
|
|
130
|
+
backgroundColor = reducedTransparencyFallbackColor
|
|
131
|
+
layer.cornerRadius = allBorderRadius
|
|
132
|
+
layer.masksToBounds = true
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private func updateBorderRadius() {
|
|
137
|
+
if #available(iOS 26.0, *) {
|
|
138
|
+
#if compiler(>=6.2)
|
|
139
|
+
let topLeft = UICornerRadius(floatLiteral: Double(topLeftRadius))
|
|
140
|
+
let topRight = UICornerRadius(floatLiteral: Double(topRightRadius))
|
|
141
|
+
let bottomLeft = UICornerRadius(floatLiteral: Double(bottomLeftRadius))
|
|
142
|
+
let bottomRight = UICornerRadius(floatLiteral: Double(bottomRightRadius))
|
|
143
|
+
|
|
144
|
+
glassEffectView?.cornerConfiguration = .corners(
|
|
145
|
+
topLeftRadius: topLeft,
|
|
146
|
+
topRightRadius: topRight,
|
|
147
|
+
bottomLeftRadius: bottomLeft,
|
|
148
|
+
bottomRightRadius: bottomRight
|
|
149
|
+
)
|
|
150
|
+
#else
|
|
151
|
+
layer.cornerRadius = allBorderRadius
|
|
152
|
+
layer.masksToBounds = true
|
|
153
|
+
#endif
|
|
154
|
+
} else {
|
|
155
|
+
layer.cornerRadius = allBorderRadius
|
|
156
|
+
layer.masksToBounds = true
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public override func layoutSubviews() {
|
|
161
|
+
super.layoutSubviews()
|
|
162
|
+
glassEffectView?.frame = bounds
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// For child view mounting
|
|
166
|
+
@objc public func getContentView() -> UIView? {
|
|
167
|
+
if #available(iOS 26.0, *) {
|
|
168
|
+
return glassEffectView?.contentView
|
|
169
|
+
} else {
|
|
170
|
+
return self
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
package/lib/module/BlurView.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { View } from 'react-native';
|
|
4
|
+
import { StyleSheet, View } from 'react-native';
|
|
5
5
|
import ReactNativeBlurView from './ReactNativeBlurViewNativeComponent';
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
7
|
/**
|
|
@@ -32,60 +32,46 @@ export const BlurView = ({
|
|
|
32
32
|
reducedTransparencyFallbackColor = '#FFFFFF',
|
|
33
33
|
style,
|
|
34
34
|
children,
|
|
35
|
-
|
|
36
|
-
glassType = 'clear',
|
|
37
|
-
glassTintColor = 'clear',
|
|
38
|
-
glassOpacity = 1.0,
|
|
39
|
-
isInteractive = true,
|
|
35
|
+
ignoreSafeArea = false,
|
|
40
36
|
...props
|
|
41
37
|
}) => {
|
|
42
38
|
// If no children, render the blur view directly (for background use)
|
|
43
39
|
if (React.Children.count(children) === 0) {
|
|
44
40
|
return /*#__PURE__*/_jsx(ReactNativeBlurView, {
|
|
41
|
+
ignoreSafeArea: ignoreSafeArea,
|
|
45
42
|
blurType: blurType,
|
|
46
43
|
blurAmount: blurAmount,
|
|
47
|
-
glassType: glassType,
|
|
48
|
-
glassTintColor: glassTintColor,
|
|
49
|
-
glassOpacity: glassOpacity,
|
|
50
|
-
type: type,
|
|
51
44
|
reducedTransparencyFallbackColor: reducedTransparencyFallbackColor,
|
|
52
45
|
style: style,
|
|
53
|
-
isInteractive: isInteractive,
|
|
54
46
|
...props
|
|
55
47
|
});
|
|
56
48
|
}
|
|
57
49
|
|
|
58
50
|
// If children exist, use the absolute positioning pattern
|
|
59
51
|
return /*#__PURE__*/_jsxs(View, {
|
|
60
|
-
style: [
|
|
61
|
-
position: 'relative',
|
|
62
|
-
overflow: 'hidden'
|
|
63
|
-
}, style],
|
|
52
|
+
style: [styles.container, style],
|
|
64
53
|
children: [/*#__PURE__*/_jsx(ReactNativeBlurView, {
|
|
54
|
+
ignoreSafeArea: ignoreSafeArea,
|
|
65
55
|
blurType: blurType,
|
|
66
56
|
blurAmount: blurAmount,
|
|
67
|
-
glassType: glassType,
|
|
68
|
-
glassTintColor: glassTintColor,
|
|
69
|
-
glassOpacity: glassOpacity,
|
|
70
|
-
type: type,
|
|
71
|
-
isInteractive: isInteractive,
|
|
72
57
|
reducedTransparencyFallbackColor: reducedTransparencyFallbackColor,
|
|
73
|
-
style:
|
|
74
|
-
position: 'absolute',
|
|
75
|
-
top: 0,
|
|
76
|
-
left: 0,
|
|
77
|
-
right: 0,
|
|
78
|
-
bottom: 0
|
|
79
|
-
},
|
|
58
|
+
style: StyleSheet.absoluteFill,
|
|
80
59
|
...props
|
|
81
60
|
}), /*#__PURE__*/_jsx(View, {
|
|
82
|
-
style:
|
|
83
|
-
position: 'relative',
|
|
84
|
-
zIndex: 1
|
|
85
|
-
},
|
|
61
|
+
style: styles.children,
|
|
86
62
|
children: children
|
|
87
63
|
})]
|
|
88
64
|
});
|
|
89
65
|
};
|
|
90
66
|
export default BlurView;
|
|
67
|
+
const styles = StyleSheet.create({
|
|
68
|
+
container: {
|
|
69
|
+
position: 'relative',
|
|
70
|
+
overflow: 'hidden'
|
|
71
|
+
},
|
|
72
|
+
children: {
|
|
73
|
+
position: 'relative',
|
|
74
|
+
zIndex: 1
|
|
75
|
+
}
|
|
76
|
+
});
|
|
91
77
|
//# sourceMappingURL=BlurView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","ReactNativeBlurView","jsx","_jsx","jsxs","_jsxs","BlurView","blurType","blurAmount","reducedTransparencyFallbackColor","style","children","
|
|
1
|
+
{"version":3,"names":["React","StyleSheet","View","ReactNativeBlurView","jsx","_jsx","jsxs","_jsxs","BlurView","blurType","blurAmount","reducedTransparencyFallbackColor","style","children","ignoreSafeArea","props","Children","count","styles","container","absoluteFill","create","position","overflow","zIndex"],"sourceRoot":"../../src","sources":["BlurView.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAE/C,OAAOC,mBAAmB,MAEnB,sCAAsC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAgD9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAiC,GAAGA,CAAC;EAChDC,QAAQ,GAAG,QAAQ;EACnBC,UAAU,GAAG,EAAE;EACfC,gCAAgC,GAAG,SAAS;EAC5CC,KAAK;EACLC,QAAQ;EACRC,cAAc,GAAG,KAAK;EACtB,GAAGC;AACL,CAAC,KAAK;EACJ;EACA,IAAIf,KAAK,CAACgB,QAAQ,CAACC,KAAK,CAACJ,QAAQ,CAAC,KAAK,CAAC,EAAE;IACxC,oBACER,IAAA,CAACF,mBAAmB;MAClBW,cAAc,EAAEA,cAAe;MAC/BL,QAAQ,EAAEA,QAAS;MACnBC,UAAU,EAAEA,UAAW;MACvBC,gCAAgC,EAAEA,gCAAiC;MACnEC,KAAK,EAAEA,KAAM;MAAA,GACTG;IAAK,CACV,CAAC;EAEN;;EAEA;EACA,oBACER,KAAA,CAACL,IAAI;IAACU,KAAK,EAAE,CAACM,MAAM,CAACC,SAAS,EAAEP,KAAK,CAAE;IAAAC,QAAA,gBAErCR,IAAA,CAACF,mBAAmB;MAClBW,cAAc,EAAEA,cAAe;MAC/BL,QAAQ,EAAEA,QAAS;MACnBC,UAAU,EAAEA,UAAW;MACvBC,gCAAgC,EAAEA,gCAAiC;MACnEC,KAAK,EAAEX,UAAU,CAACmB,YAAa;MAAA,GAC3BL;IAAK,CACV,CAAC,eAEFV,IAAA,CAACH,IAAI;MAACU,KAAK,EAAEM,MAAM,CAACL,QAAS;MAAAA,QAAA,EAAEA;IAAQ,CAAO,CAAC;EAAA,CAC3C,CAAC;AAEX,CAAC;AAED,eAAeL,QAAQ;AAEvB,MAAMU,MAAM,GAAGjB,UAAU,CAACoB,MAAM,CAAC;EAC/BF,SAAS,EAAE;IACTG,QAAQ,EAAE,UAAU;IACpBC,QAAQ,EAAE;EACZ,CAAC;EACDV,QAAQ,EAAE;IACRS,QAAQ,EAAE,UAAU;IACpBE,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Platform } from 'react-native';
|
|
5
|
+
import ReactNativeLiquidGlassView from './ReactNativeLiquidGlassViewNativeComponent';
|
|
6
|
+
import BlurView from "./BlurView.js";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
/**
|
|
9
|
+
* A Liquid Glass view component that provides iOS 26+ glass effects.
|
|
10
|
+
*
|
|
11
|
+
* This component uses the new UIKit glass effect API available on iOS 26+.
|
|
12
|
+
* On older iOS versions or when reduced transparency is enabled, it falls back
|
|
13
|
+
* to a solid color background.
|
|
14
|
+
*
|
|
15
|
+
* **Platform Support:**
|
|
16
|
+
* - iOS 26+: Native glass effect with full functionality
|
|
17
|
+
* - iOS < 26 or Android: Fallback to reducedTransparencyFallbackColor
|
|
18
|
+
*
|
|
19
|
+
* This component automatically handles the proper positioning pattern where the glass
|
|
20
|
+
* effect is positioned absolutely behind the content, ensuring interactive elements
|
|
21
|
+
* work correctly.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { LiquidGlassView } from '@sbaiahmed1/react-native-blur';
|
|
26
|
+
*
|
|
27
|
+
* <LiquidGlassView
|
|
28
|
+
* glassType="clear"
|
|
29
|
+
* glassTintColor="#007AFF"
|
|
30
|
+
* glassOpacity={0.8}
|
|
31
|
+
* style={{ flex: 1 }}
|
|
32
|
+
* >
|
|
33
|
+
* <Text>Content on top of liquid glass</Text>
|
|
34
|
+
* <Button title="Interactive Button" onPress={() => {}} />
|
|
35
|
+
* </LiquidGlassView>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @platform ios
|
|
39
|
+
*/
|
|
40
|
+
export const LiquidGlassView = ({
|
|
41
|
+
glassType = 'clear',
|
|
42
|
+
glassTintColor = 'clear',
|
|
43
|
+
glassOpacity = 1.0,
|
|
44
|
+
reducedTransparencyFallbackColor = '#FFFFFF',
|
|
45
|
+
isInteractive = true,
|
|
46
|
+
ignoreSafeArea = false,
|
|
47
|
+
style,
|
|
48
|
+
children,
|
|
49
|
+
...props
|
|
50
|
+
}) => {
|
|
51
|
+
// Only render on iOS 26+ (fallback otherwise)
|
|
52
|
+
if (Platform.OS !== 'ios' || Platform.OS === 'ios' && parseInt(Platform.Version, 10) < 26) {
|
|
53
|
+
console.warn('LiquidGlassView is only supported on iOS. Rendering children without glass effect.');
|
|
54
|
+
return /*#__PURE__*/_jsx(BlurView, {
|
|
55
|
+
blurAmount: 70,
|
|
56
|
+
style: style,
|
|
57
|
+
children: children
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// If children exist, use the absolute positioning pattern
|
|
62
|
+
return /*#__PURE__*/_jsx(ReactNativeLiquidGlassView, {
|
|
63
|
+
glassType: glassType,
|
|
64
|
+
glassTintColor: glassTintColor,
|
|
65
|
+
glassOpacity: glassOpacity,
|
|
66
|
+
reducedTransparencyFallbackColor: reducedTransparencyFallbackColor,
|
|
67
|
+
isInteractive: isInteractive,
|
|
68
|
+
ignoreSafeArea: ignoreSafeArea,
|
|
69
|
+
style: style,
|
|
70
|
+
...props,
|
|
71
|
+
children: children
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
export default LiquidGlassView;
|
|
75
|
+
//# sourceMappingURL=LiquidGlassView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Platform","ReactNativeLiquidGlassView","BlurView","jsx","_jsx","LiquidGlassView","glassType","glassTintColor","glassOpacity","reducedTransparencyFallbackColor","isInteractive","ignoreSafeArea","style","children","props","OS","parseInt","Version","console","warn","blurAmount"],"sourceRoot":"../../src","sources":["LiquidGlassView.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,cAAc;AAEvC,OAAOC,0BAA0B,MAE1B,6CAA6C;AACpD,OAAOC,QAAQ,MAAM,eAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAwDlC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAA+C,GAAGA,CAAC;EAC9DC,SAAS,GAAG,OAAO;EACnBC,cAAc,GAAG,OAAO;EACxBC,YAAY,GAAG,GAAG;EAClBC,gCAAgC,GAAG,SAAS;EAC5CC,aAAa,GAAG,IAAI;EACpBC,cAAc,GAAG,KAAK;EACtBC,KAAK;EACLC,QAAQ;EACR,GAAGC;AACL,CAAC,KAAK;EACJ;EACA,IACEd,QAAQ,CAACe,EAAE,KAAK,KAAK,IACpBf,QAAQ,CAACe,EAAE,KAAK,KAAK,IAAIC,QAAQ,CAAChB,QAAQ,CAACiB,OAAO,EAAE,EAAE,CAAC,GAAG,EAAG,EAC9D;IACAC,OAAO,CAACC,IAAI,CACV,oFACF,CAAC;IACD,oBACEf,IAAA,CAACF,QAAQ;MAACkB,UAAU,EAAE,EAAG;MAACR,KAAK,EAAEA,KAAM;MAAAC,QAAA,EACpCA;IAAQ,CACD,CAAC;EAEf;;EAEA;EACA,oBACET,IAAA,CAACH,0BAA0B;IACzBK,SAAS,EAAEA,SAAU;IACrBC,cAAc,EAAEA,cAAe;IAC/BC,YAAY,EAAEA,YAAa;IAC3BC,gCAAgC,EAAEA,gCAAiC;IACnEC,aAAa,EAAEA,aAAc;IAC7BC,cAAc,EAAEA,cAAe;IAC/BC,KAAK,EAAEA,KAAM;IAAA,GACTE,KAAK;IAAAD,QAAA,EAERA;EAAQ,CACiB,CAAC;AAEjC,CAAC;AAED,eAAeR,eAAe","ignoreList":[]}
|
|
@@ -18,17 +18,11 @@ export type BlurType =
|
|
|
18
18
|
| 'systemThickMaterial'
|
|
19
19
|
| 'systemChromeMaterial';
|
|
20
20
|
|
|
21
|
-
export type GlassType = 'clear' | 'regular';
|
|
22
|
-
|
|
23
21
|
interface NativeProps extends ViewProps {
|
|
24
|
-
glassTintColor?: WithDefault<string, 'clear'>;
|
|
25
|
-
glassOpacity?: WithDefault<Double, 1.0>;
|
|
26
22
|
blurAmount?: WithDefault<Double, 10.0>;
|
|
27
|
-
type?: WithDefault<'blur' | 'liquidGlass', 'blur'>;
|
|
28
23
|
blurType?: WithDefault<BlurType, 'xlight'>;
|
|
29
|
-
glassType?: WithDefault<GlassType, 'clear'>;
|
|
30
24
|
reducedTransparencyFallbackColor?: WithDefault<string, '#FFFFFF'>;
|
|
31
|
-
|
|
25
|
+
ignoreSafeArea?: WithDefault<boolean, false>;
|
|
32
26
|
}
|
|
33
27
|
|
|
34
28
|
export default codegenNativeComponent<NativeProps>('ReactNativeBlurView');
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
WithDefault,
|
|
5
|
+
Double,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export type GlassType = 'clear' | 'regular';
|
|
9
|
+
|
|
10
|
+
interface NativeProps extends ViewProps {
|
|
11
|
+
/**
|
|
12
|
+
* The type of glass effect to apply
|
|
13
|
+
* Platform: iOS only
|
|
14
|
+
* @default 'clear'
|
|
15
|
+
*/
|
|
16
|
+
glassType?: WithDefault<GlassType, 'clear'>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The tint color of the glass effect
|
|
20
|
+
* Platform: iOS only
|
|
21
|
+
* @default 'clear'
|
|
22
|
+
*/
|
|
23
|
+
glassTintColor?: WithDefault<string, 'clear'>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The opacity of the glass effect (0-1)
|
|
27
|
+
* Platform: iOS only
|
|
28
|
+
* @default 1.0
|
|
29
|
+
*/
|
|
30
|
+
glassOpacity?: WithDefault<Double, 1.0>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Fallback color when reduced transparency is enabled
|
|
34
|
+
* Platform: iOS only
|
|
35
|
+
* @default '#FFFFFF'
|
|
36
|
+
*/
|
|
37
|
+
reducedTransparencyFallbackColor?: WithDefault<string, '#FFFFFF'>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether the glass view should be interactive
|
|
41
|
+
* Platform: iOS only
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
isInteractive?: WithDefault<boolean, true>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Whether the glass view should ignore safe area insets
|
|
48
|
+
* Platform: iOS only
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
ignoreSafeArea?: WithDefault<boolean, false>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default codegenNativeComponent<NativeProps>(
|
|
55
|
+
'ReactNativeLiquidGlassView',
|
|
56
|
+
{ excludedPlatforms: ['android'] }
|
|
57
|
+
);
|
package/lib/module/index.js
CHANGED
|
@@ -3,4 +3,6 @@
|
|
|
3
3
|
export { default as ReactNativeBlurView } from './ReactNativeBlurViewNativeComponent';
|
|
4
4
|
export * from './ReactNativeBlurViewNativeComponent';
|
|
5
5
|
export { BlurView as default, BlurView } from "./BlurView.js";
|
|
6
|
+
export { default as ReactNativeLiquidGlassView } from './ReactNativeLiquidGlassViewNativeComponent';
|
|
7
|
+
export { LiquidGlassView } from "./LiquidGlassView.js";
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","ReactNativeBlurView","BlurView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,mBAAmB,QAAQ,sCAAsC;AACrF,cAAc,sCAAsC;AAEpD,SAASC,QAAQ,IAAIF,OAAO,EAAEE,QAAQ,QAAQ,eAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["default","ReactNativeBlurView","BlurView","ReactNativeLiquidGlassView","LiquidGlassView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,mBAAmB,QAAQ,sCAAsC;AACrF,cAAc,sCAAsC;AAEpD,SAASC,QAAQ,IAAIF,OAAO,EAAEE,QAAQ,QAAQ,eAAY;AAG1D,SAASF,OAAO,IAAIG,0BAA0B,QAAQ,6CAA6C;AAGnG,SAASC,eAAe,QAAQ,sBAAmB","ignoreList":[]}
|