Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/APPSRN-311-crear-componente-toast'
Browse files Browse the repository at this point in the history
  • Loading branch information
christian97dd committed Jul 12, 2024
2 parents 9f52090 + b81996d commit 55cd729
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.8.1] - 2024-07-12

### Fixed

- Fixed an error while trying to close toast component.

## [1.8.0] - 2024-06-27

- Added Toast component.
Expand Down
6 changes: 6 additions & 0 deletions setupTest/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ jest.mock('@gorhom/bottom-sheet', () => {
BottomSheetView: react.View,
};
});

jest.mock('react-native-toast-message', () => ({
show: jest.fn(),
hide: jest.fn(),
setRef: jest.fn(),
}));
12 changes: 10 additions & 2 deletions src/components/Toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {moderateScale, scaledForDevice} from '../../scale';
import {defaultIcon} from './utils';
import {base, black} from '../../theme/palette';
import BaseToast, {BaseToastProps} from '../BaseToast';
import ToastAction from 'react-native-toast-message';
import Text from '../Text';
import Icon from '../Icon';

Expand Down Expand Up @@ -45,6 +46,13 @@ const Toast: FC<ToastProps> = ({type, text1, text2, style, props}) => {
const selectedIconName = customIcon || defaultIconName;
const horizontalAlign = validTitle ? 'flex-start' : 'center';

const handleActionCb = () => actionCb();

const handleCloseCb = () => {
ToastAction.hide();
onCloseCb();
};

const styles = StyleSheet.create({
container: {
display: 'flex',
Expand Down Expand Up @@ -109,12 +117,12 @@ const Toast: FC<ToastProps> = ({type, text1, text2, style, props}) => {

<View style={styles.feedbackWrapper}>
{actionTitle && (
<TouchableOpacity onPress={actionCb} activeOpacity={0.6}>
<TouchableOpacity onPress={handleActionCb} activeOpacity={0.6}>
<Text style={styles.actionTitle}>{actionTitle}</Text>
</TouchableOpacity>
)}
{showCloseIcon && (
<TouchableOpacity onPress={onCloseCb} activeOpacity={0.6}>
<TouchableOpacity onPress={handleCloseCb} activeOpacity={0.6}>
<Icon name="cross_light" color={validColor} size={24} style={styles.closeIcon} />
</TouchableOpacity>
)}
Expand Down

0 comments on commit 55cd729

Please sign in to comment.