@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.
Files changed (178) hide show
  1. package/README.md +164 -97
  2. package/SliceNative.podspec +24 -0
  3. package/dist/cjs/components.js +19 -0
  4. package/dist/cjs/hooks.js +9 -0
  5. package/dist/cjs/index.js +27 -812
  6. package/dist/cjs/providers.js +9 -0
  7. package/dist/cjs/src/components/SliceBackgroundBlur/SliceBackgroundBlur.js +11 -0
  8. package/dist/cjs/src/components/SliceButton/SliceButton.js +146 -0
  9. package/dist/cjs/src/components/SliceIcon/SliceIcon.js +20 -0
  10. package/dist/cjs/src/components/SliceIcon/iconRegistry.js +668 -0
  11. package/dist/cjs/src/components/SliceIcon/icons.js +144 -0
  12. package/dist/cjs/src/components/SliceLiquidGlassView/SliceLiquidGlassView.js +12 -0
  13. package/dist/cjs/src/components/SliceText/SliceText.js +21 -0
  14. package/dist/cjs/src/components/SliceTextInput/SliceTextInput.js +117 -0
  15. package/dist/cjs/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +13 -0
  16. package/dist/cjs/src/hooks/useDeviceCapabilities/useDeviceCapabilities.js +19 -0
  17. package/dist/cjs/src/providers/SliceThemeProvider.js +37 -0
  18. package/dist/cjs/src/theme/colors/colors.js +253 -0
  19. package/dist/cjs/src/theme/corners/corners.js +14 -0
  20. package/dist/cjs/src/theme/elevations/elevations.js +17 -0
  21. package/dist/cjs/src/theme/motion/motion.js +15 -0
  22. package/dist/cjs/src/theme/motion.js +47 -0
  23. package/dist/cjs/src/theme/spacing/spacing.js +14 -0
  24. package/dist/cjs/src/theme/type/type.js +190 -0
  25. package/dist/cjs/src/utils/sizes/sizes.js +40 -0
  26. package/dist/cjs/src/utils/typography/typography.js +17 -0
  27. package/dist/cjs/theme.js +23 -538
  28. package/dist/cjs/utils.js +10 -0
  29. package/dist/esm/components.mjs +7 -0
  30. package/dist/esm/hooks.mjs +2 -0
  31. package/dist/esm/index.mjs +12 -813
  32. package/dist/esm/providers.mjs +1 -0
  33. package/dist/esm/src/components/SliceBackgroundBlur/SliceBackgroundBlur.mjs +9 -0
  34. package/dist/esm/src/components/SliceButton/SliceButton.mjs +144 -0
  35. package/dist/esm/src/components/SliceIcon/SliceIcon.mjs +18 -0
  36. package/dist/esm/src/components/SliceIcon/iconRegistry.mjs +666 -0
  37. package/dist/esm/src/components/SliceIcon/icons.mjs +142 -0
  38. package/dist/esm/src/components/SliceLiquidGlassView/SliceLiquidGlassView.mjs +10 -0
  39. package/dist/esm/src/components/SliceText/SliceText.mjs +19 -0
  40. package/dist/esm/src/components/SliceTextInput/SliceTextInput.mjs +115 -0
  41. package/dist/esm/src/hooks/useCreateThemedStyles/useCreateThemedStyles.mjs +11 -0
  42. package/dist/esm/src/hooks/useDeviceCapabilities/useDeviceCapabilities.mjs +17 -0
  43. package/dist/esm/src/providers/SliceThemeProvider.mjs +33 -0
  44. package/dist/esm/src/theme/colors/colors.mjs +249 -0
  45. package/dist/esm/src/theme/corners/corners.mjs +12 -0
  46. package/dist/esm/src/theme/elevations/elevations.mjs +15 -0
  47. package/dist/esm/src/theme/motion/motion.mjs +13 -0
  48. package/dist/esm/src/theme/motion.mjs +45 -0
  49. package/dist/esm/src/theme/spacing/spacing.mjs +12 -0
  50. package/dist/esm/src/theme/type/type.mjs +184 -0
  51. package/dist/esm/src/utils/sizes/sizes.mjs +37 -0
  52. package/dist/esm/src/utils/typography/typography.mjs +15 -0
  53. package/dist/esm/theme.mjs +7 -522
  54. package/dist/esm/utils.mjs +2 -0
  55. package/dist/react-native/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.js +6 -0
  56. package/dist/react-native/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.native.js +6 -0
  57. package/dist/react-native/native/src/components/SliceBackgroundBlur/_types.js +1 -0
  58. package/dist/react-native/native/src/components/SliceBackgroundBlur/index.js +1 -0
  59. package/dist/react-native/native/src/components/SliceButton/SliceButton.js +141 -0
  60. package/dist/react-native/native/src/components/SliceButton/_types.js +1 -0
  61. package/dist/react-native/native/src/components/SliceButton/index.js +1 -0
  62. package/dist/react-native/native/src/components/SliceIcon/SliceIcon.js +15 -0
  63. package/dist/react-native/native/src/components/SliceIcon/_types.js +1 -0
  64. package/dist/react-native/native/src/components/SliceIcon/iconRegistry.js +663 -0
  65. package/dist/react-native/native/src/components/SliceIcon/icons.js +140 -0
  66. package/dist/react-native/native/src/components/SliceIcon/index.js +2 -0
  67. package/dist/react-native/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.ios.js +6 -0
  68. package/dist/react-native/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.js +7 -0
  69. package/dist/react-native/native/src/components/SliceLiquidGlassView/_types.js +1 -0
  70. package/dist/react-native/native/src/components/SliceLiquidGlassView/index.js +1 -0
  71. package/dist/react-native/native/src/components/SliceText/SliceText.js +16 -0
  72. package/dist/react-native/native/src/components/SliceText/_types.js +1 -0
  73. package/dist/react-native/native/src/components/SliceText/index.js +1 -0
  74. package/dist/react-native/native/src/components/SliceTextInput/SliceTextInput.js +111 -0
  75. package/dist/react-native/native/src/components/SliceTextInput/_types.js +1 -0
  76. package/dist/react-native/native/src/components/SliceTextInput/index.js +1 -0
  77. package/dist/react-native/native/src/components/index.js +6 -0
  78. package/dist/react-native/native/src/hooks/index.js +2 -0
  79. package/dist/react-native/native/src/hooks/useCreateThemedStyles/index.js +1 -0
  80. package/dist/react-native/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +8 -0
  81. package/dist/react-native/native/src/hooks/useDeviceCapabilities/_types.js +1 -0
  82. package/dist/react-native/native/src/hooks/useDeviceCapabilities/index.js +1 -0
  83. package/dist/react-native/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.js +14 -0
  84. package/dist/react-native/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.native.js +23 -0
  85. package/dist/react-native/native/src/index.js +6 -0
  86. package/dist/react-native/native/src/providers/SliceThemeProvider.js +30 -0
  87. package/dist/react-native/native/src/providers/index.js +1 -0
  88. package/dist/react-native/native/src/specs/BackgroundBlurNativeComponent.ts +16 -0
  89. package/dist/react-native/native/src/specs/LiquidGlassNativeComponent.ts +18 -0
  90. package/dist/react-native/native/src/specs/NativeDeviceCapabilities.ts +13 -0
  91. package/dist/react-native/native/src/theme/index.js +69 -0
  92. package/dist/react-native/native/src/theme/motion.js +43 -0
  93. package/dist/react-native/native/src/types/index.js +1 -0
  94. package/dist/react-native/native/src/types/sharedTypes.js +1 -0
  95. package/dist/react-native/native/src/utils/index.js +2 -0
  96. package/dist/react-native/native/src/utils/sizes/index.js +1 -0
  97. package/dist/react-native/native/src/utils/sizes/sizes.js +35 -0
  98. package/dist/react-native/native/src/utils/typography/index.js +1 -0
  99. package/dist/react-native/native/src/utils/typography/typography.js +13 -0
  100. package/dist/react-native/src/theme/colors/colors.js +385 -0
  101. package/dist/react-native/src/theme/colors/types.js +1 -0
  102. package/dist/react-native/src/theme/corners/corners.js +10 -0
  103. package/dist/react-native/src/theme/corners/types.js +1 -0
  104. package/dist/react-native/src/theme/elevations/_types.js +1 -0
  105. package/dist/react-native/src/theme/elevations/elevations.js +13 -0
  106. package/dist/react-native/src/theme/motion/_types.js +1 -0
  107. package/dist/react-native/src/theme/motion/motion.js +11 -0
  108. package/dist/react-native/src/theme/spacing/_types.js +1 -0
  109. package/dist/react-native/src/theme/spacing/spacing.js +10 -0
  110. package/dist/react-native/src/theme/type/type.js +371 -0
  111. package/dist/react-native/src/theme/type/types.js +1 -0
  112. package/dist/types/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.d.ts +3 -0
  113. package/dist/types/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.native.d.ts +2 -0
  114. package/dist/types/native/src/components/SliceBackgroundBlur/_types.d.ts +24 -0
  115. package/dist/types/native/src/components/SliceBackgroundBlur/index.d.ts +2 -0
  116. package/dist/types/native/src/components/SliceButton/SliceButton.d.ts +5 -0
  117. package/dist/types/native/src/components/SliceButton/_types.d.ts +78 -0
  118. package/dist/types/native/src/components/SliceButton/index.d.ts +2 -0
  119. package/dist/types/native/src/components/SliceIcon/SliceIcon.d.ts +2 -0
  120. package/dist/types/native/{components/Icon → src/components/SliceIcon}/icons.d.ts +1 -0
  121. package/dist/types/native/src/components/SliceIcon/index.d.ts +3 -0
  122. package/dist/types/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.d.ts +3 -0
  123. package/dist/types/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.ios.d.ts +2 -0
  124. package/dist/types/native/src/components/SliceLiquidGlassView/_types.d.ts +17 -0
  125. package/dist/types/native/src/components/SliceLiquidGlassView/index.d.ts +2 -0
  126. package/dist/types/native/src/components/SliceText/SliceText.d.ts +5 -0
  127. package/dist/types/native/src/components/SliceText/_types.d.ts +17 -0
  128. package/dist/types/native/src/components/SliceText/index.d.ts +2 -0
  129. package/dist/types/native/src/components/SliceTextInput/SliceTextInput.d.ts +2 -0
  130. package/dist/types/native/src/components/SliceTextInput/_types.d.ts +58 -0
  131. package/dist/types/native/src/components/SliceTextInput/index.d.ts +2 -0
  132. package/dist/types/native/src/components/index.d.ts +12 -0
  133. package/dist/types/native/src/hooks/index.d.ts +3 -0
  134. package/dist/types/native/src/hooks/useCreateThemedStyles/index.d.ts +1 -0
  135. package/dist/types/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.d.ts +7 -0
  136. package/dist/types/native/src/hooks/useDeviceCapabilities/_types.d.ts +17 -0
  137. package/dist/types/native/src/hooks/useDeviceCapabilities/index.d.ts +2 -0
  138. package/dist/types/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.d.ts +3 -0
  139. package/dist/types/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.native.d.ts +7 -0
  140. package/dist/types/native/src/index.d.ts +12 -0
  141. package/dist/types/native/src/providers/SliceThemeProvider.d.ts +16 -0
  142. package/dist/types/native/src/providers/index.d.ts +2 -0
  143. package/dist/types/native/src/specs/BackgroundBlurNativeComponent.d.ts +9 -0
  144. package/dist/types/native/src/specs/LiquidGlassNativeComponent.d.ts +9 -0
  145. package/dist/types/native/src/specs/NativeDeviceCapabilities.d.ts +11 -0
  146. package/dist/types/native/{theme → src/theme}/index.d.ts +5 -5
  147. package/dist/types/native/src/types/index.d.ts +1 -0
  148. package/dist/types/native/src/types/sharedTypes.d.ts +14 -0
  149. package/dist/types/native/src/utils/index.d.ts +2 -0
  150. package/dist/types/native/src/utils/sizes/index.d.ts +1 -0
  151. package/dist/types/native/src/utils/sizes/sizes.d.ts +7 -0
  152. package/dist/types/native/src/utils/typography/index.d.ts +1 -0
  153. package/dist/types/native/src/utils/typography/typography.d.ts +7 -0
  154. package/package.json +57 -11
  155. package/platform/android/build.gradle +22 -0
  156. package/platform/android/src/main/AndroidManifest.xml +1 -0
  157. package/platform/android/src/main/java/com/slice/SliceBackgroundBlurManager.java +28 -0
  158. package/platform/android/src/main/java/com/slice/SliceBackgroundBlurView.java +98 -0
  159. package/platform/android/src/main/java/com/slice/SliceDeviceCapabilitiesModule.java +25 -0
  160. package/platform/android/src/main/java/com/slice/SlicePackage.java +25 -0
  161. package/platform/ios/BackgroundBlurSurface.swift +89 -0
  162. package/platform/ios/LiquidGlassSurface.swift +82 -0
  163. package/platform/ios/RCTBackgroundBlurView.h +3 -0
  164. package/platform/ios/RCTBackgroundBlurView.mm +42 -0
  165. package/platform/ios/RCTLiquidGlassView.h +8 -0
  166. package/platform/ios/RCTLiquidGlassView.mm +73 -0
  167. package/platform/ios/SliceDeviceCapabilities.h +4 -0
  168. package/platform/ios/SliceDeviceCapabilities.mm +35 -0
  169. package/react-native.config.js +1 -0
  170. package/src/specs/BackgroundBlurNativeComponent.ts +16 -0
  171. package/src/specs/LiquidGlassNativeComponent.ts +18 -0
  172. package/src/specs/NativeDeviceCapabilities.ts +13 -0
  173. package/dist/types/native/components/Icon/NativeIcon.d.ts +0 -2
  174. package/dist/types/native/components/Icon/index.d.ts +0 -3
  175. package/dist/types/native/index.d.ts +0 -4
  176. /package/dist/types/native/{components/Icon → src/components/SliceIcon}/_types.d.ts +0 -0
  177. /package/dist/types/native/{components/Icon → src/components/SliceIcon}/iconRegistry.d.ts +0 -0
  178. /package/dist/types/native/{theme → src/theme}/motion.d.ts +0 -0
