feat(#1,#2,#5): add checkup nav/progress, image optimization controls, and raise tab bar
Some checks failed
Luggage List Build / build-web (push) Successful in 31s
Luggage List Build / build-android (push) Failing after 1m46s
Luggage List Build / release (push) Has been skipped

This commit is contained in:
2026-04-18 18:45:21 +02:00
parent 89fd4c2f44
commit 0e0ab4a059
4 changed files with 111 additions and 17 deletions

View File

@@ -35,6 +35,8 @@ const emptyItemForm = () => ({
placement: 'suitcase', placement: 'suitcase',
lentTo: '', lentTo: '',
imageUri: '', imageUri: '',
imageQuality: 'balanced',
imageAllowCrop: false,
}); });
const emptyCheckupNoForm = () => ({ const emptyCheckupNoForm = () => ({
@@ -234,7 +236,7 @@ export default function AppRoot() {
setDatePicker((prev) => ({ ...prev, visible: false })); setDatePicker((prev) => ({ ...prev, visible: false }));
} }
async function pickImage(onPicked) { async function pickImage(onPicked, options = {}) {
const perm = await ImagePicker.requestMediaLibraryPermissionsAsync(); const perm = await ImagePicker.requestMediaLibraryPermissionsAsync();
if (!perm.granted) { if (!perm.granted) {
showAlert('Permission needed', 'Allow gallery access to select images.'); showAlert('Permission needed', 'Allow gallery access to select images.');
@@ -243,8 +245,8 @@ export default function AppRoot() {
const result = await ImagePicker.launchImageLibraryAsync({ const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images, mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: false, allowsEditing: !!options.allowCrop,
quality: 0.85, quality: typeof options.quality === 'number' ? options.quality : 0.85,
}); });
if (!result.canceled && result.assets?.[0]?.uri) { if (!result.canceled && result.assets?.[0]?.uri) {
@@ -252,7 +254,7 @@ export default function AppRoot() {
} }
} }
async function takeImage(onPicked) { async function takeImage(onPicked, options = {}) {
const perm = await ImagePicker.requestCameraPermissionsAsync(); const perm = await ImagePicker.requestCameraPermissionsAsync();
if (!perm.granted) { if (!perm.granted) {
showAlert('Permission needed', 'Allow camera access to take photos.'); showAlert('Permission needed', 'Allow camera access to take photos.');
@@ -260,8 +262,8 @@ export default function AppRoot() {
} }
const result = await ImagePicker.launchCameraAsync({ const result = await ImagePicker.launchCameraAsync({
allowsEditing: false, allowsEditing: !!options.allowCrop,
quality: 0.85, quality: typeof options.quality === 'number' ? options.quality : 0.85,
}); });
if (!result.canceled && result.assets?.[0]?.uri) { if (!result.canceled && result.assets?.[0]?.uri) {
@@ -434,6 +436,8 @@ export default function AppRoot() {
placement: item.placement || 'suitcase', placement: item.placement || 'suitcase',
lentTo: item.lentTo || '', lentTo: item.lentTo || '',
imageUri: item.imageUri || '', imageUri: item.imageUri || '',
imageQuality: item.imageQuality || 'balanced',
imageAllowCrop: !!item.imageAllowCrop,
}); });
setItemModalVisible(true); setItemModalVisible(true);
} }
@@ -463,6 +467,8 @@ export default function AppRoot() {
placement: itemForm.placement, placement: itemForm.placement,
lentTo: itemForm.status === 'lent-to' ? itemForm.lentTo.trim() : '', lentTo: itemForm.status === 'lent-to' ? itemForm.lentTo.trim() : '',
imageUri: itemForm.imageUri, imageUri: itemForm.imageUri,
imageQuality: itemForm.imageQuality,
imageAllowCrop: itemForm.imageAllowCrop,
createdAt: existingCreatedAt, createdAt: existingCreatedAt,
updatedAt: now, updatedAt: now,
}; };
@@ -606,6 +612,28 @@ export default function AppRoot() {
setCheckupNoForm(emptyCheckupNoForm()); setCheckupNoForm(emptyCheckupNoForm());
} }
function goBackInCheckup() {
setCheckupFlowIndex((prev) => Math.max(0, prev - 1));
setCheckupFlowMode('question');
setCheckupNoForm(emptyCheckupNoForm());
}
function skipCurrentCheckupItem() {
if (!checkupCurrentEntry) return;
setCheckupSession((prev) =>
prev.map((x) =>
x.itemId === checkupCurrentEntry.itemId
? {
...x,
confirmed: false,
result: 'pending',
}
: x
)
);
goNextInCheckup();
}
function answerCurrentCheckupYes() { function answerCurrentCheckupYes() {
const entry = checkupCurrentEntry; const entry = checkupCurrentEntry;
if (!entry) return; if (!entry) return;
@@ -855,8 +883,8 @@ export default function AppRoot() {
itemForm={itemForm} itemForm={itemForm}
setItemModalVisible={setItemModalVisible} setItemModalVisible={setItemModalVisible}
updateItemForm={updateItemForm} updateItemForm={updateItemForm}
pickItemImage={() => pickImage((uri) => updateItemForm('imageUri', uri))} pickItemImage={(options) => pickImage((uri) => updateItemForm('imageUri', uri), options)}
takeItemImage={() => takeImage((uri) => updateItemForm('imageUri', uri))} takeItemImage={(options) => takeImage((uri) => updateItemForm('imageUri', uri), options)}
saveItemFromModal={saveItemFromModal} saveItemFromModal={saveItemFromModal}
/> />
@@ -872,6 +900,8 @@ export default function AppRoot() {
onYes={answerCurrentCheckupYes} onYes={answerCurrentCheckupYes}
onNo={openCurrentCheckupNo} onNo={openCurrentCheckupNo}
onSaveNo={saveCurrentCheckupNo} onSaveNo={saveCurrentCheckupNo}
onSkip={skipCurrentCheckupItem}
onBack={goBackInCheckup}
onFinish={finishCheckupFlow} onFinish={finishCheckupFlow}
/> />

View File

@@ -17,6 +17,8 @@ export default function CheckupFlowModal({
onYes, onYes,
onNo, onNo,
onSaveNo, onSaveNo,
onSkip,
onBack,
onFinish, onFinish,
}) { }) {
const finished = !entry; const finished = !entry;
@@ -37,9 +39,14 @@ export default function CheckupFlowModal({
<View style={styles.section}> <View style={styles.section}>
<Text style={styles.cardTitle}>Done. Save this snapshot?</Text> <Text style={styles.cardTitle}>Done. Save this snapshot?</Text>
<Text style={styles.cardMeta}>All {total} items were checked.</Text> <Text style={styles.cardMeta}>All {total} items were checked.</Text>
<Pressable style={styles.primaryBtn} onPress={onFinish}> <View style={styles.actionRow}>
<Text style={styles.primaryBtnText}>Save Check-Up Snapshot</Text> <Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={onBack}>
</Pressable> <Text style={styles.secondaryBtnText}>Back</Text>
</Pressable>
<Pressable style={[styles.primaryBtnTight, styles.flex]} onPress={onFinish}>
<Text style={styles.primaryBtnText}>Save Snapshot</Text>
</Pressable>
</View>
</View> </View>
) : ( ) : (
<ScrollView <ScrollView
@@ -51,6 +58,9 @@ export default function CheckupFlowModal({
<Text style={styles.tripHistoryLabel}> <Text style={styles.tripHistoryLabel}>
Item {stepIndex + 1} / {total} Item {stepIndex + 1} / {total}
</Text> </Text>
<View style={styles.checkupProgressTrack}>
<View style={[styles.checkupProgressFill, { width: `${Math.round(((stepIndex + 1) / total) * 100)}%` }]} />
</View>
<Text style={styles.cardTitle}>{entry.name}</Text> <Text style={styles.cardTitle}>{entry.name}</Text>
<Text style={styles.cardMeta}>{entry.category || 'uncategorized'}</Text> <Text style={styles.cardMeta}>{entry.category || 'uncategorized'}</Text>
<Text style={styles.cardMeta}> <Text style={styles.cardMeta}>
@@ -60,6 +70,14 @@ export default function CheckupFlowModal({
{mode === 'question' ? ( {mode === 'question' ? (
<View style={styles.answerRowWide}> <View style={styles.answerRowWide}>
<View style={styles.actionRow}>
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={onBack}>
<Text style={styles.secondaryBtnText}>Back</Text>
</Pressable>
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={onSkip}>
<Text style={styles.secondaryBtnText}>Skip</Text>
</Pressable>
</View>
<Pressable style={styles.answerYesWide} onPress={onYes}> <Pressable style={styles.answerYesWide} onPress={onYes}>
<Text style={styles.answerText}>Yes, correct</Text> <Text style={styles.answerText}>Yes, correct</Text>
</Pressable> </Pressable>
@@ -106,9 +124,14 @@ export default function CheckupFlowModal({
</Text> </Text>
</Pressable> </Pressable>
<Pressable style={styles.primaryBtn} onPress={onSaveNo}> <View style={styles.actionRow}>
<Text style={styles.primaryBtnText}>Save update + next</Text> <Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={onBack}>
</Pressable> <Text style={styles.secondaryBtnText}>Back</Text>
</Pressable>
<Pressable style={[styles.primaryBtnTight, styles.flex]} onPress={onSaveNo}>
<Text style={styles.primaryBtnText}>Save + Next</Text>
</Pressable>
</View>
</View> </View>
)} )}
</ScrollView> </ScrollView>

View File

@@ -5,6 +5,12 @@ import ChipGroup from '../components/ChipGroup';
import Field from '../components/Field'; import Field from '../components/Field';
import { styles } from '../styles'; import { styles } from '../styles';
function qualityValue(level) {
if (level === 'high') return 0.95;
if (level === 'low') return 0.45;
return 0.75;
}
export default function ItemModal({ export default function ItemModal({
visible, visible,
itemForm, itemForm,
@@ -14,6 +20,11 @@ export default function ItemModal({
takeItemImage, takeItemImage,
saveItemFromModal, saveItemFromModal,
}) { }) {
const mediaOptions = {
quality: qualityValue(itemForm.imageQuality),
allowCrop: !!itemForm.imageAllowCrop,
};
return ( return (
<Modal visible={visible} animationType="slide" transparent> <Modal visible={visible} animationType="slide" transparent>
<View style={styles.modalBackdrop}> <View style={styles.modalBackdrop}>
@@ -82,11 +93,28 @@ export default function ItemModal({
</Field> </Field>
) : null} ) : null}
<Field label="Image optimization">
<View style={styles.chipGroup}>
{['low', 'balanced', 'high'].map((level) => {
const active = itemForm.imageQuality === level;
return (
<Pressable key={level} style={[styles.chip, active && styles.chipActive]} onPress={() => updateItemForm('imageQuality', level)}>
<Text style={[styles.chipText, active && styles.chipTextActive]}>{level}</Text>
</Pressable>
);
})}
</View>
</Field>
<Pressable style={styles.inlineToggle} onPress={() => updateItemForm('imageAllowCrop', !itemForm.imageAllowCrop)}>
<Text style={styles.inlineToggleText}>{itemForm.imageAllowCrop ? '☑' : '☐'} Enable optional crop before save</Text>
</Pressable>
<View style={styles.actionRow}> <View style={styles.actionRow}>
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={takeItemImage}> <Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={() => takeItemImage(mediaOptions)}>
<Text style={styles.secondaryBtnText}>Take photo</Text> <Text style={styles.secondaryBtnText}>Take photo</Text>
</Pressable> </Pressable>
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={pickItemImage}> <Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={() => pickItemImage(mediaOptions)}>
<Text style={styles.secondaryBtnText}>{itemForm.imageUri ? 'From gallery (change)' : 'From gallery'}</Text> <Text style={styles.secondaryBtnText}>{itemForm.imageUri ? 'From gallery (change)' : 'From gallery'}</Text>
</Pressable> </Pressable>
</View> </View>

View File

@@ -404,6 +404,19 @@ export const styles = StyleSheet.create({
marginTop: 14, marginTop: 14,
gap: 10, gap: 10,
}, },
checkupProgressTrack: {
width: '100%',
height: 8,
borderRadius: 999,
backgroundColor: '#1e293b',
overflow: 'hidden',
marginTop: 4,
marginBottom: 8,
},
checkupProgressFill: {
height: '100%',
backgroundColor: '#2563eb',
},
answerYesWide: { answerYesWide: {
backgroundColor: '#163223', backgroundColor: '#163223',
borderWidth: 1, borderWidth: 1,
@@ -494,7 +507,7 @@ export const styles = StyleSheet.create({
tabBarWrap: { tabBarWrap: {
position: 'absolute', position: 'absolute',
bottom: 0, bottom: 6,
left: 0, left: 0,
right: 0, right: 0,
paddingHorizontal: 10, paddingHorizontal: 10,