@apple-pie/slice-native 0.1.4 → 0.1.7
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 +164 -97
- package/SliceNative.podspec +24 -0
- package/dist/cjs/components.js +19 -0
- package/dist/cjs/hooks.js +9 -0
- package/dist/cjs/index.js +27 -812
- package/dist/cjs/providers.js +9 -0
- package/dist/cjs/src/components/SliceBackgroundBlur/SliceBackgroundBlur.js +11 -0
- package/dist/cjs/src/components/SliceButton/SliceButton.js +146 -0
- package/dist/cjs/src/components/SliceIcon/SliceIcon.js +20 -0
- package/dist/cjs/src/components/SliceIcon/iconRegistry.js +668 -0
- package/dist/cjs/src/components/SliceIcon/icons.js +144 -0
- package/dist/cjs/src/components/SliceLiquidGlassView/SliceLiquidGlassView.js +12 -0
- package/dist/cjs/src/components/SliceText/SliceText.js +21 -0
- package/dist/cjs/src/components/SliceTextInput/SliceTextInput.js +117 -0
- package/dist/cjs/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +13 -0
- package/dist/cjs/src/hooks/useDeviceCapabilities/useDeviceCapabilities.js +19 -0
- package/dist/cjs/src/providers/SliceThemeProvider.js +37 -0
- package/dist/cjs/src/theme/colors/colors.js +253 -0
- package/dist/cjs/src/theme/corners/corners.js +14 -0
- package/dist/cjs/src/theme/elevations/elevations.js +17 -0
- package/dist/cjs/src/theme/motion/motion.js +15 -0
- package/dist/cjs/src/theme/motion.js +47 -0
- package/dist/cjs/src/theme/spacing/spacing.js +14 -0
- package/dist/cjs/src/theme/type/type.js +190 -0
- package/dist/cjs/src/utils/sizes/sizes.js +40 -0
- package/dist/cjs/src/utils/typography/typography.js +17 -0
- package/dist/cjs/theme.js +23 -538
- package/dist/cjs/utils.js +10 -0
- package/dist/esm/components.mjs +7 -0
- package/dist/esm/hooks.mjs +2 -0
- package/dist/esm/index.mjs +12 -813
- package/dist/esm/providers.mjs +1 -0
- package/dist/esm/src/components/SliceBackgroundBlur/SliceBackgroundBlur.mjs +9 -0
- package/dist/esm/src/components/SliceButton/SliceButton.mjs +144 -0
- package/dist/esm/src/components/SliceIcon/SliceIcon.mjs +18 -0
- package/dist/esm/src/components/SliceIcon/iconRegistry.mjs +666 -0
- package/dist/esm/src/components/SliceIcon/icons.mjs +142 -0
- package/dist/esm/src/components/SliceLiquidGlassView/SliceLiquidGlassView.mjs +10 -0
- package/dist/esm/src/components/SliceText/SliceText.mjs +19 -0
- package/dist/esm/src/components/SliceTextInput/SliceTextInput.mjs +115 -0
- package/dist/esm/src/hooks/useCreateThemedStyles/useCreateThemedStyles.mjs +11 -0
- package/dist/esm/src/hooks/useDeviceCapabilities/useDeviceCapabilities.mjs +17 -0
- package/dist/esm/src/providers/SliceThemeProvider.mjs +33 -0
- package/dist/esm/src/theme/colors/colors.mjs +249 -0
- package/dist/esm/src/theme/corners/corners.mjs +12 -0
- package/dist/esm/src/theme/elevations/elevations.mjs +15 -0
- package/dist/esm/src/theme/motion/motion.mjs +13 -0
- package/dist/esm/src/theme/motion.mjs +45 -0
- package/dist/esm/src/theme/spacing/spacing.mjs +12 -0
- package/dist/esm/src/theme/type/type.mjs +184 -0
- package/dist/esm/src/utils/sizes/sizes.mjs +37 -0
- package/dist/esm/src/utils/typography/typography.mjs +15 -0
- package/dist/esm/theme.mjs +7 -522
- package/dist/esm/utils.mjs +2 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.js +6 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.native.js +6 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/index.js +1 -0
- package/dist/react-native/native/src/components/SliceButton/SliceButton.js +141 -0
- package/dist/react-native/native/src/components/SliceButton/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceButton/index.js +1 -0
- package/dist/react-native/native/src/components/SliceIcon/SliceIcon.js +15 -0
- package/dist/react-native/native/src/components/SliceIcon/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceIcon/iconRegistry.js +663 -0
- package/dist/react-native/native/src/components/SliceIcon/icons.js +140 -0
- package/dist/react-native/native/src/components/SliceIcon/index.js +2 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.ios.js +6 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.js +7 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/index.js +1 -0
- package/dist/react-native/native/src/components/SliceText/SliceText.js +16 -0
- package/dist/react-native/native/src/components/SliceText/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceText/index.js +1 -0
- package/dist/react-native/native/src/components/SliceTextInput/SliceTextInput.js +111 -0
- package/dist/react-native/native/src/components/SliceTextInput/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceTextInput/index.js +1 -0
- package/dist/react-native/native/src/components/index.js +6 -0
- package/dist/react-native/native/src/hooks/index.js +2 -0
- package/dist/react-native/native/src/hooks/useCreateThemedStyles/index.js +1 -0
- package/dist/react-native/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +8 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/_types.js +1 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/index.js +1 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.js +14 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.native.js +23 -0
- package/dist/react-native/native/src/index.js +6 -0
- package/dist/react-native/native/src/providers/SliceThemeProvider.js +30 -0
- package/dist/react-native/native/src/providers/index.js +1 -0
- package/dist/react-native/native/src/specs/BackgroundBlurNativeComponent.ts +16 -0
- package/dist/react-native/native/src/specs/LiquidGlassNativeComponent.ts +18 -0
- package/dist/react-native/native/src/specs/NativeDeviceCapabilities.ts +13 -0
- package/dist/react-native/native/src/theme/index.js +69 -0
- package/dist/react-native/native/src/theme/motion.js +43 -0
- package/dist/react-native/native/src/types/index.js +1 -0
- package/dist/react-native/native/src/types/sharedTypes.js +1 -0
- package/dist/react-native/native/src/utils/index.js +2 -0
- package/dist/react-native/native/src/utils/sizes/index.js +1 -0
- package/dist/react-native/native/src/utils/sizes/sizes.js +35 -0
- package/dist/react-native/native/src/utils/typography/index.js +1 -0
- package/dist/react-native/native/src/utils/typography/typography.js +13 -0
- package/dist/react-native/src/theme/colors/colors.js +385 -0
- package/dist/react-native/src/theme/colors/types.js +1 -0
- package/dist/react-native/src/theme/corners/corners.js +10 -0
- package/dist/react-native/src/theme/corners/types.js +1 -0
- package/dist/react-native/src/theme/elevations/_types.js +1 -0
- package/dist/react-native/src/theme/elevations/elevations.js +13 -0
- package/dist/react-native/src/theme/motion/_types.js +1 -0
- package/dist/react-native/src/theme/motion/motion.js +11 -0
- package/dist/react-native/src/theme/spacing/_types.js +1 -0
- package/dist/react-native/src/theme/spacing/spacing.js +10 -0
- package/dist/react-native/src/theme/type/type.js +371 -0
- package/dist/react-native/src/theme/type/types.js +1 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.d.ts +3 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.native.d.ts +2 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/_types.d.ts +24 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceButton/SliceButton.d.ts +5 -0
- package/dist/types/native/src/components/SliceButton/_types.d.ts +78 -0
- package/dist/types/native/src/components/SliceButton/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceIcon/SliceIcon.d.ts +2 -0
- package/dist/types/native/{components/Icon → src/components/SliceIcon}/icons.d.ts +1 -0
- package/dist/types/native/src/components/SliceIcon/index.d.ts +3 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.d.ts +3 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.ios.d.ts +2 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/_types.d.ts +17 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceText/SliceText.d.ts +5 -0
- package/dist/types/native/src/components/SliceText/_types.d.ts +17 -0
- package/dist/types/native/src/components/SliceText/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceTextInput/SliceTextInput.d.ts +2 -0
- package/dist/types/native/src/components/SliceTextInput/_types.d.ts +58 -0
- package/dist/types/native/src/components/SliceTextInput/index.d.ts +2 -0
- package/dist/types/native/src/components/index.d.ts +12 -0
- package/dist/types/native/src/hooks/index.d.ts +3 -0
- package/dist/types/native/src/hooks/useCreateThemedStyles/index.d.ts +1 -0
- package/dist/types/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.d.ts +7 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/_types.d.ts +17 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/index.d.ts +2 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.d.ts +3 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.native.d.ts +7 -0
- package/dist/types/native/src/index.d.ts +12 -0
- package/dist/types/native/src/providers/SliceThemeProvider.d.ts +16 -0
- package/dist/types/native/src/providers/index.d.ts +2 -0
- package/dist/types/native/src/specs/BackgroundBlurNativeComponent.d.ts +9 -0
- package/dist/types/native/src/specs/LiquidGlassNativeComponent.d.ts +9 -0
- package/dist/types/native/src/specs/NativeDeviceCapabilities.d.ts +11 -0
- package/dist/types/native/{theme → src/theme}/index.d.ts +5 -5
- package/dist/types/native/src/types/index.d.ts +1 -0
- package/dist/types/native/src/types/sharedTypes.d.ts +14 -0
- package/dist/types/native/src/utils/index.d.ts +2 -0
- package/dist/types/native/src/utils/sizes/index.d.ts +1 -0
- package/dist/types/native/src/utils/sizes/sizes.d.ts +7 -0
- package/dist/types/native/src/utils/typography/index.d.ts +1 -0
- package/dist/types/native/src/utils/typography/typography.d.ts +7 -0
- package/package.json +57 -11
- package/platform/android/build.gradle +22 -0
- package/platform/android/src/main/AndroidManifest.xml +1 -0
- package/platform/android/src/main/java/com/slice/SliceBackgroundBlurManager.java +28 -0
- package/platform/android/src/main/java/com/slice/SliceBackgroundBlurView.java +98 -0
- package/platform/android/src/main/java/com/slice/SliceDeviceCapabilitiesModule.java +25 -0
- package/platform/android/src/main/java/com/slice/SlicePackage.java +25 -0
- package/platform/ios/BackgroundBlurSurface.swift +89 -0
- package/platform/ios/LiquidGlassSurface.swift +82 -0
- package/platform/ios/RCTBackgroundBlurView.h +3 -0
- package/platform/ios/RCTBackgroundBlurView.mm +42 -0
- package/platform/ios/RCTLiquidGlassView.h +8 -0
- package/platform/ios/RCTLiquidGlassView.mm +73 -0
- package/platform/ios/SliceDeviceCapabilities.h +4 -0
- package/platform/ios/SliceDeviceCapabilities.mm +35 -0
- package/react-native.config.js +1 -0
- package/src/specs/BackgroundBlurNativeComponent.ts +16 -0
- package/src/specs/LiquidGlassNativeComponent.ts +18 -0
- package/src/specs/NativeDeviceCapabilities.ts +13 -0
- package/dist/types/native/components/Icon/NativeIcon.d.ts +0 -2
- package/dist/types/native/components/Icon/index.d.ts +0 -3
- package/dist/types/native/index.d.ts +0 -4
- /package/dist/types/native/{components/Icon → src/components/SliceIcon}/_types.d.ts +0 -0
- /package/dist/types/native/{components/Icon → src/components/SliceIcon}/iconRegistry.d.ts +0 -0
- /package/dist/types/native/{theme → src/theme}/motion.d.ts +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
/// UIKit surface owned by the Fabric component. React children live in contentView.
|
|
4
|
+
@objc(SliceLiquidGlassSurface)
|
|
5
|
+
public final class LiquidGlassSurface: UIView {
|
|
6
|
+
private let effectView = UIVisualEffectView(effect: nil)
|
|
7
|
+
private var usesClearGlass = false
|
|
8
|
+
private var glassTint: UIColor?
|
|
9
|
+
private var interactive = false
|
|
10
|
+
private var radius: CGFloat = 24
|
|
11
|
+
private var reduceTransparencyObserver: NSObjectProtocol?
|
|
12
|
+
|
|
13
|
+
@objc public var reactContentView: UIView { effectView.contentView }
|
|
14
|
+
|
|
15
|
+
public override init(frame: CGRect) {
|
|
16
|
+
super.init(frame: frame)
|
|
17
|
+
backgroundColor = .clear
|
|
18
|
+
addSubview(effectView)
|
|
19
|
+
effectView.frame = bounds
|
|
20
|
+
effectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
21
|
+
reduceTransparencyObserver = NotificationCenter.default.addObserver(
|
|
22
|
+
forName: UIAccessibility.reduceTransparencyStatusDidChangeNotification,
|
|
23
|
+
object: nil,
|
|
24
|
+
queue: .main
|
|
25
|
+
) { [weak self] _ in
|
|
26
|
+
MainActor.assumeIsolated { self?.updateEffect() }
|
|
27
|
+
}
|
|
28
|
+
updateEffect()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public required init?(coder: NSCoder) {
|
|
32
|
+
fatalError("init(coder:) has not been implemented")
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
deinit {
|
|
36
|
+
if let observer = reduceTransparencyObserver {
|
|
37
|
+
NotificationCenter.default.removeObserver(observer)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@objc public func configure(
|
|
42
|
+
clear: Bool,
|
|
43
|
+
tint: UIColor?,
|
|
44
|
+
interactive: Bool,
|
|
45
|
+
cornerRadius: CGFloat
|
|
46
|
+
) {
|
|
47
|
+
let nextRadius = cornerRadius.isFinite ? max(0, cornerRadius) : 24
|
|
48
|
+
guard usesClearGlass != clear || glassTint != tint || self.interactive != interactive || radius != nextRadius else {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
usesClearGlass = clear
|
|
52
|
+
glassTint = tint
|
|
53
|
+
self.interactive = interactive
|
|
54
|
+
radius = nextRadius
|
|
55
|
+
updateEffect()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private func updateEffect() {
|
|
59
|
+
if UIAccessibility.isReduceTransparencyEnabled {
|
|
60
|
+
effectView.effect = nil
|
|
61
|
+
effectView.backgroundColor = .secondarySystemBackground
|
|
62
|
+
} else {
|
|
63
|
+
effectView.backgroundColor = .clear
|
|
64
|
+
if #available(iOS 26.0, *) {
|
|
65
|
+
let effect = UIGlassEffect(style: usesClearGlass ? .clear : .regular)
|
|
66
|
+
effect.tintColor = glassTint
|
|
67
|
+
effect.isInteractive = interactive
|
|
68
|
+
effectView.effect = effect
|
|
69
|
+
} else {
|
|
70
|
+
effectView.effect = UIBlurEffect(style: .systemUltraThinMaterial)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if #available(iOS 26.0, *) {
|
|
75
|
+
effectView.cornerConfiguration = .corners(radius: .fixed(radius))
|
|
76
|
+
} else {
|
|
77
|
+
effectView.layer.cornerRadius = radius
|
|
78
|
+
effectView.layer.cornerCurve = .continuous
|
|
79
|
+
}
|
|
80
|
+
effectView.clipsToBounds = true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#import "RCTBackgroundBlurView.h"
|
|
2
|
+
#import "SliceNative-Swift.h"
|
|
3
|
+
#import <React/RCTConversions.h>
|
|
4
|
+
#import <react/renderer/components/SliceNativeSpec/ComponentDescriptors.h>
|
|
5
|
+
#import <react/renderer/components/SliceNativeSpec/Props.h>
|
|
6
|
+
#import <react/renderer/components/SliceNativeSpec/RCTComponentViewHelpers.h>
|
|
7
|
+
|
|
8
|
+
using namespace facebook::react;
|
|
9
|
+
@interface RCTBackgroundBlurView () <RCTSliceBackgroundBlurViewProtocol>
|
|
10
|
+
@end
|
|
11
|
+
@implementation RCTBackgroundBlurView {
|
|
12
|
+
SliceBackgroundBlurSurface *_surface;
|
|
13
|
+
}
|
|
14
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
15
|
+
return concreteComponentDescriptorProvider<SliceBackgroundBlurComponentDescriptor>();
|
|
16
|
+
}
|
|
17
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
18
|
+
if (self = [super initWithFrame:frame]) {
|
|
19
|
+
_props = std::make_shared<const SliceBackgroundBlurProps>();
|
|
20
|
+
_surface = [[SliceBackgroundBlurSurface alloc] initWithFrame:self.bounds];
|
|
21
|
+
self.contentView = _surface;
|
|
22
|
+
}
|
|
23
|
+
return self;
|
|
24
|
+
}
|
|
25
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
|
|
26
|
+
const auto &p = *std::static_pointer_cast<const SliceBackgroundBlurProps>(props);
|
|
27
|
+
NSString *direction = @"down";
|
|
28
|
+
switch (p.direction) {
|
|
29
|
+
case SliceBackgroundBlurDirection::Up: direction = @"up"; break;
|
|
30
|
+
case SliceBackgroundBlurDirection::Left: direction = @"left"; break;
|
|
31
|
+
case SliceBackgroundBlurDirection::Right: direction = @"right"; break;
|
|
32
|
+
default: break;
|
|
33
|
+
}
|
|
34
|
+
[_surface configureWithIntensity:p.blurIntensity fadeStop:p.fadeStop direction:direction fallbackColor:RCTUIColorFromSharedColor(p.fallbackColor)];
|
|
35
|
+
[super updateProps:props oldProps:oldProps];
|
|
36
|
+
}
|
|
37
|
+
- (void)prepareForRecycle {
|
|
38
|
+
[super prepareForRecycle];
|
|
39
|
+
[_surface configureWithIntensity:12 fadeStop:0 direction:@"down" fallbackColor:nil];
|
|
40
|
+
}
|
|
41
|
+
@end
|
|
42
|
+
Class<RCTComponentViewProtocol> SliceBackgroundBlurCls(void) { return RCTBackgroundBlurView.class; }
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#import "RCTLiquidGlassView.h"
|
|
2
|
+
#import "SliceNative-Swift.h"
|
|
3
|
+
#import <React/RCTConversions.h>
|
|
4
|
+
|
|
5
|
+
#import <react/renderer/components/SliceNativeSpec/ComponentDescriptors.h>
|
|
6
|
+
#import <react/renderer/components/SliceNativeSpec/Props.h>
|
|
7
|
+
#import <react/renderer/components/SliceNativeSpec/RCTComponentViewHelpers.h>
|
|
8
|
+
#import <react/renderer/graphics/Color.h>
|
|
9
|
+
|
|
10
|
+
using namespace facebook::react;
|
|
11
|
+
|
|
12
|
+
@interface RCTLiquidGlassView () <RCTSliceLiquidGlassViewViewProtocol>
|
|
13
|
+
@end
|
|
14
|
+
|
|
15
|
+
@implementation RCTLiquidGlassView {
|
|
16
|
+
SliceLiquidGlassSurface *_surface;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
20
|
+
{
|
|
21
|
+
return concreteComponentDescriptorProvider<SliceLiquidGlassViewComponentDescriptor>();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
25
|
+
{
|
|
26
|
+
if (self = [super initWithFrame:frame]) {
|
|
27
|
+
_props = std::make_shared<const SliceLiquidGlassViewProps>();
|
|
28
|
+
_surface = [[SliceLiquidGlassSurface alloc] initWithFrame:self.bounds];
|
|
29
|
+
[self addSubview:_surface];
|
|
30
|
+
}
|
|
31
|
+
return self;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
35
|
+
{
|
|
36
|
+
const auto &newProps = *std::static_pointer_cast<const SliceLiquidGlassViewProps>(props);
|
|
37
|
+
[_surface configureWithClear:newProps.glassStyle == SliceLiquidGlassViewGlassStyle::Clear
|
|
38
|
+
tint:RCTUIColorFromSharedColor(newProps.glassTintColor)
|
|
39
|
+
interactive:newProps.interactive
|
|
40
|
+
cornerRadius:newProps.cornerRadius];
|
|
41
|
+
[super updateProps:props oldProps:oldProps];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (void)layoutSubviews
|
|
45
|
+
{
|
|
46
|
+
[super layoutSubviews];
|
|
47
|
+
// Fill the entire view, including Yoga padding. Child frames already include padding.
|
|
48
|
+
_surface.frame = self.bounds;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
52
|
+
{
|
|
53
|
+
[_surface.reactContentView insertSubview:childComponentView atIndex:index];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
57
|
+
{
|
|
58
|
+
[childComponentView removeFromSuperview];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
- (void)prepareForRecycle
|
|
62
|
+
{
|
|
63
|
+
[super prepareForRecycle];
|
|
64
|
+
[_surface configureWithClear:NO tint:nil interactive:NO cornerRadius:24];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@end
|
|
68
|
+
|
|
69
|
+
// Also supports component discovery in React Native versions using the class provider.
|
|
70
|
+
Class<RCTComponentViewProtocol> SliceLiquidGlassViewCls(void)
|
|
71
|
+
{
|
|
72
|
+
return RCTLiquidGlassView.class;
|
|
73
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#import "SliceDeviceCapabilities.h"
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
#import <sys/utsname.h>
|
|
4
|
+
#import <cstdlib>
|
|
5
|
+
|
|
6
|
+
@implementation SliceDeviceCapabilities
|
|
7
|
+
RCT_EXPORT_MODULE(SliceDeviceCapabilities)
|
|
8
|
+
|
|
9
|
+
+ (BOOL)requiresMainQueueSetup { return NO; }
|
|
10
|
+
|
|
11
|
+
- (facebook::react::ModuleConstants<JS::NativeDeviceCapabilities::Constants>)constantsToExport {
|
|
12
|
+
return [self getConstants];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
- (facebook::react::ModuleConstants<JS::NativeDeviceCapabilities::Constants>)getConstants {
|
|
16
|
+
struct utsname systemInfo;
|
|
17
|
+
NSString *model = uname(&systemInfo) == 0 ? [NSString stringWithUTF8String:systemInfo.machine] : @"";
|
|
18
|
+
// Simulator uname reports the host architecture; use the simulated device instead.
|
|
19
|
+
const char *simulatorModel = getenv("SIMULATOR_MODEL_IDENTIFIER");
|
|
20
|
+
if (simulatorModel != nullptr) { model = [NSString stringWithUTF8String:simulatorModel]; }
|
|
21
|
+
BOOL supportsGlass = NO;
|
|
22
|
+
if (@available(iOS 26.0, *)) { supportsGlass = YES; }
|
|
23
|
+
return facebook::react::typedConstants<JS::NativeDeviceCapabilities::Constants>({
|
|
24
|
+
.supportsLiquidGlass = (bool)supportsGlass,
|
|
25
|
+
.supportsNativeBlur = true,
|
|
26
|
+
.deviceName = [UIDevice currentDevice].name,
|
|
27
|
+
.deviceModel = model ?: @"",
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
32
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
33
|
+
return std::make_shared<facebook::react::NativeDeviceCapabilitiesSpecJSI>(params);
|
|
34
|
+
}
|
|
35
|
+
@end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = { dependency: { platforms: { android: { sourceDir: './platform/android' } } } };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CodegenTypes,
|
|
3
|
+
type ColorValue,
|
|
4
|
+
type HostComponent,
|
|
5
|
+
type ViewProps,
|
|
6
|
+
codegenNativeComponent,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
export interface NativeProps extends ViewProps {
|
|
10
|
+
blurIntensity?: CodegenTypes.WithDefault<CodegenTypes.Double, 12>;
|
|
11
|
+
fadeStop?: CodegenTypes.WithDefault<CodegenTypes.Double, 0>;
|
|
12
|
+
direction?: CodegenTypes.WithDefault<'down' | 'up' | 'left' | 'right', 'down'>;
|
|
13
|
+
fallbackColor?: ColorValue;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default codegenNativeComponent<NativeProps>('SliceBackgroundBlur') as HostComponent<NativeProps>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CodegenTypes,
|
|
3
|
+
type ColorValue,
|
|
4
|
+
type HostComponent,
|
|
5
|
+
type ViewProps,
|
|
6
|
+
codegenNativeComponent,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
export interface NativeProps extends ViewProps {
|
|
10
|
+
glassStyle?: CodegenTypes.WithDefault<'regular' | 'clear', 'regular'>;
|
|
11
|
+
glassTintColor?: ColorValue;
|
|
12
|
+
interactive?: CodegenTypes.WithDefault<boolean, false>;
|
|
13
|
+
cornerRadius?: CodegenTypes.WithDefault<CodegenTypes.Double, 24>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default codegenNativeComponent<NativeProps>('SliceLiquidGlassView', {
|
|
17
|
+
excludedPlatforms: ['android'],
|
|
18
|
+
}) as HostComponent<NativeProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
readonly getConstants: () => {
|
|
6
|
+
supportsLiquidGlass: boolean;
|
|
7
|
+
supportsNativeBlur: boolean;
|
|
8
|
+
deviceName: string;
|
|
9
|
+
deviceModel: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default TurboModuleRegistry.get<Spec>('SliceDeviceCapabilities');
|
|
File without changes
|
|
File without changes
|
|
File without changes
|