package/README.md CHANGED
@@ -1,120 +1,187 @@
1
1
  # @apple-pie/slice-native
2
2
 
3
- Experimental React Native SVG icons, with the same names and artwork as the web UIKit.
4
- Includes native light/dark theme tokens; other Slice components and a theme provider
5
- are not included. It is built and published independently
6
- of `@apple-pie/slice` and does not require that package at runtime.
3
+ **Alpha software — APIs, styling, and platform behavior may change between releases.**
4
+
5
+ A React Native UI kit with themed components, SVG icons, native blur, and Liquid Glass.
6
+ It shares Slice’s visual language with the web UIKit, but is packaged independently
7
+ and does not require `@apple-pie/slice` at runtime.
8
+
9
+ **Blur, gradient masking, Liquid Glass, and device capability detection are built
10
+ into this package and connected directly to native platform code.** No additional
11
+ blur, gradient, masking, or glass libraries are required—including `expo-blur`,
12
+ `expo-linear-gradient`, and `@react-native-masked-view/masked-view`.
13
+
14
+ ## Installation
15
+
16
+ ```sh
17
+ npm install @apple-pie/slice-native
18
+ ```
19
+
20
+ Configure the package’s peer dependencies in your app: React 18/19, React Native
21
+ 0.80+, `react-native-svg` 15, and Reanimated 4 with its compatible Worklets setup.
22
+ For Expo projects, use `npx expo install` for native peers to select compatible versions.
23
+ These general UI dependencies are separate from the built-in native visual effects.
24
+
25
+ Native components require the New Architecture. iOS builds require Xcode 26+.
26
+ Install iOS pods and rebuild your app after installing or updating the package.
27
+ Expo apps need a development build; the custom native components are not available
28
+ in Expo Go. Restarting Metro alone does not register new native code.
29
+
30
+ ## Quick start
7
31
 
