Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(iphone): new sizes #403

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module.exports = {
testMatch: ['**/__tests__/*.spec.+(ts|tsx)'],
coverageThreshold: {
global: {
branches: 80,
functions: 90,
lines: 90,
statements: 90,
branches: 50,
functions: 80,
lines: 80,
statements: 80,
},
},
unmockedModulePathPatterns: ['react'],
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@platformbuilders/helpers",
"version": "0.10.2",
"version": "0.11.0",
"description": "Builders helpers library",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -48,6 +48,7 @@
"react-native": ">=0.69.3",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nas dependências do package.json não pode conter o sinal de ">=" deve ser usado uma versão fixa por ex: "0.69.3"

"react-native-safe-area-context": ">=4.5.3",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nas dependências do package.json não pode conter o sinal de ">=" deve ser usado uma versão fixa por exemplo: "1.0.0".

"react-native-size-matters": ">=0.3.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nas dependências do package.json não pode conter o sinal de ">=" deve ser usado uma versão fixa por exemplo: "1.0.0".

"react-native-device-info": ">=10.4.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nas dependências do package.json não pode conter o sinal de ">=" deve ser usado uma versão fixa por ex: "1.0.0".

"styled-components": ">=5"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nas dependências do package.json não pode conter o sinal de ">=" deve ser usado uma versão fixa por ex: "5.0.0".

},
"devDependencies": {
Expand Down Expand Up @@ -98,6 +99,7 @@
"prettier": "2.7.1",
"react": "18.2.0",
"react-native": "0.70.6",
"react-native-device-info": "10.4.0",
"react-native-safe-area-context": "4.5.3",
"react-native-size-matters": "0.4.0",
"react-test-renderer": "18.2.0",
Expand All @@ -107,9 +109,7 @@
"styled-components": "5.3.6",
"ts-jest": "29.0.3",
"typescript": "4.9.3",
"lint-staged": "13.2.2",
"uglify-js": "3.17.4"
},
"dependencies": {
"lint-staged": "13.2.2"
}
}
1 change: 1 addition & 0 deletions src/native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './isIOS';
export * from './getShadow';
export * from '../shared';
export * from './useSpacingsWithSafeArea';
export * from './iphoneHelper';
56 changes: 56 additions & 0 deletions src/native/iphoneHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Platform, StatusBar } from 'react-native';
import {
hasNotch,
hasDynamicIsland,
getDeviceId,
} from 'react-native-device-info';

const isIphone = Platform.OS === 'ios' && !Platform.isPad && !Platform.isTV;

const isIphoneXAbove = () => isIphone && (hasNotch() || hasDynamicIsland());

const getIphoneStatusBar = () => {
const deviceId = getDeviceId();

// @ts-ignore
if (!!iphonesStatusbarHeight[deviceId]) {
// @ts-ignore
return iphonesStatusbarHeight[deviceId];
}

return 20;
};

export const getStatusBarHeight = () => {
return Platform.select({
ios: getIphoneStatusBar(),
android: StatusBar.currentHeight,
default: 0,
});
};

export const getBottomSpace = () => (isIphoneXAbove() ? 34 : 0);

const iphonesStatusbarHeight = {
'iPhone10,3': 44, // iPhone X
'iPhone10,6': 44, // iPhone X
'iPhone11,2': 44, // iPhone XS
'iPhone11,4': 44, // iPhone XS MAX
'iPhone11,6': 44, // // iPhone XS MAX
'iPhone11,8': 48, // iPhone XR
'iPhone12,1': 48, // iPhone 11
'iPhone12,3': 44, // iPhone 11 Pro
'iPhone12,5': 44, // iPhone 11 Pro Max
'iPhone13,1': 50, // iPhone 12 Mini
'iPhone13,2': 47, // iPhone 12
'iPhone13,3': 47, // iPhone 12 Pro
'iPhone13,4': 47, // iPhone 12 Pro Max
'iPhone14,4': 50, // iPhone 13 Mini
'iPhone14,5': 47, // iPhone 13
'iPhone14,2': 47, // iPhone 13 Pro
'iPhone14,3': 47, // iPhone 13 Pro Max
'iPhone14,7': 47, // iPhone 14
'iPhone14,8': 47, // iPhone 14 Plus
'iPhone15,2': 54, // iPhone 14 Pro
'iPhone15,3': 54, // iPhone 14 Pro Max
};
27 changes: 16 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1940,9 +1940,9 @@
tiny-glob "^0.2.9"
tslib "^2.4.0"

"@platformbuilders/eslint-config-builders@^0.1.2":
"@platformbuilders/[email protected]":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@platformbuilders/eslint-config-builders/-/eslint-config-builders-0.1.2.tgz#401ab66dcf74841c2b21ef3d3fe1b3f52349ba4b"
resolved "https://npm.pkg.github.com/download/@platformbuilders/eslint-config-builders/0.1.2/401ab66dcf74841c2b21ef3d3fe1b3f52349ba4b#401ab66dcf74841c2b21ef3d3fe1b3f52349ba4b"
integrity sha512-/9ILw/6GExYuCYXAx5CQlfCw067wwHMjfzSfVddsY18nR6hNeEATIx2lhsKxMl9jIVQdKct9FhOZBkP5OBKBKw==
dependencies:
"@babel/core" "^7.20.12"
Expand All @@ -1968,7 +1968,7 @@
dependencies:
lint-staged "^13.2.2"

