Skip to content

Commit

Permalink
useConstants instead of constants
Browse files Browse the repository at this point in the history
  • Loading branch information
kanzitelli committed Dec 20, 2020
1 parent dddc682 commit 89f109f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 36 deletions.
22 changes: 22 additions & 0 deletions src/hooks/useConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const useContants = () => {
return {
colors: {
main: '#4d7198',
black: '#000',
white: '#fff',
lightGrey: '#dcdde1',
blue: '#4d7198',
yellow: '#fbc531',
},
sizes: {
xs: 4,
s: 8,
m: 16,
l: 24,
xl: 32,
xxl: 40,
}
}
}

export default useContants;
4 changes: 2 additions & 2 deletions src/hooks/useStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { useEffect, useState } from 'react';
import { Appearance, Dimensions, Platform, PixelRatio } from 'react-native';
import { isTablet } from 'react-native-device-info';

import Constants from '../utils/constants';
import useConstants from './useConstants';

const { colors, sizes } = Constants;
const { colors, sizes } = useConstants();
let options: UseStylesOptionsType = {
normalize: true,
darkmode: true,
Expand Down
6 changes: 3 additions & 3 deletions src/screens/CounterScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { useNavigationButtonPress } from 'react-native-navigation-hooks/dist/hoo

import { useStores } from '../stores';
import { useServices } from '../services';
import Constants from '../utils/constants';
import { ButtonIcon } from '../components/Button';
import useStyles from '../hooks/useStyles';
import { ScreenOptions } from '../services/navigation/screens';
import { Buttons } from '../services/navigation/buttons';

const CounterScreen: NavigationFunctionComponent = observer(({
componentId,
Expand All @@ -23,8 +23,8 @@ const CounterScreen: NavigationFunctionComponent = observer(({
const { } = useServices();
const { styles } = useStyles(_styles);

useNavigationButtonPress(counter.decrement, componentId, Constants.CounterScreen.decButtonId);
useNavigationButtonPress(counter.increment, componentId, Constants.CounterScreen.incButtonId);
useNavigationButtonPress(counter.decrement, componentId, Buttons.Dec.id);
useNavigationButtonPress(counter.increment, componentId, Buttons.Inc.id);

return (
<SafeAreaView style={styles.container}>
Expand Down
12 changes: 7 additions & 5 deletions src/services/navigation/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { gestureHandlerRootHOC as withGestureHandler } from 'react-native-gestur
import Screens, { ScreenNames } from './screens';
import { withStoresProvider } from '../../stores';
import { withServicesProvider } from '..';
import Constants from '../../utils/constants';
import useConstants from '../../hooks/useConstants';
import { stores } from '../../stores';
import { getTabOptions } from './tabs';
import { Layout_BottomTabs, Layout_Component, Layout_Root, Layout_StackWith } from './layout';
Expand Down Expand Up @@ -62,6 +62,8 @@ class NavigationSystem {
}

private setDefaultOptions = async () => {
const { colors } = useConstants();

Navigation.setDefaultOptions({
layout: {
orientation: ['portrait'],
Expand All @@ -70,10 +72,10 @@ class NavigationSystem {
titleDisplayMode: 'alwaysShow',
},
bottomTab: {
iconColor: Constants.colors.main,
textColor: Constants.colors.main,
selectedIconColor: Constants.colors.main,
selectedTextColor: Constants.colors.main,
iconColor: colors.main,
textColor: colors.main,
selectedIconColor: colors.main,
selectedTextColor: colors.main,
},
topBar: {
largeTitle: {
Expand Down
26 changes: 0 additions & 26 deletions src/utils/constants.ts

This file was deleted.

0 comments on commit 89f109f

Please sign in to comment.