文件
mynode/packages/app-mobile/components/buttons/LabelledIconButton.tsx
chen 301194963b
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

76 行
1.8 KiB
TypeScript

import * as React from 'react';
import { Text, TouchableRipple } from 'react-native-paper';
import Icon from '../Icon';
import { themeStyle } from '../global-style';
import { connect } from 'react-redux';
import { AppState } from '../../utils/types';
import { StyleSheet, View, ViewProps } from 'react-native';
import { useMemo } from 'react';
interface Props extends ViewProps {
themeId: number;
title: string;
icon: string;
onPress: ()=> void;
}
const useStyles = (themeId: number) => {
return useMemo(() => {
const theme = themeStyle(themeId);
return StyleSheet.create({
icon: {
fontSize: 27,
width: 44,
height: 44,
textAlign: 'center',
overflow: 'hidden',
color: theme.color3,
borderColor: theme.codeBorderColor, // TODO: Use a different theme variable
borderRadius: 22,
padding: 6,
borderWidth: 2,
backgroundColor: theme.backgroundColor3,
},
buttonContent: {
flexDirection: 'column',
alignItems: 'center',
gap: 6,
},
button: {
borderRadius: 8,
padding: 8,
},
buttonText: {
textAlign: 'center',
},
});
}, [themeId]);
};
const LabelledIconButton: React.FC<Props> = ({ title, icon, style, themeId, ...otherProps }) => {
const styles = useStyles(themeId);
return <TouchableRipple
borderless={true}
role='button'
accessibilityRole='button'
{...otherProps}
style={[styles.button, style]}
>
<View style={styles.buttonContent}>
<Icon style={styles.icon} accessibilityLabel={null} name={icon}/>
<Text
variant='labelMedium'
ellipsizeMode='tail'
numberOfLines={2}
style={styles.buttonText}
>{title}</Text>
</View>
</TouchableRipple>;
};
export default connect((state: AppState) => {
return { themeId: state.settings.theme };
})(LabelledIconButton);