Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix drawer state not updated correctly

ammarahm-ed8c69b5549953
diff --git a/apps/mobile/src/components/CustomTabs/index.js b/apps/mobile/src/components/CustomTabs/index.js
index 8e1fe798f..475c7d4a7 100644
--- a/apps/mobile/src/components/CustomTabs/index.js
+++ b/apps/mobile/src/components/CustomTabs/index.js
@@ -64,15 +64,23 @@ export default class CustomTabs extends Component {
if (this.page === 0) {
if (this.scrollOffset === 0) {
this.goToIndex(1);
+ this.currentDrawerState = false;
} else {
+ this.currentDrawerState = true;
this.goToIndex(0);
}
+ this.props.onDrawerStateChange &&
+ this.props.onDrawerStateChange(this.currentDrawerState);
}
};
closeDrawer = () => {
if (this.page === 0) {
+ console.log('CLOSING DRAWER');
this.goToIndex(1);
+ this.currentDrawerState = false;
+ this.props.onDrawerStateChange &&
+ this.props.onDrawerStateChange(this.currentDrawerState);
}
};
@@ -169,7 +177,7 @@ export default class CustomTabs extends Component {
if (this.page !== page) {
this.props.onChangeTab({i: page, from: this.page});
this.page = page;
- }
+ }
};
keyExtractor = (item, index) => item;
@@ -192,10 +200,11 @@ export default class CustomTabs extends Component {
this.nextPage = 0;
}
- let drawerState = page === 0 && this.scrollOffset < 10;
+ let drawerState = page === 0 && this.scrollOffset < 150;
if (drawerState !== this.currentDrawerState) {
this.currentDrawerState = drawerState;
- this.props.onDrawerStateChange(this.currentDrawerState);
+ this.props.onDrawerStateChange &&
+ this.props.onDrawerStateChange(this.currentDrawerState);
}
this.props.toggleOverlay(
Math.floor(this.scrollOffset) < Math.floor(this.props.offsets.a - 10)
@@ -216,6 +225,9 @@ export default class CustomTabs extends Component {
let px = event.nativeEvent.pageX;
if (px > width * 0.75 || (DDS.isSmallTab && px > this.props.widths.a)) {
this.goToIndex(1);
+ this.currentDrawerState = false;
+ this.props.onDrawerStateChange &&
+ this.props.onDrawerStateChange(this.currentDrawerState);
}
}
};
@@ -248,7 +260,7 @@ export default class CustomTabs extends Component {
alwaysBounceHorizontal={false}
scrollToOverflowEnabled={false}
scrollsToTop={false}
- scrollEventThrottle={2}
+ scrollEventThrottle={10}
directionalLockEnabled
overScrollMode="never"
maxToRenderPerBatch={100}