feat: new styles and regenerate cover
This commit is contained in:
@@ -39,6 +39,12 @@ const COVER_STYLE_PRESETS = [
|
|||||||
'Portrait théâtralisé',
|
'Portrait théâtralisé',
|
||||||
'Livre de coloriage',
|
'Livre de coloriage',
|
||||||
'Shooting',
|
'Shooting',
|
||||||
|
'Réaliste',
|
||||||
|
'Artistique',
|
||||||
|
'Afro',
|
||||||
|
'Grunge',
|
||||||
|
'Pop Art'
|
||||||
|
|
||||||
]
|
]
|
||||||
const COVER_PROGRESS_MAX = 98
|
const COVER_PROGRESS_MAX = 98
|
||||||
const COVER_PROGRESS_INTERVAL_MS = 500
|
const COVER_PROGRESS_INTERVAL_MS = 500
|
||||||
@@ -74,6 +80,7 @@ const PouchReady = () => {
|
|||||||
return 'Nous lançons la génération de ta pochette...'
|
return 'Nous lançons la génération de ta pochette...'
|
||||||
}, [coverBackgroundMessage])
|
}, [coverBackgroundMessage])
|
||||||
|
|
||||||
|
const [isEditing, setIsEditing] = useState(false)
|
||||||
const [styleMode, setStyleMode] = useState('preset')
|
const [styleMode, setStyleMode] = useState('preset')
|
||||||
const [selectedPresetStyle, setSelectedPresetStyle] = useState(COVER_STYLE_PRESETS[0])
|
const [selectedPresetStyle, setSelectedPresetStyle] = useState(COVER_STYLE_PRESETS[0])
|
||||||
const [customStyle, setCustomStyle] = useState('')
|
const [customStyle, setCustomStyle] = useState('')
|
||||||
@@ -115,7 +122,8 @@ const PouchReady = () => {
|
|||||||
const generateCover = useCallback(
|
const generateCover = useCallback(
|
||||||
async (styleValue) => {
|
async (styleValue) => {
|
||||||
if (!selectedProjectId) return
|
if (!selectedProjectId) return
|
||||||
if (hasGeneratedOptions) {
|
// We allow regeneration if isEditing is true
|
||||||
|
if (hasGeneratedOptions && !isEditing) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const trimmedStyle = String(styleValue || '').trim()
|
const trimmedStyle = String(styleValue || '').trim()
|
||||||
@@ -128,6 +136,12 @@ const PouchReady = () => {
|
|||||||
await updateProjectData(
|
await updateProjectData(
|
||||||
{
|
{
|
||||||
coverStyle: trimmedStyle,
|
coverStyle: trimmedStyle,
|
||||||
|
cover: {
|
||||||
|
options: [],
|
||||||
|
result: null,
|
||||||
|
generatedBackground: null,
|
||||||
|
selectedOptionId: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ merge: true }
|
{ merge: true }
|
||||||
)
|
)
|
||||||
@@ -137,13 +151,14 @@ const PouchReady = () => {
|
|||||||
status: 'PENDING',
|
status: 'PENDING',
|
||||||
createdAt: firebase.firestore.FieldValue.serverTimestamp(),
|
createdAt: firebase.firestore.FieldValue.serverTimestamp(),
|
||||||
})
|
})
|
||||||
|
setIsEditing(false) // Exit editing mode after triggering generation
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Cover task error', e?.message)
|
console.log('Cover task error', e?.message)
|
||||||
setIsAwaitingGenerationStart(false)
|
setIsAwaitingGenerationStart(false)
|
||||||
await setLoading(false)
|
await setLoading(false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[hasGeneratedOptions, selectedProjectId, setLoading, showGenerationLoading, updateProjectData]
|
[hasGeneratedOptions, isEditing, selectedProjectId, setLoading, showGenerationLoading, updateProjectData]
|
||||||
)
|
)
|
||||||
|
|
||||||
const requestCoverGeneration = useCallback(() => {
|
const requestCoverGeneration = useCallback(() => {
|
||||||
@@ -159,7 +174,7 @@ const PouchReady = () => {
|
|||||||
const coverPreviewUrl =
|
const coverPreviewUrl =
|
||||||
selectedProject?.cover?.result || selectedProject?.cover?.generatedBackground || null
|
selectedProject?.cover?.result || selectedProject?.cover?.generatedBackground || null
|
||||||
|
|
||||||
const shouldShowStylePanel = !isGenerating && !hasGeneratedOptions && !coverPreviewUrl
|
const shouldShowStylePanel = (!isGenerating && !hasGeneratedOptions && !coverPreviewUrl) || isEditing
|
||||||
|
|
||||||
const displayOptions = hasGeneratedOptions
|
const displayOptions = hasGeneratedOptions
|
||||||
? coverOptions
|
? coverOptions
|
||||||
@@ -527,6 +542,10 @@ const PouchReady = () => {
|
|||||||
setIsPresetDropdownOpen(false)
|
setIsPresetDropdownOpen(false)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Text style={{ color: Palette.white, fontSize: 12, paddingLeft: 24, paddingTop: 8 }}>
|
||||||
|
Donne les instructions que tu veux pour créer ta pochette
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
{styleMode === 'custom' && (
|
{styleMode === 'custom' && (
|
||||||
<View style={styles.customInputWrapper}>
|
<View style={styles.customInputWrapper}>
|
||||||
@@ -560,16 +579,44 @@ const PouchReady = () => {
|
|||||||
gap: 12,
|
gap: 12,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{!hasGeneratedOptions && (
|
{isEditing ? (
|
||||||
|
<View style={{ gap: 12 }}>
|
||||||
|
<BorderGradientButton
|
||||||
|
title={isGenerating ? 'Génération en cours...' : 'Regénérer la pochette'}
|
||||||
|
icon={icons.stars}
|
||||||
|
onPress={requestCoverGeneration}
|
||||||
|
disabled={isGenerating}
|
||||||
|
/>
|
||||||
|
<Pressable
|
||||||
|
onPress={() => setIsEditing(false)}
|
||||||
|
disabled={isGenerating}
|
||||||
|
style={{ alignSelf: 'center', padding: 8 }}
|
||||||
|
>
|
||||||
|
<Text style={{ color: Palette.gray, fontFamily: FONT_FAMILY.InterMedium }}>
|
||||||
|
Annuler
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
) : !hasGeneratedOptions ? (
|
||||||
<BorderGradientButton
|
<BorderGradientButton
|
||||||
title={isGenerating ? 'Génération en cours...' : 'Générer la pochette'}
|
title={isGenerating ? 'Génération en cours...' : 'Générer la pochette'}
|
||||||
icon={icons.stars}
|
icon={icons.stars}
|
||||||
onPress={requestCoverGeneration}
|
onPress={requestCoverGeneration}
|
||||||
disabled={isGenerating}
|
disabled={isGenerating}
|
||||||
/>
|
/>
|
||||||
)}
|
) : (
|
||||||
{hasGeneratedOptions && (
|
<>
|
||||||
|
<View style={{ flexDirection: 'column', gap: 12, width: '100%' }}>
|
||||||
<GradientButton title={'Valider la pochette'} onPress={onValidatePicture} />
|
<GradientButton title={'Valider la pochette'} onPress={onValidatePicture} />
|
||||||
|
|
||||||
|
<BorderGradientButton
|
||||||
|
title="Pas satisfait ? Modifier ma demande"
|
||||||
|
onPress={() => setIsEditing(true)}
|
||||||
|
disabled={isGenerating}
|
||||||
|
textStyle={{ fontSize: 13 }}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</KeyboardAvoidingView>
|
</KeyboardAvoidingView>
|
||||||
|
|||||||
Reference in New Issue
Block a user