Skip to content

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

fix navigation in small tablets

Ammar Ahmed770e85ae2bf3
diff --git a/apps/mobile/initializer.root.js b/apps/mobile/initializer.root.js
index 1bafe3bf4..23cd86fe4 100644
--- a/apps/mobile/initializer.root.js
+++ b/apps/mobile/initializer.root.js
@@ -26,7 +26,6 @@ import { updateStatusBarColor } from './src/utils/Colors';
import {
eClearEditor,
eCloseFullscreenEditor,
-
eOnLoadNote,
eOpenFullscreenEditor
} from './src/utils/Events';
@@ -122,12 +121,18 @@ const NativeStack = React.memo(
style: {
width:
deviceMode === 'smallTablet'
- ? dimensions.width * 0.6
+ ? dimensions.width - valueLimiter(dimensions.width * 0.4,300,450)
: dimensions.width * 0.55,
zIndex: null,
paddingHorizontal: 0,
},
});
+ if (deviceMode === "smallTablet") {
+ setTimeout(() => {
+ tabBarRef.current?.goToIndex(1);
+ },100)
+ }
+
};
useEffect(() => {
@@ -197,7 +202,7 @@ const NativeStack = React.memo(
current === 'tablet'
? size.width * 0.55
: current === 'smallTablet'
- ? size.width * 0.6
+ ? size.width - valueLimiter(size.width * 0.4,300,450)
: size.width,
zIndex: null,
paddingHorizontal: 0,
@@ -238,6 +243,18 @@ const NativeStack = React.memo(
animatedTranslateY.setValue(show ? 0 : -9999);
};
+ const valueLimiter = (value,min,max) => {
+ if (value < min) {
+ return min
+ }
+
+ if (value > max) {
+ return max
+ }
+
+ return value;
+ }
+
const offsets = {
mobile: {
a: dimensions.width * 0.75,
@@ -245,9 +262,9 @@ const NativeStack = React.memo(
c: dimensions.width * 2 + dimensions.width * 0.75,
},
smallTablet: {
- a: fullscreen ? 0 : dimensions.width * 0.2,
- b: fullscreen ? 0 : dimensions.width + dimensions.width * 0.2,
- c: fullscreen ? 0 : dimensions.width + dimensions.width * 0.2,
+ a: fullscreen ? 0 : valueLimiter(dimensions.width * 0.3,300,350),
+ b: fullscreen ? 0 : dimensions.width + valueLimiter(dimensions.width * 0.3,300,350),
+ c: fullscreen ? 0 : dimensions.width + valueLimiter(dimensions.width * 0.3,300,350),
},
tablet: {
a: 0,
@@ -256,6 +273,8 @@ const NativeStack = React.memo(
},
};
+
+
const widths = {
mobile: {
a: dimensions.width * 0.75,
@@ -263,9 +282,9 @@ const NativeStack = React.memo(
c: dimensions.width,
},
smallTablet: {
- a: dimensions.width * 0.2,
- b: dimensions.width * 0.4,
- c: dimensions.width * 0.6,
+ a: valueLimiter(dimensions.width * 0.3,300,350),
+ b: valueLimiter(dimensions.width * 0.4,300,450),
+ c: dimensions.width - valueLimiter(dimensions.width * 0.4,300,450)
},
tablet: {
a: dimensions.width * 0.15,
@@ -287,6 +306,7 @@ const NativeStack = React.memo(
<CustomTabs
ref={tabBarRef}
dimensions={dimensions}
+ widths={widths[deviceMode]}
style={{
zIndex: 1,
}}
diff --git a/apps/mobile/src/components/CustomTabs/index.js b/apps/mobile/src/components/CustomTabs/index.js
index 31db706b2..99878212c 100644
--- a/apps/mobile/src/components/CustomTabs/index.js
+++ b/apps/mobile/src/components/CustomTabs/index.js
@@ -1,6 +1,7 @@
import React, {Component, createRef} from 'react';
import {Platform} from 'react-native';
import {FlatList, TextInput, View} from 'react-native';
+import { DDS } from '../../services/DeviceDetection';
import {editing} from '../../utils';
export default class CustomTabs extends Component {
@@ -34,8 +35,15 @@ export default class CustomTabs extends Component {
? this.props.dimensions.height - 70
: this.props.dimensions.height - 140;
- if (cOffset > pOffset - 50) {
- if (x > 50 || y > heightCheck) {
+ if (DDS.isLargeTablet()) {
+ this.setScrollEnabled(false);
+ this.responderAllowedScroll = true;
+ return;
+ }
+
+ if (cOffset > pOffset - 50 || DDS.isSmallTab) {
+ if ((!DDS.isSmallTab && x > 50 || y > heightCheck) || (DDS.isSmallTab && x > this.props.widths.b)) {
+
this.responderAllowedScroll = false;
this.setScrollEnabled(false);
return;
@@ -161,7 +169,6 @@ export default class CustomTabs extends Component {
this.currentDrawerState = drawerState;
this.props.onDrawerStateChange(this.currentDrawerState);
}
- console.log(this.scrollOffset, this.props.offsets.a);
this.props.toggleOverlay(
Math.floor(this.scrollOffset) < Math.floor(this.props.offsets.a - 10)
? true
@@ -175,9 +182,12 @@ export default class CustomTabs extends Component {
onListTouchEnd = event => {
if (this.lastOffset < 30 && event) {
- if (event.nativeEvent.pageX > this.props.dimensions.width * 0.75) {
+ let width = this.props.dimensions.width;
+ let px = event.nativeEvent.pageX
+ if (px > width * 0.75 || (DDS.isSmallTab && px > this.props.widths.a)) {
this.goToIndex(1);
}
+
}
};