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

-3
This file was deleted.

.flowconfig

+1-2
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

+2-2
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

+29-15
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

+14-10
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

+14
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

+4-14
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

+7-6
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

+19
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+
)
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>

android/app/src/main/AndroidManifest.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.reactnativestyledtext">
2+
package="com.reactnativestyledtext">
33

44
<uses-permission android:name="android.permission.INTERNET" />
5-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
65

76
<application
87
android:name=".MainApplication"
98
android:label="@string/app_name"
109
android:icon="@mipmap/ic_launcher"
10+
android:roundIcon="@mipmap/ic_launcher_round"
1111
android:allowBackup="false"
1212
android:theme="@style/AppTheme">
1313
<activity

android/build.gradle

+7-13
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = "27.0.3"
5+
buildToolsVersion = "28.0.3"
66
minSdkVersion = 16
7-
compileSdkVersion = 27
8-
targetSdkVersion = 26
9-
supportLibVersion = "27.1.1"
7+
compileSdkVersion = 28
8+
targetSdkVersion = 28
9+
supportLibVersion = "28.0.0"
1010
}
1111
repositories {
12-
jcenter()
1312
google()
13+
jcenter()
1414
}
1515
dependencies {
16-
classpath 'com.android.tools.build:gradle:3.1.4'
16+
classpath('com.android.tools.build:gradle:3.4.1')
1717

1818
// NOTE: Do not place your application dependencies here; they belong
1919
// in the individual module build.gradle files
@@ -23,17 +23,11 @@ buildscript {
2323
allprojects {
2424
repositories {
2525
mavenLocal()
26+
google()
2627
jcenter()
2728
maven {
2829
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
2930
url "$rootDir/../node_modules/react-native/android"
3031
}
31-
google()
3232
}
3333
}
34-
35-
36-
task wrapper(type: Wrapper) {
37-
gradleVersion = '4.4'
38-
distributionUrl = distributionUrl.replace("bin", "all")
39-
}
1.26 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
34
zipStoreBase=GRADLE_USER_HOME
45
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

android/gradlew

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
#!/usr/bin/env sh
22

3+
#
4+
# Copyright 2015 the original author or authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
319
##############################################################################
420
##
521
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
2844
APP_BASE_NAME=`basename "$0"`
2945

3046
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31-
DEFAULT_JVM_OPTS=""
47+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
3248

3349
# Use the maximum available, or set MAX_FD != -1 to use that value.
3450
MAX_FD="maximum"

0 commit comments

Comments
 (0)