14 Commits

Author SHA1 Message Date
e1bfbdbf1e feat(#17,#18): add location filter and custom-location autofill
All checks were successful
Luggage List Build / build-web (push) Successful in 52s
Luggage List Build / build-android (push) Successful in 7m2s
Luggage List Build / release (push) Successful in 17s
2026-04-18 21:59:23 +02:00
063e5090ed feat(#16): support custom placement when selecting other
All checks were successful
Luggage List Build / build-web (push) Successful in 40s
Luggage List Build / build-android (push) Successful in 7m26s
Luggage List Build / release (push) Successful in 15s
2026-04-18 21:41:18 +02:00
354a13e9a9 fix(#14,#15): reduce UI clutter and rename status actions
All checks were successful
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / build-android (push) Successful in 6m27s
Luggage List Build / release (push) Successful in 18s
2026-04-18 21:32:12 +02:00
4018e97476 feat(#13): open item images in full-screen preview modal
All checks were successful
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / build-android (push) Successful in 5m42s
Luggage List Build / release (push) Successful in 11s
2026-04-18 19:45:53 +02:00
1e0eb7aee9 fix(#12): remove Select action from trips list
Some checks failed
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
Luggage List Build / build-web (push) Has been cancelled
2026-04-18 19:45:46 +02:00
a9ee91daf3 feat(#3,#4,#7): add backup/restore, polish labels, and rename bulk actions
All checks were successful
Luggage List Build / build-android (push) Successful in 5m45s
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / release (push) Successful in 14s
2026-04-18 19:30:03 +02:00
0e0ab4a059 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
2026-04-18 18:45:21 +02:00
89fd4c2f44 feat(#6): add randomized fake startup loader with suitcase progress
All checks were successful
Luggage List Build / build-web (push) Successful in 41s
Luggage List Build / build-android (push) Successful in 7m54s
Luggage List Build / release (push) Successful in 13s
2026-04-18 18:32:34 +02:00
fbdae66c9b feat(#8): make item thumbnails smaller and left-aligned
All checks were successful
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / build-android (push) Successful in 6m12s
Luggage List Build / release (push) Successful in 12s
2026-04-18 18:25:54 +02:00
e8ffab355e feat(#9): remove trip image controls and displays from UI 2026-04-18 18:25:49 +02:00
2ec877362f feat: add centered quick-add item button in bottom nav
All checks were successful
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / build-android (push) Successful in 5m59s
Luggage List Build / release (push) Successful in 11s
2026-04-18 18:13:28 +02:00
fb54db0619 feat: replace native alerts with custom dialog modals
All checks were successful
Luggage List Build / build-web (push) Successful in 27s
Luggage List Build / build-android (push) Successful in 9m46s
Luggage List Build / release (push) Successful in 21s
2026-04-18 15:20:25 +02:00
a93fec97dc chore: limit CI triggers and move TODOs to Gitea issues
Some checks failed
Luggage List Build / build-android (push) Has been cancelled
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-web (push) Has been cancelled
2026-04-18 15:08:45 +02:00
86976d5c26 docs: rewrite latest requested UI polish tasks
Some checks failed
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
Luggage List Build / build-web (push) Has been cancelled
2026-04-18 15:05:46 +02:00
15 changed files with 868 additions and 277 deletions

View File

@@ -3,6 +3,10 @@ on:
push: push:
branches: branches:
- main - main
paths:
- '**/*.js'
- '**/*.json'
- '.gitea/workflows/**'
jobs: jobs:
build-android: build-android:

View File

@@ -3,6 +3,10 @@ on:
push: push:
branches-ignore: branches-ignore:
- main - main
paths:
- '**/*.js'
- '**/*.json'
- '.gitea/workflows/**'
jobs: jobs:
validate: validate:

60
TODO.md
View File

@@ -1,52 +1,14 @@
# TODO - Luggage List # TODO - Luggage List
## Stage This file was intentionally nuked.
Improving & Fixing Bugs (V3)
## V2 Changes Requested All pending tasks now live as Gitea issues:
- [x] Trip can be selected from everywhere (global trip picker) - https://gitea.reversed.dev/space/luggage-list/issues/1
- [x] Fixed trip switching behavior for web by removing aggressive auto-reselect - https://gitea.reversed.dev/space/luggage-list/issues/2
- [x] Removed trip image crop (gallery pick without editing) - https://gitea.reversed.dev/space/luggage-list/issues/3
- [x] Item updates now happen in a modal - https://gitea.reversed.dev/space/luggage-list/issues/4
- [x] Redesigned item cards - https://gitea.reversed.dev/space/luggage-list/issues/5
- [x] Moved top nav to bottom and made it mobile-friendly - https://gitea.reversed.dev/space/luggage-list/issues/6
- [x] Removed top title block - https://gitea.reversed.dev/space/luggage-list/issues/7
- [x] Reworked check-up flow to yes/no checklist - https://gitea.reversed.dev/space/luggage-list/issues/8
- [x] “No” now opens update modal for check-up-only changes - https://gitea.reversed.dev/space/luggage-list/issues/9
- [x] Added optional toggle to also sync fix into trip item list
- [x] Removed JSON export feature
- [x] Improved keyboard behavior with KeyboardAvoidingView + scroll-safe forms
- [x] Full UI redesign (dark-first minimalist with accent colors)
- [x] Set new icon from `https://cdn.reversed.dev/pictures/yesnt.png`
## Validation
- [x] `npm install`
- [x] `npx expo export --platform web`
## Progress Log
- [x] V1 prototype complete and shipped
- [x] CI adjusted (no `eas init` in workflows)
- [x] V2 redesign + behavior fixes implemented
- [x] Removed legacy template src folder
- [x] Rebuilt app into modular `src/` structure (tabs/components/modals/styles/utils)
- [x] Fixed status-bar overlap with top spacing
- [x] Replaced trip date text inputs with calendar modal picker
- [x] Improved keyboard focus scrolling to focused input (not scroll-to-end)
- [x] Reworked bottom nav to real icons + labels
- [x] Clarified history as selected-trip check-up history
- [x] Increased safe top inset to avoid status-bar overlap
- [x] Added check-up stats (correct/bad/pending) and persisted per snapshot
- [x] Extra UI polish pass (spacing, cards, hierarchy)
- [x] Centered and enlarged edit/check-up modals to fully overlay nav
- [x] Fixed modal keyboard glitching (stable centered keyboard-aware layout)
- [x] Added trip view editing in modal (name/location/date/image)
- [x] Added trip archive/unarchive flow with archived section
- [x] Added item filters + bulk pack/unpack actions
## Next Improvements (Requested)
- [x] Edit trip directly in the trip view modal (name/location/dates/image)
- [x] Add archive flow for trips (hide from active list without deleting history)
- [ ] Enhance check-up modal UX (progress bar + back/skip controls)
- [x] Add bulk item actions and filters (pack all/unpack all + status/category chips)
- [ ] Add image optimization controls before save (compress/crop)
- [ ] Add JSON export/import backup + restore flow

View File

@@ -1,18 +1,20 @@
import React, { useEffect, useMemo, useRef, useState } from 'react'; import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Alert, KeyboardAvoidingView, Platform, SafeAreaView, ScrollView, StatusBar as RNStatusBar, Text, View } from 'react-native'; import { KeyboardAvoidingView, Platform, SafeAreaView, ScrollView, StatusBar as RNStatusBar, Text, View } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage'; import AsyncStorage from '@react-native-async-storage/async-storage';
import * as ImagePicker from 'expo-image-picker'; import * as ImagePicker from 'expo-image-picker';
import { StatusBar } from 'expo-status-bar'; import { StatusBar } from 'expo-status-bar';
import BottomTab from './components/BottomTab'; import BottomTab from './components/BottomTab';
import TripPicker from './components/TripPicker'; import TripPicker from './components/TripPicker';
import DatePickerModal from './components/DatePickerModal'; import DatePickerModal from './components/DatePickerModal';
import AppDialogModal from './components/AppDialogModal';
import ItemModal from './modals/ItemModal'; import ItemModal from './modals/ItemModal';
import CheckupFlowModal from './modals/CheckupFlowModal'; import CheckupFlowModal from './modals/CheckupFlowModal';
import BackupModal from './modals/BackupModal';
import TripsTab from './tabs/TripsTab'; import TripsTab from './tabs/TripsTab';
import ItemsTab from './tabs/ItemsTab'; import ItemsTab from './tabs/ItemsTab';
import CheckupTab from './tabs/CheckupTab'; import CheckupTab from './tabs/CheckupTab';
import HistoryTab from './tabs/HistoryTab'; import HistoryTab from './tabs/HistoryTab';
import { emptyData, STORAGE_KEY } from './constants'; import { emptyData, ITEM_PLACEMENTS, STORAGE_KEY } from './constants';
import { findBestTripId, makeId, parseYMD, todayYMD } from './utils/date'; import { findBestTripId, makeId, parseYMD, todayYMD } from './utils/date';
import { styles } from './styles'; import { styles } from './styles';
@@ -21,7 +23,6 @@ const emptyTripForm = () => ({
location: '', location: '',
startDate: todayYMD(), startDate: todayYMD(),
endDate: todayYMD(), endDate: todayYMD(),
imageUri: '',
copyDefaultTemplate: true, copyDefaultTemplate: true,
setAsDefaultTemplate: false, setAsDefaultTemplate: false,
}); });
@@ -33,13 +34,17 @@ const emptyItemForm = () => ({
category: '', category: '',
status: 'unpacked', status: 'unpacked',
placement: 'suitcase', placement: 'suitcase',
placementCustom: '',
lentTo: '', lentTo: '',
imageUri: '', imageUri: '',
imageQuality: 'balanced',
imageAllowCrop: false,
}); });
const emptyCheckupNoForm = () => ({ const emptyCheckupNoForm = () => ({
status: 'unpacked', status: 'unpacked',
placement: 'suitcase', placement: 'suitcase',
placementCustom: '',
lentTo: '', lentTo: '',
updateMasterList: false, updateMasterList: false,
}); });
@@ -63,6 +68,8 @@ export default function AppRoot() {
const scrollRef = useRef(null); const scrollRef = useRef(null);
const [loaded, setLoaded] = useState(false); const [loaded, setLoaded] = useState(false);
const [fakeLoadDone, setFakeLoadDone] = useState(false);
const [fakeLoadProgress, setFakeLoadProgress] = useState(0);
const [tab, setTab] = useState('trips'); const [tab, setTab] = useState('trips');
const [data, setData] = useState(emptyData); const [data, setData] = useState(emptyData);
@@ -80,8 +87,13 @@ export default function AppRoot() {
const [checkupNoForm, setCheckupNoForm] = useState(emptyCheckupNoForm()); const [checkupNoForm, setCheckupNoForm] = useState(emptyCheckupNoForm());
const [selectedCheckupId, setSelectedCheckupId] = useState(null); 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 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]); const visibleTrips = useMemo(() => data.trips.filter((trip) => !trip.archived), [data.trips]);
@@ -97,6 +109,35 @@ export default function AppRoot() {
return (data.checkupsByTrip[selectedTripId] || []).slice().sort((a, b) => b.createdAt - a.createdAt); return (data.checkupsByTrip[selectedTripId] || []).slice().sort((a, b) => b.createdAt - a.createdAt);
}, [data.checkupsByTrip, selectedTripId]); }, [data.checkupsByTrip, selectedTripId]);
const previousCustomPlacements = useMemo(() => {
const seen = new Set();
function takeFrom(items = [], bucket = []) {
items
.slice()
.sort((a, b) => (b.updatedAt || b.createdAt || 0) - (a.updatedAt || a.createdAt || 0))
.forEach((item) => {
const location = item.placement?.trim();
if (!location || ITEM_PLACEMENTS.includes(location) || seen.has(location)) return;
seen.add(location);
bucket.push(location);
});
return bucket;
}
const collected = [];
if (selectedTripId) {
takeFrom(data.itemsByTrip[selectedTripId] || [], collected);
}
Object.entries(data.itemsByTrip).forEach(([tripId, items]) => {
if (tripId === selectedTripId) return;
takeFrom(items || [], collected);
});
return collected;
}, [data.itemsByTrip, selectedTripId]);
const templateTrip = useMemo( const templateTrip = useMemo(
() => data.trips.find((trip) => trip.id === data.defaultTemplateTripId) || null, () => data.trips.find((trip) => trip.id === data.defaultTemplateTripId) || null,
[data.trips, data.defaultTemplateTripId] [data.trips, data.defaultTemplateTripId]
@@ -116,6 +157,38 @@ export default function AppRoot() {
return checkupSession[checkupFlowIndex] || null; return checkupSession[checkupFlowIndex] || null;
}, [checkupFlowVisible, checkupFlowIndex, checkupSession]); }, [checkupFlowVisible, checkupFlowIndex, checkupSession]);
function closeDialog() {
setDialogState((prev) => ({ ...prev, visible: false }));
}
function showAlert(title, message) {
setDialogState({
visible: true,
title,
message,
buttons: [{ text: 'OK', tone: 'primary', onPress: closeDialog }],
});
}
function showConfirm({ title, message, confirmText = 'Confirm', onConfirm, tone = 'danger' }) {
setDialogState({
visible: true,
title,
message,
buttons: [
{ text: 'Cancel', tone: 'neutral', onPress: closeDialog },
{
text: confirmText,
tone,
onPress: () => {
closeDialog();
if (typeof onConfirm === 'function') onConfirm();
},
},
],
});
}
useEffect(() => { useEffect(() => {
(async () => { (async () => {
try { try {
@@ -125,17 +198,37 @@ export default function AppRoot() {
setData({ ...emptyData, ...parsed }); setData({ ...emptyData, ...parsed });
} }
} catch { } catch {
Alert.alert('Error', 'Could not load local data.'); showAlert('Error', 'Could not load local data.');
} finally { } finally {
setLoaded(true); setLoaded(true);
} }
})(); })();
}, []); }, []);
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(() => { useEffect(() => {
if (!loaded) return; if (!loaded) return;
AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(data)).catch(() => { AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(data)).catch(() => {
Alert.alert('Error', 'Could not save local data.'); showAlert('Error', 'Could not save local data.');
}); });
}, [data, loaded]); }, [data, loaded]);
@@ -165,7 +258,18 @@ export default function AppRoot() {
} }
function updateItemForm(field, value) { function updateItemForm(field, value) {
setItemForm((prev) => ({ ...prev, [field]: value })); setItemForm((prev) => {
if (field === 'placement' && value === 'other') {
const fallbackLocation = previousCustomPlacements[0] || '';
return {
...prev,
placement: value,
placementCustom: prev.placementCustom?.trim() ? prev.placementCustom : fallbackLocation,
};
}
return { ...prev, [field]: value };
});
} }
function openDatePicker(field) { function openDatePicker(field) {
@@ -177,17 +281,17 @@ 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) {
Alert.alert('Permission needed', 'Allow gallery access to select images.'); showAlert('Permission needed', 'Allow gallery access to select images.');
return; return;
} }
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) {
@@ -195,16 +299,16 @@ 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) {
Alert.alert('Permission needed', 'Allow camera access to take photos.'); showAlert('Permission needed', 'Allow camera access to take photos.');
return; return;
} }
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) {
@@ -214,7 +318,7 @@ export default function AppRoot() {
function createTrip() { function createTrip() {
if (!tripForm.name.trim()) { if (!tripForm.name.trim()) {
Alert.alert('Missing name', 'Trip name is required.'); showAlert('Missing name', 'Trip name is required.');
return false; return false;
} }
@@ -222,12 +326,12 @@ export default function AppRoot() {
const end = parseYMD(tripForm.endDate); const end = parseYMD(tripForm.endDate);
if (!start || !end) { if (!start || !end) {
Alert.alert('Invalid dates', 'Please select valid trip dates.'); showAlert('Invalid dates', 'Please select valid trip dates.');
return false; return false;
} }
if (start > end) { if (start > end) {
Alert.alert('Invalid dates', 'Start date cannot be after end date.'); showAlert('Invalid dates', 'Start date cannot be after end date.');
return false; return false;
} }
@@ -245,7 +349,7 @@ export default function AppRoot() {
location: tripForm.location.trim(), location: tripForm.location.trim(),
startDate: tripForm.startDate, startDate: tripForm.startDate,
endDate: tripForm.endDate, endDate: tripForm.endDate,
imageUri: tripForm.imageUri, imageUri: '',
archived: false, archived: false,
createdAt: now, createdAt: now,
updatedAt: now, updatedAt: now,
@@ -283,7 +387,7 @@ export default function AppRoot() {
function saveTripEdits(tripId, patch) { function saveTripEdits(tripId, patch) {
if (!patch.name.trim()) { if (!patch.name.trim()) {
Alert.alert('Missing name', 'Trip name is required.'); showAlert('Missing name', 'Trip name is required.');
return false; return false;
} }
@@ -291,12 +395,12 @@ export default function AppRoot() {
const end = parseYMD(patch.endDate); const end = parseYMD(patch.endDate);
if (!start || !end) { if (!start || !end) {
Alert.alert('Invalid dates', 'Please select valid trip dates.'); showAlert('Invalid dates', 'Please select valid trip dates.');
return false; return false;
} }
if (start > end) { if (start > end) {
Alert.alert('Invalid dates', 'Start date cannot be after end date.'); showAlert('Invalid dates', 'Start date cannot be after end date.');
return false; return false;
} }
@@ -310,7 +414,6 @@ export default function AppRoot() {
location: patch.location.trim(), location: patch.location.trim(),
startDate: patch.startDate, startDate: patch.startDate,
endDate: patch.endDate, endDate: patch.endDate,
imageUri: patch.imageUri,
updatedAt: Date.now(), updatedAt: Date.now(),
} }
: trip : trip
@@ -338,30 +441,29 @@ export default function AppRoot() {
} }
function deleteTrip(tripId) { function deleteTrip(tripId) {
Alert.alert('Delete trip?', 'Trip items and check-up history will also be deleted.', [ showConfirm({
{ text: 'Cancel', style: 'cancel' }, title: 'Delete trip?',
{ message: 'Trip items and check-up history will also be deleted.',
text: 'Delete', confirmText: 'Delete',
style: 'destructive', tone: 'danger',
onPress: () => { onConfirm: () => {
setData((prev) => { setData((prev) => {
const trips = prev.trips.filter((trip) => trip.id !== tripId); const trips = prev.trips.filter((trip) => trip.id !== tripId);
const itemsByTrip = { ...prev.itemsByTrip }; const itemsByTrip = { ...prev.itemsByTrip };
const checkupsByTrip = { ...prev.checkupsByTrip }; const checkupsByTrip = { ...prev.checkupsByTrip };
delete itemsByTrip[tripId]; delete itemsByTrip[tripId];
delete checkupsByTrip[tripId]; delete checkupsByTrip[tripId];
return { return {
...prev, ...prev,
trips, trips,
itemsByTrip, itemsByTrip,
checkupsByTrip, checkupsByTrip,
defaultTemplateTripId: prev.defaultTemplateTripId === tripId ? null : prev.defaultTemplateTripId, defaultTemplateTripId: prev.defaultTemplateTripId === tripId ? null : prev.defaultTemplateTripId,
}; };
}); });
},
}, },
]); });
} }
function openAddItemModal() { function openAddItemModal() {
@@ -370,27 +472,39 @@ export default function AppRoot() {
} }
function openEditItemModal(item) { function openEditItemModal(item) {
const existingPlacement = item.placement || 'suitcase';
const hasPresetPlacement = ITEM_PLACEMENTS.includes(existingPlacement);
setItemForm({ setItemForm({
id: item.id, id: item.id,
name: item.name || '', name: item.name || '',
description: item.description || '', description: item.description || '',
category: item.category || '', category: item.category || '',
status: item.status || 'unpacked', status: item.status || 'unpacked',
placement: item.placement || 'suitcase', placement: hasPresetPlacement ? existingPlacement : 'other',
placementCustom: hasPresetPlacement || existingPlacement === 'other' ? '' : existingPlacement,
lentTo: item.lentTo || '', lentTo: item.lentTo || '',
imageUri: item.imageUri || '', imageUri: item.imageUri || '',
imageQuality: item.imageQuality || 'balanced',
imageAllowCrop: !!item.imageAllowCrop,
}); });
setItemModalVisible(true); setItemModalVisible(true);
} }
function saveItemFromModal() { function saveItemFromModal() {
if (!selectedTripId) { if (!selectedTripId) {
Alert.alert('No trip selected', 'Please select or create a trip first.'); showAlert('No trip selected', 'Please select or create a trip first.');
return; return;
} }
if (!itemForm.name.trim()) { if (!itemForm.name.trim()) {
Alert.alert('Missing name', 'Item name is required.'); showAlert('Missing name', 'Item name is required.');
return;
}
const resolvedPlacement = itemForm.placement === 'other' ? itemForm.placementCustom.trim() : itemForm.placement;
if (!resolvedPlacement) {
showAlert('Missing location', 'Please enter a custom location for "other".');
return; return;
} }
@@ -405,9 +519,11 @@ export default function AppRoot() {
description: itemForm.description.trim(), description: itemForm.description.trim(),
category: itemForm.category.trim(), category: itemForm.category.trim(),
status: itemForm.status, status: itemForm.status,
placement: itemForm.placement, placement: resolvedPlacement,
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,
}; };
@@ -491,17 +607,26 @@ export default function AppRoot() {
function deleteCheckup(checkupId) { function deleteCheckup(checkupId) {
if (!selectedTripId) return; if (!selectedTripId) return;
setData((prev) => {
const existing = prev.checkupsByTrip[selectedTripId] || []; showConfirm({
return { title: 'Delete check-up?',
...prev, message: 'This snapshot will be removed from history.',
checkupsByTrip: { confirmText: 'Delete',
...prev.checkupsByTrip, tone: 'danger',
[selectedTripId]: existing.filter((checkup) => checkup.id !== checkupId), onConfirm: () => {
}, setData((prev) => {
}; const existing = prev.checkupsByTrip[selectedTripId] || [];
return {
...prev,
checkupsByTrip: {
...prev.checkupsByTrip,
[selectedTripId]: existing.filter((checkup) => checkup.id !== checkupId),
},
};
});
setSelectedCheckupId((prev) => (prev === checkupId ? null : prev));
},
}); });
setSelectedCheckupId((prev) => (prev === checkupId ? null : prev));
} }
function createFreshCheckupSession() { function createFreshCheckupSession() {
@@ -514,11 +639,11 @@ export default function AppRoot() {
function startCheckupFlow() { function startCheckupFlow() {
if (!selectedTripId) { if (!selectedTripId) {
Alert.alert('No trip selected', 'Please select a trip first.'); showAlert('No trip selected', 'Please select a trip first.');
return; return;
} }
if (!selectedTripItems.length) { if (!selectedTripItems.length) {
Alert.alert('No items', 'Add items before starting a check-up.'); showAlert('No items', 'Add items before starting a check-up.');
return; return;
} }
@@ -542,6 +667,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;
@@ -555,9 +702,14 @@ export default function AppRoot() {
function openCurrentCheckupNo() { function openCurrentCheckupNo() {
const entry = checkupCurrentEntry; const entry = checkupCurrentEntry;
if (!entry) return; if (!entry) return;
const existingPlacement = entry.current.placement || 'suitcase';
const hasPresetPlacement = ITEM_PLACEMENTS.includes(existingPlacement);
setCheckupNoForm({ setCheckupNoForm({
status: entry.current.status || 'unpacked', status: entry.current.status || 'unpacked',
placement: entry.current.placement || 'suitcase', placement: hasPresetPlacement ? existingPlacement : 'other',
placementCustom: hasPresetPlacement || existingPlacement === 'other' ? '' : existingPlacement,
lentTo: entry.current.lentTo || '', lentTo: entry.current.lentTo || '',
updateMasterList: false, updateMasterList: false,
}); });
@@ -568,9 +720,15 @@ export default function AppRoot() {
const entry = checkupCurrentEntry; const entry = checkupCurrentEntry;
if (!entry) return; if (!entry) return;
const resolvedPlacement = checkupNoForm.placement === 'other' ? checkupNoForm.placementCustom.trim() : checkupNoForm.placement;
if (!resolvedPlacement) {
showAlert('Missing location', 'Please enter a custom location for "other".');
return;
}
const patch = { const patch = {
status: checkupNoForm.status, status: checkupNoForm.status,
placement: checkupNoForm.placement, placement: resolvedPlacement,
lentTo: checkupNoForm.status === 'lent-to' ? checkupNoForm.lentTo.trim() : '', lentTo: checkupNoForm.status === 'lent-to' ? checkupNoForm.lentTo.trim() : '',
}; };
@@ -615,18 +773,18 @@ export default function AppRoot() {
function saveCheckupSnapshot(sessionToSave) { function saveCheckupSnapshot(sessionToSave) {
if (!selectedTripId) { if (!selectedTripId) {
Alert.alert('No trip selected', 'Please select a trip first.'); showAlert('No trip selected', 'Please select a trip first.');
return false; return false;
} }
if (!sessionToSave.length) { if (!sessionToSave.length) {
Alert.alert('No items', 'Add items before creating a check-up.'); showAlert('No items', 'Add items before creating a check-up.');
return false; return false;
} }
const pending = sessionToSave.filter((entry) => !entry.confirmed).length; const pending = sessionToSave.filter((entry) => !entry.confirmed).length;
if (pending > 0) { if (pending > 0) {
Alert.alert('Incomplete', `Please confirm all items first (${pending} remaining).`); showAlert('Incomplete', `Please confirm all items first (${pending} remaining).`);
return false; return false;
} }
@@ -669,7 +827,7 @@ export default function AppRoot() {
const ok = saveCheckupSnapshot(checkupSession); const ok = saveCheckupSnapshot(checkupSession);
if (!ok) return; if (!ok) return;
Alert.alert('Saved', 'Check-up snapshot saved.'); showAlert('Saved', 'Check-up snapshot saved.');
closeCheckupFlow(); closeCheckupFlow();
createFreshCheckupSession(); createFreshCheckupSession();
} }
@@ -685,12 +843,77 @@ export default function AppRoot() {
}, 80); }, 80);
} }
if (!loaded) { function openQuickAddItemFromNav() {
if (!selectedTripId) {
showAlert('No trip selected', 'Please select or create a trip first.');
return;
}
openAddItemModal();
}
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 ( return (
<SafeAreaView style={[styles.safe, { paddingTop: topInset }]}> <SafeAreaView style={[styles.safe, { paddingTop: topInset }]}>
<StatusBar style="light" translucent={false} /> <StatusBar style="light" translucent={false} />
<View style={styles.center}> <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> </View>
</SafeAreaView> </SafeAreaView>
); );
@@ -713,23 +936,10 @@ export default function AppRoot() {
<TripsTab <TripsTab
tripForm={tripForm} tripForm={tripForm}
updateTripForm={updateTripForm} updateTripForm={updateTripForm}
pickTripImage={(onPicked) =>
pickImage((uri) => {
if (typeof onPicked === 'function') onPicked(uri);
else updateTripForm('imageUri', uri);
})
}
takeTripImage={(onPicked) =>
takeImage((uri) => {
if (typeof onPicked === 'function') onPicked(uri);
else updateTripForm('imageUri', uri);
})
}
templateTrip={templateTrip} templateTrip={templateTrip}
createTrip={createTrip} createTrip={createTrip}
trips={data.trips} trips={data.trips}
selectedTripId={selectedTripId} selectedTripId={selectedTripId}
chooseTrip={setSelectedTripId}
setTripAsTemplate={setTripAsTemplate} setTripAsTemplate={setTripAsTemplate}
saveTripEdits={saveTripEdits} saveTripEdits={saveTripEdits}
setTripArchived={setTripArchived} setTripArchived={setTripArchived}
@@ -739,6 +949,7 @@ export default function AppRoot() {
openDatePicker={openDatePicker} openDatePicker={openDatePicker}
activeTripItemCount={selectedTripItems.length} activeTripItemCount={selectedTripItems.length}
activeTripCheckupCount={selectedTripCheckups.length} activeTripCheckupCount={selectedTripCheckups.length}
openBackupModal={openBackupModal}
/> />
)} )}
@@ -775,7 +986,7 @@ export default function AppRoot() {
</ScrollView> </ScrollView>
</KeyboardAvoidingView> </KeyboardAvoidingView>
<BottomTab current={tab} onChange={setTab} /> <BottomTab current={tab} onChange={setTab} onAddItem={openQuickAddItemFromNav} canAddItem={!!selectedTripId} />
<DatePickerModal <DatePickerModal
visible={datePicker.visible} visible={datePicker.visible}
@@ -788,10 +999,11 @@ export default function AppRoot() {
<ItemModal <ItemModal
visible={itemModalVisible} visible={itemModalVisible}
itemForm={itemForm} itemForm={itemForm}
previousCustomPlacements={previousCustomPlacements}
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}
/> />
@@ -807,8 +1019,27 @@ export default function AppRoot() {
onYes={answerCurrentCheckupYes} onYes={answerCurrentCheckupYes}
onNo={openCurrentCheckupNo} onNo={openCurrentCheckupNo}
onSaveNo={saveCurrentCheckupNo} onSaveNo={saveCurrentCheckupNo}
onSkip={skipCurrentCheckupItem}
onBack={goBackInCheckup}
onFinish={finishCheckupFlow} onFinish={finishCheckupFlow}
/> />
<BackupModal
visible={backupModalVisible}
onClose={() => setBackupModalVisible(false)}
exportJson={buildBackupJson()}
importJson={backupImportText}
setImportJson={setBackupImportText}
applyImport={applyBackupImport}
/>
<AppDialogModal
visible={dialogState.visible}
title={dialogState.title}
message={dialogState.message}
buttons={dialogState.buttons}
onClose={closeDialog}
/>
</SafeAreaView> </SafeAreaView>
); );
} }

View File

@@ -0,0 +1,40 @@
import React from 'react';
import { Modal, Pressable, Text, View } from 'react-native';
import { styles } from '../styles';
export default function AppDialogModal({ visible, title, message, buttons = [], onClose }) {
if (!visible) return null;
const safeButtons = buttons.length ? buttons : [{ text: 'OK' }];
return (
<Modal visible={visible} transparent animationType="fade" onRequestClose={onClose}>
<View style={styles.dialogBackdrop}>
<View style={styles.dialogCard}>
<Text style={styles.dialogTitle}>{title || 'Notice'}</Text>
{!!message ? <Text style={styles.dialogMessage}>{message}</Text> : null}
<View style={styles.dialogButtonsRow}>
{safeButtons.map((button, idx) => {
const tone = button.tone || (button.style === 'destructive' ? 'danger' : button.style === 'cancel' ? 'neutral' : 'primary');
return (
<Pressable
key={`${button.text}-${idx}`}
style={[
styles.dialogBtn,
tone === 'primary' ? styles.dialogBtnPrimary : null,
tone === 'danger' ? styles.dialogBtnDanger : null,
tone === 'neutral' ? styles.dialogBtnNeutral : null,
]}
onPress={button.onPress}
>
<Text style={styles.dialogBtnText}>{button.text || 'OK'}</Text>
</Pressable>
);
})}
</View>
</View>
</View>
</Modal>
);
}

View File

@@ -3,10 +3,23 @@ import { Pressable, Text, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons'; import Ionicons from '@expo/vector-icons/Ionicons';
import { styles } from '../styles'; import { styles } from '../styles';
export default function BottomTab({ current, onChange }) { function TabBtn({ tab, current, onChange }) {
const tabs = [ const active = current === tab.key;
return (
<Pressable onPress={() => onChange(tab.key)} style={styles.tabItem}>
<Ionicons name={active ? tab.iconActive : tab.icon} size={18} color={active ? '#dbeafe' : '#94a3b8'} />
<Text style={[styles.tabLabel, active && styles.tabLabelActive]}>{tab.label}</Text>
</Pressable>
);
}
export default function BottomTab({ current, onChange, onAddItem, canAddItem }) {
const leftTabs = [
{ key: 'trips', label: 'Trips', icon: 'airplane-outline', iconActive: 'airplane' }, { key: 'trips', label: 'Trips', icon: 'airplane-outline', iconActive: 'airplane' },
{ key: 'items', label: 'Items', icon: 'briefcase-outline', iconActive: 'briefcase' }, { key: 'items', label: 'Items', icon: 'briefcase-outline', iconActive: 'briefcase' },
];
const rightTabs = [
{ key: 'checkup', label: 'Check-Up', icon: 'checkmark-circle-outline', iconActive: 'checkmark-circle' }, { key: 'checkup', label: 'Check-Up', icon: 'checkmark-circle-outline', iconActive: 'checkmark-circle' },
{ key: 'history', label: 'History', icon: 'time-outline', iconActive: 'time' }, { key: 'history', label: 'History', icon: 'time-outline', iconActive: 'time' },
]; ];
@@ -14,19 +27,25 @@ export default function BottomTab({ current, onChange }) {
return ( return (
<View style={styles.tabBarWrap}> <View style={styles.tabBarWrap}>
<View style={styles.tabBar}> <View style={styles.tabBar}>
{tabs.map((tab) => { <View style={styles.tabGroupSide}>
const active = current === tab.key; {leftTabs.map((tab) => (
return ( <TabBtn key={tab.key} tab={tab} current={current} onChange={onChange} />
<Pressable key={tab.key} onPress={() => onChange(tab.key)} style={styles.tabItem}> ))}
<Ionicons </View>
name={active ? tab.iconActive : tab.icon}
size={18} <Pressable
color={active ? '#dbeafe' : '#94a3b8'} style={[styles.tabAddBtn, !canAddItem && styles.tabAddBtnDisabled]}
/> onPress={onAddItem}
<Text style={[styles.tabLabel, active && styles.tabLabelActive]}>{tab.label}</Text> disabled={!canAddItem}
</Pressable> >
); <Ionicons name="add" size={26} color="#fff" />
})} </Pressable>
<View style={styles.tabGroupSide}>
{rightTabs.map((tab) => (
<TabBtn key={tab.key} tab={tab} current={current} onChange={onChange} />
))}
</View>
</View> </View>
</View> </View>
); );

View File

@@ -2,26 +2,40 @@ import React from 'react';
import { Image, Pressable, Text, View } from 'react-native'; import { Image, Pressable, Text, View } from 'react-native';
import { STATUS_COLORS } from '../constants'; import { STATUS_COLORS } from '../constants';
import { styles } from '../styles'; import { styles } from '../styles';
import { formatStatusLabel } from '../utils/labels';
function statusAccent(status) { function statusAccent(status) {
return STATUS_COLORS[status] || '#64748b'; 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 isPacked = item.status === 'packed';
const isUnpacked = item.status === 'unpacked'; const isUnpacked = item.status === 'unpacked';
return ( return (
<View style={styles.itemCard}> <View style={styles.itemCard}>
<View style={[styles.itemAccent, { backgroundColor: statusAccent(item.status) }]} /> <View style={[styles.itemAccent, { backgroundColor: statusAccent(item.status) }]} />
<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>
</View>
)}
</View>
<View style={styles.itemMain}> <View style={styles.itemMain}>
<View style={styles.cardRow}> <View style={styles.cardRow}>
<View style={styles.flex}> <View style={styles.flex}>
<Text style={styles.itemTitle}>{item.name}</Text> <Text style={styles.itemTitle} numberOfLines={1}>{item.name}</Text>
<Text style={styles.itemMeta}>{item.category || 'uncategorized'} · {item.status}</Text> <Text style={styles.itemMeta} numberOfLines={1}>{item.category || 'uncategorized'} · {formatStatusLabel(item.status, item.lentTo)}</Text>
<Text style={styles.itemMeta}>Location: {item.placement}</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.status === 'lent-to' && !!item.lentTo ? <Text style={styles.itemMeta} numberOfLines={1}>Borrower: {item.lentTo}</Text> : null}
{!!item.description ? <Text style={styles.itemMeta}>{item.description}</Text> : null} {!!item.description ? <Text style={styles.itemMeta} numberOfLines={2}>{item.description}</Text> : null}
</View> </View>
<View style={styles.stackButtons}> <View style={styles.stackButtons}>
<Pressable style={styles.miniBtn} onPress={() => onEdit(item)}> <Pressable style={styles.miniBtn} onPress={() => onEdit(item)}>
@@ -35,14 +49,12 @@ export default function ItemCard({ item, onEdit, onDelete, onQuickPack, onQuickU
<View style={styles.quickStatusRow}> <View style={styles.quickStatusRow}>
<Pressable style={[styles.quickStatusBtn, isPacked && styles.quickStatusBtnActive]} onPress={onQuickPack}> <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>
<Pressable style={[styles.quickStatusBtn, isUnpacked && styles.quickStatusBtnActive]} onPress={onQuickUnpack}> <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> </Pressable>
</View> </View>
{item.imageUri ? <Image source={{ uri: item.imageUri }} style={styles.previewImageSmall} /> : null}
</View> </View>
</View> </View>
); );

54
src/modals/BackupModal.js Normal file
View 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>
);
}

View File

@@ -4,6 +4,7 @@ import { ITEM_PLACEMENTS, ITEM_STATUSES } from '../constants';
import ChipGroup from '../components/ChipGroup'; import ChipGroup from '../components/ChipGroup';
import Field from '../components/Field'; import Field from '../components/Field';
import { styles } from '../styles'; import { styles } from '../styles';
import { formatStatusLabel } from '../utils/labels';
export default function CheckupFlowModal({ export default function CheckupFlowModal({
visible, visible,
@@ -17,6 +18,8 @@ export default function CheckupFlowModal({
onYes, onYes,
onNo, onNo,
onSaveNo, onSaveNo,
onSkip,
onBack,
onFinish, onFinish,
}) { }) {
const finished = !entry; const finished = !entry;
@@ -37,9 +40,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,15 +59,25 @@ 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}>
Current: {entry.current.status} · {entry.current.placement} Current: {formatStatusLabel(entry.current.status, entry.current.lentTo)} · {entry.current.placement}
{entry.current.status === 'lent-to' && entry.current.lentTo ? ` · ${entry.current.lentTo}` : ''}
</Text> </Text>
{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>
@@ -85,6 +103,18 @@ export default function CheckupFlowModal({
/> />
</Field> </Field>
{noForm.placement === 'other' ? (
<Field label="Custom location">
<TextInput
style={styles.input}
value={noForm.placementCustom}
onChangeText={(v) => setNoForm((prev) => ({ ...prev, placementCustom: v }))}
placeholder="bath-kit"
placeholderTextColor="#6b7280"
/>
</Field>
) : null}
{noForm.status === 'lent-to' ? ( {noForm.status === 'lent-to' ? (
<Field label="Lent to"> <Field label="Lent to">
<TextInput <TextInput
@@ -106,9 +136,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,15 +5,27 @@ 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,
previousCustomPlacements,
setItemModalVisible, setItemModalVisible,
updateItemForm, updateItemForm,
pickItemImage, pickItemImage,
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}>
@@ -70,6 +82,27 @@ export default function ItemModal({
<ChipGroup options={ITEM_PLACEMENTS} value={itemForm.placement} onChange={(v) => updateItemForm('placement', v)} /> <ChipGroup options={ITEM_PLACEMENTS} value={itemForm.placement} onChange={(v) => updateItemForm('placement', v)} />
</Field> </Field>
{itemForm.placement === 'other' ? (
<Field label="Custom location">
<TextInput
style={styles.input}
value={itemForm.placementCustom}
onChangeText={(v) => updateItemForm('placementCustom', v)}
placeholder="bath-kit"
placeholderTextColor="#6b7280"
/>
{previousCustomPlacements?.length ? (
<View style={styles.chipGroup}>
{previousCustomPlacements.slice(0, 6).map((location) => (
<Pressable key={location} style={styles.chip} onPress={() => updateItemForm('placementCustom', location)}>
<Text style={styles.chipText}>{location}</Text>
</Pressable>
))}
</View>
) : null}
</Field>
) : null}
{itemForm.status === 'lent-to' ? ( {itemForm.status === 'lent-to' ? (
<Field label="Lent to"> <Field label="Lent to">
<TextInput <TextInput
@@ -82,11 +115,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

@@ -10,10 +10,10 @@ export const styles = StyleSheet.create({
flex: 1, flex: 1,
}, },
content: { content: {
paddingHorizontal: 16, paddingHorizontal: 14,
paddingTop: 12, paddingTop: 10,
paddingBottom: TAB_BAR_HEIGHT + 22, paddingBottom: TAB_BAR_HEIGHT + 20,
gap: 14, gap: 10,
}, },
statusSpacer: { statusSpacer: {
height: Platform.OS === 'android' ? 8 : 0, height: Platform.OS === 'android' ? 8 : 0,
@@ -26,6 +26,28 @@ export const styles = StyleSheet.create({
muted: { muted: {
color: '#8793a5', 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: { tripPickerWrap: {
marginBottom: 6, marginBottom: 6,
@@ -64,7 +86,7 @@ export const styles = StyleSheet.create({
}, },
section: { section: {
gap: 12, gap: 10,
}, },
sectionTitle: { sectionTitle: {
color: '#f1f5f9', color: '#f1f5f9',
@@ -83,8 +105,8 @@ export const styles = StyleSheet.create({
borderRadius: 16, borderRadius: 16,
borderWidth: 1, borderWidth: 1,
borderColor: '#1f2937', borderColor: '#1f2937',
padding: 12, padding: 10,
gap: 8, gap: 6,
}, },
cardActive: { cardActive: {
borderColor: '#60a5fa', borderColor: '#60a5fa',
@@ -98,12 +120,12 @@ export const styles = StyleSheet.create({
borderRadius: 16, borderRadius: 16,
borderWidth: 1, borderWidth: 1,
borderColor: '#1e293b', borderColor: '#1e293b',
padding: 12, padding: 10,
gap: 10, gap: 8,
}, },
cardRow: { cardRow: {
flexDirection: 'row', flexDirection: 'row',
gap: 10, gap: 8,
}, },
cardTitle: { cardTitle: {
color: '#f8fafc', color: '#f8fafc',
@@ -112,8 +134,8 @@ export const styles = StyleSheet.create({
}, },
cardMeta: { cardMeta: {
color: '#94a3b8', color: '#94a3b8',
marginTop: 3, marginTop: 2,
fontSize: 13, fontSize: 12,
}, },
tripHistoryLabel: { tripHistoryLabel: {
color: '#93c5fd', color: '#93c5fd',
@@ -126,8 +148,8 @@ export const styles = StyleSheet.create({
borderRadius: 18, borderRadius: 18,
borderWidth: 1, borderWidth: 1,
borderColor: '#334155', borderColor: '#334155',
padding: 12, padding: 10,
gap: 8, gap: 6,
}, },
tripHeroImage: { tripHeroImage: {
width: '100%', width: '100%',
@@ -138,7 +160,7 @@ export const styles = StyleSheet.create({
tripHeroTitle: { tripHeroTitle: {
color: '#f8fafc', color: '#f8fafc',
fontWeight: '800', fontWeight: '800',
fontSize: 22, fontSize: 20,
}, },
tripListTitle: { tripListTitle: {
color: '#cbd5e1', color: '#cbd5e1',
@@ -164,6 +186,19 @@ export const styles = StyleSheet.create({
paddingHorizontal: 10, paddingHorizontal: 10,
paddingVertical: 11, 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: { dateInput: {
borderWidth: 1, borderWidth: 1,
borderColor: '#29415e', borderColor: '#29415e',
@@ -255,19 +290,19 @@ export const styles = StyleSheet.create({
}, },
stackButtons: { stackButtons: {
gap: 7, gap: 6,
}, },
miniBtn: { miniBtn: {
backgroundColor: '#1e293b', backgroundColor: '#1e293b',
borderRadius: 8, borderRadius: 8,
paddingVertical: 7, paddingVertical: 6,
paddingHorizontal: 10, paddingHorizontal: 9,
}, },
miniBtnDanger: { miniBtnDanger: {
backgroundColor: '#3b1d22', backgroundColor: '#3b1d22',
borderRadius: 8, borderRadius: 8,
paddingVertical: 7, paddingVertical: 6,
paddingHorizontal: 10, paddingHorizontal: 9,
}, },
miniBtnText: { miniBtnText: {
color: '#e2e8f0', color: '#e2e8f0',
@@ -282,14 +317,39 @@ export const styles = StyleSheet.create({
borderColor: '#1f2937', borderColor: '#1f2937',
overflow: 'hidden', overflow: 'hidden',
flexDirection: 'row', flexDirection: 'row',
alignItems: 'flex-start',
}, },
itemAccent: { itemAccent: {
width: 5, width: 5,
alignSelf: 'stretch',
},
itemThumbWrap: {
paddingTop: 8,
paddingLeft: 8,
},
itemThumbSmall: {
width: 42,
height: 42,
borderRadius: 8,
backgroundColor: '#0b1220',
},
itemThumbPlaceholder: {
width: 42,
height: 42,
borderRadius: 8,
backgroundColor: '#0b1220',
alignItems: 'center',
justifyContent: 'center',
borderWidth: 1,
borderColor: '#243244',
},
itemThumbPlaceholderText: {
fontSize: 16,
}, },
itemMain: { itemMain: {
flex: 1, flex: 1,
padding: 12, padding: 8,
gap: 8, gap: 6,
}, },
itemTitle: { itemTitle: {
color: '#f8fafc', color: '#f8fafc',
@@ -298,17 +358,17 @@ export const styles = StyleSheet.create({
}, },
itemMeta: { itemMeta: {
color: '#94a3b8', color: '#94a3b8',
marginTop: 2, marginTop: 1,
fontSize: 13, fontSize: 12,
}, },
quickStatusRow: { quickStatusRow: {
flexDirection: 'row', flexDirection: 'row',
gap: 8, gap: 6,
marginTop: 2, marginTop: 1,
}, },
quickStatusBtn: { quickStatusBtn: {
paddingVertical: 6, paddingVertical: 5,
paddingHorizontal: 12, paddingHorizontal: 10,
borderRadius: 999, borderRadius: 999,
borderWidth: 1, borderWidth: 1,
borderColor: '#334155', borderColor: '#334155',
@@ -321,7 +381,7 @@ export const styles = StyleSheet.create({
quickStatusBtnText: { quickStatusBtnText: {
color: '#cbd5e1', color: '#cbd5e1',
fontWeight: '700', fontWeight: '700',
fontSize: 12, fontSize: 11,
}, },
quickStatusBtnTextActive: { quickStatusBtnTextActive: {
color: '#dbeafe', color: '#dbeafe',
@@ -357,6 +417,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,
@@ -444,10 +517,39 @@ export const styles = StyleSheet.create({
borderRadius: 10, borderRadius: 10,
backgroundColor: '#111827', 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: { tabBarWrap: {
position: 'absolute', position: 'absolute',
bottom: 0, bottom: 6,
left: 0, left: 0,
right: 0, right: 0,
paddingHorizontal: 10, paddingHorizontal: 10,
@@ -462,17 +564,38 @@ export const styles = StyleSheet.create({
borderColor: '#1f2937', borderColor: '#1f2937',
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 8,
},
tabGroupSide: {
flexDirection: 'row',
width: '42%',
justifyContent: 'space-around', justifyContent: 'space-around',
alignItems: 'center',
}, },
tabItem: { tabItem: {
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
gap: 4, gap: 3,
minWidth: 62, minWidth: 56,
},
tabAddBtn: {
width: 54,
height: 54,
borderRadius: 999,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#2563eb',
marginTop: -24,
borderWidth: 2,
borderColor: '#0b1220',
},
tabAddBtnDisabled: {
opacity: 0.45,
}, },
tabLabel: { tabLabel: {
color: '#94a3b8', color: '#94a3b8',
fontSize: 12, fontSize: 11,
fontWeight: '600', fontWeight: '600',
}, },
tabLabelActive: { tabLabelActive: {
@@ -484,6 +607,59 @@ export const styles = StyleSheet.create({
backgroundColor: 'rgba(2,6,23,0.72)', backgroundColor: 'rgba(2,6,23,0.72)',
paddingHorizontal: 12, paddingHorizontal: 12,
}, },
dialogBackdrop: {
flex: 1,
backgroundColor: 'rgba(2,6,23,0.72)',
alignItems: 'center',
justifyContent: 'center',
paddingHorizontal: 18,
},
dialogCard: {
width: '100%',
backgroundColor: '#0f172a',
borderRadius: 16,
borderWidth: 1,
borderColor: '#1e293b',
padding: 14,
gap: 12,
},
dialogTitle: {
color: '#f8fafc',
fontWeight: '700',
fontSize: 17,
},
dialogMessage: {
color: '#cbd5e1',
lineHeight: 20,
},
dialogButtonsRow: {
flexDirection: 'row',
gap: 8,
justifyContent: 'flex-end',
flexWrap: 'wrap',
},
dialogBtn: {
borderRadius: 10,
paddingVertical: 9,
paddingHorizontal: 14,
borderWidth: 1,
},
dialogBtnPrimary: {
backgroundColor: '#2563eb',
borderColor: '#2563eb',
},
dialogBtnDanger: {
backgroundColor: '#7f1d1d',
borderColor: '#991b1b',
},
dialogBtnNeutral: {
backgroundColor: '#1e293b',
borderColor: '#334155',
},
dialogBtnText: {
color: '#f8fafc',
fontWeight: '700',
},
modalKeyboardWrap: { modalKeyboardWrap: {
flex: 1, flex: 1,
width: '100%', width: '100%',
@@ -497,8 +673,8 @@ export const styles = StyleSheet.create({
borderRadius: 20, borderRadius: 20,
borderWidth: 1, borderWidth: 1,
borderColor: '#1e293b', borderColor: '#1e293b',
padding: 16, padding: 14,
gap: 10, gap: 8,
}, },
closeText: { closeText: {
color: '#93c5fd', color: '#93c5fd',

View File

@@ -1,25 +1,9 @@
import React from 'react'; import React from 'react';
import { Alert, Pressable, Text, View } from 'react-native'; import { Pressable, Text, View } from 'react-native';
import { styles } from '../styles'; import { styles } from '../styles';
import { formatStatusLabel } from '../utils/labels';
export default function HistoryTab({ export default function HistoryTab({ selectedTrip, selectedTripCheckups, selectedCheckupId, setSelectedCheckupId, onDeleteCheckup }) {
selectedTrip,
selectedTripCheckups,
selectedCheckupId,
setSelectedCheckupId,
onDeleteCheckup,
}) {
function askDelete(checkup) {
Alert.alert('Delete check-up?', 'This snapshot will be removed from history.', [
{ text: 'Cancel', style: 'cancel' },
{
text: 'Delete',
style: 'destructive',
onPress: () => onDeleteCheckup(checkup.id),
},
]);
}
return ( return (
<View style={styles.section}> <View style={styles.section}>
<Text style={styles.sectionTitle}>History</Text> <Text style={styles.sectionTitle}>History</Text>
@@ -32,7 +16,7 @@ export default function HistoryTab({
<View key={checkup.id} style={styles.cardSoft}> <View key={checkup.id} style={styles.cardSoft}>
<Pressable <Pressable
onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))} onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}
onLongPress={() => askDelete(checkup)} onLongPress={() => onDeleteCheckup(checkup.id)}
delayLongPress={280} delayLongPress={280}
> >
<Text style={styles.cardTitle}>{new Date(checkup.createdAt).toLocaleString()}</Text> <Text style={styles.cardTitle}>{new Date(checkup.createdAt).toLocaleString()}</Text>
@@ -49,8 +33,7 @@ export default function HistoryTab({
<View key={entry.itemId} style={styles.snapshotRow}> <View key={entry.itemId} style={styles.snapshotRow}>
<Text style={styles.snapshotTitle}>{entry.name}</Text> <Text style={styles.snapshotTitle}>{entry.name}</Text>
<Text style={styles.cardMeta}> <Text style={styles.cardMeta}>
{entry.status} · {entry.placement} {formatStatusLabel(entry.status, entry.lentTo)} · {entry.placement}
{entry.status === 'lent-to' && entry.lentTo ? ` · ${entry.lentTo}` : ''}
</Text> </Text>
</View> </View>
))} ))}

View File

@@ -1,8 +1,9 @@
import React, { useMemo, useState } from 'react'; 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 ItemCard from '../components/ItemCard';
import { ITEM_STATUSES } from '../constants'; import { ITEM_STATUSES } from '../constants';
import { styles } from '../styles'; import { styles } from '../styles';
import { formatFilterLabel, formatStatusLabel } from '../utils/labels';
export default function ItemsTab({ export default function ItemsTab({
selectedTrip, selectedTrip,
@@ -15,25 +16,35 @@ export default function ItemsTab({
}) { }) {
const [statusFilter, setStatusFilter] = useState('all'); const [statusFilter, setStatusFilter] = useState('all');
const [categoryFilter, setCategoryFilter] = useState('all'); const [categoryFilter, setCategoryFilter] = useState('all');
const [locationFilter, setLocationFilter] = useState('all');
const [imagePreviewUri, setImagePreviewUri] = useState('');
const categories = useMemo( const categories = useMemo(
() => Array.from(new Set(selectedTripItems.map((item) => item.category?.trim()).filter(Boolean))).sort((a, b) => a.localeCompare(b)), () => Array.from(new Set(selectedTripItems.map((item) => item.category?.trim()).filter(Boolean))).sort((a, b) => a.localeCompare(b)),
[selectedTripItems] [selectedTripItems]
); );
const locations = useMemo(
() => Array.from(new Set(selectedTripItems.map((item) => item.placement?.trim()).filter(Boolean))).sort((a, b) => a.localeCompare(b)),
[selectedTripItems]
);
const filteredItems = useMemo( const filteredItems = useMemo(
() => () =>
selectedTripItems.filter((item) => { selectedTripItems.filter((item) => {
const matchStatus = statusFilter === 'all' || item.status === statusFilter; const matchStatus = statusFilter === 'all' || item.status === statusFilter;
const itemCategory = item.category?.trim() || ''; const itemCategory = item.category?.trim() || '';
const itemLocation = item.placement?.trim() || '';
const matchCategory = categoryFilter === 'all' || itemCategory === categoryFilter; const matchCategory = categoryFilter === 'all' || itemCategory === categoryFilter;
return matchStatus && matchCategory; const matchLocation = locationFilter === 'all' || itemLocation === locationFilter;
return matchStatus && matchCategory && matchLocation;
}), }),
[selectedTripItems, statusFilter, categoryFilter] [selectedTripItems, statusFilter, categoryFilter, locationFilter]
); );
const filterStatusOptions = ['all', ...ITEM_STATUSES]; const filterStatusOptions = ['all', ...ITEM_STATUSES];
const filterCategoryOptions = ['all', ...categories]; const filterCategoryOptions = ['all', ...categories];
const filterLocationOptions = ['all', ...locations];
return ( return (
<View style={styles.section}> <View style={styles.section}>
@@ -52,10 +63,10 @@ export default function ItemsTab({
<Text style={styles.cardTitle}>Quick actions</Text> <Text style={styles.cardTitle}>Quick actions</Text>
<View style={styles.actionRow}> <View style={styles.actionRow}>
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={() => bulkSetItemStatus(filteredItems.map((x) => x.id), 'packed')}> <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>
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={() => bulkSetItemStatus(filteredItems.map((x) => x.id), 'unpacked')}> <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> </Pressable>
</View> </View>
</View> </View>
@@ -71,7 +82,7 @@ export default function ItemsTab({
const active = statusFilter === status; const active = statusFilter === status;
return ( return (
<Pressable key={status} style={[styles.chip, active && styles.chipActive]} onPress={() => setStatusFilter(status)}> <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> </Pressable>
); );
})} })}
@@ -83,7 +94,19 @@ export default function ItemsTab({
const active = categoryFilter === category; const active = categoryFilter === category;
return ( return (
<Pressable key={category} style={[styles.chip, active && styles.chipActive]} onPress={() => setCategoryFilter(category)}> <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>
);
})}
</View>
<Text style={styles.cardMeta}>Location</Text>
<View style={styles.chipGroup}>
{filterLocationOptions.map((location) => {
const active = locationFilter === location;
return (
<Pressable key={location} style={[styles.chip, active && styles.chipActive]} onPress={() => setLocationFilter(location)}>
<Text style={[styles.chipText, active && styles.chipTextActive]}>{formatFilterLabel(location)}</Text>
</Pressable> </Pressable>
); );
})} })}
@@ -99,10 +122,20 @@ export default function ItemsTab({
onDelete={deleteItem} onDelete={deleteItem}
onQuickPack={() => quickSetItemStatus(item.id, 'packed')} onQuickPack={() => quickSetItemStatus(item.id, 'packed')}
onQuickUnpack={() => quickSetItemStatus(item.id, 'unpacked')} 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} {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> </View>
); );
} }

View File

@@ -1,5 +1,5 @@
import React, { useMemo, useState } from 'react'; import React, { useMemo, useState } from 'react';
import { Image, KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native'; import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
import DatePickerModal from '../components/DatePickerModal'; import DatePickerModal from '../components/DatePickerModal';
import Field from '../components/Field'; import Field from '../components/Field';
import { styles } from '../styles'; import { styles } from '../styles';
@@ -19,19 +19,15 @@ const emptyEditForm = {
location: '', location: '',
startDate: '', startDate: '',
endDate: '', endDate: '',
imageUri: '',
}; };
export default function TripsTab({ export default function TripsTab({
tripForm, tripForm,
updateTripForm, updateTripForm,
pickTripImage,
takeTripImage,
templateTrip, templateTrip,
createTrip, createTrip,
trips, trips,
selectedTripId, selectedTripId,
chooseTrip,
setTripAsTemplate, setTripAsTemplate,
saveTripEdits, saveTripEdits,
setTripArchived, setTripArchived,
@@ -41,6 +37,7 @@ export default function TripsTab({
openDatePicker, openDatePicker,
activeTripItemCount, activeTripItemCount,
activeTripCheckupCount, activeTripCheckupCount,
openBackupModal,
}) { }) {
const [createModalVisible, setCreateModalVisible] = useState(false); const [createModalVisible, setCreateModalVisible] = useState(false);
const [viewTripId, setViewTripId] = useState(null); const [viewTripId, setViewTripId] = useState(null);
@@ -68,7 +65,6 @@ export default function TripsTab({
location: trip.location || '', location: trip.location || '',
startDate: trip.startDate || '', startDate: trip.startDate || '',
endDate: trip.endDate || '', endDate: trip.endDate || '',
imageUri: trip.imageUri || '',
}); });
} }
@@ -83,14 +79,6 @@ export default function TripsTab({
setEditMode(false); setEditMode(false);
} }
function pickViewTripImage() {
pickTripImage((uri) => updateEditForm('imageUri', uri));
}
function takeViewTripImage() {
takeTripImage((uri) => updateEditForm('imageUri', uri));
}
function applyTemplateFromView() { function applyTemplateFromView() {
if (!viewingTrip) return; if (!viewingTrip) return;
setTripAsTemplate(viewingTrip.id); setTripAsTemplate(viewingTrip.id);
@@ -117,14 +105,18 @@ export default function TripsTab({
<View style={styles.section}> <View style={styles.section}>
<View style={styles.sectionRow}> <View style={styles.sectionRow}>
<Text style={styles.sectionTitle}>Trips</Text> <Text style={styles.sectionTitle}>Trips</Text>
<Pressable style={styles.primaryBtnTight} onPress={() => setCreateModalVisible(true)}> <View style={styles.actionRow}>
<Text style={styles.primaryBtnText}>+ New Trip</Text> <Pressable style={styles.secondaryBtnTight} onPress={openBackupModal}>
</Pressable> <Text style={styles.secondaryBtnText}>Backup</Text>
</Pressable>
<Pressable style={styles.primaryBtnTight} onPress={() => setCreateModalVisible(true)}>
<Text style={styles.primaryBtnText}>+ New Trip</Text>
</Pressable>
</View>
</View> </View>
{activeTrip ? ( {activeTrip ? (
<View style={styles.tripHeroCard}> <View style={styles.tripHeroCard}>
{activeTrip.imageUri ? <Image source={{ uri: activeTrip.imageUri }} style={styles.tripHeroImage} /> : null}
<Text style={styles.tripHeroTitle}>{activeTrip.name}</Text> <Text style={styles.tripHeroTitle}>{activeTrip.name}</Text>
<Text style={styles.cardMeta}>{activeTrip.location || 'No location'} · {activeTrip.startDate} {activeTrip.endDate}</Text> <Text style={styles.cardMeta}>{activeTrip.location || 'No location'} · {activeTrip.startDate} {activeTrip.endDate}</Text>
<Text style={styles.cardMeta}>{activeTripItemCount} items · {activeTripCheckupCount} check-ups</Text> <Text style={styles.cardMeta}>{activeTripItemCount} items · {activeTripCheckupCount} check-ups</Text>
@@ -144,18 +136,14 @@ export default function TripsTab({
<View style={styles.flex}> <View style={styles.flex}>
<Text style={styles.cardTitle}>{trip.name}</Text> <Text style={styles.cardTitle}>{trip.name}</Text>
<Text style={styles.cardMeta}>{trip.location || 'No location'} · {trip.startDate} {trip.endDate}</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>
<View style={styles.stackButtons}> <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)}> <Pressable style={styles.miniBtn} onPress={() => openView(trip.id)}>
<Text style={styles.miniBtnText}>View</Text> <Text style={styles.miniBtnText}>View</Text>
</Pressable> </Pressable>
</View> </View>
</View> </View>
{trip.imageUri ? <Image source={{ uri: trip.imageUri }} style={styles.previewImageSmall} /> : null}
</View> </View>
))} ))}
@@ -226,17 +214,6 @@ export default function TripsTab({
<DateField label="Start Date" value={tripForm.startDate} onPress={() => openDatePicker('startDate')} /> <DateField label="Start Date" value={tripForm.startDate} onPress={() => openDatePicker('startDate')} />
<DateField label="End Date" value={tripForm.endDate} onPress={() => openDatePicker('endDate')} /> <DateField label="End Date" value={tripForm.endDate} onPress={() => openDatePicker('endDate')} />
<View style={styles.actionRow}>
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={takeTripImage}>
<Text style={styles.secondaryBtnText}>Take photo</Text>
</Pressable>
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={pickTripImage}>
<Text style={styles.secondaryBtnText}>{tripForm.imageUri ? 'From gallery (change)' : 'From gallery'}</Text>
</Pressable>
</View>
{tripForm.imageUri ? <Image source={{ uri: tripForm.imageUri }} style={styles.previewImage} /> : null}
{templateTrip ? ( {templateTrip ? (
<Pressable style={styles.inlineToggle} onPress={() => updateTripForm('copyDefaultTemplate', !tripForm.copyDefaultTemplate)}> <Pressable style={styles.inlineToggle} onPress={() => updateTripForm('copyDefaultTemplate', !tripForm.copyDefaultTemplate)}>
<Text style={styles.inlineToggleText}> <Text style={styles.inlineToggleText}>
@@ -283,7 +260,6 @@ export default function TripsTab({
> >
{!editMode ? ( {!editMode ? (
<> <>
{viewingTrip.imageUri ? <Image source={{ uri: viewingTrip.imageUri }} style={styles.previewImage} /> : null}
<Text style={styles.tripHeroTitle}>{viewingTrip.name}</Text> <Text style={styles.tripHeroTitle}>{viewingTrip.name}</Text>
<Text style={styles.cardMeta}>{viewingTrip.location || 'No location'}</Text> <Text style={styles.cardMeta}>{viewingTrip.location || 'No location'}</Text>
<Text style={styles.cardMeta}>{viewingTrip.startDate} {viewingTrip.endDate}</Text> <Text style={styles.cardMeta}>{viewingTrip.startDate} {viewingTrip.endDate}</Text>
@@ -333,17 +309,6 @@ export default function TripsTab({
<DateField label="Start Date" value={editForm.startDate} onPress={() => setViewDatePicker({ visible: true, field: 'startDate' })} /> <DateField label="Start Date" value={editForm.startDate} onPress={() => setViewDatePicker({ visible: true, field: 'startDate' })} />
<DateField label="End Date" value={editForm.endDate} onPress={() => setViewDatePicker({ visible: true, field: 'endDate' })} /> <DateField label="End Date" value={editForm.endDate} onPress={() => setViewDatePicker({ visible: true, field: 'endDate' })} />
<View style={styles.actionRow}>
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={takeViewTripImage}>
<Text style={styles.secondaryBtnText}>Take photo</Text>
</Pressable>
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={pickViewTripImage}>
<Text style={styles.secondaryBtnText}>{editForm.imageUri ? 'From gallery (change)' : 'From gallery'}</Text>
</Pressable>
</View>
{editForm.imageUri ? <Image source={{ uri: editForm.imageUri }} style={styles.previewImage} /> : null}
<Pressable style={styles.primaryBtn} onPress={saveEditFromView}> <Pressable style={styles.primaryBtn} onPress={saveEditFromView}>
<Text style={styles.primaryBtnText}>Save Trip</Text> <Text style={styles.primaryBtnText}>Save Trip</Text>
</Pressable> </Pressable>

23
src/utils/labels.js Normal file
View 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);
}