8
32
  ```tsx
9
- import { Icon, SliceIcons } from '@apple-pie/slice-native';
10
-
11
- <Icon
12
- name={SliceIcons.ui.home}
13
- size={24}
14
- strokeColor="#334155"
15
- accessibilityLabel="Go home"
16
- onPress={() => navigation.navigate('Home')}
17
- />
33
+ import { View } from 'react-native';
34
+ import {
35
+ SliceButton,
36
+ SliceIcons,
37
+ SliceTextInput,
38
+ SliceThemeProvider,
39
+ } from '@apple-pie/slice-native';
40
+
41
+ export default function App() {
42
+ return (
43
+ <SliceThemeProvider>
44
+ <View style={{ padding: 24, gap: 16 }}>
45
+ <SliceTextInput accessibilityLabel="Search tasks" placeholder="Search…" />
46
+ <SliceButton icon={SliceIcons.ui.home} onPress={() => console.log('Home')}>
47
+ Go home
48
+ </SliceButton>
49
+ </View>
50
+ </SliceThemeProvider>
51
+ );
52
+ }
18
53
  ```
19
54
 
20
- `NativeIcon` is also exported as an alias of `Icon`. Supply native SVG props and
21
- native `style` objects; use `onPress` instead of `onClick`. CSS classes, cursor
22
- styling (`pointer`), and browser keyboard handlers are not part of this API.
23
- Use an enclosing React Native `Pressable` when you need a larger touch target or
24
- button feedback, and mark the icon `accessible={false}` when it is decorative.
55
+ ## Components
25
56
 