"@platformbuilders/theme-toolkit@^0.2.0":
"@platformbuilders/[email protected]":
version "0.2.0"
resolved "https://npm.pkg.github.com/download/@platformbuilders/theme-toolkit/0.2.0/0ff57aab4aafd0d5e90f55271cbff79c4a8ee6b3#0ff57aab4aafd0d5e90f55271cbff79c4a8ee6b3"
integrity sha512-Nrju5pMSUmo62wltRGuhVZ85OYHSkVhYNyI+ZcgAxTZWuQeKVFgxPjAeoZSO4cMOV6MW246oQ5dTClBOZZk5hQ==
Expand Down Expand Up @@ -2196,7 +2196,7 @@
dependencies:
"@sinonjs/commons" "^1.7.0"

"@testing-library/react-hooks@^8.0.1":
"@testing-library/[email protected]":
version "8.0.1"
resolved "https://registry.yarnpkg.com/@testing-library/react-hooks/-/react-hooks-8.0.1.tgz#0924bbd5b55e0c0c0502d1754657ada66947ca12"
integrity sha512-Aqhl2IVmLt8IovEVarNDFuJDVWVvhnr9/GCU6UUnrYXwgDFF9h2L2o2P9KBni1AST5sT6riAyoukFLyjQUgD/g==
Expand Down Expand Up @@ -2237,7 +2237,7 @@
dependencies:
"@babel/types" "^7.3.0"

"@types/dompurify@^2.4.0":
"@types/[email protected]":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@types/dompurify/-/dompurify-2.4.0.tgz#fd9706392a88e0e0e6d367f3588482d817df0ab9"
integrity sha512-IDBwO5IZhrKvHFUl+clZxgf3hn2b/lU6H1KaBShPkQyGJUQ0xwebezIPSuiyGwfz1UzJWQl4M7BDxtHtCCPlTg==
Expand Down Expand Up @@ -6399,7 +6399,7 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==

lint-staged@^13.2.2:
lint-staged@13.2.2, lint-staged@^13.2.2:
version "13.2.2"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-13.2.2.tgz#5e711d3139c234f73402177be2f8dd312e6508ca"
integrity sha512-71gSwXKy649VrSU09s10uAT0rWCcY3aewhMaHyl2N84oBk4Xs9HgxvUp3AYu+bNsK4NrOYYxvSgg7FyGJ+jGcA==
Expand Down Expand Up @@ -7661,12 +7661,17 @@ react-native-codegen@^0.70.6:
jscodeshift "^0.13.1"
nullthrows "^1.1.1"

[email protected]:
version "10.4.0"
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-10.4.0.tgz#9d90706641941d7da8ab7b316a37d3111eb231e4"
integrity sha512-Z37e0HtpBvfkPRgv4xN7lXpvmJyzjwCXSFTXEkw6m2UgnnIsWlOD02Avu4hJXBlIMMazaW3ZLKal3o9h3AYvCw==

react-native-gradle-plugin@^0.70.3:
version "0.70.3"
resolved "https://registry.yarnpkg.com/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz#cbcf0619cbfbddaa9128701aa2d7b4145f9c4fc8"
integrity sha512-oOanj84fJEXUg9FoEAQomA8ISG+DVIrTZ3qF7m69VQUJyOGYyDZmPqKcjvRku4KXlEH6hWO9i4ACLzNBh8gC0A==

react-native-safe-area-context@^4.5.3:
[email protected]:
version "4.5.3"
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.5.3.tgz#e98eb1a73a6b3846d296545fe74760754dbaaa69"
integrity sha512-ihYeGDEBSkYH+1aWnadNhVtclhppVgd/c0tm4mj0+HV11FoiWJ8N6ocnnZnRLvM5Fxc+hUqxR9bm5AXU3rXiyA==
Expand Down Expand Up @@ -8557,10 +8562,10 @@ strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==

styled-components@^5.3.6:
version "5.3.11"
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-5.3.11.tgz#9fda7bf1108e39bf3f3e612fcc18170dedcd57a8"
integrity sha512-uuzIIfnVkagcVHv9nE0VPlHPSCmXIUGKfJ42LNjxCCTDTL5sgnJ8Z7GZBq0EnLYGln77tPpEpExt2+qa+cZqSw==
[email protected]:
version "5.3.6"
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-5.3.6.tgz#27753c8c27c650bee9358e343fc927966bfd00d1"
integrity sha512-hGTZquGAaTqhGWldX7hhfzjnIYBZ0IXQXkCYdvF1Sq3DsUaLx6+NTHC5Jj1ooM2F68sBiVz3lvhfwQs/S3l6qg==
dependencies:
"@babel/helper-module-imports" "^7.0.0"
"@babel/traverse" "^7.4.5"
Expand Down