Skip to content

Commit

Permalink
Switch to react-native-drawer-layout
Browse files Browse the repository at this point in the history
The polyfill has been abandoned for some time. The drawer layout is
still maintained and part of react-navigation.
  • Loading branch information
mhoran committed Feb 18, 2024
1 parent 3e8ced0 commit cb4a091
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 31 deletions.
5 changes: 4 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module.exports = {
presets: [
'babel-preset-expo'
]
],
plugins: [
'react-native-reanimated/plugin',
],
}
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'react-native-gesture-handler';
import { registerRootComponent } from 'expo';
import Root from "./src/usecase/Root";

Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"js-sha256": "^0.9.0",
"react": "18.2.0",
"react-native": "0.73.4",
"react-native-drawer-layout": "https://github.com/mhoran/react-native-drawer-layout#91a2476",
"react-native-drawer-layout-polyfill": "^2.0.0",
"react-native-drawer-layout": "^3.2.2",
"react-native-gesture-handler": "~2.14.0",
"react-native-parsed-text": "^0.0.22",
"react-native-reanimated": "~3.6.2",
"react-redux": "^8.0.2",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
Expand All @@ -45,8 +46,5 @@
"redux-devtools-extension": "^2.13.8",
"tslib": "^2.5.0",
"typescript": "^5.3.0"
},
"resolutions": {
"react-native-drawer-layout-polyfill/react-native-drawer-layout": "https://github.com/mhoran/react-native-drawer-layout#91a2476"
}
}
31 changes: 17 additions & 14 deletions src/usecase/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from 'react-native';
import { connect, ConnectedProps } from 'react-redux';

import DrawerLayout from 'react-native-drawer-layout-polyfill';
import { Drawer } from 'react-native-drawer-layout';

import BufferGate from './buffers/ui/BufferGate';
import BufferList from './buffers/ui/BufferList';
Expand Down Expand Up @@ -53,7 +53,6 @@ interface State {
}