26
- Defaults are 20×20, stroke width 1.5, and black/white colors based on the system
27
- color scheme. Pass `strokeColor` and `coverUp` explicitly to match an app theme.
28
- `fillColor` retains the web API's meaning: **opacity from 0 to 1**, not a color.
29
- `fill` enables that opacity (default 0.125 in light mode, 0.2 in dark mode).
30
- `toggle` selects the on variant when available; unknown names render nothing.
31
- `disabled` blocks press callbacks and halves the specified opacity.
57
+ | Component | Summary |
58
+ | --- | --- |
59
+ | `SliceButton` | Primary/secondary buttons, optional icons, disabled states, Reanimated transitions, and optional Liquid Glass backgrounds. |
60
+ | `SliceTextInput` | Themed native input with icons, optional focus control, focus callbacks, and opt-in clearing on blur. |
61
+ | `StyledText` | Theme-based typography presets with native text props. |
62
+ | `SliceIcon` / `SliceIcons` | Native SVG artwork and typed icon names shared with the web UIKit. Supports toggles, fills, sizing, and press handlers. |
63
+ | `SliceLiquidGlassView` | Native glass container with children, tint, interaction feedback, and rounded corners. |
64
+ | `SliceBackgroundBlur` | Background blur overlay with an optional directional fade on iOS. |
32
65
 
