xref: /MusicFree/src/components/base/imageBtn.tsx (revision ceb900cd812eb1b086ac040a306ddf325339e920)
1*ceb900cdS猫头猫import React from 'react';
2*ceb900cdS猫头猫import {StyleProp, StyleSheet, ViewStyle} from 'react-native';
3*ceb900cdS猫头猫import rpx from '@/utils/rpx';
4*ceb900cdS猫头猫import {TouchableOpacity} from 'react-native-gesture-handler';
5*ceb900cdS猫头猫import Image from './image';
6*ceb900cdS猫头猫import {ImgAsset} from '@/constants/assetsConst';
7*ceb900cdS猫头猫import ThemeText from './themeText';
8*ceb900cdS猫头猫
9*ceb900cdS猫头猫interface IImageBtnProps {
10*ceb900cdS猫头猫    uri?: string;
11*ceb900cdS猫头猫    title?: string;
12*ceb900cdS猫头猫    onPress?: () => void;
13*ceb900cdS猫头猫    style?: StyleProp<ViewStyle>;
14*ceb900cdS猫头猫}
15*ceb900cdS猫头猫export default function ImageBtn(props: IImageBtnProps) {
16*ceb900cdS猫头猫    const {onPress, uri, title, style: _style} = props ?? {};
17*ceb900cdS猫头猫    return (
18*ceb900cdS猫头猫        <TouchableOpacity
19*ceb900cdS猫头猫            activeOpacity={0.5}
20*ceb900cdS猫头猫            onPress={onPress}
21*ceb900cdS猫头猫            style={[style.wrapper, _style]}>
22*ceb900cdS猫头猫            <Image
23*ceb900cdS猫头猫                style={style.image}
24*ceb900cdS猫头猫                uri={uri}
25*ceb900cdS猫头猫                emptySrc={ImgAsset.albumDefault}
26*ceb900cdS猫头猫            />
27*ceb900cdS猫头猫            <ThemeText
28*ceb900cdS猫头猫                fontSize="subTitle"
29*ceb900cdS猫头猫                numberOfLines={2}
30*ceb900cdS猫头猫                ellipsizeMode="tail">
31*ceb900cdS猫头猫                {title ?? ''}
32*ceb900cdS猫头猫            </ThemeText>
33*ceb900cdS猫头猫        </TouchableOpacity>
34*ceb900cdS猫头猫    );
35*ceb900cdS猫头猫}
36*ceb900cdS猫头猫
37*ceb900cdS猫头猫const style = StyleSheet.create({
38*ceb900cdS猫头猫    wrapper: {
39*ceb900cdS猫头猫        width: rpx(210),
40*ceb900cdS猫头猫        height: rpx(290),
41*ceb900cdS猫头猫        flexGrow: 0,
42*ceb900cdS猫头猫        flexShrink: 0,
43*ceb900cdS猫头猫        justifyContent: 'space-between',
44*ceb900cdS猫头猫    },
45*ceb900cdS猫头猫    image: {
46*ceb900cdS猫头猫        width: rpx(210),
47*ceb900cdS猫头猫        height: rpx(210),
48*ceb900cdS猫头猫        borderRadius: rpx(12),
49*ceb900cdS猫头猫    },
50*ceb900cdS猫头猫});
51