Skip to content

Commit 830a00d

Browse files
committed
fix: building on old xcode, code examples
1 parent 38692a3 commit 830a00d

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,25 @@ npm install @callstack/liquid-glass
2222
yarn add @callstack/liquid-glass
2323
```
2424

25+
> [!WARNING]
26+
> Make sure to compile your app with Xcode >= 26.
27+
2528
### Usage
2629

2730
```tsx
2831
import { LiquidGlassView } from '@callstack/liquid-glass';
2932

33+
// Handle fallback for unsupported iOS versions
34+
const supportsLiquidGlass =
35+
Platform.OS === 'ios' && Number(Platform.Version.split('.').at(0)) >= 26;
36+
3037
function MyComponent() {
3138
return (
3239
<LiquidGlassView
33-
style={{ width: 200, height: 100, borderRadius: 20 }}
40+
style={[
41+
{ width: 200, height: 100, borderRadius: 20 },
42+
!supportsLiquidGlass && { backgroundColor: 'rgba(255,255,255,0.5)' },
43+
]}
3444
interactive
3545
effect="clear"
3646
>
@@ -40,6 +50,9 @@ function MyComponent() {
4050
}
4151
```
4252

53+
> [!NOTE]
54+
> On unsupported iOS version (below iOS 26), it will render a normal `View` without any effects.
55+
4356
### LiquidGlassView - Props
4457

4558
| Prop | Type | Default | Description |
@@ -49,6 +62,10 @@ function MyComponent() {
4962
| `tintColor` | `ColorValue` | `undefined` | Overlay color tint applied to the glass effect. Accepts any React Native color format (hex, rgba, named colors) |
5063
| `colorScheme` | `'light' \| 'dark' \| 'system'` | `'system'` | Color scheme adaptation:<br/>• `light` - Light appearance<br/>• `dark` - Dark appearance<br/>• `system` - Follows system appearance |
5164

65+
## Known issues
66+
67+
- `interactive` prop is not changed dynamically, it is only set on mount.
68+
5269
## Made with ❤️ at Callstack
5370

5471
`liquid-glass` is an open source project and will always remain free to use. If you think it's cool, please star it 🌟.

ios/LiquidGlassContainerView.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ - (instancetype)initWithFrame:(CGRect)frame
3838
return self;
3939
}
4040

41+
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 260000 /* __IPHONE_26_0 */
42+
4143
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
4244
{
4345
const auto &oldViewProps = *std::static_pointer_cast<LiquidGlassContainerViewProps const>(_props);
@@ -46,8 +48,6 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
4648
if (oldViewProps.spacing != newViewProps.spacing) {
4749
[_view setSpacing:newViewProps.spacing];
4850
}
49-
50-
5151

5252
[super updateProps:props oldProps:oldProps];
5353
}
@@ -59,6 +59,7 @@ - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompone
5959
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
6060
[childComponentView removeFromSuperview];
6161
}
62+
#endif
6263

6364
@end
6465

ios/LiquidGlassContainerView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import UIKit
22

3+
#if compiler(>=6.2)
34

45
@objc public class LiquidGlassConatinerViewImpl: UIVisualEffectView {
56
public override func layoutSubviews() {
@@ -20,3 +21,8 @@ import UIKit
2021
}
2122
}
2223

24+
#else
25+
26+
@objc public class LiquidGlassConatinerViewImpl: UIView {}
27+
28+
#endif

ios/LiquidGlassView.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ - (instancetype)initWithFrame:(CGRect)frame
3939

4040
return self;
4141
}
42+
43+
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 260000 /* __IPHONE_26_0 */
4244
- (void)layoutSubviews {
4345
[super layoutSubviews];
4446
_view.layer.cornerRadius = self.layer.cornerRadius;
4547
_view.layer.cornerCurve = self.layer.cornerCurve;
4648
}
4749

48-
4950
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
5051
{
5152
const auto &oldViewProps = *std::static_pointer_cast<LiquidGlassViewProps const>(_props);
5253
const auto &newViewProps = *std::static_pointer_cast<LiquidGlassViewProps const>(props);
5354

54-
5555
if (oldViewProps.tintColor != newViewProps.tintColor) {
5656
_view.effectTintColor = RCTUIColorFromSharedColor(newViewProps.tintColor);
5757
}
@@ -113,4 +113,6 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
113113
[childComponentView removeFromSuperview];
114114
}
115115

116+
#endif
117+
116118
@end

ios/LiquidGlassView.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import UIKit
22

33

4+
#if compiler(>=6.2)
5+
46
@available(iOS 26.0, *)
57
@objc public class LiquidGlassViewImpl: UIVisualEffectView {
68
@objc public var effectTintColor: UIColor?
@@ -20,3 +22,10 @@ import UIKit
2022
self.effect = glassEffect
2123
}
2224
}
25+
26+
#else
27+
28+
@objc public class LiquidGlassViewImpl: UIView {}
29+
30+
#endif
31+

0 commit comments

Comments
 (0)