33
- The package requires React, React Native, and react-native-svg as peers. Install
34
- the native SVG dependency in the consuming app using its normal native/Expo setup.
66
+ Buttons and inputs support `size` (`s`, `m`, `l`, or a number), `borderRadius`
67
+ (`pill`, `rectangular`, or a number), `borderWidth`, `borderColor`, and
68
+ `backgroundColor`. Sizes define minimum heights, allowing room for larger text.
69
+ Inputs forward `style` to the underlying text field. Buttons expose `animatedStyle`
70
+ for their wrapper.
35
71
 
36
- ## Development
72
+ `SliceButton`, `SliceTextInput`, and `StyledText` use `SliceThemeProvider`. Give
73
+ inputs and icon-only buttons an accessible name. Icons inside these components
74
+ are decorative; standalone icons can use `accessibilityLabel` and `onPress`.
75
+ For `SliceIcon`, `fillColor` means fill opacity, not a color value.
37
76
 
38
- The package manifest and entry point live in `native/`. Icon components, types,
39
- generated artwork, and tests live in `native/components/Icon/`.
77
+ ### Built-in Liquid Glass and blur
40
78
 
41
- From this directory, run `npm run generate` after changing the web icon registry
42
- or `SliceIcons` constants. Generated files contain native SVG components and have
43
- no runtime imports from the web UIKit. Run `npm run typecheck` with the peer
44
- dependencies installed and TypeScript available from the repository.
79
+ | Effect | iOS | Android | Web |
80
+ | --- | --- | --- | --- |
81
+ | `SliceLiquidGlassView` | Native Liquid Glass on iOS 26+; system blur on older iOS. | Tinted color fallback. | Tinted color fallback. |
82
+ | `SliceBackgroundBlur` | Native backdrop blur; optional directional fade. | Uniform backdrop blur when the required API is present (SDK 37.2+) and hardware acceleration is available; otherwise a color fallback. | Color fallback. |
45
83
 
