Skip to content

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

add font scaling

ammarahm-edb87dd1c16a7e
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index 7f82b111c..7aea56c3b 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -2,7 +2,13 @@ import Storage from 'notes-core/api/index';
import React, {useEffect, useState} from 'react';
import {Platform, StatusBar, View, Text} from 'react-native';
import * as Animatable from 'react-native-animatable';
-import {getColorScheme, WEIGHT, SIZE} from './src/common/common';
+import {
+ getColorScheme,
+ WEIGHT,
+ SIZE,
+ scale,
+ updateSize,
+} from './src/common/common';
import {DialogManager} from './src/components/DialogManager';
import {Menu} from './src/components/Menu';
import {ModalMenu} from './src/components/ModalMenu';
@@ -153,17 +159,6 @@ const App = () => {
let user = await db.user.get();
dispatch({type: ACTIONS.USER, user: user});
- let s = await FastStorage.getItem('settings');
- if (typeof s !== 'string') {
- s = defaultState.settings;
- s = JSON.stringify(s);
- await FastStorage.setItem('settings', s);
- dispatch({type: ACTIONS.SETTINGS, s});
- } else {
- s = JSON.parse(s);
- dispatch({type: ACTIONS.SETTINGS, settings: s});
- }
-
setInit(true);
});
});
@@ -171,6 +166,21 @@ const App = () => {
async function updateAppTheme(colors = colors) {
let newColors = await getColorScheme(colors);
+ let s = await FastStorage.getItem('settings');
+ if (typeof s !== 'string') {
+ s = defaultState.settings;
+
+ s = JSON.stringify(s);
+ await FastStorage.setItem('settings', s);
+ dispatch({type: ACTIONS.SETTINGS, s});
+ } else {
+ s = JSON.parse(s);
+ scale.fontScale = s.fontScale;
+ console.log(scale.fontScale);
+ updateSize();
+ console.log(SIZE.lg);
+ dispatch({type: ACTIONS.SETTINGS, settings: {...s}});
+ }
dispatch({type: ACTIONS.THEME, colors: newColors});
}
diff --git a/apps/mobile/src/common/common.js b/apps/mobile/src/common/common.js
index e91e4a96f..47878e981 100755
--- a/apps/mobile/src/common/common.js
+++ b/apps/mobile/src/common/common.js
@@ -7,6 +7,9 @@ import {
} from '../services/eventManager';
import {eThemeUpdated} from '../services/events';
+export const scale = {
+ fontScale: 1,
+};
const {height, width} = Dimensions.get('window');
const standardLength = width > height ? width : height;
@@ -134,19 +137,32 @@ export const normalize = size => {
};
export const SIZE = {
- xxs: 10,
- xs: 12,
- sm: normalize(15),
- md: normalize(17),
- lg: normalize(24),
- xl: normalize(27),
- xxl: normalize(31),
- xxxl: normalize(34),
+ xxs: 10 * scale.fontScale,
+ xs: 12 * scale.fontScale,
+ sm: normalize(15) * scale.fontScale,
+ md: normalize(17) * scale.fontScale,
+ lg: normalize(24) * scale.fontScale,
+ xl: normalize(27) * scale.fontScale,
+ xxl: normalize(31) * scale.fontScale,
+ xxxl: normalize(34) * scale.fontScale,
};
+export function updateSize() {
+ SIZE.xxs = 10 * scale.fontScale;
+ SIZE.xs = 12 * scale.fontScale;
+ SIZE.sm = normalize(15) * scale.fontScale;
+ SIZE.md = normalize(17) * scale.fontScale;
+ SIZE.lg = normalize(24) * scale.fontScale;
+ SIZE.xl = normalize(27) * scale.fontScale;
+ SIZE.xxl = normalize(31) * scale.fontScale;
+ SIZE.xxxl = normalize(34) * scale.fontScale;
+ ph = normalize(10) * scale.fontScale;
+ pv = normalize(10) * scale.fontScale;
+}
+
export const br = 5; // border radius
-export const ph = normalize(10); // padding horizontal
-export const pv = normalize(10); // padding vertical
+export var ph = normalize(10); // padding horizontal
+export var pv = normalize(10); // padding vertical
export const opacity = 0.5; // active opacity
// GLOBAL FONT
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index eadf1cd64..da853eb62 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -21,11 +21,14 @@ import {
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import Container from '../../components/Container';
import {useTracked} from '../../provider';
-import {w, hexToRGBA} from '../../utils/utils';
+import {w, hexToRGBA, getElevation} from '../../utils/utils';
import {ACTIONS} from '../../provider/actions';
import FastStorage from 'react-native-fast-storage';
import {DDS} from '../../../App';
import {updateEvent} from '../../components/DialogManager';
+import {eSendEvent} from '../../services/eventManager';
+import {eOpenLoginDialog} from '../../services/events';
+import NavigationService from '../../services/NavigationService';
export async function setSetting(settings, name, value) {
let s = {...settings};
@@ -206,8 +209,10 @@ export const Settings = ({navigation}) => {
: scale === 1.4
? (scale = 1.5)
: scale === 1.5
- ? (scale = 1)
- : (scale = 1);
+ ? (scale = 0.8)
+ : scale === 0.8
+ ? (scale = 0.9)
+ : (scale = 0.9 ? (scale = 1) : (scale = 1));
await setSetting(settings, 'fontScale', scale);
}}
@@ -219,8 +224,6 @@ export const Settings = ({navigation}) => {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
- borderBottomWidth: 1,
- borderBottomColor: colors.nav,
}}>
<Text
style={{
@@ -496,7 +499,46 @@ export const Settings = ({navigation}) => {
</TouchableOpacity>
))}
</>
- ) : null}
+ ) : (
+ <TouchableOpacity
+ onPress={() => {
+ DDS.isTab
+ ? eSendEvent(eOpenLoginDialog)
+ : NavigationService.navigate('Login');
+ }}
+ activeOpacity={opacity / 2}
+ style={{
+ ...getElevation(2),
+ paddingVertical: pv + 5,
+ marginVertical: pv + 5,
+ width: '100%',
+ justifyContent: 'flex-start',
+ alignItems: 'center',
+ flexDirection: 'row',
+ backgroundColor: colors.accent,
+ borderRadius: 5,
+ paddingHorizontal: 6,
+ }}>
+ <Icon
+ style={{
+ minWidth: 35,
+ textAlign: 'left',
+ }}
+ name="login"
+ color="white"
+ size={SIZE.lg}
+ />
+
+ <Text
+ style={{
+ fontFamily: WEIGHT.regular,
+ color: 'white',
+ fontSize: SIZE.md,
+ }}>
+ Login
+ </Text>
+ </TouchableOpacity>
+ )}
<Text
style={{