Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

J UI p 150 creacion componente tabs #38

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

dam788
Copy link

@dam788 dam788 commented Jun 12, 2024

LINK DE TICKET:

https://janiscommerce.atlassian.net/browse/JUIP-149

DESCRIPCIÓN DEL REQUERIMIENTO:

Contexto
En los nuevos diseños de las apps, tenemos tabs en la parte superior de algunas pantallas

Necesidad
Se requiere tener el componente uppertabs que tenemos en las apps, adaptado para ui native

DESCRIPCIÓN DE LA SOLUCIÓN:

  • Se agrego el componente Tab:
props tipo de dato valor por defecto es requerido nota
initialTab number null 0 no
scenes arrayOf({ title: string escene: React.Node disabled: boolean})   si el titulo y componente que se renderiza dentro de la tab.
position enum('top', 'bottom') ‘top’ no la posición del tab
onPressTabCb (initialTab: number) => void no callback que se active cuando presiono una tab. Devuelve por params el numero de tab.
ScrollContentStyle ViewStyle {} no estilos para esl scrollview que renderiza el contenido
style ViewStyle {} no extension de los estilos

CÓMO SE PUEDE PROBAR?

Es en storybook:

  • npm start | npm run storybook:android

En la app:

  • Pegar este código en App.tsx:
/* eslint-disable react-native/no-inline-styles */
import React from 'react';
import {View} from 'react-native';
import Tabs from './src/components/Tabs';
import Svg from './src/components/Svg';

const App = () => {
	const SceneX = ({children}) => (
		<View
			style={{
				justifyContent: 'center',
				alignItems: 'center',
				padding: 20,
				backgroundColor: 'whitesmoke',
			}}>
			{children}
		</View>
	);

	const scenes = [
		{
			title: 'Inicio',
			scene: (
				<SceneX>
					<Svg name="login-illustration" size={220} />
					<Svg name="login-illustration" size={220} />
					<Svg name="login-illustration" size={220} />
					<Svg name="login-illustration" size={220} />
					<Svg name="login-illustration" size={220} />
					<Svg name="login-illustration" size={220} />
				</SceneX>
			),
			// disabled: true,
		},
		{
			title: 'Notificationes',
			scene: (
				<SceneX>
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
				</SceneX>
			),
			// disabled: false,
		},
		{
			title: 'Firma',
			scene: (
				<SceneX>
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
				</SceneX>
			),
			// disabled: false,
		},
		{
			title: 'Tab 4',
			scene: (
				<SceneX>
					<Svg name="login-illustration" size={220} />
					<Svg name="login-illustration" size={220} />
					<Svg name="login-illustration" size={220} />
					<Svg name="login-illustration" size={220} />
					<Svg name="login-illustration" size={220} />
					<Svg name="login-illustration" size={220} />
				</SceneX>
			),
			// disabled: true,
		},
		{
			title: 'Tab 5',
			scene: (
				<SceneX>
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
					<Svg name="no-notifications" size={220} />
				</SceneX>
			),
			// disabled: false,
		},
		{
			title: 'Tab 6',
			scene: (
				<SceneX>
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
					<Svg name="empty-illustration" size={220} />
				</SceneX>
			),
			disabled: false,
		},
	];

	return (
		<View style={{flex: 1}}>
			<Tabs
				scenes={scenes}
				initialTab={1}
				scrollContentStyle={{padding: 20}}
				position="top" // bottom
			/>
		</View>
	);
};

export default App;

En la app Wms:

  • En el repo de ui-nativenpm run build y yalc push.
  • En la app wms yalc add @janis-commerce/ui-native y npm i.
  • Pegar este código en Notifications.js:
import React from 'react';
import {useTranslation} from 'react-i18next';
import {Text} from 'react-native';
import LayoutComp from 'layouts/LayoutWithBottomButtons';
import {Tabs} from '@janiscommerce/ui-native';
import Styles from './styles';

const Notifications = () => {
	const {t} = useTranslation('appCommon');

	const scene = (
		<>
			<Styles.Wrapper testID="notifications">
				<Styles.Svg name="no-notifications" width={81} height={117} />
				<Styles.Title>{t('appCommon.message.ooops')}</Styles.Title>
				<Styles.Text>{t('appCommon.message.noNotifications')}</Styles.Text>
			</Styles.Wrapper>
			<Styles.Wrapper testID="notifications">
				<Styles.Svg name="no-notifications" width={81} height={117} />
				<Styles.Title>{t('appCommon.message.ooops')}</Styles.Title>
				<Styles.Text>{t('appCommon.message.noNotifications')}</Styles.Text>
			</Styles.Wrapper>
			<Styles.Wrapper testID="notifications">
				<Styles.Svg name="no-notifications" width={81} height={117} />
				<Styles.Title>{t('appCommon.message.ooops')}</Styles.Title>
				<Styles.Text>{t('appCommon.message.noNotifications')}</Styles.Text>
			</Styles.Wrapper>
			<Styles.Wrapper testID="notifications">
				<Styles.Svg name="no-notifications" width={81} height={117} />
				<Styles.Title>{t('appCommon.message.ooops')}</Styles.Title>
				<Styles.Text>{t('appCommon.message.noNotifications')}</Styles.Text>
			</Styles.Wrapper>
		</>
	);

	// eslint-disable-next-line react/prop-types
	const SceneX = ({children}) => <Styles.Wrapper testID="notifications">{children}</Styles.Wrapper>;

	const scenes = [
		{
			title: 'Init',
			scene,
		},
		{
			title: 'Notifications',
			scene: (
				<SceneX>
					<Text>Notifications</Text>
				</SceneX>
			),
		},
		{
			title: 'Config',
			scene,
		},
		{
			title: 'Tab 4',
			scene,
		},
		{
			title: 'Tab5',
			scene: (
				<SceneX>
					<Text>Notifications</Text>
				</SceneX>
			),
		},
		{
			title: 'Tab 6',
			scene,
		},
	];

	// bottom buttons
	const bottomButtons = [
		{
			title: t('appCommon.action.scanProduct'),
			startIcon: 'scanner',
			iconSize: 24,
			color: 'black',
			onPress: () => {},
		},
	];

	return (
		<LayoutComp
			style={{flex: 1}}
			buttons={bottomButtons}
			buttonBackgroundColor="white"
			buttonsDirection="column"
			variant="rounded">
			<Tabs scenes={scenes} initialTab={1} />
		</LayoutComp>
	);
};

