Skip to content

Commit

Permalink
refactor: toast #140
Browse files Browse the repository at this point in the history
  • Loading branch information
BANG88 committed Dec 2, 2018
1 parent 84d17b5 commit a40840c
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion components/checkbox/style/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ViewStyle, ImageStyle, TextStyle } from 'react-native';
import { TextStyle, ViewStyle } from 'react-native';
import variables from '../../style/themes/default';

export interface ICheckboxStyle {
Expand Down
4 changes: 2 additions & 2 deletions components/icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
OutlineGlyphMapType,
} from '@ant-design/icons-react-native';
import variables from '../style/themes/default';

export type IconNames = OutlineGlyphMapType;
export interface IconProps extends TextProps {
size?: 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | number;
color?: string;
name: OutlineGlyphMapType;
name: IconNames;
}

export default class Icon extends React.Component<IconProps, any> {
Expand Down
27 changes: 14 additions & 13 deletions components/toast/ToastContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
// tslint:disable:jsx-no-multiline-js

import React from 'react';
import {
ActivityIndicator,
Animated,
Image,
StyleSheet,
Text,
View,
} from 'react-native';
import { ActivityIndicator, Animated, StyleSheet, Text, View } from 'react-native';
import Icon, { IconNames } from '../icon';
import ToastContainerStyle, { IToastStyle } from './style/index';

export interface ToastProps {
Expand Down Expand Up @@ -79,11 +73,11 @@ export default class ToastContainer extends React.Component<ToastProps, any> {
const { type = '', content, mask } = this.props;
const styles = this.props.styles!;
const iconType: {
[key: string]: any;
[key: string]: IconNames;
} = {
success: require('./images/success.png'),
fail: require('./images/fail.png'),
offline: require('./images/offline.png'),
success: 'check-circle',
fail: 'close-circle',
offline: 'frown',
};

let iconDom: React.ReactElement<any> | null = null;
Expand All @@ -99,7 +93,14 @@ export default class ToastContainer extends React.Component<ToastProps, any> {
} else if (type === 'info') {
iconDom = null;
} else {
iconDom = <Image source={iconType[type]} style={styles.image} />;
iconDom = (
<Icon
name={iconType[type]}
style={styles.image}
color="white"
size={32}
/>
);
}

return (
Expand Down
Binary file removed components/toast/images/fail.png
Binary file not shown.
Binary file removed components/toast/images/fail@2x.png
Binary file not shown.
Binary file removed components/toast/images/fail@3x.png
Binary file not shown.
Binary file removed components/toast/images/offline.png
Binary file not shown.
Binary file removed components/toast/images/offline@2x.png
Binary file not shown.
Binary file removed components/toast/images/offline@3x.png
Binary file not shown.
Binary file removed components/toast/images/success.png
Binary file not shown.
Binary file removed components/toast/images/success@2x.png
Binary file not shown.
Binary file removed components/toast/images/success@3x.png
Binary file not shown.
4 changes: 2 additions & 2 deletions components/toast/style/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import variables from '../../style/themes/default';
import { Platform, ViewStyle, ImageStyle, TextStyle } from 'react-native';
import { Platform, ViewStyle, TextStyle } from 'react-native';

export interface IToastStyle {
container: ViewStyle;
Expand All @@ -8,7 +8,7 @@ export interface IToastStyle {
iconToast: ViewStyle;
textToast: ViewStyle;
content: TextStyle;
image: ImageStyle;
image: TextStyle;
centering: ViewStyle;
}

Expand Down

0 comments on commit a40840c

Please sign in to comment.