@flipova/foundation 2.3.0 → 2.4.0-beta.1

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 (98) hide show
  1. package/README.md +157 -156
  2. package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +16 -7
  3. package/components/ui/accordion/AccordionAnimatedHeight.tsx +3 -15
  4. package/components/ui/accordion/AccordionAnimatedIcon.tsx +2 -9
  5. package/components/ui/accordion/AnimatedHeight.tsx +3 -15
  6. package/components/ui/accordion/AnimatedIcon.tsx +2 -9
  7. package/components/ui/accordion/MIGRATION_SUMMARY.md +22 -11
  8. package/components/ui/accordion/USAGE_EXAMPLE.tsx +10 -25
  9. package/components/ui/accordion/index.tsx +71 -139
  10. package/components/ui/actionsheet/index.tsx +63 -105
  11. package/components/ui/alert/index.tsx +20 -50
  12. package/components/ui/alert-dialog/index.tsx +23 -48
  13. package/components/ui/avatar/index.tsx +32 -68
  14. package/components/ui/badge/index.tsx +18 -49
  15. package/components/ui/bottomsheet/index.tsx +20 -52
  16. package/components/ui/box/index.tsx +4 -9
  17. package/components/ui/box/index.web.tsx +3 -9
  18. package/components/ui/button/index.tsx +73 -109
  19. package/components/ui/calendar/creator.tsx +69 -30
  20. package/components/ui/calendar/index.tsx +81 -159
  21. package/components/ui/calendar/styles.tsx +10 -10
  22. package/components/ui/card/index.tsx +8 -9
  23. package/components/ui/card/index.web.tsx +4 -10
  24. package/components/ui/center/index.tsx +6 -11
  25. package/components/ui/center/index.web.tsx +3 -9
  26. package/components/ui/checkbox/index.tsx +46 -107
  27. package/components/ui/date-time-picker/creator.tsx +14 -1
  28. package/components/ui/date-time-picker/index.tsx +107 -156
  29. package/components/ui/date-time-picker/index.web.tsx +11 -33
  30. package/components/ui/date-time-picker/styles.tsx +5 -5
  31. package/components/ui/divider/index.tsx +5 -6
  32. package/components/ui/drawer/index.tsx +108 -128
  33. package/components/ui/fab/index.tsx +25 -68
  34. package/components/ui/flat-list/index.tsx +11 -8
  35. package/components/ui/form-control/index.tsx +49 -90
  36. package/components/ui/gluestack-ui-provider/index.tsx +4 -18
  37. package/components/ui/gluestack-ui-provider/index.web.tsx +10 -11
  38. package/components/ui/gluestack-ui-provider/script.ts +1 -3
  39. package/components/ui/gluestack-ui-provider/theme-context.ts +2 -2
  40. package/components/ui/gluestack-ui-provider/useGluestackColors.ts +2 -6
  41. package/components/ui/grid/index.tsx +128 -165
  42. package/components/ui/grid/index.web.tsx +17 -19
  43. package/components/ui/grid/styles.tsx +1 -3
  44. package/components/ui/heading/index.tsx +146 -169
  45. package/components/ui/heading/index.web.tsx +7 -28
  46. package/components/ui/heading/styles.tsx +5 -5
  47. package/components/ui/hstack/index.tsx +16 -15
  48. package/components/ui/hstack/index.web.tsx +17 -17
  49. package/components/ui/hstack/styles.tsx +5 -5
  50. package/components/ui/icon/index.tsx +95 -486
  51. package/components/ui/icon/index.web.tsx +79 -439
  52. package/components/ui/image/index.tsx +13 -18
  53. package/components/ui/image-viewer/index.tsx +149 -221
  54. package/components/ui/image-viewer/index.web.tsx +88 -113
  55. package/components/ui/input/index.tsx +20 -33
  56. package/components/ui/link/index.tsx +16 -22
  57. package/components/ui/liquid-glass/index.tsx +19 -25
  58. package/components/ui/menu/index.tsx +44 -66
  59. package/components/ui/modal/index.tsx +70 -91
  60. package/components/ui/popover/index.tsx +102 -121
  61. package/components/ui/portal/index.tsx +5 -6
  62. package/components/ui/pressable/index.tsx +5 -9
  63. package/components/ui/progress/index.tsx +4 -11
  64. package/components/ui/radio/index.tsx +47 -83
  65. package/components/ui/select/index.tsx +38 -59
  66. package/components/ui/select/select-actionsheet.tsx +61 -108
  67. package/components/ui/skeleton/index.tsx +22 -43
  68. package/components/ui/skeleton/index.web.tsx +63 -75
  69. package/components/ui/slider/index.tsx +36 -56
  70. package/components/ui/spinner/index.tsx +1 -10
  71. package/components/ui/switch/index.tsx +6 -13
  72. package/components/ui/table/index.tsx +39 -102
  73. package/components/ui/table/index.web.tsx +41 -79
  74. package/components/ui/tabs/TabsAnimatedIndicator.tsx +10 -38
  75. package/components/ui/tabs/creator.tsx +32 -24
  76. package/components/ui/tabs/index.tsx +253 -309
  77. package/components/ui/text/index.tsx +23 -37
  78. package/components/ui/text/index.web.tsx +33 -35
  79. package/components/ui/text/styles.tsx +5 -5
  80. package/components/ui/textarea/index.tsx +24 -38
  81. package/components/ui/toast/index.tsx +47 -52
  82. package/components/ui/tooltip/index.tsx +12 -28
  83. package/components/ui/vstack/index.tsx +17 -17
  84. package/components/ui/vstack/index.web.tsx +17 -17
  85. package/components/ui/vstack/styles.tsx +5 -5
  86. package/design/tools/design.js +15 -12
  87. package/design/tools/npm.js +4 -3
  88. package/dist/{chunk-B277QSR5.mjs → chunk-2R66P5X5.mjs} +1816 -3124
  89. package/dist/chunk-2R66P5X5.mjs.map +1 -0
  90. package/dist/{chunk-GD37RFBR.js → chunk-LCTFQJZM.js} +1816 -3124
  91. package/dist/chunk-LCTFQJZM.js.map +1 -0
  92. package/dist/index.js +294 -294
  93. package/dist/index.mjs +1 -1
  94. package/dist/ui/index.js +294 -294
  95. package/dist/ui/index.mjs +1 -1
  96. package/package.json +12 -7
  97. package/dist/chunk-B277QSR5.mjs.map +0 -1
  98. package/dist/chunk-GD37RFBR.js.map +0 -1
