@amazon-devices/react-linear-gradient
v2.0.1758683737
Published
A <LinearGradient> element for React Native Keplerscript
Readme
@amazon-devices/react-linear-gradient
@amazon-devices/react-linear-gradient provides support on Kepler for react-native-linear-gradient which provides a <LinearGradient> element for React Native applications.
This is a system-deployed library and is available to KeplerScript apps without a separate installation process. It is deployed as an autolinking library which your app links to at runtime. Compatibility is guaranteed only between the library and the version of KeplerScript for which it is built.
When you up level the version of KeplerScript with which your app is built, it a best practice to also uplevel the version of the library on which it is dependent.
Documentation
Check the original library documentation for more info about this library, API reference and more here: README.md.
Installation
- Add the JavaScript library dependency in the
package.jsonfile:
"dependencies": {
...
"@amazon-devices/react-linear-gradient": "^2.0.0"
}- Reinstall
package-lock.jsonfile usingnpm installcommand.
Examples
import * as React from 'react';
import { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import LinearGradient from '@amazon-devices/react-linear-gradient';
const styles = StyleSheet.create({
linearGradient: {
justifyContent: 'center',
width: 500,
height: 100,
borderRadius: 5
},
buttonText: {
fontSize: 18,
fontFamily: 'Gill Sans',
textAlign: 'center',
margin: 10,
color: '#ffffff',
backgroundColor: 'transparent'
}
});
export class LinearGradientScreen extends Component {
render() {
return (
<View
style={{
flex: 1,
backgroundColor: 'transparent',
justifyContent: 'center',
alignItems: 'center'
}}>
<LinearGradient
colors={['#4c669f', '#3b5998', '#192f6a']}
style={styles.linearGradient}>
<Text style={styles.buttonText}>Sign in with Vega OS</Text>
</LinearGradient>
</View>
);
}
}
export default LinearGradientScreen;API supported on Kepler
Component API
| Prop | Description | Default | Platform |
| --- | --- | --- | --- |
| colors | Mandatory - An array of at least two color values that represent gradient colors. Example: ['red', 'blue'] sets gradient from red to blue. | None | All |
| start | An optional object of the following type: { x: number, y: number }. Coordinates declare the position that the gradient starts at, as a fraction of the overall size of the gradient, starting from the top left corner. Example: { x: 0.1, y: 0.1 } means that the gradient will start 10% from the top and 10% from the left. | None | All |
| end | Same as start, but for the end of the gradient. | None | All |
| locations | An optional array of numbers defining the location of each gradient color stop, mapping to the color with the same index in colors prop. Example: [0.1, 0.75, 1] means that first color will take 0% - 10%, second color will take 10% - 75% and finally third color will occupy 75% - 100%. | None | All |
| useAngle | Used to turn on/off angle based calculation (as opposed to start/end) | None | All |
| angle | The desired angle in degrees | None | All |
| angleCenter | The center point of the angle (will control the weight and stretch of the gradient like it does in photoshop) | None | All |
Supported react-native-kepler versions
| version | @amazon-devices/react-native-kepler version | | ----------- | --------------------------------- | | 2.0.x+2.6.2 | 2.0.x+rn0.72.0 |
