-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for setTextRunValueAtPath
- Loading branch information
1 parent
21b96a3
commit c899dbf
Showing
13 changed files
with
151 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as React from 'react'; | ||
import { useRef } from 'react'; | ||
|
||
import { SafeAreaView, ScrollView, StyleSheet } from 'react-native'; | ||
import { TextInput } from 'react-native-gesture-handler'; | ||
import Rive, { | ||
Alignment, | ||
Fit, | ||
RNRiveError, | ||
RNRiveErrorType, | ||
RiveRef, | ||
} from 'rive-react-native'; | ||
|
||
export default function NestedDynamicText() { | ||
const riveRef = useRef<RiveRef>(null); | ||
|
||
const handleInputChange = (e: string) => { | ||
// Set the TextRun value of the 'name' TextRun | ||
// The name must exist else an error will be thrown | ||
// See: https://help.rive.app/runtimes/text | ||
riveRef.current?.setTextRunValue('Run A', e); | ||
// Set the TextRun value of the 'Run B' TextRun in nested Artboard 2. | ||
riveRef.current?.setTextRunValueAtPath('Run B', e, 'Artboard 2'); | ||
}; | ||
|
||
return ( | ||
<SafeAreaView style={styles.safeAreaViewContainer}> | ||
<ScrollView> | ||
<Rive | ||
ref={riveRef} | ||
fit={Fit.Contain} | ||
alignment={Alignment.Center} | ||
style={styles.animation} | ||
resourceName="hello_world_nested" | ||
onError={(riveError: RNRiveError) => { | ||
switch (riveError.type) { | ||
case RNRiveErrorType.TextRunNotFoundError: { | ||
console.log(`${riveError.message}`); | ||
return; | ||
} | ||
default: | ||
console.log('Unhandled error'); | ||
return; | ||
} | ||
}} | ||
/> | ||
<TextInput | ||
onChangeText={handleInputChange} | ||
defaultValue="" | ||
style={styles.input} | ||
/> | ||
</ScrollView> | ||
</SafeAreaView> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
safeAreaViewContainer: { | ||
flex: 1, | ||
}, | ||
input: { | ||
height: 40, | ||
margin: 12, | ||
borderWidth: 1, | ||
padding: 10, | ||
}, | ||
animation: { | ||
width: '100%', | ||
height: 100, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters