Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,15 @@ concurrency:

jobs:
build:
name: Build Android Example App (${{ matrix.arch }})
name: Build Android Example App
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [new, old]
steps:
- uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2

- name: Install dependencies (bun)
run: bun install

- name: Disable new architecture in gradle.properties
if: matrix.arch == 'old'
run: sed -i "s/newArchEnabled=true/newArchEnabled=false/g" example/android/gradle.properties

- name: Setup JDK 17
uses: actions/setup-java@v5
with:
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ concurrency:

jobs:
build:
name: Build iOS Example App (${{ matrix.arch }})
name: Build iOS Example App
runs-on: macOS-15
strategy:
fail-fast: false
matrix:
arch: [new, old]
steps:
- uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2
Expand All @@ -64,10 +60,6 @@ jobs:
- name: Install dependencies (bun)
run: bun install

- name: Disable new architecture in Podfile
if: matrix.arch == 'old'
run: sed -i "" "s/ENV\['RCT_NEW_ARCH_ENABLED'\] = '1'/ENV['RCT_NEW_ARCH_ENABLED'] = '0'/g" example/ios/Podfile

- name: Setup Ruby (bundle)
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- name: Checkout
Expand Down
129 changes: 129 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ https://github.com/user-attachments/assets/57f56b3f-3988-4235-af83-a5f2cfd82121
- Nested fragments merge into a single native text view
- Rendering Markdown and HTML (coming soon).
- Supports only the New Architecture
- Animations with React Native Reanimated (text, fontSize, fontColor, letterSpacing)

## Requirements

Expand Down Expand Up @@ -139,6 +140,134 @@ export function MenuExample() {
}
```

## Animations with React Native Reanimated

NitroText supports animating text properties using React Native Reanimated. Animations run directly on the UI thread for smooth, performant updates even when the JavaScript thread is busy.

### Setup

First, install the required dependencies:

```bash
yarn add react-native-reanimated react-native-worklets
```

Then, configure Babel to use the worklets plugin. Add it to your `babel.config.js`:

```js
module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: [
// ... other plugins
'react-native-worklets/plugin',
],
};
```

### Supported Animated Props

The following props can be animated:
- `text` - Animate the text content
- `fontSize` - Animate font size
- `fontColor` - Animate text color (as hex string, e.g., `"#FF0000"`)
- `letterSpacing` - Animate letter spacing

### Basic Example

Animate text content using `animatedProps`:

```tsx
import { NitroText } from 'react-native-nitro-text'
import Animated, { useAnimatedProps, useSharedValue, withTiming } from 'react-native-reanimated'
import { useEffect } from 'react'

const AnimatedNitroText = Animated.createAnimatedComponent(NitroText)

export function AnimatedTextExample() {
const progress = useSharedValue(0)

useEffect(() => {
progress.value = withTiming(1, { duration: 1000 })
}, [])

const animatedProps = useAnimatedProps(() => ({
text: `Progress: ${Math.round(progress.value * 100)}%`,
}))

return (
<AnimatedNitroText
animatedProps={animatedProps}
style={{ fontSize: 24, fontWeight: 'bold' }}
/>
)
}
```

### Advanced Example

Animate multiple properties simultaneously:

```tsx
import { NitroText } from 'react-native-nitro-text'
import Animated, {
useAnimatedProps,
useSharedValue,
withRepeat,
withTiming,
Easing
} from 'react-native-reanimated'
import { useEffect } from 'react'

const AnimatedNitroText = Animated.createAnimatedComponent(NitroText)

export function AdvancedAnimationExample() {
const scale = useSharedValue(1)
const color = useSharedValue(0)

useEffect(() => {
scale.value = withRepeat(
withTiming(1.2, { duration: 1000, easing: Easing.inOut(Easing.ease) }),
-1,
true
)

color.value = withRepeat(
withTiming(1, { duration: 2000, easing: Easing.linear }),
-1,
false
)
}, [])

const animatedProps = useAnimatedProps(() => {
const fontSize = 16 + (scale.value - 1) * 8
const hue = Math.round(color.value * 360)

return {
fontSize,
fontColor: `hsl(${hue}, 70%, 50%)`,
} as any
})

return (
<AnimatedNitroText
animatedProps={animatedProps}
style={{ fontWeight: '600' }}
>
Animated Text
</AnimatedNitroText>
)
}
```

### Performance Benefits

Since animations run on the UI thread, NitroText animations remain smooth even when:
- The JavaScript thread is blocked
- Heavy computations are running
- The app is processing large amounts of data

This makes NitroText ideal for real-time text updates, counters, and dynamic content that needs to stay responsive.

## Platform Support

- iOS
Expand Down
Loading