Skip to content

Commit

Permalink
v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarCruz committed Jan 10, 2019
1 parent 2ddea0f commit f6a5844
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 115 deletions.
66 changes: 28 additions & 38 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
# node.js
#
node_modules/
*.log
*.bak
yarn.lock

# OSX / Xcode
#
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.pbxuser
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
.*
.bak/
.DS_Store
.gradle
.idea
*.bak
*.hmap
*.iml
*.ipa
*.keystore
*.log
*.mode1v3
*.mode2v3
*.moved-aside
*.pbxuser
*.perspectivev3
*.tgz
*.xccheckout
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
.idea
.gradle
**/.vscode/.react/
\.buckd/
~*
android/build/
local.properties
*.iml

# BUCK
buck-out/
\.buckd/
*.keystore

# Development
.bak/
.docs/
**/.vscode/.react/
*.tgz
build/
DerivedData
local.properties
node_modules/
package-lock.json
project.xcworkspace
xcuserdata
yarn.lock
58 changes: 28 additions & 30 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
# Almost the same as .gitignore, but for publishing or local installation
#
node_modules/
*.log
*.bak
yarn.lock
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.pbxuser
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
.*
.bak/
.DS_Store
.gradle
.idea
*.bak
*.hmap
*.iml
*.ipa
*.keystore
*.log
*.mode1v3
*.mode2v3
*.moved-aside
*.pbxuser
*.perspectivev3
*.tgz
*.xccheckout
*.xcuserstate
project.xcworkspace
.idea
.gradle
**/.vscode/.react/
\.buckd/
~*
android/build/
local.properties
*.iml
buck-out/
\.buckd/
*.keystore
# Development
.bak/
.docs/
**/.vscode/.react/
example/
*.tgz
build/
DerivedData
local.properties
node_modules/
package-lock.json
project.xcworkspace
xcuserdata
yarn.lock
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@

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).

## \[2.1.0] - 2019-01-10
## \[3.0.0] - 2019-01-10

### Added

- Support `textTransform:uppercase` for specsForTextStyles in Android.

### Changed

- peerDependency on react-native to >=57.0
- Update gradle files to be consistent with RN 0.57
- Update License year.

### Removed

- Unused 'example' directory.

## \[2.1.1] - 2019-01-10

### Added

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 2-Clause License