export default Notifications;
  • Y éste es el styles.js:
import styled from 'styled-components/native';
import {getColor} from 'theme/utils';
import {getScale} from 'src/utils';
import {fontWeight} from 'theme/typography';
import {Svg as SvgComponent} from '@janiscommerce/ui-native';

const {verticalScale} = getScale();

const Wrapper = styled.View`
	background-color: ${getColor('white', 'main')};
	align-items: center;
	padding: ${verticalScale(59)}px;
`;

const Title = styled.Text`
	color: ${getColor('grey', '600')};
	font-size: ${verticalScale(20)}px;
	${fontWeight.medium};
	letter-spacing: 0;
	line-height: ${verticalScale(28)}px;
	margin-top: ${verticalScale(36)}px;
	margin-bottom: ${verticalScale(12)}px;
`;

const Text = styled.Text`
	color: ${getColor('grey', '500')};
	font-size: ${verticalScale(16)}px;
	letter-spacing: 0;
	line-height: ${verticalScale(24)}px;
`;

const Svg = styled(SvgComponent)``;

export default {Wrapper, Title, Text, Svg};

SCREENSHOTS:

Kapture 2024-06-12 at 19 29 59
Kapture 2024-06-12 at 19 38 55

DATOS EXTRA A TENER EN CUENTA:

CHANGELOG:

@coveralls
Copy link

coveralls commented Jun 12, 2024

Pull Request Test Coverage Report for Build 9490758039

Details

  • 31 of 31 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 9405014264: 0.0%
Covered Lines: 537
Relevant Lines: 537

💛 - Coveralls

src/components/Tabs/utils/index.tsx Outdated Show resolved Hide resolved
src/components/Tabs/index.tsx Outdated Show resolved Hide resolved
src/components/Tabs/index.tsx Outdated Show resolved Hide resolved
src/components/Tabs/index.tsx Outdated Show resolved Hide resolved
src/components/Tabs/index.tsx Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Jun 14, 2024

Pull Request Test Coverage Report for Build 9522367456

Details

  • 31 of 31 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 9405014264: 0.0%
Covered Lines: 537
Relevant Lines: 537

💛 - Coveralls

return null;
}

const [activeTab, setActiveTab] = useState(initialTab);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dam788 los ajustes de estilos quedaron bien, revisate que, cuando le paso un valor a initialTab que no sea 0, me rompe con este error:

Invariant Violation: scrollToIndex should be used in conjunction with getItemLayout or onScrollToIndexFailed, otherwise there is no way to know the location of offscreen indices or handle failures.

Cualquier cosa, si vos haces la prueba y no te pasa avisame y lo vemos a ver si estoy bardeando con algo.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

si gonza, me encontre con unos problemas que no habia tenido en cuenta. Ahi los resolvi, gracias!

@dam788 dam788 requested a review from GonzaFran June 18, 2024 17:52
@coveralls
Copy link

coveralls commented Jun 18, 2024

Pull Request Test Coverage Report for Build 9571647947

Details

  • 39 of 39 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 9405014264: 0.0%
Covered Lines: 545
Relevant Lines: 545

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 18, 2024

Pull Request Test Coverage Report for Build 9571672680

Details

  • 39 of 39 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 9405014264: 0.0%
Covered Lines: 545
Relevant Lines: 545

💛 - Coveralls

Copy link

@WilliamSaya-lvl30 WilliamSaya-lvl30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dam788 Punto que me sñalaron en diseño cuando se implemento, las tabs cuando estan inactivas tienen el titulo en negro.
Captura de pantalla de 2024-06-18 20-36-58

Tambien hay que revisar como se ve en web.

Captura de pantalla de 2024-06-18 20-16-40

@coveralls
Copy link

coveralls commented Jun 19, 2024

Pull Request Test Coverage Report for Build 9583526137

Details

  • 40 of 40 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 9405014264: 0.0%
Covered Lines: 546
Relevant Lines: 546

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 19, 2024

Pull Request Test Coverage Report for Build 9586828157

Details

  • 40 of 40 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 9405014264: 0.0%
Covered Lines: 546
Relevant Lines: 546

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants