Skip to content

Commit f6a5844

Browse files
author
aMarCruz
committed
v3.0.0
1 parent 2ddea0f commit f6a5844

File tree

12 files changed

+108
-115
lines changed

12 files changed

+108
-115
lines changed

.gitignore

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,36 @@
1-
# node.js
2-
#
3-
node_modules/
4-
*.log
5-
*.bak
6-
yarn.lock
7-
8-
# OSX / Xcode
9-
#
10-
.DS_Store
11-
build/
12-
*.pbxuser
13-
!default.pbxuser
14-
*.mode1v3
151
!default.mode1v3
16-
*.mode2v3
172
!default.mode2v3
18-
*.perspectivev3
3+
!default.pbxuser
194
!default.perspectivev3
20-
xcuserdata
21-
*.xccheckout
22-
*.moved-aside
23-
DerivedData
5+
.*
6+
.bak/
7+
.DS_Store
8+
.gradle
9+
.idea
10+
*.bak
2411
*.hmap
12+
*.iml
2513
*.ipa
14+
*.keystore
15+
*.log
16+
*.mode1v3
17+
*.mode2v3
18+
*.moved-aside
19+
*.pbxuser
20+
*.perspectivev3
21+
*.tgz
22+
*.xccheckout
2623
*.xcuserstate
27-
project.xcworkspace
28-
29-
# Android/IntelliJ
30-
#
31-
.idea
32-
.gradle
24+
**/.vscode/.react/
25+
\.buckd/
26+
~*
3327
android/build/
34-
local.properties
35-
*.iml
36-
37-
# BUCK
3828
buck-out/
39-
\.buckd/
40-
*.keystore
41-
42-
# Development
43-
.bak/
44-
.docs/
45-
**/.vscode/.react/
46-
*.tgz
29+
build/
30+
DerivedData
31+
local.properties
32+
node_modules/
33+
package-lock.json
34+
project.xcworkspace
35+
xcuserdata
36+
yarn.lock

.npmignore

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
# Almost the same as .gitignore, but for publishing or local installation
2-
#
3-
node_modules/
4-
*.log
5-
*.bak
6-
yarn.lock
7-
.DS_Store
8-
build/
9-
*.pbxuser
10-
!default.pbxuser
11-
*.mode1v3
121
!default.mode1v3
13-
*.mode2v3
142
!default.mode2v3
15-
*.perspectivev3
3+
!default.pbxuser
164
!default.perspectivev3
17-
xcuserdata
18-
*.xccheckout
19-
*.moved-aside
20-
DerivedData
5+
.*
6+
.bak/
7+
.DS_Store
8+
.gradle
9+
.idea
10+
*.bak
2111
*.hmap
12+
*.iml
2213
*.ipa
14+
*.keystore
15+
*.log
16+
*.mode1v3
17+
*.mode2v3
18+
*.moved-aside
19+
*.pbxuser
20+
*.perspectivev3
21+
*.tgz
22+
*.xccheckout
2323
*.xcuserstate
24-
project.xcworkspace
25-
.idea
26-
.gradle
24+
**/.vscode/.react/
25+
\.buckd/
26+
~*
2727
android/build/
28-
local.properties
29-
*.iml
3028
buck-out/
31-
\.buckd/
32-
*.keystore
33-
# Development
34-
.bak/
35-
.docs/
36-
**/.vscode/.react/
37-
example/
38-
*.tgz
29+
build/
30+
DerivedData
31+
local.properties
32+
node_modules/
33+
package-lock.json
34+
project.xcworkspace
35+
xcuserdata
36+
yarn.lock

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22

33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

5-
## \[2.1.0] - 2019-01-10
5+
## \[3.0.0] - 2019-01-10
6+
7+
### Added
8+
9+
- Support `textTransform:uppercase` for specsForTextStyles in Android.
10+
11+
### Changed
12+
13+
- peerDependency on react-native to >=57.0
14+
- Update gradle files to be consistent with RN 0.57
15+
- Update License year.
16+
17+
### Removed
18+
19+
- Unused 'example' directory.
20+
21+
## \[2.1.1] - 2019-01-10
622

723
### Added
824

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 2-Clause License
22

