Skip to content

Commit a18f657

Browse files
committed
new: Some of the function returning type definitions are added. getStatusBarHeight undefined warning is fixed
1 parent 208eced commit a18f657

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

lib/helpers/notch/Notch.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Dimensions, ScaledSize, Platform, StatusBar } from "react-native";
2+
const DEFAULT_STATUSBAR_HEIGHT = 30;
23
// ? iPhone X Family
34
// iPhone X Dimension
45
const iPhoneX_HEIGHT = 812;
@@ -33,15 +34,15 @@ const iPhone12Mini_HEIGHT = 812;
3334
* hasNotch is more accurate name
3435
*/
3536

36-
const isIPhoneNotchFamily = () => {
37+
const isIPhoneNotchFamily = (): boolean => {
3738
return detection();
3839
};
3940

40-
const isIPhoneXFamily = () => {
41+
const isIPhoneXFamily = (): boolean => {
4142
return detection();
4243
};
4344

44-
const hasNotch = () => {
45+
const hasNotch = (): boolean => {
4546
return detection();
4647
};
4748

@@ -63,7 +64,7 @@ const isIPhone12ProMax = (dim: ScaledSize) =>
6364
dim.height === iPhone12ProMax_HEIGHT;
6465
const isIPhone12Mini = (dim: ScaledSize) => dim.height === iPhone12Mini_HEIGHT;
6566

66-
const detection = () => {
67+
const detection = (): boolean => {
6768
const dim = Dimensions.get("window");
6869
return (
6970
Platform.OS === "ios" &&
@@ -82,11 +83,13 @@ const detection = () => {
8283
);
8384
};
8485

85-
const getStatusBarHeight = () => {
86-
return Platform.select({
87-
ios: hasNotch() ? 44 : 30,
88-
android: StatusBar.currentHeight,
89-
});
86+
const getStatusBarHeight = (): number => {
87+
return (
88+
Platform.select({
89+
ios: hasNotch() ? 44 : DEFAULT_STATUSBAR_HEIGHT,
90+
android: StatusBar.currentHeight || DEFAULT_STATUSBAR_HEIGHT,
91+
}) || DEFAULT_STATUSBAR_HEIGHT
92+
);
9093
};
9194

9295
export {

lib/helpers/text/Text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const numberFormat = (
22
value: any,
3-
locale: string = "tr-TR",
3+
locale: string = "en-GB",
44
options: any = {},
55
) => new Intl.NumberFormat(locale, options).format(value);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@freakycoder/react-native-helpers",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "All helpers in one; iPhone series support, dimensions helper, hasNotch helper, normalize text helper and text helpers for React Native with very easy use",
55
"keywords": [
66
"ios",

0 commit comments

Comments
 (0)