Copyright (c) 2018 Alberto Martínez.
Copyright (c) 2018-2019 Alberto Martínez.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ yarn add react-native-text-size
react-native link react-native-text-size
```

Change the `compile` directive to `implementation` in the dependencies block of the android/app/build.gradle file.

**Requirements:**

- React Native v0.52 to v0.56.
- React Native v0.57 or later.
- Android API 16 or iOS 9.0 and above.

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.
For versions prior to 0.56 of React Native, please use react-native-text-size v2.1.0

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

Expand Down Expand Up @@ -95,7 +97,7 @@ fontSize | number | 14 | The default font size comes from RN.
fontStyle | string | 'normal' | One of "normal" or "italic".
fontVariant | array | (none) | _iOS only_
allowFontScaling | boolean | true | To respect the user' setting of large fonts (i.e. use SP units).
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+_
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+_
includeFontPadding | boolean | true | Include additional top and bottom padding, to avoid clipping certain characters.<br>_Android only_
textBreakStrategy | string | 'highQuality' | One of 'simple', 'balanced', or 'highQuality'.<br>_Android only, with API 23+_
width | number | MAX_INT | Restrict the width. The resulting height will vary depending on the automatic flow of the text.
Expand Down Expand Up @@ -382,7 +384,7 @@ Thanks for your support!

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

&copy; 2018, Alberto Martínez. All rights reserved.
&copy; 2018-2019, Alberto Martínez. All rights reserved.

[npm-badge]: https://img.shields.io/npm/v/react-native-text-size.svg
[npm-url]: https://www.npmjs.com/package/react-native-text-size
Expand Down
34 changes: 9 additions & 25 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@ def safeExtGet(prop, fallback) {
return rootProject.ext.hasProperty(prop) ? rootProject.ext.get(prop) : fallback
}

def _buildToolsVersion = safeExtGet('buildToolsVersion', '26.0.3')
def _compileSdkVersion = safeExtGet('compileSdkVersion', 26)
def _buildToolsVersion = safeExtGet('buildToolsVersion', '27.0.3')
def _compileSdkVersion = safeExtGet('compileSdkVersion', 27)
def _targetSdkVersion = safeExtGet('targetSdkVersion', 26)
def _minSdkVersion = safeExtGet('minSdkVersion', 16)

buildscript {
repositories {
maven {
url 'https://maven.google.com/'
name 'google'
}
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.1.4'
}
}

Expand All @@ -35,43 +32,30 @@ android {
defaultConfig {
minSdkVersion _minSdkVersion
targetSdkVersion _targetSdkVersion
versionCode 2
versionCode 3
versionName getPackageVersion()
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}

repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
name 'React Native (local)'
}
maven {
url 'https://maven.google.com/'
name 'google'
}
jcenter()
}

dependencies {
compile 'com.facebook.react:react-native:+'
compileOnly 'com.facebook.react:react-native:+'
}

task customClean(type: Delete) {
delete rootProject.buildDir
}
clean.dependsOn customClean

//gradle.projectsEvaluated {
// tasks.withType(JavaCompile) {
// options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
// }
//}
clean.dependsOn customClean
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ static boolean supportLetterSpacing() {
return reactNativeVersion >= 55;
}

static boolean supportUpperCaseTransform() {
return reactNativeVersion >= 57;
}

private final ReadableMap mOpts;
private final boolean allowFontScaling;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void measure(@Nullable final ReadableMap specs, final Promise promise) {

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

/**
* See https://material.io/design/typography/#type-scale
*
* TODO:
* Send PR to RN for supporting textTransform, like the iOS one in
* https://github.com/facebook/react-native/commit/8621d4b79731e13a0c6e397abd93c193c6219000
*/
@SuppressWarnings("unused")
@ReactMethod
Expand All @@ -277,9 +273,9 @@ public void specsForTextStyles(final Promise promise) {
result.putMap("subtitle2", makeFontSpecs("-medium", 14, 0.1));
result.putMap("body1", makeFontSpecs(null, 16, 0.5));
result.putMap("body2", makeFontSpecs(null, 14, 0.25));
result.putMap("button", makeFontSpecs("-medium", 14, 0.75));
result.putMap("button", makeFontSpecs("-medium", 14, 0.75, true));
result.putMap("caption", makeFontSpecs(null, 12, 0.4));
result.putMap("overline", makeFontSpecs(null, 10, 1.5));
result.putMap("overline", makeFontSpecs(null, 10, 1.5, true));

promise.resolve(result);
}
Expand Down Expand Up @@ -382,7 +378,7 @@ private double minimalHeight(final float density, final boolean includeFontPaddi
* @param letterSpacing Sugest this to user
* @return map with specs
*/
private WritableMap makeFontSpecs(String suffix, int fontSize, double letterSpacing) {
private WritableMap makeFontSpecs(String suffix, int fontSize, double letterSpacing, boolean upcase) {
final WritableMap map = Arguments.createMap();
final String roboto = "sans-serif";

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

if (upcase && RNTextSizeConf.supportUpperCaseTransform()) {
map.putString("textTransform", "uppercase");
}

return map;
}

private WritableMap makeFontSpecs(String suffix, int fontSize, double letterSpacing) {
return makeFontSpecs(suffix, fontSize, letterSpacing, false);
}

@NonNull
private WritableMap fontInfoFromTypeface(
@NonNull final TextPaint textPaint,
Expand Down
5 changes: 0 additions & 5 deletions example/README.md

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-text-size",
"version": "2.1.0",
"version": "3.0.0",
"description": "Measure text accurately before laying it out and get font information from your App",
"main": "index.js",
"keywords": [
Expand All @@ -25,6 +25,6 @@
"clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && cd android && ./gradlew clean"
},
"peerDependencies": {
"react-native": ">=0.52.0 <0.57.0"
"react-native": ">=0.57.0"
}
}

0 comments on commit f6a5844

Please sign in to comment.