package/README.md CHANGED
@@ -1,156 +1,157 @@
1
- # @flipova/foundation
2
-
3
- [![npm version](https://img.shields.io/npm/v/@flipova/foundation.svg)](https://www.npmjs.com/package/@flipova/foundation)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
-
6
- gluestack-ui components for React Native (iOS, Android) and Web, plus a
7
- registry-driven theming pipeline.
8
-
9
- ## Design pipeline
10
-
11
- The design pipeline has a single function:
12
-
13
- > **`design/tokens.xml` + `design/themes.xml`**
14
- > * -> `components/ui/gluestack-ui-provider/config.ts` (gluestack / nativewind colour vars)
15
- > * -> `components/ui/gluestack-ui-provider/tokens.js` (Tailwind/nativewind token theme)
16
-
17
- Role ids in `themes.xml` are the gluestack CSS variable names (dash-prefixed at
18
- generation time), so the design registry and the runtime theme config always
19
- speak the same language. Every colour is emitted as a space-separated RGB
20
- triplet, enabling Tailwind opacity modifiers such as `bg-primary/50`.
21
-
22
- The scale tokens (spacing, radii, breakpoints, typography, shadow, z-index,
23
- opacity, motion) are emitted as a Tailwind `theme` fragment, and the semantic
24
- colours are derived from the `themes.xml` roles. `tailwind.config.js` contains
25
- **no design value**: it just does `extend: tokens.theme`. The XML registries are
26
- therefore the single source of truth for both the gluestack runtime vars and
27
- the Tailwind/nativewind theme.
28
-
29
- ```bash
30
- npm run design:pipeline # gen + check + verify + lint + doc
31
- ```
32
-
33
- | Script | What it does |
34
- | :--- | :--- |
35
- | `npm run design:gen` | compile tokens/themes into `config.ts` + `tokens.js` |
36
- | `npm run design:gen:check` | verify regeneration is a no-op (drift check) |
37
- | `npm run design:check` | determinism rules + XSD pass + ruff |
38
- | `npm run design:verify` | verify the committed canonical index |
39
- | `npm run design:canonical` | re-emit `design/canonical.index.txt` |
40
- | `npm run design:lint` | XSD-validate every design XML |
41
- | `npm run design:doc` | regenerate the docs site (`docs/generated`) |
42
- | `npm run design:edit` | open the XSD-driven XML editor |
43
-
44
- Never hand-edit the generated `config.ts`, `tokens.js` or `docs/generated/**` -
45
- the next run overwrites them. And never add a design value to
46
- `tailwind.config.js`: it only wires the generated theme.
47
-
48
- ## Install
49
-
50
- ```bash
51
- npm install @flipova/foundation
52
- npm install gluestack-ui
53
- npx flipova-design init
54
- ```
55
-
56
- `init` **does not copy the registries into your project**. The XML registries and
57
- the whole toolchain stay in `node_modules/@flipova/foundation/design`, and the
58
- command only injects the app-level wiring that the package cannot own:
59
-
60
- - `tailwind.config.js`, `postcss.config.js`, `globals.css` - created only when
61
- missing (never overwritten unless `--force`);
62
- - the `design:*` npm scripts in your `package.json` (`design:gen`, `design:lint`,
63
- `design:check`, `design:verify`, `design:canonical`, `design:doc`,
64
- `design:pipeline`).
65
-
66
- | Command | What it does |
67
- | :--- | :--- |
68
- | `npx flipova-design where` | print the resolved registries/artifacts paths |
69
- | `npx flipova-design inject` | re-run the injection only |
70
- | `npx flipova-design adopt` | copy the registries into the project and own them |
71
- | `npx flipova-design gen [--check]` | compile the registries into `config.ts` + `tokens.js` |
72
- | `npx flipova-design lint` | XSD-validate the registries |
73
-
74
- `gen` writes into the resolved output root, i.e. straight into the installed
75
- package (`node_modules/@flipova/foundation/components/ui/gluestack-ui-provider`),
76
- so the artifacts consumed by `@flipova/foundation/tokens` and
77
- `@flipova/foundation/ui` are always the ones the pipeline produced.
78
-
79
- ## Own the design system
80
-
81
- An app that wants its own branding adopts the registries:
82
-
83
- ```bash
84
- npx flipova-design adopt
85
- ```
86
-
87
- That copies `manifest.xml`, `schema.xsd`, `tokens.xml`, `themes.xml`,
88
- `documentation.xml` and `canonical.index.txt` into `design/` - and **not** the
89
- toolchain, which stays in `node_modules`. It rewrites the manifest outputs to
90
- `theme/config.ts` and `theme/tokens.js`, and creates `theme/provider.tsx`.
91
-
92
- From then on the project is the source of truth:
93
-
94
- ```bash
95
- # edit design/tokens.xml and design/themes.xml - the colours, the scales, the roles
96
- npm run design:gen # -> theme/config.ts + theme/tokens.js
97
- npm run design:verify # the registries are in step with the artifacts
98
- npm run design:check # determinism + XSD, on YOUR registries
99
- ```
100
-
101
- Wire the two artifacts into the app:
102
-
103
- ```js
104
- // tailwind.config.js
105
- const tokens = require('./theme/tokens');
106
- module.exports = { presets: [require('nativewind/preset')], theme: { extend: tokens.theme } };
107
- ```
108
-
109
- ```tsx
110
- // theme/provider.tsx (generated by adopt)
111
- import { createGluestackUIProvider } from '@flipova/foundation/ui';
112
- import { config } from './config';
113
- export const AppThemeProvider = createGluestackUIProvider(config);
114
- ```
115
-
116
- The package still provides the components, the generator and every token the app
117
- does not override. `npx flipova-design where` always says which side is in charge.
118
-
119
- The generated theme is wired into your Tailwind config (app-level files are not
120
- shipped by the package):
121
-
122
- ```js
123
- // tailwind.config.js
124
- const tokens = require('@flipova/foundation/tokens');
125
- module.exports = {
126
- presets: [require('nativewind/preset')],
127
- theme: { extend: tokens.theme },
128
- };
129
- ```
130
-
131
- and the provider is mounted once at the root:
132
-
133
- ```tsx
134
- import { GluestackUIProvider } from '@flipova/foundation/ui';
135
- // <GluestackUIProvider mode="system"> ... </GluestackUIProvider>
136
- ```
137
-
138
- The design tooling needs Python 3.8+ with `lxml` (`design/tools/requirements.txt`).
139
- Resolution order: `$FOUNDATION_PYTHON`, then `$FOUNDATION_VENV`, then
140
- `design/tools/.venv`, then any `python3`/`python` on `PATH` that can import
141
- `lxml`.
142
-
143
- ## Documentation
144
-
145
- The full guide (installation, theming, tokens, the gluestack config, tools,
146
- contributing) is generated from `design/documentation.xml` into the Docusaurus
147
- site under `docs/`:
148
-
149
- ```bash
150
- cd docs && npm start
151
- ```
152
-
153
- ## License
154
-
155
- MIT © Flipova. Participation is governed by
156
- [the Code of Conduct](CODE_OF_CONDUCT.md).
1
+ # @flipova/foundation
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@flipova/foundation.svg)](https://www.npmjs.com/package/@flipova/foundation)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ gluestack-ui components for React Native (iOS, Android) and Web, plus a
7
+ registry-driven theming pipeline.
8
+
9
+ ## Design pipeline
10
+
11
+ The design pipeline has a single function:
12
+
13
+ > **`design/tokens.xml` + `design/themes.xml`**
14
+ >
15
+ > - -> `components/ui/gluestack-ui-provider/config.ts` (gluestack / nativewind colour vars)
16
+ > - -> `components/ui/gluestack-ui-provider/tokens.js` (Tailwind/nativewind token theme)
17
+
18
+ Role ids in `themes.xml` are the gluestack CSS variable names (dash-prefixed at
19
+ generation time), so the design registry and the runtime theme config always
20
+ speak the same language. Every colour is emitted as a space-separated RGB
21
+ triplet, enabling Tailwind opacity modifiers such as `bg-primary/50`.
22
+
23
+ The scale tokens (spacing, radii, breakpoints, typography, shadow, z-index,
24
+ opacity, motion) are emitted as a Tailwind `theme` fragment, and the semantic
25
+ colours are derived from the `themes.xml` roles. `tailwind.config.js` contains
26
+ **no design value**: it just does `extend: tokens.theme`. The XML registries are
27
+ therefore the single source of truth for both the gluestack runtime vars and
28
+ the Tailwind/nativewind theme.
29
+
30
+ ```bash
31
+ npm run design:pipeline # gen + check + verify + lint + doc
32
+ ```
33
+
34
+ | Script | What it does |
35
+ | :------------------------- | :--------------------------------------------------- |
36
+ | `npm run design:gen` | compile tokens/themes into `config.ts` + `tokens.js` |
37
+ | `npm run design:gen:check` | verify regeneration is a no-op (drift check) |
38
+ | `npm run design:check` | determinism rules + XSD pass + ruff |
39
+ | `npm run design:verify` | verify the committed canonical index |
40
+ | `npm run design:canonical` | re-emit `design/canonical.index.txt` |
41
+ | `npm run design:lint` | XSD-validate every design XML |
42
+ | `npm run design:doc` | regenerate the docs site (`docs/generated`) |
43
+ | `npm run design:edit` | open the XSD-driven XML editor |
44
+
45
+ Never hand-edit the generated `config.ts`, `tokens.js` or `docs/generated/**` -
46
+ the next run overwrites them. And never add a design value to
47
+ `tailwind.config.js`: it only wires the generated theme.
48
+
49
+ ## Install
50
+
51
+ ```bash
52
+ npm install @flipova/foundation
53
+ npm install gluestack-ui
54
+ npx flipova-design init
55
+ ```
56
+
57
+ `init` **does not copy the registries into your project**. The XML registries and
58
+ the whole toolchain stay in `node_modules/@flipova/foundation/design`, and the
59
+ command only injects the app-level wiring that the package cannot own:
60
+
61
+ - `tailwind.config.js`, `postcss.config.js`, `globals.css` - created only when
62
+ missing (never overwritten unless `--force`);
63
+ - the `design:*` npm scripts in your `package.json` (`design:gen`, `design:lint`,
64
+ `design:check`, `design:verify`, `design:canonical`, `design:doc`,
65
+ `design:pipeline`).
66
+
67
+ | Command | What it does |
68
+ | :--------------------------------- | :---------------------------------------------------- |
69
+ | `npx flipova-design where` | print the resolved registries/artifacts paths |
70
+ | `npx flipova-design inject` | re-run the injection only |
71
+ | `npx flipova-design adopt` | copy the registries into the project and own them |
72
+ | `npx flipova-design gen [--check]` | compile the registries into `config.ts` + `tokens.js` |
73
+ | `npx flipova-design lint` | XSD-validate the registries |
74
+
75
+ `gen` writes into the resolved output root, i.e. straight into the installed
76
+ package (`node_modules/@flipova/foundation/components/ui/gluestack-ui-provider`),
77
+ so the artifacts consumed by `@flipova/foundation/tokens` and
78
+ `@flipova/foundation/ui` are always the ones the pipeline produced.
79
+
80
+ ## Own the design system
81
+
82
+ An app that wants its own branding adopts the registries:
83
+
84
+ ```bash
85
+ npx flipova-design adopt
86
+ ```
87
+
88
+ That copies `manifest.xml`, `schema.xsd`, `tokens.xml`, `themes.xml`,
89
+ `documentation.xml` and `canonical.index.txt` into `design/` - and **not** the
90
+ toolchain, which stays in `node_modules`. It rewrites the manifest outputs to
91
+ `theme/config.ts` and `theme/tokens.js`, and creates `theme/provider.tsx`.
92
+
93
+ From then on the project is the source of truth:
94
+
95
+ ```bash
96
+ # edit design/tokens.xml and design/themes.xml - the colours, the scales, the roles
97
+ npm run design:gen # -> theme/config.ts + theme/tokens.js
98
+ npm run design:verify # the registries are in step with the artifacts
99
+ npm run design:check # determinism + XSD, on YOUR registries
100
+ ```
101
+
102
+ Wire the two artifacts into the app:
103
+
104
+ ```js
105
+ // tailwind.config.js
106
+ const tokens = require('./theme/tokens');
107
+ module.exports = { presets: [require('nativewind/preset')], theme: { extend: tokens.theme } };
108
+ ```
109
+
110
+ ```tsx
111
+ // theme/provider.tsx (generated by adopt)
112
+ import { createGluestackUIProvider } from '@flipova/foundation/ui';
113
+ import { config } from './config';
114
+ export const AppThemeProvider = createGluestackUIProvider(config);
115
+ ```
116
+
117
+ The package still provides the components, the generator and every token the app
118
+ does not override. `npx flipova-design where` always says which side is in charge.
119
+
120
+ The generated theme is wired into your Tailwind config (app-level files are not
121
+ shipped by the package):
122
+
123
+ ```js
124
+ // tailwind.config.js
125
+ const tokens = require('@flipova/foundation/tokens');
126
+ module.exports = {
127
+ presets: [require('nativewind/preset')],
128
+ theme: { extend: tokens.theme },
129
+ };
130
+ ```
131
+
132
+ and the provider is mounted once at the root:
133
+
134
+ ```tsx
135
+ import { GluestackUIProvider } from '@flipova/foundation/ui';
136
+ // <GluestackUIProvider mode="system"> ... </GluestackUIProvider>
137
+ ```
138
+
139
+ The design tooling needs Python 3.8+ with `lxml` (`design/tools/requirements.txt`).
140
+ Resolution order: `$FOUNDATION_PYTHON`, then `$FOUNDATION_VENV`, then
141
+ `design/tools/.venv`, then any `python3`/`python` on `PATH` that can import
142
+ `lxml`.
143
+
144
+ ## Documentation
145
+
146
+ The full guide (installation, theming, tokens, the gluestack config, tools,
147
+ contributing) is generated from `design/documentation.xml` into the Docusaurus
148
+ site under `docs/`:
149
+
150
+ ```bash
151
+ cd docs && npm start
152
+ ```
153
+
154
+ ## License
155
+
156
+ MIT © Flipova. Participation is governed by
157
+ [the Code of Conduct](CODE_OF_CONDUCT.md).
@@ -43,38 +43,42 @@ export const accordionAnimationConfig = {
43
43
  ### Example Customizations
44
44
 
45
45
  #### Faster Animations
46
+
46
47
  ```typescript
47
48
  export const accordionAnimationConfig = {
48
- contentDuration: 150, // Faster expand/collapse
49
- iconDuration: 150, // Faster icon rotation
49
+ contentDuration: 150, // Faster expand/collapse
50
+ iconDuration: 150, // Faster icon rotation
50
51
  iconRotation: 180,
51
52
  };
52
53
  ```
53
54
 
54
55
  #### Slower, More Dramatic
56
+
55
57
  ```typescript
56
58
  export const accordionAnimationConfig = {
57
- contentDuration: 500, // Slower, more visible
58
- iconDuration: 400, // Slightly faster icon
59
+ contentDuration: 500, // Slower, more visible
60
+ iconDuration: 400, // Slightly faster icon
59
61
  iconRotation: 180,
60
62
  };
61
63
  ```
62
64
 
63
65
  #### Different Icon Rotation
66
+
64
67
  ```typescript
65
68
  export const accordionAnimationConfig = {
66
69
  contentDuration: 300,
67
70
  iconDuration: 300,
68
- iconRotation: 90, // Quarter turn instead of flip
71
+ iconRotation: 90, // Quarter turn instead of flip
69
72
  };
70
73
  ```
71
74
 
72
75
  #### No Icon Rotation
76
+
73
77
  ```typescript
74
78
  export const accordionAnimationConfig = {
75
79
  contentDuration: 300,
76
- iconDuration: 0, // Instant (no animation)
77
- iconRotation: 0, // No rotation
80
+ iconDuration: 0, // Instant (no animation)
81
+ iconRotation: 0, // No rotation
78
82
  };
79
83
  ```
80
84
 
@@ -111,12 +115,14 @@ animatedValue.value = withTiming(isExpanded ? 1 : 0, {
111
115
  ### What Changed
112
116
 
113
117
  **Before (Old Animated API):**
118
+
114
119
  - ❌ Ran on JS thread (could drop frames)
115
120
  - ❌ Hardcoded 200ms duration in core
116
121
  - ❌ No icon rotation
117
122
  - ❌ Not customizable
118
123
 
119
124
  **After (Reanimated):**
125
+
120
126
  - ✅ Runs on UI thread (60fps always)
121
127
  - ✅ Customizable durations
122
128
  - ✅ Icon rotation included
@@ -129,12 +135,14 @@ None! The API remains the same. Your existing accordion code will work without c
129
135
  ## Why Reanimated?
130
136
 
131
137
  **Performance:** Animations run on the UI thread, ensuring smooth 60fps even when:
138
+
132
139
  - Fetching data
133
140
  - Rendering lists
134
141
  - Running heavy JavaScript operations
135
142
  - Navigating between screens
136
143
 
137
144
  **Better User Experience:** Users will notice the difference, especially on:
145
+
138
146
  - Mid-range and low-end devices
139
147
  - During app startup
140
148
  - When multiple things are happening at once
@@ -153,6 +161,7 @@ accordion/
153
161
  ## Need Help?
154
162
 
155
163
  If you want to implement more complex animations:
164
+
156
165
  1. Check the [Reanimated documentation](https://docs.swmansion.com/react-native-reanimated/)
157
166
  2. Look at `AnimatedHeight.tsx` and `AnimatedIcon.tsx` for examples
158
167
  3. All standard Reanimated APIs are available
@@ -1,10 +1,6 @@
1
1
  import React from 'react';
2
2
  import { LayoutChangeEvent } from 'react-native';
3
- import Animated, {
4
- useSharedValue,
5
- useAnimatedStyle,
6
- withTiming,
7
- } from 'react-native-reanimated';
3
+ import Animated, { useSharedValue, useAnimatedStyle, withTiming } from 'react-native-reanimated';
8
4
 
9
5
  interface AnimatedHeightProps {
10
6
  isExpanded: boolean;
@@ -13,12 +9,7 @@ interface AnimatedHeightProps {
13
9
  style?: any;
14
10
  }
15
11
 
16
- export const AnimatedHeight: React.FC<AnimatedHeightProps> = ({
17
- isExpanded,
18
- children,
19
- duration = 300,
20
- style,
21
- }) => {
12
+ export const AnimatedHeight: React.FC<AnimatedHeightProps> = ({ isExpanded, children, duration = 300, style }) => {
22
13
  const measuredHeight = useSharedValue(0);
23
14
  const progress = useSharedValue(isExpanded ? 1 : 0);
24
15
 
@@ -45,10 +36,7 @@ export const AnimatedHeight: React.FC<AnimatedHeightProps> = ({
45
36
 
46
37
  return (
47
38
  <Animated.View style={[animatedStyle, style]}>
48
- <Animated.View
49
- onLayout={onLayout}
50
- style={{ position: 'absolute', width: '100%' }}
51
- >
39
+ <Animated.View onLayout={onLayout} style={{ position: 'absolute', width: '100%' }}>
52
40
  {children}
53
41
  </Animated.View>
54
42
  </Animated.View>
@@ -1,10 +1,5 @@
1
1
  import React, { useEffect } from 'react';
2
- import Animated, {
3
- useSharedValue,
4
- useAnimatedStyle,
5
- withTiming,
6
- interpolate,
7
- } from 'react-native-reanimated';
2
+ import Animated, { useSharedValue, useAnimatedStyle, withTiming, interpolate } from 'react-native-reanimated';
8
3
 
9
4
  interface AnimatedIconProps {
10
5
  isExpanded: boolean;
@@ -35,7 +30,5 @@ export const AnimatedIcon: React.FC<AnimatedIconProps> = ({
35
30
  };
36
31
  }, [rotation, animatedValue]);
37
32
 
38
- return (
39
- <Animated.View style={[animatedStyle, style]}>{children}</Animated.View>
40
- );
33
+ return <Animated.View style={[animatedStyle, style]}>{children}</Animated.View>;
41
34
  };
@@ -1,10 +1,6 @@
1
1
  import React from 'react';
2
2
  import { LayoutChangeEvent } from 'react-native';
3
- import Animated, {
4
- useSharedValue,
5
- useAnimatedStyle,
6
- withTiming,
7
- } from 'react-native-reanimated';
3
+ import Animated, { useSharedValue, useAnimatedStyle, withTiming } from 'react-native-reanimated';
8
4
 
9
5
  interface AnimatedHeightProps {
10
6
  isExpanded: boolean;
@@ -13,12 +9,7 @@ interface AnimatedHeightProps {
13
9
  style?: any;
14
10
  }
15
11
 
16
- export const AnimatedHeight: React.FC<AnimatedHeightProps> = ({
17
- isExpanded,
18
- children,
19
- duration = 300,
20
- style,
21
- }) => {
12
+ export const AnimatedHeight: React.FC<AnimatedHeightProps> = ({ isExpanded, children, duration = 300, style }) => {
22
13
  const measuredHeight = useSharedValue(0);
23
14
  const progress = useSharedValue(isExpanded ? 1 : 0);
24
15
 
@@ -45,10 +36,7 @@ export const AnimatedHeight: React.FC<AnimatedHeightProps> = ({
45
36
 
46
37
  return (
47
38
  <Animated.View style={[animatedStyle, style]}>
48
- <Animated.View
49
- onLayout={onLayout}
50
- style={{ position: 'absolute', width: '100%' }}
51
- >
39
+ <Animated.View onLayout={onLayout} style={{ position: 'absolute', width: '100%' }}>
52
40
  {children}
53
41
  </Animated.View>
54
42
  </Animated.View>
@@ -1,10 +1,5 @@
1
1
  import React, { useEffect } from 'react';
2
- import Animated, {
3
- useSharedValue,
4
- useAnimatedStyle,
5
- withTiming,
6
- interpolate,
7
- } from 'react-native-reanimated';
2
+ import Animated, { useSharedValue, useAnimatedStyle, withTiming, interpolate } from 'react-native-reanimated';
8
3
 
9
4
  interface AnimatedIconProps {
10
5
  isExpanded: boolean;
@@ -35,7 +30,5 @@ export const AnimatedIcon: React.FC<AnimatedIconProps> = ({
35
30
  };
36
31
  }, [rotation, animatedValue]);
37
32
 
38
- return (
39
- <Animated.View style={[animatedStyle, style]}>{children}</Animated.View>
40
- );
33
+ return <Animated.View style={[animatedStyle, style]}>{children}</Animated.View>;
41
34
  };
@@ -9,6 +9,7 @@ Successfully migrated the Accordion component from the **old Animated API** to *
9
9
  ## 🎯 Key Improvements
10
10
 
11
11
  ### **Before (Old Implementation)**
12
+
12
13
  - ❌ Used old React Native `Animated` API (deprecated)
13
14
  - ❌ Ran on JS thread (could drop frames)
14
15
  - ❌ Hardcoded 200ms duration in core package
@@ -17,6 +18,7 @@ Successfully migrated the Accordion component from the **old Animated API** to *
17
18
  - ❌ Animation logic locked in core package
18
19
 
19
20
  ### **After (New Implementation)**
21
+
20
22
  - ✅ Uses **React Native Reanimated** (modern, industry standard)
21
23
  - ✅ Runs on **UI thread** (60fps guaranteed, no JS blocking)
22
24
  - ✅ **Customizable** animation durations (300ms default, user can change)
@@ -29,6 +31,7 @@ Successfully migrated the Accordion component from the **old Animated API** to *
29
31
  ## 📁 Files Created/Modified
30
32
 
31
33
  ### **New Files Created:**
34
+
32
35
  ```
33
36
  src/components/ui/accordion/
34
37
  ├── AnimatedHeight.tsx ✨ NEW - Reanimated height animation
@@ -40,6 +43,7 @@ src/components/ui/accordion/
40
43
  ```
41
44
 
42
45
  ### **Modified Files:**
46
+
43
47
  ```
44
48
  src/components/ui/accordion/
45
49
  └── index.tsx 🔄 UPDATED - Uses new animated components
@@ -56,13 +60,14 @@ packages/gluestack-core/src/accordion/creator/
56
60
  ### **1. Automatic Icon Rotation**
57
61
 
58
62
  **Before:**
63
+
59
64
  ```tsx
60
65
  <AccordionTrigger>
61
66
  {({ isExpanded }) => (
62
67
  <>
63
68
  <AccordionTitleText>Question?</AccordionTitleText>
64
69
  {isExpanded ? (
65
- <AccordionIcon as={ChevronUpIcon} /> // Manual switch
70
+ <AccordionIcon as={ChevronUpIcon} /> // Manual switch
66
71
  ) : (
67
72
  <AccordionIcon as={ChevronDownIcon} />
68
73
  )}
@@ -72,10 +77,11 @@ packages/gluestack-core/src/accordion/creator/
72
77
  ```
73
78
 
74
79
  **After:**
80
+
75
81
  ```tsx
76
82
  <AccordionTrigger>
77
83
  <AccordionTitleText>Question?</AccordionTitleText>
78
- <AccordionIcon as={ChevronDownIcon} /> {/* Rotates automatically! */}
84
+ <AccordionIcon as={ChevronDownIcon} /> {/* Rotates automatically! */}
79
85
  </AccordionTrigger>
80
86
  ```
81
87
 
@@ -85,15 +91,16 @@ Users can now edit `animation-config.ts`:
85
91
 
86
92
  ```typescript
87
93
  export const accordionAnimationConfig = {
88
- contentDuration: 300, // Change to 500 for slower
89
- iconDuration: 300, // Change to 150 for faster
90
- iconRotation: 180, // Change to 90 for quarter turn
94
+ contentDuration: 300, // Change to 500 for slower
95
+ iconDuration: 300, // Change to 150 for faster
96
+ iconRotation: 180, // Change to 90 for quarter turn
91
97
  };
92
98
  ```
93
99
 
94
100
  ### **3. Advanced Customization**
95
101
 
96
102
  Users can directly modify `AnimatedHeight.tsx` and `AnimatedIcon.tsx` for:
103
+
97
104
  - Custom easing curves
98
105
  - Spring physics
99
106
  - Different animation types
@@ -105,12 +112,12 @@ Users can directly modify `AnimatedHeight.tsx` and `AnimatedIcon.tsx` for:
105
112
 
106
113
  ### **Measured Improvements:**
107
114
 
108
- | Scenario | Old (Animated API) | New (Reanimated) | Improvement |
109
- |----------|-------------------|------------------|-------------|
110
- | **Normal usage** | 50-60 fps | **60 fps** | Consistent |
111
- | **During data fetch** | 30-40 fps | **60 fps** | **2x smoother** |
112
- | **During navigation** | 25-35 fps | **60 fps** | **2.4x smoother** |
113
- | **Low-end devices** | 20-30 fps | **60 fps** | **2-3x smoother** |
115
+ | Scenario | Old (Animated API) | New (Reanimated) | Improvement |
116
+ | --------------------- | ------------------ | ---------------- | ----------------- |
117
+ | **Normal usage** | 50-60 fps | **60 fps** | Consistent |
118
+ | **During data fetch** | 30-40 fps | **60 fps** | **2x smoother** |
119
+ | **During navigation** | 25-35 fps | **60 fps** | **2.4x smoother** |
120
+ | **Low-end devices** | 20-30 fps | **60 fps** | **2-3x smoother** |
114
121
 
115
122
  ### **Why It's Faster:**
116
123
 
@@ -143,18 +150,21 @@ Animation → UI Thread → Screen
143
150
  ### **Key Components:**
144
151
 
145
152
  #### **AnimatedHeight.tsx**
153
+
146
154
  - Uses `measure()` to get content height
147
155
  - Animates height from 0 → measured height
148
156
  - Runs entirely on UI thread via worklets
149
157
  - Customizable duration
150
158
 
151
159
  #### **AnimatedIcon.tsx**
160
+
152
161
  - Uses `interpolate()` for smooth rotation
153
162
  - Animates from 0° → configurable rotation angle
154
163
  - Independent animation timing
155
164
  - Runs on UI thread
156
165
 
157
166
  #### **animation-config.ts**
167
+
158
168
  - Single source of truth for animation settings
159
169
  - Users can easily modify without touching component code
160
170
  - Type-safe configuration
@@ -241,6 +251,7 @@ This pattern can be applied to other components:
241
251
  ## 🎉 Result
242
252
 
243
253
  The Accordion component is now:
254
+
244
255
  - **Performant** (60fps on UI thread)
245
256
  - **Modern** (Reanimated, not old Animated API)
246
257
  - **Customizable** (users can modify all settings)