3-
Copyright (c) 2018 Alberto Martínez.
3+
Copyright (c) 2018-2019 Alberto Martínez.
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ yarn add react-native-text-size
4343
react-native link react-native-text-size
4444
```
4545

46+
Change the `compile` directive to `implementation` in the dependencies block of the android/app/build.gradle file.
47+
4648
**Requirements:**
4749

48-
- React Native v0.52 to v0.56.
50+
- React Native v0.57 or later.
4951
- Android API 16 or iOS 9.0 and above.
5052

51-
If you are using Gradle 4 or later, don't forget to change the `compile` directive to `implementation` in the dependencies block of the android/app/build.gradle file.
53+
For versions prior to 0.56 of React Native, please use react-native-text-size v2.1.0
5254

5355
See [Manual Installation][2] on the Wiki as an alternative if you have problems with automatic installation.
5456

@@ -95,7 +97,7 @@ fontSize | number | 14 | The default font size comes from RN.
9597
fontStyle | string | 'normal' | One of "normal" or "italic".
9698
fontVariant | array | (none) | _iOS only_
9799
allowFontScaling | boolean | true | To respect the user' setting of large fonts (i.e. use SP units).
98-
letterSpacing | number | (none) | Additional spacing between characters (aka `tracking`).<br>**Note:** In iOS a zero cancels automatic kerning.<br>_All iOS, Android with API 21+ and RN 0.55+_
100+
letterSpacing | number | (none) | Additional spacing between characters (aka `tracking`).<br>**Note:** In iOS a zero cancels automatic kerning.<br>_All iOS, Android with API 21+_
99101
includeFontPadding | boolean | true | Include additional top and bottom padding, to avoid clipping certain characters.<br>_Android only_
100102
textBreakStrategy | string | 'highQuality' | One of 'simple', 'balanced', or 'highQuality'.<br>_Android only, with API 23+_
101103
width | number | MAX_INT | Restrict the width. The resulting height will vary depending on the automatic flow of the text.
@@ -382,7 +384,7 @@ Thanks for your support!
382384

383385
The [BSD 2-Clause](LICENSE) "Simplified" License.
384386

385-
&copy; 2018, Alberto Martínez. All rights reserved.
387+
&copy; 2018-2019, Alberto Martínez. All rights reserved.
386388

387389
[npm-badge]: https://img.shields.io/npm/v/react-native-text-size.svg
388390
[npm-url]: https://www.npmjs.com/package/react-native-text-size

android/build.gradle

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,18 @@ def safeExtGet(prop, fallback) {
88
return rootProject.ext.hasProperty(prop) ? rootProject.ext.get(prop) : fallback
99
}
1010

11-
def _buildToolsVersion = safeExtGet('buildToolsVersion', '26.0.3')
12-
def _compileSdkVersion = safeExtGet('compileSdkVersion', 26)
11+
def _buildToolsVersion = safeExtGet('buildToolsVersion', '27.0.3')
12+
def _compileSdkVersion = safeExtGet('compileSdkVersion', 27)
1313
def _targetSdkVersion = safeExtGet('targetSdkVersion', 26)
1414
def _minSdkVersion = safeExtGet('minSdkVersion', 16)
1515

1616
buildscript {
1717
repositories {
18-
maven {
19-
url 'https://maven.google.com/'
20-
name 'google'
21-
}
18+
google()
2219
jcenter()
2320
}
2421
dependencies {
25-
classpath 'com.android.tools.build:gradle:2.3.3'
22+
classpath 'com.android.tools.build:gradle:3.1.4'
2623
}
2724
}
2825

@@ -35,43 +32,30 @@ android {
3532
defaultConfig {
3633
minSdkVersion _minSdkVersion
3734
targetSdkVersion _targetSdkVersion
38-
versionCode 2
35+
versionCode 3
3936
versionName getPackageVersion()
4037
}
4138
lintOptions {
4239
abortOnError false
4340
}
44-
compileOptions {
45-
sourceCompatibility JavaVersion.VERSION_1_7
46-
targetCompatibility JavaVersion.VERSION_1_7
47-
}
4841
}
4942

5043
repositories {
5144
mavenLocal()
45+
google()
46+
jcenter()
5247
maven {
5348
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
5449
url "$rootDir/../node_modules/react-native/android"
55-
name 'React Native (local)'
56-
}
57-
maven {
58-
url 'https://maven.google.com/'
59-
name 'google'
6050
}
61-
jcenter()
6251
}
6352

6453
dependencies {
65-
compile 'com.facebook.react:react-native:+'
54+
compileOnly 'com.facebook.react:react-native:+'
6655
}
6756

6857
task customClean(type: Delete) {
6958
delete rootProject.buildDir
7059
}
71-
clean.dependsOn customClean
7260

73-
//gradle.projectsEvaluated {
74-
// tasks.withType(JavaCompile) {
75-
// options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
76-
// }
77-
//}
61+
clean.dependsOn customClean
693 Bytes
Binary file not shown.

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

android/src/main/java/com/github/amarcruz/rntextsize/RNTextSizeConf.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ static boolean supportLetterSpacing() {
5656
return reactNativeVersion >= 55;
5757
}
5858

59+
static boolean supportUpperCaseTransform() {
60+
return reactNativeVersion >= 57;
61+
}
62+
5963
private final ReadableMap mOpts;
6064
private final boolean allowFontScaling;
6165

android/src/main/java/com/github/amarcruz/rntextsize/RNTextSizeModule.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void measure(@Nullable final ReadableMap specs, final Promise promise) {
162162

163163
Integer lineInfoForLine = conf.getIntOrNull("lineInfoForLine");
164164
if (lineInfoForLine != null && lineInfoForLine >= 0) {
165-
final int line = Math.max(lineInfoForLine, lineCount);
165+
final int line = Math.min(lineInfoForLine, lineCount);
166166
final WritableMap info = Arguments.createMap();
167167
info.putInt("line", line);
168168
info.putInt("start", layout.getLineStart(line));
@@ -257,10 +257,6 @@ public void flatHeights(@Nullable final ReadableMap specs, final Promise promise
257257

258258
/**
259259
* See https://material.io/design/typography/#type-scale
260-
*
261-
* TODO:
262-
* Send PR to RN for supporting textTransform, like the iOS one in
263-
* https://github.com/facebook/react-native/commit/8621d4b79731e13a0c6e397abd93c193c6219000
264260
*/
265261
@SuppressWarnings("unused")
266262
@ReactMethod
@@ -277,9 +273,9 @@ public void specsForTextStyles(final Promise promise) {
277273
result.putMap("subtitle2", makeFontSpecs("-medium", 14, 0.1));
278274
result.putMap("body1", makeFontSpecs(null, 16, 0.5));
279275
result.putMap("body2", makeFontSpecs(null, 14, 0.25));
280-
result.putMap("button", makeFontSpecs("-medium", 14, 0.75));
276+
result.putMap("button", makeFontSpecs("-medium", 14, 0.75, true));
281277
result.putMap("caption", makeFontSpecs(null, 12, 0.4));
282-
result.putMap("overline", makeFontSpecs(null, 10, 1.5));
278+
result.putMap("overline", makeFontSpecs(null, 10, 1.5, true));
283279

284280
promise.resolve(result);
285281
}
@@ -382,7 +378,7 @@ private double minimalHeight(final float density, final boolean includeFontPaddi
382378
* @param letterSpacing Sugest this to user
383379
* @return map with specs
384380
*/
385-
private WritableMap makeFontSpecs(String suffix, int fontSize, double letterSpacing) {
381+
private WritableMap makeFontSpecs(String suffix, int fontSize, double letterSpacing, boolean upcase) {
386382
final WritableMap map = Arguments.createMap();
387383
final String roboto = "sans-serif";
388384

@@ -394,9 +390,17 @@ private WritableMap makeFontSpecs(String suffix, int fontSize, double letterSpac
394390
map.putDouble("letterSpacing", letterSpacing);
395391
}
396392

393+
if (upcase && RNTextSizeConf.supportUpperCaseTransform()) {
394+
map.putString("textTransform", "uppercase");
395+
}
396+
397397
return map;
398398
}
399399

400+
private WritableMap makeFontSpecs(String suffix, int fontSize, double letterSpacing) {
401+
return makeFontSpecs(suffix, fontSize, letterSpacing, false);
402+
}
403+
400404
@NonNull
401405
private WritableMap fontInfoFromTypeface(
402406
@NonNull final TextPaint textPaint,

0 commit comments

Comments
 (0)