Skip to content

Commit 61c6661

Browse files
authored
Merge pull request #22 from fram-x/release/1.0.0
Release/1.0.0
2 parents 1eb5c0f + ede4993 commit 61c6661

34 files changed

+2539
-2186
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.flowconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
[libs]
2525
node_modules/react-native/Libraries/react-native/react-native-interface.js
2626
node_modules/react-native/flow/
27-
node_modules/react-native/flow-github/
2827

2928
[options]
3029
emoji=true
@@ -67,4 +66,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
6766
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
6867

6968
[version]
70-
^0.81.0
69+
^0.92.0

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"eslint.enable": true,
3-
"eslint.autoFixOnSave": true,
2+
// "eslint.enable": true,
3+
// "eslint.autoFixOnSave": true,
44
// For flow
55
"flow.runOnAllFiles": true,
66
"flow.useNPMPackagedFlow": true,

App.js

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,54 @@ export default class App extends Component<Props> {
2424
return (
2525
<View style={styles.container}>
2626
<StyledText
27-
text="Welcome to <b>React <u>Native</u> <demo><i>Styled</i> Text</demo></b> demo!"
2827
style={styles.welcome}
2928
textStyles={textStyles}
30-
/>
29+
>
30+
{"Welcome to <b>React <u>Native</u> <demo><i>Styled</i> Text</demo></b> demo!"}
31+
</StyledText>
3132
<StyledText
32-
text="Run <code>yarn add react-native-styled-text</code> to install"
3333
style={styles.instruction}
3434
textStyles={textStyles}
35-
/>
35+
>
36+
{"Run <code>yarn add react-native-styled-text</code> to install"}
37+
</StyledText>
3638
<View style={styles.jsxContainer}>
3739
<StyledText
38-
text={'<ltgt>&lt;</ltgt><comp>StyledText</comp>'}
3940
style={styles.jsx}
4041
textStyles={jsxStyles}
41-
/>
42+
>
43+
{'<ltgt>&lt;</ltgt><comp>StyledText</comp>'}
44+
</StyledText>
4245
<StyledText
43-
text={'text<eq>=</eq><string>"Ha&lt;i&gt;pp&lt;/i&gt;y &lt;b&gt;Styling&lt;/b&gt;!"'}
4446
style={[styles.jsx, styles.jsxProp]}
4547
textStyles={jsxStyles}
46-
/>
48+
>
49+
{"style<eq>=</eq><brace>{</brace>styles.header<brace>}</brace>"}
50+
</StyledText>
51+
<StyledText
52+
style={styles.jsx}
53+
textStyles={jsxStyles}
54+
>
55+
{'<ltgt>></ltgt>'}
56+
</StyledText>
4757
<StyledText
48-
text={"style<eq>=</eq><brace>{</brace>styles.header<brace>}</brace>"}
4958
style={[styles.jsx, styles.jsxProp]}
5059
textStyles={jsxStyles}
51-
/>
60+
>
61+
{'<brace>{</brace><string>"Ha&lt;i&gt;pp&lt;/i&gt;y &lt;b&gt;Styling&lt;/b&gt;!"<brace>}</brace>'}
62+
</StyledText>
5263
<StyledText
53-
text="<ltgt>/></ltgt>"
5464
style={styles.jsx}
5565
textStyles={jsxStyles}
56-
/>
66+
>
67+
{'<ltgt>&lt;\/</ltgt><comp>StyledText</comp><ltgt>></ltgt>'}
68+
</StyledText>
5769
</View>
5870
<StyledText
59-
text="Ha<i>pp</i>y <b>Styling</b>!"
6071
style={styles.header}
61-
/>
72+
>
73+
{"Ha<i>pp</i>y <b>Styling</b>!"}
74+
</StyledText>
6275
</View>
6376
);
6477
}
@@ -94,9 +107,10 @@ const styles = StyleSheet.create({
94107
jsx: {
95108
textAlign: 'left',
96109
paddingLeft: 10,
97-
paddingVertical: 4,
110+
paddingVertical: 0,
98111
fontWeight: '500',
99112
fontSize: 12,
113+
100114
fontFamily: 'courier',
101115
},
102116
jsxProp: {

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The purpose of this library is to support easy rendering of mixed text styles.
1111
<img src="https://github.com/fram-x/react-native-styled-text/raw/develop/docs/example-ios.png" width="400" />
1212
<img src="https://github.com/fram-x/react-native-styled-text/raw/develop/docs/example-android.png" width="400" />
1313

14-
The library implements a `StyledText` component taking an HTML-like text and a styles object as input properties.
14+
The library implements a `StyledText` component taking an HTML-like string in the `children` property and an optional text styles property.
1515

1616
## Installation
1717
To install the library into your project, run yarn or npm:
@@ -39,9 +39,10 @@ import StyledText from 'react-native-styled-text';
3939

4040
...
4141
<StyledText
42-
text="Ha<i>pp</i>y <b>Styling</b>!"
4342
style={styles.header}
44-
/>
43+
>
44+
{"Ha<i>pp</i>y <b>Styling</b>!"}
45+
</StyledText>
4546
...
4647

4748
const styles = StyleSheet.create({
@@ -70,10 +71,11 @@ import StyledText from 'react-native-styled-text';
7071

7172
...
7273
<StyledText
73-
text="Welcome to <b><u>React Native</u> <demo><i>Styled</i> Text</demo></b> demo!"
7474
style={styles.welcome}
7575
textStyles={textStyles}
76-
/>
76+
>
77+
{"Welcome to <b><u>React Native</u> <demo><i>Styled</i> Text</demo></b> demo!"}
78+
</StyledText>
7779
...
7880

7981
const styles = StyleSheet.create({
@@ -102,15 +104,16 @@ Renders as
102104

103105
## How it works
104106

105-
Internally, the `render` function of `StyledText` parses the value of the `text` property and returns a nested structure of React Native [`Text`](https://facebook.github.io/react-native/docs/text) components.
107+
Internally, the `render` function of `StyledText` parses the value of the `children` property, which must be a string, and returns a nested structure of React Native [`Text`](https://facebook.github.io/react-native/docs/text) components.
106108

107109
From the example above:
108110

109111
```javascript
110112
<StyledText
111-
text="Ha<i>pp</i>y <b>Styling</b>!"
112113
style={styles.header}
113-
/>
114+
>
115+
{"Ha<i>pp</i>y <b>Styling</b>!"}
116+
</StyledText>
114117
```
115118
would be transformed to:
116119

@@ -125,11 +128,12 @@ So `StyledText` just provides a more compact, readable and flexible coding of ne
125128

126129

127130
## API
128-
In addition to the React Native `Text` properties, `StyledText` supports the following properties:
131+
132+
In addition to the React Native `Text` properties, `StyledText` supports the following properties, with a restriction on the `children` proerty:
129133

130134
| Name | Description |
131135
| ---- | ----------- |
132-
| text | String with style tags for mixed styling of the text. Each style tag must match one of the styles provided in textStyles or one of the default styles, see below. |
136+
| children | String with style tags for mixed styling of the text. Each style tag must match one of the styles provided in textStyles or one of the default styles, see below. (Optional) |
133137
| textStyles | Object (e.g. `StyleSheet`) containing definition of the styles used in the provided text. (Optional) |
134138

135139
The following default styles are defined:

__tests__/App-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import App from '../App';
8+
9+
// Note: test renderer must be required after react-native.
10+
import renderer from 'react-test-renderer';
11+
12+
it('renders correctly', () => {
13+
renderer.create(<App />);
14+
});

android/app/BUCK

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@
88
# - `buck install -r android/app` - compile, install and run application
99
#
1010

11+
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12+
1113
lib_deps = []
1214

13-
for jarfile in glob(['libs/*.jar']):
14-
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
15-
lib_deps.append(':' + name)
16-
prebuilt_jar(
17-
name = name,
18-
binary_jar = jarfile,
19-
)
15+
create_aar_targets(glob(["libs/*.aar"]))
2016

21-
for aarfile in glob(['libs/*.aar']):
22-
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
23-
lib_deps.append(':' + name)
24-
android_prebuilt_aar(
25-
name = name,
26-
aar = aarfile,
27-
)
17+
create_jar_targets(glob(["libs/*.jar"]))
2818

2919
android_library(
3020
name = "all-libs",

android/app/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,25 @@ def enableProguardInReleaseBuilds = false
9595

9696
android {
9797
compileSdkVersion rootProject.ext.compileSdkVersion
98-
buildToolsVersion rootProject.ext.buildToolsVersion
98+
99+
compileOptions {
100+
sourceCompatibility JavaVersion.VERSION_1_8
101+
targetCompatibility JavaVersion.VERSION_1_8
102+
}
99103

100104
defaultConfig {
101105
applicationId "com.reactnativestyledtext"
102106
minSdkVersion rootProject.ext.minSdkVersion
103107
targetSdkVersion rootProject.ext.targetSdkVersion
104108
versionCode 1
105109
versionName "1.0"
106-
ndk {
107-
abiFilters "armeabi-v7a", "x86"
108-
}
109110
}
110111
splits {
111112
abi {
112113
reset()
113114
enable enableSeparateBuildPerCPUArchitecture
114115
universalApk false // If true, also generate a universal APK
115-
include "armeabi-v7a", "x86"
116+
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
116117
}
117118
}
118119
buildTypes {
@@ -126,7 +127,7 @@ android {
126127
variant.outputs.each { output ->
127128
// For each separate APK per architecture, set a unique version code as described here:
128129
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
129-
def versionCodes = ["armeabi-v7a":1, "x86":2]
130+
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
130131
def abi = output.getFilter(OutputFile.ABI)
131132
if (abi != null) { // null for the universal-debug, universal-release variants
132133
output.versionCodeOverride =

android/app/build_defs.bzl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Helper definitions to glob .aar and .jar targets"""
2+
3+
def create_aar_targets(aarfiles):
4+
for aarfile in aarfiles:
5+
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6+
lib_deps.append(":" + name)
7+
android_prebuilt_aar(
8+
name = name,
9+
aar = aarfile,
10+
)
11+
12+
def create_jar_targets(jarfiles):
13+
for jarfile in jarfiles:
14+
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15+
lib_deps.append(":" + name)
16+
prebuilt_jar(
17+
name = name,
18+
binary_jar = jarfile,
19+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
6+
7+
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
8+
</manifest>

0 commit comments

Comments
 (0)