Skip to content

Commit

Permalink
Fixing a mobile classname bug • The nav mobile works on mobile • addi…
Browse files Browse the repository at this point in the history
…ng react native animated for future
  • Loading branch information
AnselmMarie committed Sep 13, 2024
1 parent 1e81f38 commit 8275042
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 20 deletions.
1 change: 1 addition & 0 deletions apps/mobile-app/.babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = function (api) {
return {
presets: ['babel-preset-expo'],
plugins: [
'react-native-reanimated/plugin',
[
'module:react-native-dotenv',
{
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile-app/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { assetExts, sourceExts } = defaultConfig.resolver;
*
* @type {import('metro-config').MetroConfig}
*/
const customConfig = {
const svgConfig = {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
Expand All @@ -21,7 +21,7 @@ const customConfig = {
},
};

module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
module.exports = withNxMetro(mergeConfig(defaultConfig, svgConfig), {
// Change this to true to see debugging info.
// Useful if you have issues resolving modules
debug: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { memo, ReactElement, useEffect } from 'react';

import { ThemeTypeEnum, useThemeStore } from '@pokemon-pet-shop/store';
import { IconTypeEnum, SwitchStatusEnum, UiSwitch } from '@pokemon-pet-shop/ui';
import { IconTypeEnum, SwitchStatusEnum, UiSwitch, UiTypography } from '@pokemon-pet-shop/ui';

import { SwitchProps } from './switch.theme.interface';

/** @todo hiding this code until a way to create a theming process for web and mobile */
const SwitchTheme = ({ className }: SwitchProps): ReactElement => {
const { theme, updateTheme } = useThemeStore();

const updateTheming = (newTheme: ThemeTypeEnum) => {
updateTheme(newTheme);
const el = document.querySelector('html');
// const el = document.querySelector('html');

el?.classList.toggle(ThemeTypeEnum.DARK);
el?.classList.toggle(ThemeTypeEnum.LIGHT);
// el?.classList.toggle(ThemeTypeEnum.DARK);
// el?.classList.toggle(ThemeTypeEnum.LIGHT);
};

const turnLightOnClick = () => {
Expand All @@ -25,9 +26,8 @@ const SwitchTheme = ({ className }: SwitchProps): ReactElement => {
};

useEffect(() => {
const el = document.querySelector('html');

el?.classList.add(theme);
// const el = document.querySelector('html');
// el?.classList.add(theme);
}, [theme]);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { StyleSheet } from 'react-native';

export const styles = StyleSheet.create({
modal: {
backgroundColor: 'white',
position: 'relative',
display: 'flex',
flexDirection: 'row',
height: '94%',
width: '100%',
},
navWrapper: {
display: 'flex',
justifyContent: 'space-between',
flex: 1,
flexDirection: 'column',
marginLeft: 15,
marginRight: 15,
marginBottom: 15,
},
switchWrapper: {
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import styles from './nav.mobile.module.css';

export { styles };
2 changes: 1 addition & 1 deletion libs/features/src/lib/navigation/nav.mobile/nav.mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UiElementLayout, UiTypography } from '@pokemon-pet-shop/ui';

import { UiSwitchTheme } from '../component/switch.theme';

import styles from './nav.mobile.module.css';
import { styles } from './nav.mobile.module';

const NavMobileModal = (): ReactElement => {
return (
Expand Down
4 changes: 4 additions & 0 deletions libs/ui/src/lib-base/ui/switch/switch.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ export interface SwitchProps {
onLeftClick?: GenericNonReturnType;
onRightClick?: GenericNonReturnType;
}

export interface SwitchButtonProps {
className?: string;
}
3 changes: 0 additions & 3 deletions libs/ui/src/lib-base/ui/switch/switch.module.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ export const styles = StyleSheet.create({
switchWrapper: {
borderRadius: 100,
backgroundColor: 'grey',
display: 'flex',
width: 85,
paddingTop: 14,
paddingBottom: 14,
paddingLeft: 10,
paddingRight: 10,
alignItems: 'center',
justifyContent: 'space-between',
position: 'relative',
flexDirection: 'row',
},
icon: {
Expand All @@ -32,7 +30,6 @@ export const styles = StyleSheet.create({
backgroundColor: 'blue',
zIndex: 0,
borderRadius: 100,
// transition: left 100ms ease-in-out;
},
circleLightPosition: {
left: 8,
Expand Down
4 changes: 2 additions & 2 deletions libs/utils/src/lib-base/utils/classnames.util.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ export const classNamesUtil = (...args) => {
const mergedStyles = args.reduce((accumulator, currentValue) => {
let newAcc = accumulator;
let newCurVal = currentValue;
if (typeof accumulator !== 'object') {
if (typeof newAcc !== 'object' || newAcc === undefined) {
newAcc = {};
}
if (typeof accumulator !== 'object') {
if (typeof newCurVal !== 'object' || newCurVal === undefined) {
newCurVal = {};
}
return { ...newAcc, ...newCurVal };
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"react-native": "0.74.5",
"react-native-dotenv": "^3.4.11",
"react-native-error-boundary": "^1.2.4",
"react-native-reanimated": "^3.14.0",
"react-native-reanimated": "~3.10.1",
"react-native-svg": "15.2.0",
"react-native-svg-transformer": "^1.5.0",
"react-native-web": "~0.19.11",
Expand Down

0 comments on commit 8275042

Please sign in to comment.