Skip to content

Commit e16559b

Browse files
committed
fixed bugs and added 1.0.0
1 parent 034546c commit e16559b

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ Interested in contributing to this repo? Have a look at our [Contributing Guide]
9191
## Related Projects
9292

9393
#### [react-native-general-calendars](https://github.com/rghorbani/react-native-general-calendars)
94-
A `react-native` component with support of gregorian, jalaali and hijri calendar to selectand work with date and time, created by [@rghorbani](https://github.com/rghorbani).
94+
A `react-native` component with support of gregorian, jalaali and hijri calendar to select and work with date and time, created by [@rghorbani](https://github.com/rghorbani).

jest-setup.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const {NativeModules} = require('react-native');
2+
3+
NativeModules.StatusBarManager = {getHeight: jest.fn()};

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-common",
3-
"version": "0.17.2",
3+
"version": "1.0.0",
44
"description": "React Native common components",
55
"main": "src/index.js",
66
"scripts": {
@@ -51,8 +51,6 @@
5151
"hoist-non-react-statics": "^2.5.0",
5252
"immutable": "~3.8.2",
5353
"lodash": "^4.17.4",
54-
"moment": "^2.21.0",
55-
"moment-jalaali": "^0.7.2",
5654
"prop-types": "~15.6.0",
5755
"react-native-animatable": "^1.2.4",
5856
"react-native-blur": "~3.2.2",
@@ -91,8 +89,10 @@
9189
"preset": "react-native",
9290
"testPathIgnorePatterns": [
9391
"src/components/navigator",
92+
"/e2e/",
9493
"/node_modules/"
95-
]
94+
],
95+
"setupFiles": ["./jest-setup.js"]
9696
},
9797
"rnpm": {
9898
"android": {

src/components/header/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,19 @@ class Header extends BaseComponent {
6666
* style the action bar
6767
*/
6868
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),
69+
/**
70+
* use safe area
71+
*/
72+
useSafeArea: PropTypes.bool,
73+
/**
74+
* Use to identify the button in tests
75+
*/
6976
testID: PropTypes.string,
7077
};
7178

7279
static defaultProps = {
7380
useNative: false,
81+
useSafeArea: true,
7482
backgroundColor: Colors.white,
7583
titleColor: Colors.yellow,
7684
itemsColor: Colors.black
@@ -198,6 +206,7 @@ class Header extends BaseComponent {
198206
leftItems,
199207
rightItems,
200208
itemsColor,
209+
useSafeArea,
201210
style,
202211
} = this.props;
203212

@@ -223,6 +232,7 @@ class Header extends BaseComponent {
223232

224233
return (
225234
<View
235+
useSafeArea={useSafeArea}
226236
style={[
227237
this.styles.container,
228238
style,

src/components/inputs/TextInput.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ class TextInput extends BaseInput {
122122
}
123123

124124
componentWillReceiveProps(nextProps) {
125+
if (nextProps.rtl !== this.props.rtl) {
126+
this.styles = createStyles({
127+
...this.props,
128+
rtl: nextProps.rtl,
129+
});
130+
}
125131
if (nextProps.value !== this.props.value) {
126132
this.setState(
127133
{
@@ -285,10 +291,11 @@ class TextInput extends BaseInput {
285291
}
286292

287293
renderCharCounter() {
294+
const {focused} = this.state;
288295
const {maxLength, showCharacterCounter} = this.props;
289296
if (maxLength && showCharacterCounter) {
290297
const counter = this.getCharCount();
291-
const color = this.isCounterLimit() ? charCountColorLimit : charCountColorDefault;
298+
const color = this.isCounterLimit() && focused ? charCountColorLimit : charCountColorDefault;
292299
return (
293300
<Text
294301
style={[{color}, this.styles.charCounter]}

src/helpers/Constants.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@ const { Dimensions, Platform, NativeModules } = require('react-native');
1010

1111
const { StatusBarManager } = NativeModules;
1212
const { height, width } = Dimensions.get('window');
13+
let statusBarHeight = Platform.OS === 'ios' ? 20 : StatusBarManager.HEIGHT;
1314

1415
module.exports = {
1516
isAndroid: Platform.OS === 'android',
1617
isIOS: Platform.OS === 'ios',
17-
isIphoneX: (Platform.OS === 'ios' && !Platform.isPad && !Platform.isTVOS && (height === 812 || width === 812)),
1818
screenHeight: height,
1919
screenWidth: width,
20-
isSmallScreen: Platform.OS === 'ios' ? (width <= 320) : (width <= 360),
20+
isSmallScreen: Platform.OS === 'ios' ? width <= 320 : width <= 360,
2121
isShortScreen: height <= 600,
22-
statusBarHeight: Platform.OS === 'ios' ? 20 : StatusBarManager.HEIGHT,
22+
statusBarHeight: statusBarHeight,
23+
isIphoneX: Platform.OS === 'ios' && !Platform.isPad && !Platform.isTVOS && (height === 812 || width === 812),
2324
};
25+
26+
if (Platform.OS === 'ios') {
27+
StatusBarManager.getHeight(data => (statusBarHeight = data.height));
28+
}

0 commit comments

Comments
 (0)