class App extends React.Component<Props, State> {
drawer: DrawerLayout;
dimensionsListener: EmitterSubscription | undefined;

drawerWidth = () => {
Expand All @@ -74,13 +73,14 @@ class App extends React.Component<Props, State> {

state: State = {
showTopic: false,
drawerWidth: this.drawerWidth()
drawerWidth: this.drawerWidth(),
drawerOpen: true
};

changeCurrentBuffer = (buffer: WeechatBuffer) => {
const { currentBufferId, fetchBufferInfo } = this.props;

this.drawer.closeDrawer();
this.closeDrawer();
if (currentBufferId !== buffer.id) {
this.props.dispatch({
type: 'CHANGE_CURRENT_BUFFER',
Expand All @@ -98,10 +98,14 @@ class App extends React.Component<Props, State> {
};

openDrawer = () => {
this.drawer.openDrawer();
this.setState((state) => ({drawerOpen: true}));
Keyboard.dismiss();
};

closeDrawer = () => {
this.setState((state) => ({drawerOpen: false}));
};

sendMessage = (message: string) => {
const { currentBuffer, sendMessageToBuffer } = this.props;

Expand All @@ -120,8 +124,6 @@ class App extends React.Component<Props, State> {
const { currentBufferId, fetchBufferInfo } = this.props;
if (currentBufferId) {
fetchBufferInfo(currentBufferId);
} else {
this.drawer.openDrawer();
}

registerForPushNotificationsAsync();
Expand All @@ -134,7 +136,7 @@ class App extends React.Component<Props, State> {
componentDidUpdate(prevProps: Props) {
const { currentBufferId } = this.props;
if (currentBufferId !== prevProps.currentBufferId && !currentBufferId) {
this.drawer.openDrawer();
this.openDrawer();
}
}

Expand All @@ -158,12 +160,13 @@ class App extends React.Component<Props, State> {

return (
<View style={styles.container}>
<DrawerLayout
ref={(d: DrawerLayout) => (this.drawer = d)}
renderNavigationView={sidebar}
<Drawer
open={this.state.drawerOpen}
renderDrawerContent={sidebar}
keyboardDismissMode={'on-drag'}
drawerWidth={drawerWidth}
useNativeAnimations={true}
drawerStyle={{width: drawerWidth}}
onOpen={this.openDrawer}
onClose={this.closeDrawer}
>
<SafeAreaView style={styles.container}>
<View style={styles.topbar}>
Expand Down Expand Up @@ -204,7 +207,7 @@ class App extends React.Component<Props, State> {
bufferId={currentBufferId}
/>
</SafeAreaView>
</DrawerLayout>
</Drawer>
</View>
);
}
Expand Down
118 changes: 107 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
"@babel/helper-replace-supers" "^7.18.9"
"@babel/helper-split-export-declaration" "^7.18.6"

"@babel/helper-create-class-features-plugin@^7.22.15":
"@babel/helper-create-class-features-plugin@^7.22.15", "@babel/helper-create-class-features-plugin@^7.23.6":
version "7.23.10"
resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.23.10.tgz#25d55fafbaea31fd0e723820bb6cc3df72edf7ea"
integrity sha512-2XpP2XhkXzgxecPNEEK8Vz8Asj9aRxt08oKOqtiZoqV2UGZ5T+EkyP9sXQ9nwMxBIG34a7jmasVqoMop7VdPUw==
Expand Down Expand Up @@ -431,6 +431,17 @@
"@babel/traverse" "^7.20.1"
"@babel/types" "^7.20.2"

"@babel/helper-module-transforms@^7.23.3":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.23.3.tgz#d7d12c3c5d30af5b3c0fcab2a6d5217773e2d0f1"
integrity sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ==
dependencies:
"@babel/helper-environment-visitor" "^7.22.20"
"@babel/helper-module-imports" "^7.22.15"
"@babel/helper-simple-access" "^7.22.5"
"@babel/helper-split-export-declaration" "^7.22.6"
"@babel/helper-validator-identifier" "^7.22.20"

"@babel/helper-optimise-call-expression@^7.18.6":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz#9369aa943ee7da47edab2cb4e838acf09d290ffe"
Expand Down Expand Up @@ -525,6 +536,13 @@
dependencies:
"@babel/types" "^7.20.2"

"@babel/helper-simple-access@^7.22.5":
version "7.22.5"
resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz#4938357dc7d782b80ed6dbb03a0fba3d22b1d5de"
integrity sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==
dependencies:
"@babel/types" "^7.22.5"

"@babel/helper-skip-transparent-expression-wrappers@^7.18.9":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.18.9.tgz#778d87b3a758d90b471e7b9918f34a9a02eb5818"
Expand Down Expand Up @@ -1058,6 +1076,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"

"@babel/plugin-syntax-typescript@^7.23.3":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.23.3.tgz#24f460c85dbbc983cd2b9c4994178bcc01df958f"
integrity sha512-9EiNjVJOMwCO+43TqoTrgQ8jMwcAd0sWyXi9RPfIsLTj4R2MADDDQXELhffaUx/uJv2AYcxBgPwH6j4TIA4ytQ==
dependencies:
"@babel/helper-plugin-utils" "^7.22.5"

"@babel/plugin-syntax-typescript@^7.7.2":
version "7.20.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz#4e9a0cfc769c85689b77a2e642d24e9f697fc8c7"
Expand Down Expand Up @@ -1281,6 +1306,15 @@
"@babel/helper-plugin-utils" "^7.20.2"
"@babel/helper-simple-access" "^7.20.2"

"@babel/plugin-transform-modules-commonjs@^7.23.3":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.23.3.tgz#661ae831b9577e52be57dd8356b734f9700b53b4"
integrity sha512-aVS0F65LKsdNOtcz6FRCpE4OgsP2OFnW46qNxNIX9h3wuzaNcSQsJysuMwqSibC98HPrf2vCgtxKNwS0DAlgcA==
dependencies:
"@babel/helper-module-transforms" "^7.23.3"
"@babel/helper-plugin-utils" "^7.22.5"
"@babel/helper-simple-access" "^7.22.5"

"@babel/plugin-transform-modules-systemjs@^7.18.9":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.18.9.tgz#545df284a7ac6a05125e3e405e536c5853099a06"
Expand Down Expand Up @@ -1333,6 +1367,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"

"@babel/plugin-transform-object-assign@^7.16.7":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.23.3.tgz#64177e8cf943460c7f0e1c410277546804f59625"
integrity sha512-TPJ6O7gVC2rlQH2hvQGRH273G1xdoloCj9Pc07Q7JbIZYDi+Sv5gaE2fu+r5E7qK4zyt6vj0FbZaZTRU5C3OMA==
dependencies:
"@babel/helper-plugin-utils" "^7.22.5"

"@babel/plugin-transform-object-rest-spread@^7.12.13":
version "7.23.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.23.4.tgz#2b9c2d26bf62710460bdc0d1730d4f1048361b83"
Expand Down Expand Up @@ -1550,6 +1591,16 @@
"@babel/helper-plugin-utils" "^7.18.9"
"@babel/plugin-syntax-typescript" "^7.18.6"

"@babel/plugin-transform-typescript@^7.23.3":
version "7.23.6"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.23.6.tgz#aa36a94e5da8d94339ae3a4e22d40ed287feb34c"
integrity sha512-6cBG5mBvUu4VUD04OHKnYzbuHNP8huDsD3EDqqpIpsswTDoqHCjLoHb6+QgsV1WsT2nipRqCPgxD3LXnEO7XfA==
dependencies:
"@babel/helper-annotate-as-pure" "^7.22.5"
"@babel/helper-create-class-features-plugin" "^7.23.6"
"@babel/helper-plugin-utils" "^7.22.5"
"@babel/plugin-syntax-typescript" "^7.23.3"

"@babel/plugin-transform-unicode-escapes@^7.18.10":
version "7.18.10"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz#1ecfb0eda83d09bbcb77c09970c2dd55832aa246"
Expand Down Expand Up @@ -1768,6 +1819,17 @@
"@babel/helper-validator-option" "^7.18.6"
"@babel/plugin-transform-typescript" "^7.18.6"

"@babel/preset-typescript@^7.16.7":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.23.3.tgz#14534b34ed5b6d435aa05f1ae1c5e7adcc01d913"
integrity sha512-17oIGVlqz6CchO9RFYn5U6ZpWRZIngayYCtrPRSgANSwC2V1Jb+iP74nVxzzXJte8b8BYxrL1yY96xfhTBrNNQ==
dependencies:
"@babel/helper-plugin-utils" "^7.22.5"
"@babel/helper-validator-option" "^7.22.15"
"@babel/plugin-syntax-jsx" "^7.23.3"
"@babel/plugin-transform-modules-commonjs" "^7.23.3"
"@babel/plugin-transform-typescript" "^7.23.3"

"@babel/register@^7.13.16":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.18.9.tgz#1888b24bc28d5cc41c412feb015e9ff6b96e439c"
Expand Down Expand Up @@ -1923,6 +1985,13 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@egjs/hammerjs@^2.0.17":
version "2.0.17"
resolved "https://registry.yarnpkg.com/@egjs/hammerjs/-/hammerjs-2.0.17.tgz#5dc02af75a6a06e4c2db0202cae38c9263895124"
integrity sha512-XQsZgjm2EcVUiZQf11UBJQfmZeEmOW8DpI1gsFeln6w0ae0ii4dMQEQ0kjl6DspdWX1aGY1/loyXnP0JS06e/A==
dependencies:
"@types/hammerjs" "^2.0.36"

"@eslint-community/eslint-utils@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.2.0.tgz#a831e6e468b4b2b5ae42bf658bea015bf10bc518"
Expand Down Expand Up @@ -3141,6 +3210,11 @@
dependencies:
"@types/node" "*"

"@types/hammerjs@^2.0.36":
version "2.0.45"
resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.45.tgz#ffa764bb68a66c08db6efb9c816eb7be850577b1"
integrity sha512-qkcUlZmX6c4J8q45taBKTL3p+LbITgyx7qhlPYOdOHZB7B31K0mXbP5YA7i7SgDeEGuI9MnumiKPEMrxg8j3KQ==

"@types/hoist-non-react-statics@^3.3.0", "@types/hoist-non-react-statics@^3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f"
Expand Down Expand Up @@ -6769,7 +6843,7 @@ lodash.throttle@^4.1.1:
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
integrity sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==

lodash@^4.17.13, lodash@^4.17.19, lodash@^4.17.4:
lodash@^4.17.13, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.17.4:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
Expand Down Expand Up @@ -7850,7 +7924,7 @@ prompts@^2.0.1, prompts@^2.2.1, prompts@^2.3.2, prompts@^2.4.2:
kleur "^3.0.3"
sisteransi "^1.0.5"

prop-types@^15.7.x, prop-types@^15.8.1:
prop-types@^15.7.2, prop-types@^15.7.x, prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
Expand Down Expand Up @@ -7947,16 +8021,23 @@ react-is@^17.0.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==

react-native-drawer-layout-polyfill@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/react-native-drawer-layout-polyfill/-/react-native-drawer-layout-polyfill-2.0.0.tgz#03d6658ae1e52db64ecee05e7642d17af1c37ec1"
integrity sha512-v7bj60VLHmgi8wMN7KdV6bxLmVK8X2qKR0U9mTJA2LdTxXt4eAo1bE7IT2mDZF0Na1lRYWj4wqbyQ34dLFxkog==
react-native-drawer-layout@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/react-native-drawer-layout/-/react-native-drawer-layout-3.2.2.tgz#ceee2f1fe362522b1391435e2c0d095c18d5d1f2"
integrity sha512-t28FVAhtrEJluIOpDpVNBWG74ij9ZguBC+FLmv/+lewhWTgZQ6rTw5GgQ9sUxmHx+ertcWG/uH0Jye7gbbm9jg==
dependencies:
react-native-drawer-layout "2.0.0"
use-latest-callback "^0.1.5"

[email protected], "react-native-drawer-layout@https://github.com/mhoran/react-native-drawer-layout#91a2476":
version "2.0.0"
resolved "https://github.com/mhoran/react-native-drawer-layout#91a2476383751c56019d6ac3f61fb1d16606ae65"
react-native-gesture-handler@~2.14.0:
version "2.14.1"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.14.1.tgz#930640231024b7921435ab476aa501dd4a6b2e01"
integrity sha512-YiM1BApV4aKeuwsM6O4C2ufwewYEKk6VMXOt0YqEZFMwABBFWhXLySFZYjBSNRU2USGppJbfHP1q1DfFQpKhdA==
dependencies:
"@egjs/hammerjs" "^2.0.17"
hoist-non-react-statics "^3.3.0"
invariant "^2.2.4"
lodash "^4.17.21"
prop-types "^15.7.2"

react-native-parsed-text@^0.0.22:
version "0.0.22"
Expand All @@ -7965,6 +8046,16 @@ react-native-parsed-text@^0.0.22:
dependencies:
prop-types "^15.7.x"

react-native-reanimated@~3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-3.6.2.tgz#8a48c37251cbd3b665a659444fa9778f5b510356"
integrity sha512-IIMREMOrxhtK35drfpzh2UhxNqAOHnuvGgtMofj7yHcMj16tmWZR2zFvMUf6z2MfmXv+aVgFQ6TRZ6yKYf7LNA==
dependencies:
"@babel/plugin-transform-object-assign" "^7.16.7"
"@babel/preset-typescript" "^7.16.7"
convert-source-map "^2.0.0"
invariant "^2.2.4"

[email protected]:
version "0.73.4"
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.73.4.tgz#81e07d4e7b6308c4649d5fa24038c0e87b17f2e1"
Expand Down Expand Up @@ -9225,6 +9316,11 @@ url-parse@^1.5.3:
querystringify "^2.1.1"
requires-port "^1.0.0"

use-latest-callback@^0.1.5:
version "0.1.9"
resolved "https://registry.yarnpkg.com/use-latest-callback/-/use-latest-callback-0.1.9.tgz#10191dc54257e65a8e52322127643a8940271e2a"
integrity sha512-CL/29uS74AwreI/f2oz2hLTW7ZqVeV5+gxFeGudzQrgkCytrHw33G4KbnQOrRlAEzzAFXi7dDLMC9zhWcVpzmw==

use-sync-external-store@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a"
Expand Down

0 comments on commit cb4a091

Please sign in to comment.