| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import * as React from 'react';
- import { Animated } from 'react-native';
- import { Div, Button, Image, Text, Tag, Icon } from 'react-native-magnus';
- import { useAnimation } from 'react-native-animation-hooks';
- import SvgIcon from './SvgIcon';
- const map = new Map([
- [
- 'bad',
- {
- name: '差评',
- },
- ],
- [
- 'good',
- {
- name: '好评',
- },
- ],
- ]);
- export default function Choose(props) {
- const { chooseValue, changeValue } = props;
- const badOpacity = useAnimation({
- type: 'timing',
- initialValue: 1,
- duration: 100,
- toValue: chooseValue && chooseValue !== 'bad' ? 0 : 1,
- });
- const goodOpacity = useAnimation({
- type: 'timing',
- initialValue: 1,
- duration: 100,
- toValue: chooseValue && chooseValue !== 'good' ? 0 : 1,
- });
- const chooseStyle = {
- position: 'absolute',
- left: '50%',
- transform: [{ translateX: 0 - 53 / 2 }],
- top: 12,
- };
- return (
- <Div>
- <Div row justifyContent="space-around" py={12} px={15}>
- <Animated.View
- style={[
- {
- opacity: badOpacity,
- },
- chooseValue === 'bad' && chooseStyle,
- ]}
- >
- <Button
- bg="hide"
- disabled={chooseValue}
- onPress={() => changeValue('bad')}
- >
- <Div alignItems="center">
- <SvgIcon name="bad" width={53} height={53} />
- </Div>
- </Button>
- </Animated.View>
- <Animated.View
- style={[
- {
- opacity: goodOpacity,
- },
- chooseValue === 'good' && chooseStyle,
- ]}
- >
- <Button
- bg="hide"
- disabled={chooseValue}
- onPress={() => changeValue('good')}
- >
- <Div alignItems="center">
- <SvgIcon name="good" width={53} height={53} />
- </Div>
- </Button>
- </Animated.View>
- </Div>
- <Div alignItems="center">
- <Div>
- {!!chooseValue && (
- <Tag
- suffix={<Icon name="close" color="black700" fontSize="caption" />}
- color="brand500"
- onPress={() => changeValue('')}
- >
- 当前已选择:{map.get(chooseValue).name}
- </Tag>
- )}
- </Div>
- </Div>
- </Div>
- );
- }
|