mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
fix device mode
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import {isNull} from 'lodash';
|
|
||||||
import React, {useEffect, useState} from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import {Dimensions, Platform, View} from 'react-native';
|
import {Dimensions, Platform, View} from 'react-native';
|
||||||
import ScrollableTabView from 'react-native-scrollable-tab-view';
|
import ScrollableTabView from 'react-native-scrollable-tab-view';
|
||||||
import SplashScreen from 'react-native-splash-screen';
|
|
||||||
import {notesnook} from './e2e/test.ids';
|
import {notesnook} from './e2e/test.ids';
|
||||||
import ContextMenu from './src/components/ContextMenu';
|
import ContextMenu from './src/components/ContextMenu';
|
||||||
import {DialogManager} from './src/components/DialogManager';
|
import {DialogManager} from './src/components/DialogManager';
|
||||||
@@ -19,9 +17,7 @@ import {
|
|||||||
eSubscribeEvent,
|
eSubscribeEvent,
|
||||||
eUnSubscribeEvent,
|
eUnSubscribeEvent,
|
||||||
} from './src/services/EventManager';
|
} from './src/services/EventManager';
|
||||||
import IntentService from './src/services/IntentService';
|
import {editing, setWidthHeight} from './src/utils';
|
||||||
import SettingsService from './src/services/SettingsService';
|
|
||||||
import {dWidth, editing, setWidthHeight} from './src/utils';
|
|
||||||
import {
|
import {
|
||||||
eCloseFullscreenEditor,
|
eCloseFullscreenEditor,
|
||||||
eCloseSideMenu,
|
eCloseSideMenu,
|
||||||
@@ -30,7 +26,6 @@ import {
|
|||||||
eOpenSideMenu,
|
eOpenSideMenu,
|
||||||
} from './src/utils/Events';
|
} from './src/utils/Events';
|
||||||
import {editorRef, tabBarRef} from './src/utils/Refs';
|
import {editorRef, tabBarRef} from './src/utils/Refs';
|
||||||
import {sleep} from './src/utils/TimeUtils';
|
|
||||||
import {EditorWrapper} from './src/views/Editor/EditorWrapper';
|
import {EditorWrapper} from './src/views/Editor/EditorWrapper';
|
||||||
import {getIntent, getNote, post} from './src/views/Editor/Functions';
|
import {getIntent, getNote, post} from './src/views/Editor/Functions';
|
||||||
|
|
||||||
@@ -121,7 +116,13 @@ const AppStack = React.memo(
|
|||||||
() => {
|
() => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {colors} = state;
|
const {colors} = state;
|
||||||
const [mode, setMode] = useState(null);
|
const [mode, setMode] = useState(
|
||||||
|
DDS.isLargeTablet()
|
||||||
|
? 'tablet'
|
||||||
|
: DDS.isSmallTab
|
||||||
|
? 'smallTablet'
|
||||||
|
: 'mobile',
|
||||||
|
);
|
||||||
const [dimensions, setDimensions] = useState({width, height});
|
const [dimensions, setDimensions] = useState({width, height});
|
||||||
|
|
||||||
const showFullScreenEditor = () => {
|
const showFullScreenEditor = () => {
|
||||||
@@ -168,6 +169,7 @@ const AppStack = React.memo(
|
|||||||
let size = event?.nativeEvent?.layout;
|
let size = event?.nativeEvent?.layout;
|
||||||
updatedDimensions = size;
|
updatedDimensions = size;
|
||||||
if (!size || (size.width === dimensions.width && mode !== null)) {
|
if (!size || (size.width === dimensions.width && mode !== null)) {
|
||||||
|
dispatch({type: Actions.DEVICE_MODE, state: mode});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,6 +188,7 @@ const AppStack = React.memo(
|
|||||||
setWidthHeight(size);
|
setWidthHeight(size);
|
||||||
DDS.setSize(size);
|
DDS.setSize(size);
|
||||||
DDS.checkSmallTab(size.width > size.height ? 'LANDSCAPE' : 'PORTRAIT');
|
DDS.checkSmallTab(size.width > size.height ? 'LANDSCAPE' : 'PORTRAIT');
|
||||||
|
|
||||||
if (DDS.isLargeTablet()) {
|
if (DDS.isLargeTablet()) {
|
||||||
setDeviceMode('tablet', size);
|
setDeviceMode('tablet', size);
|
||||||
} else if (DDS.isSmallTab) {
|
} else if (DDS.isSmallTab) {
|
||||||
@@ -198,6 +201,7 @@ const AppStack = React.memo(
|
|||||||
function setDeviceMode(current, size) {
|
function setDeviceMode(current, size) {
|
||||||
eSendEvent(current !== 'mobile' ? eCloseSideMenu : eOpenSideMenu);
|
eSendEvent(current !== 'mobile' ? eCloseSideMenu : eOpenSideMenu);
|
||||||
setMode(current);
|
setMode(current);
|
||||||
|
console.log(current, 'DEVICE MODE');
|
||||||
dispatch({type: Actions.DEVICE_MODE, state: current});
|
dispatch({type: Actions.DEVICE_MODE, state: current});
|
||||||
dispatch({type: Actions.FULLSCREEN, state: false});
|
dispatch({type: Actions.FULLSCREEN, state: false});
|
||||||
editorRef.current?.setNativeProps({
|
editorRef.current?.setNativeProps({
|
||||||
|
|||||||
Reference in New Issue
Block a user