46
- From the repository root:
84
+ The implementations ship with the package: Swift/UIKit and Fabric on iOS, and Java
85
+ platform code on Android. Consumers do not need to install another effects library.
86
+ iOS respects Reduce Transparency and renders a fallback when it is enabled.
47
87
 
48
- ```sh
49
- npm install
50
- npm install --prefix native
51
- npm run lint --prefix native
52
- npm test --prefix native
53
- npm run build --prefix native
54
- ```
88
+ ```tsx
89
+ import { SliceBackgroundBlur, SliceLiquidGlassView } from '@apple-pie/slice-native';
90
+
91
+ // Place over background content; fills its parent by default.
92
+ <SliceBackgroundBlur blurIntensity={20} fadeStop={0.5} direction="down" />
55
93
 
56
- The build refreshes generated icons, checks types, and produces `dist/cjs/index.js`,
57
- `dist/esm/index.mjs`, and declarations under `dist/types`. React, React Native, and
58
- react-native-svg stay external peer dependencies. The web build is independent.
94
+ <SliceLiquidGlassView cornerRadius={24} glassStyle="regular" style={{ padding: 20 }}>
95
+ {/* Foreground content */}
96
+ </SliceLiquidGlassView>
59
97
 
60
- Native tests use their own `vitest.config.mts` and mocked native components. Install native
61
- dependencies before running them. Root tests and coverage do not include the native package;
62
- passing the native unit tests does not replace device rendering checks.
98
+ <SliceButton liquidGlassBackground={{ glassStyle: 'clear', fallbackColor: '#eeeeee' }}>
99
+ Continue
100
+ </SliceButton>
101
+ ```
102
+
103
+ Blur defaults to intensity `12` and `fadeStop={0}`, which renders uniform blur
104
+ without a mask. A positive `fadeStop` (0–1) enables fading on iOS. Directions are
105
+ `down`, `up`, `left`, and `right`, from transparent toward full blur. Android
106
+ ignores fading props. This fades the visibility of a uniform blur rather than
107
+ varying the blur radius across the view.
63
108
 
64
- CI runs these checks independently in **Slice Native Lint, Build, Test** on Node 24.
65
- It uses `npm run lint:ci --prefix native` to check formatting and types without writing
66
- fixes, then runs native tests, builds, and inspects the package contents. Root dependencies
67
- provide shared tooling such as Biome; native dependencies are installed separately.
109
+ Use `cornerRadius` to control a glass container’s shape. Supported glass buttons
110
+ keep their background transparent; unsupported devices use their solid background
111
+ or configured fallback. Both effect components accept `fallbackColor`. Avoid opaque
112
+ content over glass when you want the backdrop to remain visible. Android backdrop
113
+ blur samples the same window; separately composed surfaces such as video may differ.
68
114
 
69
- Run `npm pack --dry-run` from `native/` to inspect the publishable files, or
70
- `npm pack` to create a tarball. The `prepack` hook builds automatically. Build and
71
- pack from this repository: generation uses the web artwork in `src/components/Icon`.
115
+ ## Hooks, provider, and theme
72
116
 
73
- ## Theme tokens
117
+ | Export | Purpose |
118
+ | --- | --- |
119
+ | `SliceThemeProvider` | Light/dark themes; follows the system by default. Use `preference="light"` or `"dark"` to override. |
120
+ | `useSliceTheme()` | Returns the active theme. |
121
+ | `useSliceContext()` | Returns the theme, mode, preference, and optional preference setter. |
122
+ | `useCreateThemedStyles(factory)` | Creates memoized styles from the active theme. Define the factory outside the component for stable reuse. |
123
+ | `useDeviceCapabilities()` | Reports native effect support, platform, OS/API version, and device information. Does not require the theme provider. |
74
124
 
