Compare commits
6 Commits
luggage-li
...
luggage-li
| Author | SHA1 | Date | |
|---|---|---|---|
| 354a13e9a9 | |||
| 4018e97476 | |||
| 1e0eb7aee9 | |||
| a9ee91daf3 | |||
| 0e0ab4a059 | |||
| 89fd4c2f44 |
145
src/AppRoot.js
145
src/AppRoot.js
@@ -9,6 +9,7 @@ import DatePickerModal from './components/DatePickerModal';
|
||||
import AppDialogModal from './components/AppDialogModal';
|
||||
import ItemModal from './modals/ItemModal';
|
||||
import CheckupFlowModal from './modals/CheckupFlowModal';
|
||||
import BackupModal from './modals/BackupModal';
|
||||
import TripsTab from './tabs/TripsTab';
|
||||
import ItemsTab from './tabs/ItemsTab';
|
||||
import CheckupTab from './tabs/CheckupTab';
|
||||
@@ -35,6 +36,8 @@ const emptyItemForm = () => ({
|
||||
placement: 'suitcase',
|
||||
lentTo: '',
|
||||
imageUri: '',
|
||||
imageQuality: 'balanced',
|
||||
imageAllowCrop: false,
|
||||
});
|
||||
|
||||
const emptyCheckupNoForm = () => ({
|
||||
@@ -63,6 +66,8 @@ export default function AppRoot() {
|
||||
const scrollRef = useRef(null);
|
||||
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [fakeLoadDone, setFakeLoadDone] = useState(false);
|
||||
const [fakeLoadProgress, setFakeLoadProgress] = useState(0);
|
||||
const [tab, setTab] = useState('trips');
|
||||
const [data, setData] = useState(emptyData);
|
||||
|
||||
@@ -81,8 +86,12 @@ export default function AppRoot() {
|
||||
|
||||
const [selectedCheckupId, setSelectedCheckupId] = useState(null);
|
||||
const [dialogState, setDialogState] = useState({ visible: false, title: '', message: '', buttons: [] });
|
||||
const [backupModalVisible, setBackupModalVisible] = useState(false);
|
||||
const [backupImportText, setBackupImportText] = useState('');
|
||||
|
||||
const topInset = Platform.OS === 'android' ? (RNStatusBar.currentHeight || 0) + 10 : 0;
|
||||
const fakeLoadTotalMs = useMemo(() => 1200 + Math.floor(Math.random() * 2801), []);
|
||||
const appReady = loaded && fakeLoadDone;
|
||||
|
||||
const visibleTrips = useMemo(() => data.trips.filter((trip) => !trip.archived), [data.trips]);
|
||||
|
||||
@@ -165,6 +174,26 @@ export default function AppRoot() {
|
||||
})();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const startedAt = Date.now();
|
||||
|
||||
const interval = setInterval(() => {
|
||||
const elapsed = Date.now() - startedAt;
|
||||
setFakeLoadProgress(Math.min(1, elapsed / fakeLoadTotalMs));
|
||||
}, 60);
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
setFakeLoadProgress(1);
|
||||
setFakeLoadDone(true);
|
||||
clearInterval(interval);
|
||||
}, fakeLoadTotalMs);
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [fakeLoadTotalMs]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!loaded) return;
|
||||
AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(data)).catch(() => {
|
||||
@@ -210,7 +239,7 @@ export default function AppRoot() {
|
||||
setDatePicker((prev) => ({ ...prev, visible: false }));
|
||||
}
|
||||
|
||||
async function pickImage(onPicked) {
|
||||
async function pickImage(onPicked, options = {}) {
|
||||
const perm = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||
if (!perm.granted) {
|
||||
showAlert('Permission needed', 'Allow gallery access to select images.');
|
||||
@@ -219,8 +248,8 @@ export default function AppRoot() {
|
||||
|
||||
const result = await ImagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||
allowsEditing: false,
|
||||
quality: 0.85,
|
||||
allowsEditing: !!options.allowCrop,
|
||||
quality: typeof options.quality === 'number' ? options.quality : 0.85,
|
||||
});
|
||||
|
||||
if (!result.canceled && result.assets?.[0]?.uri) {
|
||||
@@ -228,7 +257,7 @@ export default function AppRoot() {
|
||||
}
|
||||
}
|
||||
|
||||
async function takeImage(onPicked) {
|
||||
async function takeImage(onPicked, options = {}) {
|
||||
const perm = await ImagePicker.requestCameraPermissionsAsync();
|
||||
if (!perm.granted) {
|
||||
showAlert('Permission needed', 'Allow camera access to take photos.');
|
||||
@@ -236,8 +265,8 @@ export default function AppRoot() {
|
||||
}
|
||||
|
||||
const result = await ImagePicker.launchCameraAsync({
|
||||
allowsEditing: false,
|
||||
quality: 0.85,
|
||||
allowsEditing: !!options.allowCrop,
|
||||
quality: typeof options.quality === 'number' ? options.quality : 0.85,
|
||||
});
|
||||
|
||||
if (!result.canceled && result.assets?.[0]?.uri) {
|
||||
@@ -410,6 +439,8 @@ export default function AppRoot() {
|
||||
placement: item.placement || 'suitcase',
|
||||
lentTo: item.lentTo || '',
|
||||
imageUri: item.imageUri || '',
|
||||
imageQuality: item.imageQuality || 'balanced',
|
||||
imageAllowCrop: !!item.imageAllowCrop,
|
||||
});
|
||||
setItemModalVisible(true);
|
||||
}
|
||||
@@ -439,6 +470,8 @@ export default function AppRoot() {
|
||||
placement: itemForm.placement,
|
||||
lentTo: itemForm.status === 'lent-to' ? itemForm.lentTo.trim() : '',
|
||||
imageUri: itemForm.imageUri,
|
||||
imageQuality: itemForm.imageQuality,
|
||||
imageAllowCrop: itemForm.imageAllowCrop,
|
||||
createdAt: existingCreatedAt,
|
||||
updatedAt: now,
|
||||
};
|
||||
@@ -582,6 +615,28 @@ export default function AppRoot() {
|
||||
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() {
|
||||
const entry = checkupCurrentEntry;
|
||||
if (!entry) return;
|
||||
@@ -733,12 +788,69 @@ export default function AppRoot() {
|
||||
openAddItemModal();
|
||||
}
|
||||
|
||||
if (!loaded) {
|
||||
function buildBackupJson() {
|
||||
return JSON.stringify(
|
||||
{
|
||||
version: 2,
|
||||
exportedAt: new Date().toISOString(),
|
||||
data,
|
||||
},
|
||||
null,
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
function openBackupModal() {
|
||||
setBackupImportText('');
|
||||
setBackupModalVisible(true);
|
||||
}
|
||||
|
||||
function applyBackupImport() {
|
||||
if (!backupImportText.trim()) {
|
||||
showAlert('Missing backup', 'Paste backup JSON first.');
|
||||
return;
|
||||
}
|
||||
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(backupImportText);
|
||||
} catch {
|
||||
showAlert('Invalid JSON', 'Backup JSON could not be parsed.');
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = parsed?.data && typeof parsed.data === 'object' ? parsed.data : parsed;
|
||||
|
||||
if (!payload || typeof payload !== 'object' || !Array.isArray(payload.trips) || !payload.itemsByTrip || !payload.checkupsByTrip) {
|
||||
showAlert('Invalid backup', 'Backup format is not supported.');
|
||||
return;
|
||||
}
|
||||
|
||||
showConfirm({
|
||||
title: 'Import backup?',
|
||||
message: 'This will replace all current local data.',
|
||||
confirmText: 'Import',
|
||||
tone: 'danger',
|
||||
onConfirm: () => {
|
||||
setData({ ...emptyData, ...payload });
|
||||
setBackupModalVisible(false);
|
||||
setBackupImportText('');
|
||||
showAlert('Imported', 'Backup data was restored.');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (!appReady) {
|
||||
return (
|
||||
<SafeAreaView style={[styles.safe, { paddingTop: topInset }]}>
|
||||
<StatusBar style="light" translucent={false} />
|
||||
<View style={styles.center}>
|
||||
<Text style={styles.muted}>Loading local data...</Text>
|
||||
<Text style={styles.loadingEmoji}>🧳</Text>
|
||||
<Text style={styles.loadingTitle}>Packing your list...</Text>
|
||||
<View style={styles.loadingBarTrack}>
|
||||
<View style={[styles.loadingBarFill, { width: `${Math.round(fakeLoadProgress * 100)}%` }]} />
|
||||
</View>
|
||||
<Text style={styles.muted}>{Math.round(fakeLoadProgress * 100)}%</Text>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
);
|
||||
@@ -765,7 +877,6 @@ export default function AppRoot() {
|
||||
createTrip={createTrip}
|
||||
trips={data.trips}
|
||||
selectedTripId={selectedTripId}
|
||||
chooseTrip={setSelectedTripId}
|
||||
setTripAsTemplate={setTripAsTemplate}
|
||||
saveTripEdits={saveTripEdits}
|
||||
setTripArchived={setTripArchived}
|
||||
@@ -775,6 +886,7 @@ export default function AppRoot() {
|
||||
openDatePicker={openDatePicker}
|
||||
activeTripItemCount={selectedTripItems.length}
|
||||
activeTripCheckupCount={selectedTripCheckups.length}
|
||||
openBackupModal={openBackupModal}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -826,8 +938,8 @@ export default function AppRoot() {
|
||||
itemForm={itemForm}
|
||||
setItemModalVisible={setItemModalVisible}
|
||||
updateItemForm={updateItemForm}
|
||||
pickItemImage={() => pickImage((uri) => updateItemForm('imageUri', uri))}
|
||||
takeItemImage={() => takeImage((uri) => updateItemForm('imageUri', uri))}
|
||||
pickItemImage={(options) => pickImage((uri) => updateItemForm('imageUri', uri), options)}
|
||||
takeItemImage={(options) => takeImage((uri) => updateItemForm('imageUri', uri), options)}
|
||||
saveItemFromModal={saveItemFromModal}
|
||||
/>
|
||||
|
||||
@@ -843,9 +955,20 @@ export default function AppRoot() {
|
||||
onYes={answerCurrentCheckupYes}
|
||||
onNo={openCurrentCheckupNo}
|
||||
onSaveNo={saveCurrentCheckupNo}
|
||||
onSkip={skipCurrentCheckupItem}
|
||||
onBack={goBackInCheckup}
|
||||
onFinish={finishCheckupFlow}
|
||||
/>
|
||||
|
||||
<BackupModal
|
||||
visible={backupModalVisible}
|
||||
onClose={() => setBackupModalVisible(false)}
|
||||
exportJson={buildBackupJson()}
|
||||
importJson={backupImportText}
|
||||
setImportJson={setBackupImportText}
|
||||
applyImport={applyBackupImport}
|
||||
/>
|
||||
|
||||
<AppDialogModal
|
||||
visible={dialogState.visible}
|
||||
title={dialogState.title}
|
||||
|
||||
@@ -2,12 +2,13 @@ import React from 'react';
|
||||
import { Image, Pressable, Text, View } from 'react-native';
|
||||
import { STATUS_COLORS } from '../constants';
|
||||
import { styles } from '../styles';
|
||||
import { formatStatusLabel } from '../utils/labels';
|
||||
|
||||
function statusAccent(status) {
|
||||
return STATUS_COLORS[status] || '#64748b';
|
||||
}
|
||||
|
||||
export default function ItemCard({ item, onEdit, onDelete, onQuickPack, onQuickUnpack }) {
|
||||
export default function ItemCard({ item, onEdit, onDelete, onQuickPack, onQuickUnpack, onOpenImage }) {
|
||||
const isPacked = item.status === 'packed';
|
||||
const isUnpacked = item.status === 'unpacked';
|
||||
|
||||
@@ -17,7 +18,9 @@ export default function ItemCard({ item, onEdit, onDelete, onQuickPack, onQuickU
|
||||
|
||||
<View style={styles.itemThumbWrap}>
|
||||
{item.imageUri ? (
|
||||
<Pressable onPress={() => onOpenImage?.(item.imageUri)}>
|
||||
<Image source={{ uri: item.imageUri }} style={styles.itemThumbSmall} />
|
||||
</Pressable>
|
||||
) : (
|
||||
<View style={styles.itemThumbPlaceholder}>
|
||||
<Text style={styles.itemThumbPlaceholderText}>🧳</Text>
|
||||
@@ -28,11 +31,11 @@ export default function ItemCard({ item, onEdit, onDelete, onQuickPack, onQuickU
|
||||
<View style={styles.itemMain}>
|
||||
<View style={styles.cardRow}>
|
||||
<View style={styles.flex}>
|
||||
<Text style={styles.itemTitle}>{item.name}</Text>
|
||||
<Text style={styles.itemMeta}>{item.category || 'uncategorized'} · {item.status}</Text>
|
||||
<Text style={styles.itemTitle} numberOfLines={1}>{item.name}</Text>
|
||||
<Text style={styles.itemMeta} numberOfLines={1}>{item.category || 'uncategorized'} · {formatStatusLabel(item.status, item.lentTo)}</Text>
|
||||
<Text style={styles.itemMeta}>Location: {item.placement}</Text>
|
||||
{item.status === 'lent-to' && !!item.lentTo ? <Text style={styles.itemMeta}>Lent to: {item.lentTo}</Text> : null}
|
||||
{!!item.description ? <Text style={styles.itemMeta}>{item.description}</Text> : null}
|
||||
{item.status === 'lent-to' && !!item.lentTo ? <Text style={styles.itemMeta} numberOfLines={1}>Borrower: {item.lentTo}</Text> : null}
|
||||
{!!item.description ? <Text style={styles.itemMeta} numberOfLines={2}>{item.description}</Text> : null}
|
||||
</View>
|
||||
<View style={styles.stackButtons}>
|
||||
<Pressable style={styles.miniBtn} onPress={() => onEdit(item)}>
|
||||
@@ -46,10 +49,10 @@ export default function ItemCard({ item, onEdit, onDelete, onQuickPack, onQuickU
|
||||
|
||||
<View style={styles.quickStatusRow}>
|
||||
<Pressable style={[styles.quickStatusBtn, isPacked && styles.quickStatusBtnActive]} onPress={onQuickPack}>
|
||||
<Text style={[styles.quickStatusBtnText, isPacked && styles.quickStatusBtnTextActive]}>Pack</Text>
|
||||
<Text style={[styles.quickStatusBtnText, isPacked && styles.quickStatusBtnTextActive]}>Packed</Text>
|
||||
</Pressable>
|
||||
<Pressable style={[styles.quickStatusBtn, isUnpacked && styles.quickStatusBtnActive]} onPress={onQuickUnpack}>
|
||||
<Text style={[styles.quickStatusBtnText, isUnpacked && styles.quickStatusBtnTextActive]}>Unpack</Text>
|
||||
<Text style={[styles.quickStatusBtnText, isUnpacked && styles.quickStatusBtnTextActive]}>Unpacked</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
54
src/modals/BackupModal.js
Normal file
54
src/modals/BackupModal.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import React from 'react';
|
||||
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
||||
import { styles } from '../styles';
|
||||
|
||||
export default function BackupModal({
|
||||
visible,
|
||||
onClose,
|
||||
exportJson,
|
||||
importJson,
|
||||
setImportJson,
|
||||
applyImport,
|
||||
}) {
|
||||
return (
|
||||
<Modal visible={visible} animationType="slide" transparent>
|
||||
<View style={styles.modalBackdrop}>
|
||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={styles.modalKeyboardWrap}>
|
||||
<View style={styles.modalCard}>
|
||||
<View style={styles.sectionRow}>
|
||||
<Text style={styles.sectionTitle}>Backup & Restore</Text>
|
||||
<Pressable onPress={onClose}>
|
||||
<Text style={styles.closeText}>Close</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
<ScrollView keyboardShouldPersistTaps="handled" contentContainerStyle={{ paddingBottom: 12 }} showsVerticalScrollIndicator={false}>
|
||||
<Text style={styles.cardTitle}>Export JSON</Text>
|
||||
<Text style={styles.cardMeta}>Copy this JSON and store it safely.</Text>
|
||||
<TextInput
|
||||
style={styles.inputMultiline}
|
||||
multiline
|
||||
value={exportJson}
|
||||
editable={false}
|
||||
selectTextOnFocus
|
||||
/>
|
||||
<Text style={styles.cardTitle}>Import JSON</Text>
|
||||
<Text style={styles.cardMeta}>Paste a previous backup. This will replace current data.</Text>
|
||||
<TextInput
|
||||
style={styles.inputMultiline}
|
||||
multiline
|
||||
value={importJson}
|
||||
onChangeText={setImportJson}
|
||||
placeholder="Paste backup JSON here"
|
||||
placeholderTextColor="#6b7280"
|
||||
/>
|
||||
<Pressable style={styles.primaryBtn} onPress={applyImport}>
|
||||
<Text style={styles.primaryBtnText}>Import & Replace</Text>
|
||||
</Pressable>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</View>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { ITEM_PLACEMENTS, ITEM_STATUSES } from '../constants';
|
||||
import ChipGroup from '../components/ChipGroup';
|
||||
import Field from '../components/Field';
|
||||
import { styles } from '../styles';
|
||||
import { formatStatusLabel } from '../utils/labels';
|
||||
|
||||
export default function CheckupFlowModal({
|
||||
visible,
|
||||
@@ -17,6 +18,8 @@ export default function CheckupFlowModal({
|
||||
onYes,
|
||||
onNo,
|
||||
onSaveNo,
|
||||
onSkip,
|
||||
onBack,
|
||||
onFinish,
|
||||
}) {
|
||||
const finished = !entry;
|
||||
@@ -37,9 +40,14 @@ export default function CheckupFlowModal({
|
||||
<View style={styles.section}>
|
||||
<Text style={styles.cardTitle}>Done. Save this snapshot?</Text>
|
||||
<Text style={styles.cardMeta}>All {total} items were checked.</Text>
|
||||
<Pressable style={styles.primaryBtn} onPress={onFinish}>
|
||||
<Text style={styles.primaryBtnText}>Save Check-Up Snapshot</Text>
|
||||
<View style={styles.actionRow}>
|
||||
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={onBack}>
|
||||
<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>
|
||||
) : (
|
||||
<ScrollView
|
||||
@@ -51,15 +59,25 @@ export default function CheckupFlowModal({
|
||||
<Text style={styles.tripHistoryLabel}>
|
||||
Item {stepIndex + 1} / {total}
|
||||
</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.cardMeta}>{entry.category || 'uncategorized'}</Text>
|
||||
<Text style={styles.cardMeta}>
|
||||
Current: {entry.current.status} · {entry.current.placement}
|
||||
{entry.current.status === 'lent-to' && entry.current.lentTo ? ` · ${entry.current.lentTo}` : ''}
|
||||
Current: {formatStatusLabel(entry.current.status, entry.current.lentTo)} · {entry.current.placement}
|
||||
</Text>
|
||||
|
||||
{mode === 'question' ? (
|
||||
<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}>
|
||||
<Text style={styles.answerText}>Yes, correct</Text>
|
||||
</Pressable>
|
||||
@@ -106,9 +124,14 @@ export default function CheckupFlowModal({
|
||||
</Text>
|
||||
</Pressable>
|
||||
|
||||
<Pressable style={styles.primaryBtn} onPress={onSaveNo}>
|
||||
<Text style={styles.primaryBtnText}>Save update + next</Text>
|
||||
<View style={styles.actionRow}>
|
||||
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={onBack}>
|
||||
<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>
|
||||
)}
|
||||
</ScrollView>
|
||||
|
||||
@@ -5,6 +5,12 @@ import ChipGroup from '../components/ChipGroup';
|
||||
import Field from '../components/Field';
|
||||
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({
|
||||
visible,
|
||||
itemForm,
|
||||
@@ -14,6 +20,11 @@ export default function ItemModal({
|
||||
takeItemImage,
|
||||
saveItemFromModal,
|
||||
}) {
|
||||
const mediaOptions = {
|
||||
quality: qualityValue(itemForm.imageQuality),
|
||||
allowCrop: !!itemForm.imageAllowCrop,
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal visible={visible} animationType="slide" transparent>
|
||||
<View style={styles.modalBackdrop}>
|
||||
@@ -82,11 +93,28 @@ export default function ItemModal({
|
||||
</Field>
|
||||
) : 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}>
|
||||
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={takeItemImage}>
|
||||
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={() => takeItemImage(mediaOptions)}>
|
||||
<Text style={styles.secondaryBtnText}>Take photo</Text>
|
||||
</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>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
161
src/styles.js
161
src/styles.js
@@ -10,10 +10,10 @@ export const styles = StyleSheet.create({
|
||||
flex: 1,
|
||||
},
|
||||
content: {
|
||||
paddingHorizontal: 16,
|
||||
paddingTop: 12,
|
||||
paddingBottom: TAB_BAR_HEIGHT + 22,
|
||||
gap: 14,
|
||||
paddingHorizontal: 14,
|
||||
paddingTop: 10,
|
||||
paddingBottom: TAB_BAR_HEIGHT + 20,
|
||||
gap: 10,
|
||||
},
|
||||
statusSpacer: {
|
||||
height: Platform.OS === 'android' ? 8 : 0,
|
||||
@@ -26,6 +26,28 @@ export const styles = StyleSheet.create({
|
||||
muted: {
|
||||
color: '#8793a5',
|
||||
},
|
||||
loadingEmoji: {
|
||||
fontSize: 52,
|
||||
marginBottom: 8,
|
||||
},
|
||||
loadingTitle: {
|
||||
color: '#f8fafc',
|
||||
fontWeight: '700',
|
||||
fontSize: 17,
|
||||
marginBottom: 10,
|
||||
},
|
||||
loadingBarTrack: {
|
||||
width: 220,
|
||||
height: 10,
|
||||
borderRadius: 999,
|
||||
backgroundColor: '#1e293b',
|
||||
overflow: 'hidden',
|
||||
marginBottom: 8,
|
||||
},
|
||||
loadingBarFill: {
|
||||
height: '100%',
|
||||
backgroundColor: '#2563eb',
|
||||
},
|
||||
|
||||
tripPickerWrap: {
|
||||
marginBottom: 6,
|
||||
@@ -64,7 +86,7 @@ export const styles = StyleSheet.create({
|
||||
},
|
||||
|
||||
section: {
|
||||
gap: 12,
|
||||
gap: 10,
|
||||
},
|
||||
sectionTitle: {
|
||||
color: '#f1f5f9',
|
||||
@@ -83,8 +105,8 @@ export const styles = StyleSheet.create({
|
||||
borderRadius: 16,
|
||||
borderWidth: 1,
|
||||
borderColor: '#1f2937',
|
||||
padding: 12,
|
||||
gap: 8,
|
||||
padding: 10,
|
||||
gap: 6,
|
||||
},
|
||||
cardActive: {
|
||||
borderColor: '#60a5fa',
|
||||
@@ -98,12 +120,12 @@ export const styles = StyleSheet.create({
|
||||
borderRadius: 16,
|
||||
borderWidth: 1,
|
||||
borderColor: '#1e293b',
|
||||
padding: 12,
|
||||
gap: 10,
|
||||
padding: 10,
|
||||
gap: 8,
|
||||
},
|
||||
cardRow: {
|
||||
flexDirection: 'row',
|
||||
gap: 10,
|
||||
gap: 8,
|
||||
},
|
||||
cardTitle: {
|
||||
color: '#f8fafc',
|
||||
@@ -112,8 +134,8 @@ export const styles = StyleSheet.create({
|
||||
},
|
||||
cardMeta: {
|
||||
color: '#94a3b8',
|
||||
marginTop: 3,
|
||||
fontSize: 13,
|
||||
marginTop: 2,
|
||||
fontSize: 12,
|
||||
},
|
||||
tripHistoryLabel: {
|
||||
color: '#93c5fd',
|
||||
@@ -126,8 +148,8 @@ export const styles = StyleSheet.create({
|
||||
borderRadius: 18,
|
||||
borderWidth: 1,
|
||||
borderColor: '#334155',
|
||||
padding: 12,
|
||||
gap: 8,
|
||||
padding: 10,
|
||||
gap: 6,
|
||||
},
|
||||
tripHeroImage: {
|
||||
width: '100%',
|
||||
@@ -138,7 +160,7 @@ export const styles = StyleSheet.create({
|
||||
tripHeroTitle: {
|
||||
color: '#f8fafc',
|
||||
fontWeight: '800',
|
||||
fontSize: 22,
|
||||
fontSize: 20,
|
||||
},
|
||||
tripListTitle: {
|
||||
color: '#cbd5e1',
|
||||
@@ -164,6 +186,19 @@ export const styles = StyleSheet.create({
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 11,
|
||||
},
|
||||
inputMultiline: {
|
||||
borderWidth: 1,
|
||||
borderColor: '#243244',
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#0b1220',
|
||||
color: '#e5e7eb',
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 10,
|
||||
minHeight: 150,
|
||||
textAlignVertical: 'top',
|
||||
fontSize: 12,
|
||||
fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
|
||||
},
|
||||
dateInput: {
|
||||
borderWidth: 1,
|
||||
borderColor: '#29415e',
|
||||
@@ -255,19 +290,19 @@ export const styles = StyleSheet.create({
|
||||
},
|
||||
|
||||
stackButtons: {
|
||||
gap: 7,
|
||||
gap: 6,
|
||||
},
|
||||
miniBtn: {
|
||||
backgroundColor: '#1e293b',
|
||||
borderRadius: 8,
|
||||
paddingVertical: 7,
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 6,
|
||||
paddingHorizontal: 9,
|
||||
},
|
||||
miniBtnDanger: {
|
||||
backgroundColor: '#3b1d22',
|
||||
borderRadius: 8,
|
||||
paddingVertical: 7,
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 6,
|
||||
paddingHorizontal: 9,
|
||||
},
|
||||
miniBtnText: {
|
||||
color: '#e2e8f0',
|
||||
@@ -289,18 +324,18 @@ export const styles = StyleSheet.create({
|
||||
alignSelf: 'stretch',
|
||||
},
|
||||
itemThumbWrap: {
|
||||
paddingTop: 10,
|
||||
paddingLeft: 10,
|
||||
paddingTop: 8,
|
||||
paddingLeft: 8,
|
||||
},
|
||||
itemThumbSmall: {
|
||||
width: 46,
|
||||
height: 46,
|
||||
width: 42,
|
||||
height: 42,
|
||||
borderRadius: 8,
|
||||
backgroundColor: '#0b1220',
|
||||
},
|
||||
itemThumbPlaceholder: {
|
||||
width: 46,
|
||||
height: 46,
|
||||
width: 42,
|
||||
height: 42,
|
||||
borderRadius: 8,
|
||||
backgroundColor: '#0b1220',
|
||||
alignItems: 'center',
|
||||
@@ -309,12 +344,12 @@ export const styles = StyleSheet.create({
|
||||
borderColor: '#243244',
|
||||
},
|
||||
itemThumbPlaceholderText: {
|
||||
fontSize: 18,
|
||||
fontSize: 16,
|
||||
},
|
||||
itemMain: {
|
||||
flex: 1,
|
||||
padding: 10,
|
||||
gap: 8,
|
||||
padding: 8,
|
||||
gap: 6,
|
||||
},
|
||||
itemTitle: {
|
||||
color: '#f8fafc',
|
||||
@@ -323,17 +358,17 @@ export const styles = StyleSheet.create({
|
||||
},
|
||||
itemMeta: {
|
||||
color: '#94a3b8',
|
||||
marginTop: 2,
|
||||
fontSize: 13,
|
||||
marginTop: 1,
|
||||
fontSize: 12,
|
||||
},
|
||||
quickStatusRow: {
|
||||
flexDirection: 'row',
|
||||
gap: 8,
|
||||
marginTop: 2,
|
||||
gap: 6,
|
||||
marginTop: 1,
|
||||
},
|
||||
quickStatusBtn: {
|
||||
paddingVertical: 6,
|
||||
paddingHorizontal: 12,
|
||||
paddingVertical: 5,
|
||||
paddingHorizontal: 10,
|
||||
borderRadius: 999,
|
||||
borderWidth: 1,
|
||||
borderColor: '#334155',
|
||||
@@ -346,7 +381,7 @@ export const styles = StyleSheet.create({
|
||||
quickStatusBtnText: {
|
||||
color: '#cbd5e1',
|
||||
fontWeight: '700',
|
||||
fontSize: 12,
|
||||
fontSize: 11,
|
||||
},
|
||||
quickStatusBtnTextActive: {
|
||||
color: '#dbeafe',
|
||||
@@ -382,6 +417,19 @@ export const styles = StyleSheet.create({
|
||||
marginTop: 14,
|
||||
gap: 10,
|
||||
},
|
||||
checkupProgressTrack: {
|
||||
width: '100%',
|
||||
height: 8,
|
||||
borderRadius: 999,
|
||||
backgroundColor: '#1e293b',
|
||||
overflow: 'hidden',
|
||||
marginTop: 4,
|
||||
marginBottom: 8,
|
||||
},
|
||||
checkupProgressFill: {
|
||||
height: '100%',
|
||||
backgroundColor: '#2563eb',
|
||||
},
|
||||
answerYesWide: {
|
||||
backgroundColor: '#163223',
|
||||
borderWidth: 1,
|
||||
@@ -469,10 +517,39 @@ export const styles = StyleSheet.create({
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#111827',
|
||||
},
|
||||
imagePreviewBackdrop: {
|
||||
flex: 1,
|
||||
backgroundColor: 'rgba(2,6,23,0.88)',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
paddingHorizontal: 14,
|
||||
},
|
||||
imagePreviewCard: {
|
||||
width: '100%',
|
||||
maxWidth: 460,
|
||||
borderRadius: 14,
|
||||
borderWidth: 1,
|
||||
borderColor: '#334155',
|
||||
backgroundColor: '#0f172a',
|
||||
padding: 10,
|
||||
gap: 8,
|
||||
},
|
||||
imagePreviewImage: {
|
||||
width: '100%',
|
||||
height: 360,
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#0b1220',
|
||||
},
|
||||
imagePreviewHint: {
|
||||
color: '#93c5fd',
|
||||
textAlign: 'center',
|
||||
fontSize: 12,
|
||||
fontWeight: '600',
|
||||
},
|
||||
|
||||
tabBarWrap: {
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
bottom: 6,
|
||||
left: 0,
|
||||
right: 0,
|
||||
paddingHorizontal: 10,
|
||||
@@ -499,8 +576,8 @@ export const styles = StyleSheet.create({
|
||||
tabItem: {
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
gap: 4,
|
||||
minWidth: 58,
|
||||
gap: 3,
|
||||
minWidth: 56,
|
||||
},
|
||||
tabAddBtn: {
|
||||
width: 54,
|
||||
@@ -518,7 +595,7 @@ export const styles = StyleSheet.create({
|
||||
},
|
||||
tabLabel: {
|
||||
color: '#94a3b8',
|
||||
fontSize: 12,
|
||||
fontSize: 11,
|
||||
fontWeight: '600',
|
||||
},
|
||||
tabLabelActive: {
|
||||
@@ -596,8 +673,8 @@ export const styles = StyleSheet.create({
|
||||
borderRadius: 20,
|
||||
borderWidth: 1,
|
||||
borderColor: '#1e293b',
|
||||
padding: 16,
|
||||
gap: 10,
|
||||
padding: 14,
|
||||
gap: 8,
|
||||
},
|
||||
closeText: {
|
||||
color: '#93c5fd',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
import { styles } from '../styles';
|
||||
import { formatStatusLabel } from '../utils/labels';
|
||||
|
||||
export default function HistoryTab({ selectedTrip, selectedTripCheckups, selectedCheckupId, setSelectedCheckupId, onDeleteCheckup }) {
|
||||
return (
|
||||
@@ -32,8 +33,7 @@ export default function HistoryTab({ selectedTrip, selectedTripCheckups, selecte
|
||||
<View key={entry.itemId} style={styles.snapshotRow}>
|
||||
<Text style={styles.snapshotTitle}>{entry.name}</Text>
|
||||
<Text style={styles.cardMeta}>
|
||||
{entry.status} · {entry.placement}
|
||||
{entry.status === 'lent-to' && entry.lentTo ? ` · ${entry.lentTo}` : ''}
|
||||
{formatStatusLabel(entry.status, entry.lentTo)} · {entry.placement}
|
||||
</Text>
|
||||
</View>
|
||||
))}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
import { Image, Modal, Pressable, Text, View } from 'react-native';
|
||||
import ItemCard from '../components/ItemCard';
|
||||
import { ITEM_STATUSES } from '../constants';
|
||||
import { styles } from '../styles';
|
||||
import { formatFilterLabel, formatStatusLabel } from '../utils/labels';
|
||||
|
||||
export default function ItemsTab({
|
||||
selectedTrip,
|
||||
@@ -15,6 +16,7 @@ export default function ItemsTab({
|
||||
}) {
|
||||
const [statusFilter, setStatusFilter] = useState('all');
|
||||
const [categoryFilter, setCategoryFilter] = useState('all');
|
||||
const [imagePreviewUri, setImagePreviewUri] = useState('');
|
||||
|
||||
const categories = useMemo(
|
||||
() => Array.from(new Set(selectedTripItems.map((item) => item.category?.trim()).filter(Boolean))).sort((a, b) => a.localeCompare(b)),
|
||||
@@ -52,10 +54,10 @@ export default function ItemsTab({
|
||||
<Text style={styles.cardTitle}>Quick actions</Text>
|
||||
<View style={styles.actionRow}>
|
||||
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={() => bulkSetItemStatus(filteredItems.map((x) => x.id), 'packed')}>
|
||||
<Text style={styles.secondaryBtnText}>Pack shown ({filteredItems.length})</Text>
|
||||
<Text style={styles.secondaryBtnText}>Pack All ({filteredItems.length})</Text>
|
||||
</Pressable>
|
||||
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={() => bulkSetItemStatus(filteredItems.map((x) => x.id), 'unpacked')}>
|
||||
<Text style={styles.secondaryBtnText}>Unpack shown ({filteredItems.length})</Text>
|
||||
<Text style={styles.secondaryBtnText}>Unpack All ({filteredItems.length})</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
@@ -71,7 +73,7 @@ export default function ItemsTab({
|
||||
const active = statusFilter === status;
|
||||
return (
|
||||
<Pressable key={status} style={[styles.chip, active && styles.chipActive]} onPress={() => setStatusFilter(status)}>
|
||||
<Text style={[styles.chipText, active && styles.chipTextActive]}>{status}</Text>
|
||||
<Text style={[styles.chipText, active && styles.chipTextActive]}>{status === 'all' ? formatFilterLabel(status) : formatStatusLabel(status)}</Text>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
@@ -83,7 +85,7 @@ export default function ItemsTab({
|
||||
const active = categoryFilter === category;
|
||||
return (
|
||||
<Pressable key={category} style={[styles.chip, active && styles.chipActive]} onPress={() => setCategoryFilter(category)}>
|
||||
<Text style={[styles.chipText, active && styles.chipTextActive]}>{category}</Text>
|
||||
<Text style={[styles.chipText, active && styles.chipTextActive]}>{formatFilterLabel(category)}</Text>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
@@ -99,10 +101,20 @@ export default function ItemsTab({
|
||||
onDelete={deleteItem}
|
||||
onQuickPack={() => quickSetItemStatus(item.id, 'packed')}
|
||||
onQuickUnpack={() => quickSetItemStatus(item.id, 'unpacked')}
|
||||
onOpenImage={(uri) => setImagePreviewUri(uri)}
|
||||
/>
|
||||
))}
|
||||
|
||||
{selectedTripItems.length > 0 && filteredItems.length === 0 ? <Text style={styles.muted}>No items match the current filters.</Text> : null}
|
||||
|
||||
<Modal visible={!!imagePreviewUri} transparent animationType="fade">
|
||||
<Pressable style={styles.imagePreviewBackdrop} onPress={() => setImagePreviewUri('')}>
|
||||
<Pressable style={styles.imagePreviewCard} onPress={() => {}}>
|
||||
{imagePreviewUri ? <Image source={{ uri: imagePreviewUri }} style={styles.imagePreviewImage} resizeMode="contain" /> : null}
|
||||
<Text style={styles.imagePreviewHint}>Tap outside to close</Text>
|
||||
</Pressable>
|
||||
</Pressable>
|
||||
</Modal>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ export default function TripsTab({
|
||||
createTrip,
|
||||
trips,
|
||||
selectedTripId,
|
||||
chooseTrip,
|
||||
setTripAsTemplate,
|
||||
saveTripEdits,
|
||||
setTripArchived,
|
||||
@@ -38,6 +37,7 @@ export default function TripsTab({
|
||||
openDatePicker,
|
||||
activeTripItemCount,
|
||||
activeTripCheckupCount,
|
||||
openBackupModal,
|
||||
}) {
|
||||
const [createModalVisible, setCreateModalVisible] = useState(false);
|
||||
const [viewTripId, setViewTripId] = useState(null);
|
||||
@@ -105,10 +105,15 @@ export default function TripsTab({
|
||||
<View style={styles.section}>
|
||||
<View style={styles.sectionRow}>
|
||||
<Text style={styles.sectionTitle}>Trips</Text>
|
||||
<View style={styles.actionRow}>
|
||||
<Pressable style={styles.secondaryBtnTight} onPress={openBackupModal}>
|
||||
<Text style={styles.secondaryBtnText}>Backup</Text>
|
||||
</Pressable>
|
||||
<Pressable style={styles.primaryBtnTight} onPress={() => setCreateModalVisible(true)}>
|
||||
<Text style={styles.primaryBtnText}>+ New Trip</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{activeTrip ? (
|
||||
<View style={styles.tripHeroCard}>
|
||||
@@ -131,12 +136,9 @@ export default function TripsTab({
|
||||
<View style={styles.flex}>
|
||||
<Text style={styles.cardTitle}>{trip.name}</Text>
|
||||
<Text style={styles.cardMeta}>{trip.location || 'No location'} · {trip.startDate} → {trip.endDate}</Text>
|
||||
<Text style={styles.cardMeta}>{defaultTemplateTripId === trip.id ? 'Default template' : ' '}</Text>
|
||||
{defaultTemplateTripId === trip.id ? <Text style={styles.cardMeta}>Default template</Text> : null}
|
||||
</View>
|
||||
<View style={styles.stackButtons}>
|
||||
<Pressable style={styles.miniBtn} onPress={() => chooseTrip(trip.id)}>
|
||||
<Text style={styles.miniBtnText}>Select</Text>
|
||||
</Pressable>
|
||||
<Pressable style={styles.miniBtn} onPress={() => openView(trip.id)}>
|
||||
<Text style={styles.miniBtnText}>View</Text>
|
||||
</Pressable>
|
||||
|
||||
23
src/utils/labels.js
Normal file
23
src/utils/labels.js
Normal file
@@ -0,0 +1,23 @@
|
||||
export function toTitleWords(value) {
|
||||
if (!value) return '';
|
||||
return value
|
||||
.toString()
|
||||
.split('-')
|
||||
.map((part) => (part ? part[0].toUpperCase() + part.slice(1) : part))
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
export function formatStatusLabel(status, lentTo = '') {
|
||||
if (!status) return '';
|
||||
if (status === 'lent-to') {
|
||||
const name = lentTo?.trim();
|
||||
return name ? `Lent To ${name}` : 'Lent To';
|
||||
}
|
||||
return toTitleWords(status);
|
||||
}
|
||||
|
||||
export function formatFilterLabel(value) {
|
||||
if (!value) return '';
|
||||
if (value === 'all') return 'All';
|
||||
return toTitleWords(value);
|
||||
}
|
||||
Reference in New Issue
Block a user