dry-react
Version:
Initialiseur de structure React Native typée et modulaire
96 lines (92 loc) • 2.4 kB
JavaScript
const fs = require('fs');
const path = require('path');
module.exports = function generateToastConfig() {
const configPath = path.join(__dirname, '..', 'src', 'config');
fs.mkdirSync(configPath, { recursive: true });
const content = `import { StyleSheet, Text, View } from 'react-native';
export const DryToastConfig = {
success: (props: any) => (
<View style={toastStyles.successContainer}>
<Text style={toastStyles.successText1}>{props.text1}</Text>
<Text style={toastStyles.successText2}>{props.text2}</Text>
</View>
),
error: (props: any) => (
<View style={toastStyles.errorContainer}>
<Text style={toastStyles.errorText1}>{props.text1}</Text>
<Text style={toastStyles.errorText2}>{props.text2}</Text>
</View>
),
info: (props: any) => (
<View style={toastStyles.infoContainer}>
<Text style={toastStyles.infoText1}>{props.text1}</Text>
<Text style={toastStyles.infoText2}>{props.text2}</Text>
</View>
),
};
const toastStyles = StyleSheet.create({
successContainer: {
minHeight: 80,
width: '90%',
borderRadius: 12,
padding: 20,
backgroundColor: '#4CAF50',
borderLeftWidth: 6,
borderLeftColor: '#388E3C',
},
errorContainer: {
minHeight: 80,
width: '90%',
borderRadius: 12,
padding: 20,
backgroundColor: '#F44336',
borderLeftWidth: 6,
borderLeftColor: '#D32F2F',
},
infoContainer: {
minHeight: 80,
width: '90%',
borderRadius: 12,
padding: 20,
backgroundColor: '#2196F3',
borderLeftWidth: 6,
borderLeftColor: '#1976D2',
},
successText1: {
fontSize: 15,
fontWeight: 'bold',
color: 'white',
marginBottom: 5,
},
successText2: {
fontSize: 13,
color: 'white',
opacity: 0.9,
},
errorText1: {
fontSize: 15,
fontWeight: 'bold',
color: 'white',
marginBottom: 5,
},
errorText2: {
fontSize: 13,
color: 'white',
opacity: 0.9,
},
infoText1: {
fontSize: 15,
fontWeight: 'bold',
color: 'white',
marginBottom: 5,
},
infoText2: {
fontSize: 13,
color: 'white',
opacity: 0.9,
},
});
`;
fs.writeFileSync(path.join(configPath, 'toast.config.tsx'), content);
console.log(`🔔 Fichier toast.config.ts généré dans src/config.`);
};