75
125
  ```tsx
76
- import { Text, View, useColorScheme } from 'react-native';
77
- import { lightTheme, darkTheme } from '@apple-pie/slice-native/theme';
126
+ const {
127
+ supportsLiquidGlass,
128
+ supportsNativeBlur,
129
+ platform,
130
+ iosVersion,
131
+ androidSdkVersion,
132
+ deviceName,
133
+ deviceModel,
134
+ } = useDeviceCapabilities();
135
+ ```
78
136
 
79
- function Card() {
80
- const theme = useColorScheme() === 'dark' ? darkTheme : lightTheme;
81
- return (
82
- <View style={{
83
- backgroundColor: theme.colors['core-surface-primary'],
84
- padding: theme.spacing.m,
85
- borderRadius: theme.corners['corner-m'],
86
- ...theme.shadows['surface-shadow-soft'],
87
- }}>
88
- <Text style={{ ...theme.type['body-m-regular'], color: theme.colors['core-text-primary'] }}>
89
- Hello Slice
90
- </Text>
91
- </View>
92
- );
93
- }
137
+ Capability flags describe API availability, not live accessibility settings or
138
+ per-view rendering conditions. They return `false` when the native module is absent.
139
+ `iosVersion` is a full version string; `androidSdkVersion` is an integer API level
140
+ without minor-release information. Use the support flags for effects decisions.
141
+ Unavailable fields are `null`. iOS device names may be generic; its model is a
142
+ hardware identifier such as `iPhone17,1`, not a marketing name. Android reports
143
+ the system model name/code.
144
+
145
+ `lightTheme`, `darkTheme`, and `createTypography` are exported alongside theme types.
146
+ Themes include colors, spacing, corners, typography, shadows, stacking levels, and
147
+ motion. The `/theme` entry also exposes the underlying token groups. Typography
148
+ uses Funnel Sans by default; load it in your app or use `createTypography` with
149
+ your own loaded font. Fonts are not loaded by the package.
150
+
151
+ ## Utilities and entry points
152
+
153
+ | Utility | Purpose |
154
+ | --- | --- |
155
+ | `sizeToNumber(size)` | Resolves size presets to points: `s` = 40, `m` = 48, `l` = 56. |
156
+ | `borderRadiusToNumber(radius)` | Resolves `pill` to 1000, `rectangular` to 4, and numeric radii to nonnegative points. |
157
+ | `lineHeightTextStyle(style, multiplier)` | Returns a new text style with an absolute line height. |
158
+
159
+ Public types include `Size`, `BorderRadius`, `LiquidGlassBackground`,
160
+ `DeviceCapabilities`, component props, and theme/provider types.
161
+
162
+ Import from the package root or the dedicated `/components`, `/hooks`, `/providers`,
163
+ `/theme`, and `/utils` entry points. ESM, CommonJS, TypeScript declarations, and
164
+ Metro platform files are included. Theme tokens and utilities can be used independently
165
+ of the component runtime.
166
+
167
+ ## Development
168
+
169
+ From the repository root:
170
+
171
+ ```sh
172
+ npm install
173
+ npm install --prefix native
174
+ npm run lint:ci --prefix native
175
+ npm run coverage --prefix native
176
+ npm run test:package --prefix native
177
+ npm run pack:tarball --prefix native
94
178
  ```
95
179
 
