Skip to content

Commit ebd136d

Browse files
committed
Merge branch 'master' into android-nested-gradient
2 parents 7dbec32 + 44fd99a commit ebd136d

File tree

4 files changed

+70
-26
lines changed

4 files changed

+70
-26
lines changed

README.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# react-native-text-gradient
2+
23
[![npm version](https://badge.fury.io/js/react-native-text-gradient.svg?t=1495378566925)](https://badge.fury.io/js/react-native-text-gradient)
34
[![Dependency Status](https://david-dm.org/iyegoroff/react-native-text-gradient.svg?t=1495378566925)](https://david-dm.org/iyegoroff/react-native-text-gradient)
45
[![typings included](https://img.shields.io/badge/typings-included-brightgreen.svg?t=1495378566925)](#typescript)
@@ -18,6 +19,8 @@ React-Native text gradient component for iOS & Android.
1819

1920
[link](manual_installation.md)
2021

22+
> If you are using Cocoapods you need to follow the manual installation guide.
23+
2124
## Status
2225

2326
- Component works as drop-in replacement for standard `Text` component and it is possible to have nested gradients.
@@ -29,46 +32,50 @@ React-Native text gradient component for iOS & Android.
2932
- rn 0.53.0 is not supported;
3033
- with rn >= 0.50.0 use 0.0.3.
3134

32-
3335
## Example
3436

3537
```javascript
36-
import { LinearTextGradient } from 'react-native-text-gradient';
38+
import { LinearTextGradient } from "react-native-text-gradient";
3739

3840
<LinearTextGradient
39-
style={{ fontWeight: 'bold', fontSize: 72 }}
41+
style={{ fontWeight: "bold", fontSize: 72 }}
4042
locations={[0, 1]}
41-
colors={['red', 'blue']}
43+
colors={["red", "blue"]}
4244
start={{ x: 0, y: 0 }}
4345
end={{ x: 1, y: 0 }}
4446
>
4547
THIS IS TEXT GRADIENT
46-
</LinearTextGradient>
48+
</LinearTextGradient>;
4749
```
4850

49-
iOS | Android
50-
:---------------------------------------------:|:---------------------------------------------:
51-
<img src="img/ios.png" align="left" height="275"> | <img src="img/android.jpg" align="right" height="275">
52-
51+
| iOS | Android |
52+
| :-----------------------------------------------: | :----------------------------------------------------: |
53+
| <img src="img/ios.png" align="left" height="275"> | <img src="img/android.jpg" align="right" height="275"> |
5354

5455
## Usage
5556

5657
### LinearTextGradient
58+
5759
Interface is similar to `Text` & [LinearGradient](https://github.com/react-native-community/react-native-linear-gradient)
5860

5961
#### colors
62+
6063
An array of at least two color values that represent gradient colors. Example: `['red', 'blue']` sets gradient from red to blue.
61-
64+
6265
#### start
66+
6367
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.
64-
68+
6569
#### end
70+
6671
Same as start, but for the end of the gradient.
67-
72+
6873
#### locations
74+
6975
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%.
7076

7177
#### useViewFrame
78+
7279
Optional. If true gradient will be calculated for text view background frame rather than text frame.
7380

7481
```javascript
@@ -77,7 +84,7 @@ Optional. If true gradient will be calculated for text view background frame rat
7784
useViewFrame={true}
7885
locations={[0.5, 0.95]}
7986
// note colors like '#FF000000' are used for seamless transition to transparent
80-
colors={['#FF0000', '#FF000000']}
87+
colors={["#FF0000", "#FF000000"]}
8188
start={{ x: 0, y: 0 }}
8289
end={{ x: 1, y: 0 }}
8390
>
@@ -87,27 +94,28 @@ Optional. If true gradient will be calculated for text view background frame rat
8794

8895
<img src="img/useViewFrame.png" width="300">
8996

90-
9197
## Usage with rn >= 0.56.0
9298

9399
Wait until https://github.com/facebook/react/pull/13211 will be merged or patch react-native to remove failing invariant checks
94100

95101
`$ node node_modules/react-native-text-gradient/patch-rn.js`
96102

97-
98103
## Caveats
99104

100105
When mixing several text gradients and `Text`s top component always should be text gradient.
106+
101107
```javascript
102108
<LinearTextGradient {...someGradientProps}>
103109
<Text>123</Text>
104110
qwerty
105111
<LinearTextGradient {...anotherGradientProps}>321</LinearTextGradient>
106112
</LinearTextGradient>
107113
```
114+
108115
This is necessary because only top text component is 'mapped' to actual native node and its children are 'virtual' from the native perspective.
109116

110117
## FAQ
111118

112119
#### Is it ready for production?
120+
113121
- Yes, I use it in production

RNTextGradientView.podspec

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 = "react-native-text-gradient"
7+
s.version = package['version']
8+
s.summary = "Text gradient for React-Native"
9+
10+
s.authors = { "iyegoroff" => "[email protected]" }
11+
s.homepage = "https://github.com/iyegoroff/react-native-text-gradient"
12+
s.license = "MIT"
13+
s.platform = :ios, "8.0"
14+
15+
s.source = { :git => "https://github.com/iyegoroff/react-native-text-gradient.git" }
16+
s.source_files = "ios/**/*.{h,m}"
17+
18+
s.dependency 'React'
19+
end

manual_installation.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
### Manual installation
22

3-
43
#### iOS
54

5+
##### With Cocoapods
6+
7+
1. Open your Podfile in (usually in `[your project's name]``ios``Podfile`)
8+
2. Append the following lines to your `Podfile`:
9+
```
10+
pod 'react-native-text-gradient',
11+
:path => "../node_modules/react-native-text-gradient/RNTextGradientView.podspec"
12+
```
13+
3. Go to `[your project's name]``ios` and run the following:
14+
```
15+
pod install
16+
```
17+
4. Run your project (`Cmd+R`)<
18+
19+
##### Without Cocoapods
20+
621
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
722
2. Go to `node_modules``react-native-text-gradient` and add `RNTextGradient.xcodeproj`
823
3. In XCode, in the project navigator, select your project. Add `libRNTextGradient.a` to your project's `Build Phases``Link Binary With Libraries`
@@ -11,14 +26,16 @@
1126
#### Android
1227

1328
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
14-
- Add `import iyegoroff.RNTextGradient.RNTextGradientPackage;` to the imports at the top of the file
15-
- Add `new RNTextGradientPackage()` to the list returned by the `getPackages()` method
29+
30+
- Add `import iyegoroff.RNTextGradient.RNTextGradientPackage;` to the imports at the top of the file
31+
- Add `new RNTextGradientPackage()` to the list returned by the `getPackages()` method
32+
1633
2. Append the following lines to `android/settings.gradle`:
17-
```
18-
include ':react-native-text-gradient'
19-
project(':react-native-text-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-text-gradient/android')
20-
```
34+
```
35+
include ':react-native-text-gradient'
36+
project(':react-native-text-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-text-gradient/android')
37+
```
2138
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
22-
```
23-
compile project(':react-native-text-gradient')
24-
```
39+
```
40+
compile project(':react-native-text-gradient')
41+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-text-gradient",
3-
"version": "0.0.16",
3+
"version": "0.0.17",
44
"description": "Text gradient for React-Native",
55
"main": "src/index.js",
66
"types": "src/index.d.ts",

0 commit comments

Comments
 (0)