Skip to content

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

add responsivness

ammarahm-edaef3cc5cda62
diff --git a/apps/mobile/src/common/common.js b/apps/mobile/src/common/common.js
index 5b6f4fed8..f9507ba3c 100755
--- a/apps/mobile/src/common/common.js
+++ b/apps/mobile/src/common/common.js
@@ -1,4 +1,4 @@
-import {StatusBar, PixelRatio} from 'react-native';
+import {Platform, StatusBar, Dimensions, PixelRatio} from 'react-native';
import FastStorage from 'react-native-fast-storage';
import {
eSendEvent,
@@ -6,6 +6,10 @@ import {
eUnSubscribeEvent,
} from '../services/eventManager';
import {eThemeUpdated} from '../services/events';
+import {DDS} from '../../App';
+
+const {height, width} = Dimensions.get('window');
+const standardLength = width > height ? width : height;
//COLOR SCHEME
export const ACCENT = {
@@ -56,26 +60,82 @@ export const COLOR_SCHEME_DARK = {
...fixedColors,
};
-//FONT FAMILY
-//export const FONT = '';
-//export const FONT_BOLD = '';
+const windowSize = Dimensions.get('window');
+const adjustedWidth = windowSize.width * PixelRatio.get();
+const adjustedHeight = windowSize.height * PixelRatio.get();
+const pixelDensity = PixelRatio.get();
+
+const getDeviceSize = () => {
+ let dpi = getDpi(pixelDensity);
+ let deviceWidthInInches = adjustedWidth / dpi;
+ let deviceHeightInInches = adjustedHeight / dpi;
+ let diagonalSize = Math.sqrt(
+ Math.pow(deviceWidthInInches, 2) + Math.pow(deviceHeightInInches, 2),
+ );
+
+ return diagonalSize;
+};
+
+const getDpi = pd => {
+ if (pd === 1 || pd < 1) {
+ return 160 * pd;
+ } else if (pd > 1 && pd < 1.51) {
+ let multiplier = pd / 1.5;
+ return 240 * multiplier;
+ } else if (pd > 1.5 && pd < 2.01) {
+ let multiplier = pd / 1.5;
+ return 320 * multiplier;
+ } else if (pd > 2 && pd < 3) {
+ let multiplier = pd / 3;
+ return 430 * multiplier;
+ } else if (pd > 3) {
+ return 510;
+ }
+};
+
+export const normalize = size => {
+ let pd = pixelDensity;
+
+ if (pd === 1 || pd < 1) {
+ return correction(size, 0.75);
+ } else if (pd > 1 && pd < 1.51) {
+ return correction(size, 0.8);
+ } else if (pd > 1.5 && pd < 2.01) {
+ return correction(size, 0.84);
+ } else if (pd > 2 && pd < 3) {
+ return correction(size, 0.87);
+ } else if (pd > 3) {
+ return size;
+ }
+};
-//FONT SIZE
+const correction = (size, multiplier) => {
+ let dSize = getDeviceSize();
+ if (dSize <= 7.2) {
+ return size * multiplier;
+ } else if (dSize > 7.2 && dSize < 8.5) {
+ return size * (multiplier + 0.05);
+ } else if (dSize > 8.5 && dSize < 9.8) {
+ return size * (multiplier + 0.05);
+ } else if (dSize > 9.8) {
+ return size;
+ }
+};
export const SIZE = {
- xxs: PixelRatio.getFontScale() * 10,
- xs: PixelRatio.getFontScale() * 12,
- sm: PixelRatio.getFontScale() * 15,
- md: PixelRatio.getFontScale() * 18,
- lg: PixelRatio.getFontScale() * 24,
- xl: PixelRatio.getFontScale() * 28,
- xxl: PixelRatio.getFontScale() * 32,
- xxxl: PixelRatio.getFontScale() * 36,
+ xxs: normalize(10),
+ xs: normalize(12),
+ sm: normalize(15),
+ md: normalize(18),
+ lg: normalize(24),
+ xl: normalize(28),
+ xxl: normalize(32),
+ xxxl: normalize(36),
};
export const br = 5; // border radius
-export const ph = 10; // padding horizontal
-export const pv = 10; // padding vertical
+export const ph = normalize(10); // padding horizontal
+export const pv = normalize(10); // padding vertical
export const opacity = 0.5; // active opacity
// GLOBAL FONT
diff --git a/apps/mobile/src/components/LoginDialog/index.js b/apps/mobile/src/components/LoginDialog/index.js
index c9b249d0d..babbb2289 100644
--- a/apps/mobile/src/components/LoginDialog/index.js
+++ b/apps/mobile/src/components/LoginDialog/index.js
@@ -12,6 +12,7 @@ import {DDS} from '../../../App';
import {getElevation, w} from '../../utils/utils';
import {eSendEvent} from '../../services/eventManager';
import {eLoginDialogNavigateBack} from '../../services/events';
+import {normalize} from '../../common/common';
const fade = props => {
const {position, scene} = props;
@@ -147,8 +148,8 @@ class LoginDialog extends React.Component {
<View
style={{
...getElevation(DDS.isTab ? 10 : 0),
- width: DDS.isTab ? 600 : '100%',
- height: DDS.isTab ? 500 : '100%',
+ width: DDS.isTab ? normalize(600) : '100%',
+ height: DDS.isTab ? normalize(500) : '100%',
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.bg,
padding: 8,
diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.js
index 2087f3c2e..0626f1c43 100644
--- a/apps/mobile/src/components/Menu/index.js
+++ b/apps/mobile/src/components/Menu/index.js
@@ -20,6 +20,7 @@ import {
setColorScheme,
SIZE,
WEIGHT,
+ normalize,
} from '../../common/common';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
@@ -131,8 +132,7 @@ export const Menu = ({
style={{
minHeight: 2,
width: '100%',
-
- paddingHorizontal: 12,
+ paddingHorizontal: noTextMode ? 0 : 12,
height: 50,
marginBottom: 0,
alignItems: 'center',
@@ -205,7 +205,7 @@ export const Menu = ({
<ScrollView
contentContainerStyle={{minHeight: '80%'}}
style={{
- paddingHorizontal: noTextMode ? 6 : 12,
+ paddingHorizontal: noTextMode ? 0 : 12,
}}
showsVerticalScrollIndicator={false}>
<View>
@@ -225,8 +225,9 @@ export const Menu = ({
flexDirection: 'row',
justifyContent: noTextMode ? 'center' : 'space-between',
alignItems: 'center',
- paddingBottom: noTextMode ? 12 : 15,
- paddingTop: index === 0 ? 10 : noTextMode ? 12 : 15,
+ paddingBottom: noTextMode ? pv + 2 : normalize(15),
+ paddingTop:
+ index === 0 ? pv : noTextMode ? pv + 2 : normalize(15),
}}>
<View
style={{
@@ -235,7 +236,7 @@ export const Menu = ({
}}>
<Icon
style={{
- minWidth: noTextMode ? 20 : 30,
+ minWidth: noTextMode ? 5 : 30,
}}
name={item.icon}
color={colors.pri}
@@ -278,7 +279,7 @@ export const Menu = ({
flexDirection: 'row',
justifyContent: noTextMode ? 'center' : 'space-between',
alignItems: 'flex-end',
- marginTop: noTextMode ? 10 : 15,
+ marginTop: noTextMode ? pv : normalize(15),
}}>
<View
style={{
@@ -288,7 +289,7 @@ export const Menu = ({
}}>
<Icon
style={{
- minWidth: noTextMode ? 20 : 30,
+ minWidth: noTextMode ? 5 : 30,
}}
name="tag"
color={colors.pri}
@@ -356,8 +357,8 @@ export const Menu = ({
style={{
flexDirection: noTextMode ? 'column' : 'row',
flexWrap: noTextMode ? 'nowrap' : 'wrap',
- marginTop: 12,
- marginBottom: 12,
+ marginTop: pv / 2,
+ marginBottom: pv / 2,
}}>
{['red', 'yellow', 'green', 'blue', 'purple', 'orange', 'gray'].map(
item => (
@@ -369,12 +370,12 @@ export const Menu = ({
justifyContent: noTextMode ? 'center' : 'flex-start',
alignItems: 'center',
margin: noTextMode ? 0 : 5,
- marginTop: 12,
+ marginTop: normalize(15),
}}>
<View
style={{
- width: noTextMode ? 20 : 30,
- height: noTextMode ? 20 : 30,
+ width: noTextMode ? SIZE.md : normalize(30),
+ height: noTextMode ? SIZE.md : normalize(30),
backgroundColor: item,
borderRadius: 100,
}}
@@ -421,10 +422,10 @@ export const Menu = ({
<View
style={{
width: '100%',
- justifyContent: 'space-between',
+ justifyContent: noTextMode ? 'center' : 'space-between',
alignItems: 'center',
alignSelf: 'center',
- marginBottom: 20,
+ marginBottom: 15,
flexDirection: 'row',
}}>
<TouchableOpacity
@@ -438,9 +439,9 @@ export const Menu = ({
activeOpacity={opacity / 2}
style={{
paddingVertical: pv + 5,
- paddingHorizontal: 12,
+ paddingHorizontal: noTextMode ? 0 : 12,
width: '100%',
- justifyContent: 'flex-start',
+ justifyContent: noTextMode ? 'center' : 'flex-start',
alignItems: 'center',
flexDirection: 'row',
}}>