96
- `lightTheme`, `darkTheme`, `createTypography`, and the `SliceNativeTheme` type are
97
- also available from the package root. `SliceTheme` aliases the native theme type.
98
- The dedicated `/theme` entry has no runtime React Native, React, or SVG imports.
99
- It also exports `coreColors`, `corners`, `spacing`, `elevations`, `type`, and `motion`.
100
-
101
- Colors, spacing, corners, and stacking levels are sourced from the web tokens at
102
- build time and bundled into this package. No web package is needed in an app.
103
- CSS shadow strings are removed from `colors` and `coreColors`; use `theme.shadows`
104
- instead. Shadows use native `boxShadow` arrays, which require the New Architecture
105
- and supported Android versions (outset shadows require Android 9+).
106
-
107
- Typography uses a fixed 16dp base for rem conversion and numeric line heights and
108
- letter spacing. Load Funnel Sans in your app, or replace `theme.type` with
109
- `createTypography('YourLoadedFontName')`. Exact font weights depend on the font
110
- and platform; test your loaded font on devices. This package does not load fonts.
111
-
112
- Motion durations are milliseconds. Curve tokens are easing functions suitable for
113
- `Animated.timing`'s `easing` option; the CSS spring is interpolated from its original
114
- samples, preserving overshoot. They are ordinary JavaScript functions, not Reanimated
115
- worklets. `elevations` retains the web stacking levels for `zIndex`; do not pass these
116
- values to Android's `elevation` property.
117
-
118
- Build from the repository so shared source tokens are available. All generated
119
- JavaScript and declarations are included under `dist/`, including declarations for
120
- shared source types. Changes to web tokens are picked up by the next native build.
180
+ Builds regenerate and automatically format native icons from the shared web artwork,
181
+ check types, and emit the package distributions. The tarball is written to
182
+ `native/pack/apple-pie-slice-native-<version>.tgz`; reinstall it and rebuild the
183
+ consuming native app when testing platform changes.
184
+
185
+ Browser documentation runs with `npm run storybook:native` from the repository root.
186
+ It previews web fallbacks; native effects need simulator/device checks. Native unit
187
+ coverage enforces a 95% overall threshold and does not measure Swift/Java rendering.
@@ -0,0 +1,24 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'SliceNative'
7
+ s.module_name = 'SliceNative'
8
+ s.version = package['version']
9
+ s.summary = package['description']
10
+ s.homepage = 'https://github.com/uris/slice'
11
+ s.license = package['license']
12
+ s.authors = package['author']
13
+ s.source = { :git => 'https://github.com/uris/slice.git', :tag => "native-v#{s.version}" }
14
+ s.platforms = { :ios => min_ios_version_supported }
15
+ s.swift_version = '5.0'
16
+ s.requires_arc = true
17
+ s.source_files = 'platform/ios/**/*.{h,m,mm,swift}'
18
+ # Keep C++ React headers out of the module imported by the Swift compiler.
19
+ s.private_header_files = 'platform/ios/RCT*View.h', 'platform/ios/SliceDeviceCapabilities.h'
20
+ s.frameworks = 'UIKit'
21
+ s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
22
+
23
+ install_modules_dependencies(s)
24
+ end
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var SliceIcon = require('./src/components/SliceIcon/SliceIcon.js');
4
+ var icons = require('./src/components/SliceIcon/icons.js');
5
+ var SliceText = require('./src/components/SliceText/SliceText.js');
6
+ var SliceButton = require('./src/components/SliceButton/SliceButton.js');
7
+ var SliceTextInput = require('./src/components/SliceTextInput/SliceTextInput.js');
8
+ var SliceLiquidGlassView = require('./src/components/SliceLiquidGlassView/SliceLiquidGlassView.js');
9
+ var SliceBackgroundBlur = require('./src/components/SliceBackgroundBlur/SliceBackgroundBlur.js');
10
+
11
+
12
+
13
+ exports.SliceIcon = SliceIcon.SliceIcon;
14
+ exports.SliceIcons = icons.SliceIcons;
15
+ exports.StyledText = SliceText.StyledText;
16
+ exports.SliceButton = SliceButton.SliceButton;
17
+ exports.SliceTextInput = SliceTextInput.SliceTextInput;
18
+ exports.SliceLiquidGlassView = SliceLiquidGlassView.SliceLiquidGlassView;
19
+ exports.SliceBackgroundBlur = SliceBackgroundBlur.SliceBackgroundBlur;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var useCreateThemedStyles = require('./src/hooks/useCreateThemedStyles/useCreateThemedStyles.js');
4
+ var useDeviceCapabilities = require('./src/hooks/useDeviceCapabilities/useDeviceCapabilities.js');
5
+
6
+
7
+
8
+ exports.useCreateThemedStyles = useCreateThemedStyles.useCreateThemedStyles;
9
+ exports.useDeviceCapabilities = useDeviceCapabilities.useDeviceCapabilities;