Skip to content

Commit 4b4406a

Browse files
authored
Fanchen/fix positioning issue with android (#2)
* fix: include device brand to fix positioning issue within android * fix: fix examples to add brand as prop for SlidingDrawer * docs: update readme to add 'brand' as a prop * chore: prep the source code at root
1 parent d3b4149 commit 4b4406a

File tree

17 files changed

+112
-32
lines changed

17 files changed

+112
-32
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ The example app is running from [`./example/App.tsx`](./example/App.tsx)
103103
| `peekSize` | `number` | (required) | The height of the visible section of the drawer after it is closed. This is also referred to as the peek section. If set to 0, the drawer completely disappears after it is closed. |
104104
| `openSize` | `number` | (required) | The height of the entire visible drawer's after it is opened. Note that this is **NOT** the height of the drawer's open section, but the sum of the heights of the peek and open sections. |
105105
| `fixedLoc` | `'top' \| 'bottom' \| 'left' \| 'right'` | (required) | The location where the sliding drawer is located. Can only be one of the four allowed strings. |
106+
| `brand` | `string` | `''` | Brand of the device. Android only. Use [`react-native-device-info`](https://www.npmjs.com/package/react-native-device-info) to obtain brand name. Brand name is necessary for Android devices because different brands might have different ways to configure drawer positions. Currently supported brand: `'google'`, `'samsung'`. For an unsupported brand, the behavior defaults to that of a Samsung device. If the UI looks wanky, raise an issue or open a pull request to add support for that brand.|
106107
| `drawerWidth` | `number` | `-1` | Manual override of the drawer's width. Applicable only when `fixedLoc` is `top` or `bottom`. Default to -1, meaning no manual override is present. |
107108
| `drawerHeight` | `number` | `-1` | Manual override of the drawer's height. Applicable only when `fixedLoc` is `left` or `right`. Default to -1, meaning no manual override is present. |
108109
| `screenWidth` | `number` | `-1` | Manual override of the screen's width. Generally speaking, this prop does not need to be set as screen width is obtained automatically. But in case the automatic screen width is inaccurate, use this prop to override it. Applicable only when `fixedLoc` is `left` or `right`. Default to -1, meaning no manual override is present. |

example/ios/Podfile.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ PODS:
337337
- React-jsi (= 0.66.4)
338338
- React-logger (= 0.66.4)
339339
- React-perflogger (= 0.66.4)
340+
- RNDeviceInfo (8.7.1):
341+
- React-Core
340342
- Yoga (1.14.0)
341343
- YogaKit (1.18.1):
342344
- Yoga (~> 1.14)
@@ -394,6 +396,7 @@ DEPENDENCIES:
394396
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
395397
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
396398
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
399+
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
397400
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
398401

399402
SPEC REPOS:
@@ -472,6 +475,8 @@ EXTERNAL SOURCES:
472475
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
473476
ReactCommon:
474477
:path: "../node_modules/react-native/ReactCommon"
478+
RNDeviceInfo:
479+
:path: "../node_modules/react-native-device-info"
475480
Yoga:
476481
:path: "../node_modules/react-native/ReactCommon/yoga"
477482

@@ -518,9 +523,10 @@ SPEC CHECKSUMS:
518523
React-RCTVibration: e3ffca672dd3772536cb844274094b0e2c31b187
519524
React-runtimeexecutor: dec32ee6f2e2a26e13e58152271535fadff5455a
520525
ReactCommon: 57b69f6383eafcbd7da625bfa6003810332313c4
526+
RNDeviceInfo: aad3c663b25752a52bf8fce93f2354001dd185aa
521527
Yoga: e7dc4e71caba6472ff48ad7d234389b91dadc280
522528
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
523529

524530
PODFILE CHECKSUM: 9af65361d8a000b8f3b07171fd9cfcc3632878eb
525531

526-
COCOAPODS: 1.11.2
532+
COCOAPODS: 1.11.3

example/package-lock.json

Lines changed: 22 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
1111
},
1212
"dependencies": {
13-
"@fanchenbao/react-native-sliding-drawer": "file:../fanchenbao-react-native-sliding-drawer-0.4.1.tgz",
13+
"@fanchenbao/react-native-sliding-drawer": "file:../fanchenbao-react-native-sliding-drawer-0.4.2.tgz",
1414
"react": "17.0.2",
15-
"react-native": "0.66.4"
15+
"react-native": "0.66.4",
16+
"react-native-device-info": "^8.7.1"
1617
},
1718
"devDependencies": {
1819
"@babel/core": "^7.12.9",

example/src/FadeBgNonSlideOpenNotTappable/Drawers/BottomDrawer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import * as React from 'react';
1212
import {SlidingDrawer} from '../../react-native-sliding-drawer';
1313
import {BottomDrawerContent} from '../../DrawerContent/index';
14+
import {getBrand} from 'react-native-device-info';
1415

1516
type PropsT = {
1617
onDrawerPeek: () => void;
@@ -37,6 +38,7 @@ export const BottomDrawer: React.FC<PropsT> = props => {
3738
peekSize={peekSize}
3839
openSize={openSize}
3940
fixedLoc="bottom"
41+
brand={getBrand()}
4042
onDrawerPeek={onDrawerPeek}
4143
enableNonSlideOpen={true}
4244
nonSlideOpen={nonSlideOpen}

example/src/FadeBgNonSlideOpenNotTappable/Drawers/TopDrawer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import * as React from 'react';
1212
import {SlidingDrawer} from '../../react-native-sliding-drawer';
1313
import {TopDrawerContent} from '../../DrawerContent/index';
14+
import {getBrand} from 'react-native-device-info';
1415

1516
type PropsT = {
1617
onDrawerPeek: () => void;
@@ -37,6 +38,7 @@ export const TopDrawer: React.FC<PropsT> = props => {
3738
peekSize={peekSize}
3839
openSize={openSize}
3940
fixedLoc="top"
41+
brand={getBrand()}
4042
onDrawerPeek={onDrawerPeek}
4143
enableNonSlideOpen={true}
4244
nonSlideOpen={nonSlideOpen}

example/src/FadeBgPeekableNotTappable/Drawers/BottomDrawer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import * as React from 'react';
1212
import {SlidingDrawer} from '../../react-native-sliding-drawer';
1313
import {BottomDrawerContent} from '../../DrawerContent/index';
14+
import {getBrand} from 'react-native-device-info';
1415

1516
/**
1617
* Example for a bottom drawer
@@ -24,6 +25,7 @@ export const BottomDrawer: React.FC = () => {
2425
peekSize={peekSize}
2526
openSize={openSize}
2627
fixedLoc="bottom"
28+
brand={getBrand()}
2729
enableFadeBackground={true}>
2830
<BottomDrawerContent peekSize={peekSize} />
2931
</SlidingDrawer>

example/src/FadeBgPeekableNotTappable/Drawers/TopDrawer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import * as React from 'react';
1212
import {SlidingDrawer} from '../../react-native-sliding-drawer';
1313
import {TopDrawerContent} from '../../DrawerContent/index';
14+
import {getBrand} from 'react-native-device-info';
1415

1516
/**
1617
* Example for a top drawer
@@ -24,6 +25,7 @@ export const TopDrawer: React.FC = () => {
2425
peekSize={peekSize}
2526
openSize={openSize}
2627
fixedLoc="top"
28+
brand={getBrand()}
2729
enableFadeBackground={true}>
2830
<TopDrawerContent peekSize={peekSize} />
2931
</SlidingDrawer>

example/src/FadeBgTappable/Drawers/BottomDrawer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import * as React from 'react';
1212
import {SlidingDrawer} from '../../react-native-sliding-drawer';
1313
import {BottomDrawerContent} from '../../DrawerContent/index';
14+
import {getBrand} from 'react-native-device-info';
1415

1516
type PropsT = {
1617
isInitialPeek: boolean;
@@ -47,6 +48,7 @@ export const BottomDrawer: React.FC<PropsT> = props => {
4748
peekSize={peekSize}
4849
openSize={openSize}
4950
fixedLoc="bottom"
51+
brand={getBrand()}
5052
onDrawerOpen={onDrawerOpen}
5153
onDrawerPeek={onDrawerPeek}
5254
isInitialPeek={isInitialPeek}

example/src/FadeBgTappable/Drawers/TopDrawer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import * as React from 'react';
1212
import {SlidingDrawer} from '../../react-native-sliding-drawer';
1313
import {TopDrawerContent} from '../../DrawerContent/index';
14+
import {getBrand} from 'react-native-device-info';
1415

1516
type PropsT = {
1617
isInitialPeek: boolean;
@@ -47,6 +48,7 @@ export const TopDrawer: React.FC<PropsT> = props => {
4748
peekSize={peekSize}
4849
openSize={openSize}
4950
fixedLoc="top"
51+
brand={getBrand()}
5052
onDrawerOpen={onDrawerOpen}
5153
onDrawerPeek={onDrawerPeek}
5254
isInitialPeek={isInitialPeek}

0 commit comments

Comments
 (0)