Compare commits
8 Commits
luggage-li
...
luggage-li
| Author | SHA1 | Date | |
|---|---|---|---|
| d33fecd657 | |||
| 2417d2d597 | |||
| f28ff010d7 | |||
| d40bd6a41c | |||
| 2e45261354 | |||
| bd500674a0 | |||
| ef7e0ba7a1 | |||
| f34ffe39c0 |
@@ -5,7 +5,7 @@ Minimal local-first luggage management app built with Expo.
|
|||||||
## Current Features (V2)
|
## Current Features (V2)
|
||||||
|
|
||||||
- No auth, no server, local storage only (AsyncStorage)
|
- No auth, no server, local storage only (AsyncStorage)
|
||||||
- Trips with name, location, dates, optional image from gallery
|
- Trips with name, location, calendar date picker, optional image from gallery
|
||||||
- Active trip auto-select on first load, with manual trip switching anytime via global trip picker
|
- Active trip auto-select on first load, with manual trip switching anytime via global trip picker
|
||||||
- Default trip template (copied into new trip, not linked)
|
- Default trip template (copied into new trip, not linked)
|
||||||
- Luggage items with:
|
- Luggage items with:
|
||||||
@@ -14,10 +14,10 @@ Minimal local-first luggage management app built with Expo.
|
|||||||
- placement: suitcase, backpack, with-user, other
|
- placement: suitcase, backpack, with-user, other
|
||||||
- optional image from gallery
|
- optional image from gallery
|
||||||
- Item create/edit via modal
|
- Item create/edit via modal
|
||||||
- Check-up flow as yes/no checklist:
|
- Check-up flow as yes/no checklist with live stats (correct/bad/pending):
|
||||||
- “No” opens update modal
|
- “No” opens update modal
|
||||||
- fixes can be check-up-only or optionally synced to trip item list
|
- fixes can be check-up-only or optionally synced to trip item list
|
||||||
- Check-up history per trip with saved snapshots
|
- Check-up history per selected trip with saved snapshots + stats
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
|||||||
5
TODO.md
5
TODO.md
@@ -34,3 +34,8 @@ Improving & Fixing Bugs (V3)
|
|||||||
- [x] Improved keyboard focus scrolling to focused input (not scroll-to-end)
|
- [x] Improved keyboard focus scrolling to focused input (not scroll-to-end)
|
||||||
- [x] Reworked bottom nav to real icons + labels
|
- [x] Reworked bottom nav to real icons + labels
|
||||||
- [x] Clarified history as selected-trip check-up history
|
- [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)
|
||||||
|
|||||||
9
app.json
9
app.json
@@ -34,6 +34,15 @@
|
|||||||
"eas": {
|
"eas": {
|
||||||
"projectId": "1275f90e-33c6-4af1-942e-ca29a309f8c8"
|
"projectId": "1275f90e-33c6-4af1-942e-ca29a309f8c8"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
[
|
||||||
|
"expo-image-picker",
|
||||||
|
{
|
||||||
|
"photosPermission": "Allow Luggage List to access your photos for trip and item images.",
|
||||||
|
"cameraPermission": "Allow Luggage List to use your camera to take trip and item photos."
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
339
src/AppRoot.js
339
src/AppRoot.js
@@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { Alert, KeyboardAvoidingView, Platform, SafeAreaView, ScrollView, Text, View } from 'react-native';
|
import { Alert, 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';
|
||||||
@@ -7,13 +7,13 @@ 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 ItemModal from './modals/ItemModal';
|
import ItemModal from './modals/ItemModal';
|
||||||
import CheckupFixModal from './modals/CheckupFixModal';
|
import CheckupFlowModal from './modals/CheckupFlowModal';
|
||||||
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, STORAGE_KEY } from './constants';
|
||||||
import { findActiveTripId, makeId, parseYMD, todayYMD } from './utils/date';
|
import { findBestTripId, makeId, parseYMD, todayYMD } from './utils/date';
|
||||||
import { styles } from './styles';
|
import { styles } from './styles';
|
||||||
|
|
||||||
const emptyTripForm = () => ({
|
const emptyTripForm = () => ({
|
||||||
@@ -37,6 +37,28 @@ const emptyItemForm = () => ({
|
|||||||
imageUri: '',
|
imageUri: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const emptyCheckupNoForm = () => ({
|
||||||
|
status: 'unpacked',
|
||||||
|
placement: 'suitcase',
|
||||||
|
lentTo: '',
|
||||||
|
updateMasterList: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
function buildCheckupSession(items) {
|
||||||
|
return items.map((item) => ({
|
||||||
|
itemId: item.id,
|
||||||
|
name: item.name,
|
||||||
|
category: item.category,
|
||||||
|
current: {
|
||||||
|
status: item.status,
|
||||||
|
placement: item.placement,
|
||||||
|
lentTo: item.lentTo || '',
|
||||||
|
},
|
||||||
|
confirmed: false,
|
||||||
|
result: 'pending',
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
export default function AppRoot() {
|
export default function AppRoot() {
|
||||||
const scrollRef = useRef(null);
|
const scrollRef = useRef(null);
|
||||||
|
|
||||||
@@ -52,17 +74,15 @@ export default function AppRoot() {
|
|||||||
const [itemForm, setItemForm] = useState(emptyItemForm());
|
const [itemForm, setItemForm] = useState(emptyItemForm());
|
||||||
|
|
||||||
const [checkupSession, setCheckupSession] = useState([]);
|
const [checkupSession, setCheckupSession] = useState([]);
|
||||||
const [checkupFixModalVisible, setCheckupFixModalVisible] = useState(false);
|
const [checkupFlowVisible, setCheckupFlowVisible] = useState(false);
|
||||||
const [checkupFixTargetId, setCheckupFixTargetId] = useState(null);
|
const [checkupFlowIndex, setCheckupFlowIndex] = useState(0);
|
||||||
const [checkupFixForm, setCheckupFixForm] = useState({
|
const [checkupFlowMode, setCheckupFlowMode] = useState('question');
|
||||||
status: 'unpacked',
|
const [checkupNoForm, setCheckupNoForm] = useState(emptyCheckupNoForm());
|
||||||
placement: 'suitcase',
|
|
||||||
lentTo: '',
|
|
||||||
updateMasterList: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const [selectedCheckupId, setSelectedCheckupId] = useState(null);
|
const [selectedCheckupId, setSelectedCheckupId] = useState(null);
|
||||||
|
|
||||||
|
const topInset = Platform.OS === 'android' ? (RNStatusBar.currentHeight || 0) + 10 : 0;
|
||||||
|
|
||||||
const selectedTrip = useMemo(() => data.trips.find((trip) => trip.id === selectedTripId) || null, [data.trips, selectedTripId]);
|
const selectedTrip = useMemo(() => data.trips.find((trip) => trip.id === selectedTripId) || null, [data.trips, selectedTripId]);
|
||||||
|
|
||||||
const selectedTripItems = useMemo(() => {
|
const selectedTripItems = useMemo(() => {
|
||||||
@@ -80,6 +100,20 @@ export default function AppRoot() {
|
|||||||
[data.trips, data.defaultTemplateTripId]
|
[data.trips, data.defaultTemplateTripId]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const checkupStats = useMemo(() => {
|
||||||
|
const total = checkupSession.length;
|
||||||
|
const correct = checkupSession.filter((entry) => entry.result === 'correct').length;
|
||||||
|
const bad = checkupSession.filter((entry) => entry.result === 'bad').length;
|
||||||
|
const pending = total - correct - bad;
|
||||||
|
return { total, correct, bad, pending };
|
||||||
|
}, [checkupSession]);
|
||||||
|
|
||||||
|
const checkupCurrentEntry = useMemo(() => {
|
||||||
|
if (!checkupFlowVisible) return null;
|
||||||
|
if (checkupFlowIndex >= checkupSession.length) return null;
|
||||||
|
return checkupSession[checkupFlowIndex] || null;
|
||||||
|
}, [checkupFlowVisible, checkupFlowIndex, checkupSession]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -114,8 +148,8 @@ export default function AppRoot() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeTripId = findActiveTripId(data.trips);
|
const bestTripId = findBestTripId(data.trips);
|
||||||
setSelectedTripId(activeTripId || data.trips[0].id);
|
setSelectedTripId(bestTripId || data.trips[0].id);
|
||||||
}, [data.trips, selectedTripId, loaded]);
|
}, [data.trips, selectedTripId, loaded]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -159,10 +193,27 @@ export default function AppRoot() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function takeImage(onPicked) {
|
||||||
|
const perm = await ImagePicker.requestCameraPermissionsAsync();
|
||||||
|
if (!perm.granted) {
|
||||||
|
Alert.alert('Permission needed', 'Allow camera access to take photos.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await ImagePicker.launchCameraAsync({
|
||||||
|
allowsEditing: false,
|
||||||
|
quality: 0.85,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result.canceled && result.assets?.[0]?.uri) {
|
||||||
|
onPicked(result.assets[0].uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createTrip() {
|
function createTrip() {
|
||||||
if (!tripForm.name.trim()) {
|
if (!tripForm.name.trim()) {
|
||||||
Alert.alert('Missing name', 'Trip name is required.');
|
Alert.alert('Missing name', 'Trip name is required.');
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const start = parseYMD(tripForm.startDate);
|
const start = parseYMD(tripForm.startDate);
|
||||||
@@ -170,12 +221,12 @@ export default function AppRoot() {
|
|||||||
|
|
||||||
if (!start || !end) {
|
if (!start || !end) {
|
||||||
Alert.alert('Invalid dates', 'Please select valid trip dates.');
|
Alert.alert('Invalid dates', 'Please select valid trip dates.');
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start > end) {
|
if (start > end) {
|
||||||
Alert.alert('Invalid dates', 'Start date cannot be after end date.');
|
Alert.alert('Invalid dates', 'Start date cannot be after end date.');
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
@@ -220,6 +271,7 @@ export default function AppRoot() {
|
|||||||
|
|
||||||
setSelectedTripId(tripId);
|
setSelectedTripId(tripId);
|
||||||
setTripForm(emptyTripForm());
|
setTripForm(emptyTripForm());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTripAsTemplate(tripId) {
|
function setTripAsTemplate(tripId) {
|
||||||
@@ -331,68 +383,8 @@ export default function AppRoot() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createFreshCheckupSession() {
|
function quickSetItemStatus(itemId, status) {
|
||||||
if (!selectedTripItems.length) {
|
if (!selectedTripId) return;
|
||||||
setCheckupSession([]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fresh = selectedTripItems.map((item) => ({
|
|
||||||
itemId: item.id,
|
|
||||||
name: item.name,
|
|
||||||
category: item.category,
|
|
||||||
current: {
|
|
||||||
status: item.status,
|
|
||||||
placement: item.placement,
|
|
||||||
lentTo: item.lentTo || '',
|
|
||||||
},
|
|
||||||
confirmed: false,
|
|
||||||
}));
|
|
||||||
|
|
||||||
setCheckupSession(fresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
function answerCheckupYes(itemId) {
|
|
||||||
setCheckupSession((prev) => prev.map((entry) => (entry.itemId === itemId ? { ...entry, confirmed: true } : entry)));
|
|
||||||
}
|
|
||||||
|
|
||||||
function openFixModal(itemId) {
|
|
||||||
const entry = checkupSession.find((x) => x.itemId === itemId);
|
|
||||||
if (!entry) return;
|
|
||||||
|
|
||||||
setCheckupFixTargetId(itemId);
|
|
||||||
setCheckupFixForm({
|
|
||||||
status: entry.current.status || 'unpacked',
|
|
||||||
placement: entry.current.placement || 'suitcase',
|
|
||||||
lentTo: entry.current.lentTo || '',
|
|
||||||
updateMasterList: false,
|
|
||||||
});
|
|
||||||
setCheckupFixModalVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveFixModal() {
|
|
||||||
if (!checkupFixTargetId) return;
|
|
||||||
|
|
||||||
const targetId = checkupFixTargetId;
|
|
||||||
const patch = {
|
|
||||||
status: checkupFixForm.status,
|
|
||||||
placement: checkupFixForm.placement,
|
|
||||||
lentTo: checkupFixForm.status === 'lent-to' ? checkupFixForm.lentTo.trim() : '',
|
|
||||||
};
|
|
||||||
|
|
||||||
setCheckupSession((prev) =>
|
|
||||||
prev.map((entry) =>
|
|
||||||
entry.itemId === targetId
|
|
||||||
? {
|
|
||||||
...entry,
|
|
||||||
current: patch,
|
|
||||||
confirmed: true,
|
|
||||||
}
|
|
||||||
: entry
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (checkupFixForm.updateMasterList && selectedTripId) {
|
|
||||||
setData((prev) => {
|
setData((prev) => {
|
||||||
const items = prev.itemsByTrip[selectedTripId] || [];
|
const items = prev.itemsByTrip[selectedTripId] || [];
|
||||||
return {
|
return {
|
||||||
@@ -400,7 +392,127 @@ export default function AppRoot() {
|
|||||||
itemsByTrip: {
|
itemsByTrip: {
|
||||||
...prev.itemsByTrip,
|
...prev.itemsByTrip,
|
||||||
[selectedTripId]: items.map((item) =>
|
[selectedTripId]: items.map((item) =>
|
||||||
item.id === targetId
|
item.id === itemId
|
||||||
|
? {
|
||||||
|
...item,
|
||||||
|
status,
|
||||||
|
lentTo: status === 'lent-to' ? item.lentTo : '',
|
||||||
|
updatedAt: Date.now(),
|
||||||
|
}
|
||||||
|
: item
|
||||||
|
),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteCheckup(checkupId) {
|
||||||
|
if (!selectedTripId) return;
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
function createFreshCheckupSession() {
|
||||||
|
if (!selectedTripItems.length) {
|
||||||
|
setCheckupSession([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setCheckupSession(buildCheckupSession(selectedTripItems));
|
||||||
|
}
|
||||||
|
|
||||||
|
function startCheckupFlow() {
|
||||||
|
if (!selectedTripId) {
|
||||||
|
Alert.alert('No trip selected', 'Please select a trip first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!selectedTripItems.length) {
|
||||||
|
Alert.alert('No items', 'Add items before starting a check-up.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fresh = buildCheckupSession(selectedTripItems);
|
||||||
|
setCheckupSession(fresh);
|
||||||
|
setCheckupFlowIndex(0);
|
||||||
|
setCheckupFlowMode('question');
|
||||||
|
setCheckupNoForm(emptyCheckupNoForm());
|
||||||
|
setCheckupFlowVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeCheckupFlow() {
|
||||||
|
setCheckupFlowVisible(false);
|
||||||
|
setCheckupFlowMode('question');
|
||||||
|
setCheckupNoForm(emptyCheckupNoForm());
|
||||||
|
}
|
||||||
|
|
||||||
|
function goNextInCheckup() {
|
||||||
|
setCheckupFlowIndex((prev) => prev + 1);
|
||||||
|
setCheckupFlowMode('question');
|
||||||
|
setCheckupNoForm(emptyCheckupNoForm());
|
||||||
|
}
|
||||||
|
|
||||||
|
function answerCurrentCheckupYes() {
|
||||||
|
const entry = checkupCurrentEntry;
|
||||||
|
if (!entry) return;
|
||||||
|
|
||||||
|
setCheckupSession((prev) =>
|
||||||
|
prev.map((x) => (x.itemId === entry.itemId ? { ...x, confirmed: true, result: 'correct' } : x))
|
||||||
|
);
|
||||||
|
goNextInCheckup();
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCurrentCheckupNo() {
|
||||||
|
const entry = checkupCurrentEntry;
|
||||||
|
if (!entry) return;
|
||||||
|
setCheckupNoForm({
|
||||||
|
status: entry.current.status || 'unpacked',
|
||||||
|
placement: entry.current.placement || 'suitcase',
|
||||||
|
lentTo: entry.current.lentTo || '',
|
||||||
|
updateMasterList: false,
|
||||||
|
});
|
||||||
|
setCheckupFlowMode('edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveCurrentCheckupNo() {
|
||||||
|
const entry = checkupCurrentEntry;
|
||||||
|
if (!entry) return;
|
||||||
|
|
||||||
|
const patch = {
|
||||||
|
status: checkupNoForm.status,
|
||||||
|
placement: checkupNoForm.placement,
|
||||||
|
lentTo: checkupNoForm.status === 'lent-to' ? checkupNoForm.lentTo.trim() : '',
|
||||||
|
};
|
||||||
|
|
||||||
|
setCheckupSession((prev) =>
|
||||||
|
prev.map((x) =>
|
||||||
|
x.itemId === entry.itemId
|
||||||
|
? {
|
||||||
|
...x,
|
||||||
|
current: patch,
|
||||||
|
confirmed: true,
|
||||||
|
result: 'bad',
|
||||||
|
}
|
||||||
|
: x
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (checkupNoForm.updateMasterList && selectedTripId) {
|
||||||
|
setData((prev) => {
|
||||||
|
const items = prev.itemsByTrip[selectedTripId] || [];
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
itemsByTrip: {
|
||||||
|
...prev.itemsByTrip,
|
||||||
|
[selectedTripId]: items.map((item) =>
|
||||||
|
item.id === entry.itemId
|
||||||
? {
|
? {
|
||||||
...item,
|
...item,
|
||||||
status: patch.status,
|
status: patch.status,
|
||||||
@@ -415,34 +527,34 @@ export default function AppRoot() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setCheckupFixModalVisible(false);
|
goNextInCheckup();
|
||||||
setCheckupFixTargetId(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveCheckup() {
|
function saveCheckupSnapshot(sessionToSave) {
|
||||||
if (!selectedTripId) {
|
if (!selectedTripId) {
|
||||||
Alert.alert('No trip selected', 'Please select a trip first.');
|
Alert.alert('No trip selected', 'Please select a trip first.');
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkupSession.length) {
|
if (!sessionToSave.length) {
|
||||||
Alert.alert('No items', 'Add items before creating a check-up.');
|
Alert.alert('No items', 'Add items before creating a check-up.');
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pending = checkupSession.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).`);
|
Alert.alert('Incomplete', `Please confirm all items first (${pending} remaining).`);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const snapshot = checkupSession.map((entry) => ({
|
const snapshot = sessionToSave.map((entry) => ({
|
||||||
itemId: entry.itemId,
|
itemId: entry.itemId,
|
||||||
name: entry.name,
|
name: entry.name,
|
||||||
category: entry.category,
|
category: entry.category,
|
||||||
status: entry.current.status,
|
status: entry.current.status,
|
||||||
placement: entry.current.placement,
|
placement: entry.current.placement,
|
||||||
lentTo: entry.current.status === 'lent-to' ? entry.current.lentTo : '',
|
lentTo: entry.current.status === 'lent-to' ? entry.current.lentTo : '',
|
||||||
|
result: entry.result || 'pending',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setData((prev) => {
|
setData((prev) => {
|
||||||
@@ -457,13 +569,25 @@ export default function AppRoot() {
|
|||||||
id: makeId('checkup'),
|
id: makeId('checkup'),
|
||||||
createdAt: Date.now(),
|
createdAt: Date.now(),
|
||||||
snapshot,
|
snapshot,
|
||||||
|
stats: {
|
||||||
|
correct: snapshot.filter((entry) => entry.result === 'correct').length,
|
||||||
|
bad: snapshot.filter((entry) => entry.result === 'bad').length,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishCheckupFlow() {
|
||||||
|
const ok = saveCheckupSnapshot(checkupSession);
|
||||||
|
if (!ok) return;
|
||||||
|
|
||||||
Alert.alert('Saved', 'Check-up snapshot saved.');
|
Alert.alert('Saved', 'Check-up snapshot saved.');
|
||||||
|
closeCheckupFlow();
|
||||||
createFreshCheckupSession();
|
createFreshCheckupSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,7 +604,7 @@ export default function AppRoot() {
|
|||||||
|
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={styles.safe}>
|
<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.muted}>Loading local data...</Text>
|
||||||
@@ -490,7 +614,7 @@ export default function AppRoot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={styles.safe}>
|
<SafeAreaView style={[styles.safe, { paddingTop: topInset }]}>
|
||||||
<StatusBar style="light" translucent={false} />
|
<StatusBar style="light" translucent={false} />
|
||||||
|
|
||||||
<KeyboardAvoidingView style={styles.flex} behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
|
<KeyboardAvoidingView style={styles.flex} behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
|
||||||
@@ -500,7 +624,6 @@ export default function AppRoot() {
|
|||||||
keyboardShouldPersistTaps="handled"
|
keyboardShouldPersistTaps="handled"
|
||||||
showsVerticalScrollIndicator={false}
|
showsVerticalScrollIndicator={false}
|
||||||
>
|
>
|
||||||
<View style={styles.statusSpacer} />
|
|
||||||
<TripPicker trips={data.trips} selectedTripId={selectedTripId} onChooseTrip={setSelectedTripId} />
|
<TripPicker trips={data.trips} selectedTripId={selectedTripId} onChooseTrip={setSelectedTripId} />
|
||||||
|
|
||||||
{tab === 'trips' && (
|
{tab === 'trips' && (
|
||||||
@@ -508,6 +631,7 @@ export default function AppRoot() {
|
|||||||
tripForm={tripForm}
|
tripForm={tripForm}
|
||||||
updateTripForm={updateTripForm}
|
updateTripForm={updateTripForm}
|
||||||
pickTripImage={() => pickImage((uri) => updateTripForm('imageUri', uri))}
|
pickTripImage={() => pickImage((uri) => updateTripForm('imageUri', uri))}
|
||||||
|
takeTripImage={() => takeImage((uri) => updateTripForm('imageUri', uri))}
|
||||||
templateTrip={templateTrip}
|
templateTrip={templateTrip}
|
||||||
createTrip={createTrip}
|
createTrip={createTrip}
|
||||||
trips={data.trips}
|
trips={data.trips}
|
||||||
@@ -518,6 +642,8 @@ export default function AppRoot() {
|
|||||||
onInputFocus={onInputFocus}
|
onInputFocus={onInputFocus}
|
||||||
defaultTemplateTripId={data.defaultTemplateTripId}
|
defaultTemplateTripId={data.defaultTemplateTripId}
|
||||||
openDatePicker={openDatePicker}
|
openDatePicker={openDatePicker}
|
||||||
|
activeTripItemCount={selectedTripItems.length}
|
||||||
|
activeTripCheckupCount={selectedTripCheckups.length}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -528,16 +654,16 @@ export default function AppRoot() {
|
|||||||
openAddItemModal={openAddItemModal}
|
openAddItemModal={openAddItemModal}
|
||||||
openEditItemModal={openEditItemModal}
|
openEditItemModal={openEditItemModal}
|
||||||
deleteItem={deleteItem}
|
deleteItem={deleteItem}
|
||||||
|
quickSetItemStatus={quickSetItemStatus}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{tab === 'checkup' && (
|
{tab === 'checkup' && (
|
||||||
<CheckupTab
|
<CheckupTab
|
||||||
checkupSession={checkupSession}
|
selectedTrip={selectedTrip}
|
||||||
answerCheckupYes={answerCheckupYes}
|
selectedTripItems={selectedTripItems}
|
||||||
openFixModal={openFixModal}
|
checkupStats={checkupStats}
|
||||||
createFreshCheckupSession={createFreshCheckupSession}
|
startCheckupFlow={startCheckupFlow}
|
||||||
saveCheckup={saveCheckup}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -547,6 +673,7 @@ export default function AppRoot() {
|
|||||||
selectedTripCheckups={selectedTripCheckups}
|
selectedTripCheckups={selectedTripCheckups}
|
||||||
selectedCheckupId={selectedCheckupId}
|
selectedCheckupId={selectedCheckupId}
|
||||||
setSelectedCheckupId={setSelectedCheckupId}
|
setSelectedCheckupId={setSelectedCheckupId}
|
||||||
|
onDeleteCheckup={deleteCheckup}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
@@ -568,15 +695,23 @@ export default function AppRoot() {
|
|||||||
setItemModalVisible={setItemModalVisible}
|
setItemModalVisible={setItemModalVisible}
|
||||||
updateItemForm={updateItemForm}
|
updateItemForm={updateItemForm}
|
||||||
pickItemImage={() => pickImage((uri) => updateItemForm('imageUri', uri))}
|
pickItemImage={() => pickImage((uri) => updateItemForm('imageUri', uri))}
|
||||||
|
takeItemImage={() => takeImage((uri) => updateItemForm('imageUri', uri))}
|
||||||
saveItemFromModal={saveItemFromModal}
|
saveItemFromModal={saveItemFromModal}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CheckupFixModal
|
<CheckupFlowModal
|
||||||
visible={checkupFixModalVisible}
|
visible={checkupFlowVisible}
|
||||||
checkupFixForm={checkupFixForm}
|
entry={checkupCurrentEntry}
|
||||||
setCheckupFixForm={setCheckupFixForm}
|
stepIndex={checkupFlowIndex}
|
||||||
setCheckupFixModalVisible={setCheckupFixModalVisible}
|
total={checkupSession.length}
|
||||||
saveFixModal={saveFixModal}
|
mode={checkupFlowMode}
|
||||||
|
noForm={checkupNoForm}
|
||||||
|
setNoForm={setCheckupNoForm}
|
||||||
|
onClose={closeCheckupFlow}
|
||||||
|
onYes={answerCurrentCheckupYes}
|
||||||
|
onNo={openCurrentCheckupNo}
|
||||||
|
onSaveNo={saveCurrentCheckupNo}
|
||||||
|
onFinish={finishCheckupFlow}
|
||||||
/>
|
/>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ function statusAccent(status) {
|
|||||||
return STATUS_COLORS[status] || '#64748b';
|
return STATUS_COLORS[status] || '#64748b';
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ItemCard({ item, onEdit, onDelete }) {
|
export default function ItemCard({ item, onEdit, onDelete, onQuickPack, onQuickUnpack }) {
|
||||||
|
const isPacked = item.status === 'packed';
|
||||||
|
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) }]} />
|
||||||
@@ -29,6 +32,16 @@ export default function ItemCard({ item, onEdit, onDelete }) {
|
|||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.quickStatusRow}>
|
||||||
|
<Pressable style={[styles.quickStatusBtn, isPacked && styles.quickStatusBtnActive]} onPress={onQuickPack}>
|
||||||
|
<Text style={[styles.quickStatusBtnText, isPacked && styles.quickStatusBtnTextActive]}>Pack</Text>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable style={[styles.quickStatusBtn, isUnpacked && styles.quickStatusBtnActive]} onPress={onQuickUnpack}>
|
||||||
|
<Text style={[styles.quickStatusBtnText, isUnpacked && styles.quickStatusBtnTextActive]}>Unpack</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
{item.imageUri ? <Image source={{ uri: item.imageUri }} style={styles.previewImageSmall} /> : null}
|
{item.imageUri ? <Image source={{ uri: item.imageUri }} style={styles.previewImageSmall} /> : null}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export default function CheckupFixModal({
|
|||||||
return (
|
return (
|
||||||
<Modal visible={visible} animationType="slide" transparent>
|
<Modal visible={visible} animationType="slide" transparent>
|
||||||
<View style={styles.modalBackdrop}>
|
<View style={styles.modalBackdrop}>
|
||||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={styles.modalKeyboardWrap}>
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={styles.modalKeyboardWrap}>
|
||||||
<View style={styles.modalCard}>
|
<View style={styles.modalCard}>
|
||||||
<View style={styles.sectionRow}>
|
<View style={styles.sectionRow}>
|
||||||
<Text style={styles.sectionTitle}>Update for this Check-Up</Text>
|
<Text style={styles.sectionTitle}>Update for this Check-Up</Text>
|
||||||
@@ -24,7 +24,12 @@ export default function CheckupFixModal({
|
|||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ScrollView keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>
|
<ScrollView
|
||||||
|
keyboardShouldPersistTaps="handled"
|
||||||
|
keyboardDismissMode="interactive"
|
||||||
|
contentContainerStyle={{ paddingBottom: 12 }}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
<Field label="Status">
|
<Field label="Status">
|
||||||
<ChipGroup
|
<ChipGroup
|
||||||
options={ITEM_STATUSES}
|
options={ITEM_STATUSES}
|
||||||
|
|||||||
121
src/modals/CheckupFlowModal.js
Normal file
121
src/modals/CheckupFlowModal.js
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
||||||
|
import { ITEM_PLACEMENTS, ITEM_STATUSES } from '../constants';
|
||||||
|
import ChipGroup from '../components/ChipGroup';
|
||||||
|
import Field from '../components/Field';
|
||||||
|
import { styles } from '../styles';
|
||||||
|
|
||||||
|
export default function CheckupFlowModal({
|
||||||
|
visible,
|
||||||
|
entry,
|
||||||
|
stepIndex,
|
||||||
|
total,
|
||||||
|
mode,
|
||||||
|
noForm,
|
||||||
|
setNoForm,
|
||||||
|
onClose,
|
||||||
|
onYes,
|
||||||
|
onNo,
|
||||||
|
onSaveNo,
|
||||||
|
onFinish,
|
||||||
|
}) {
|
||||||
|
const finished = !entry;
|
||||||
|
|
||||||
|
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}>Check-Up</Text>
|
||||||
|
<Pressable onPress={onClose}>
|
||||||
|
<Text style={styles.closeText}>Close</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{finished ? (
|
||||||
|
<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>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<ScrollView
|
||||||
|
keyboardShouldPersistTaps="handled"
|
||||||
|
keyboardDismissMode="interactive"
|
||||||
|
contentContainerStyle={{ paddingBottom: 12 }}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
|
<Text style={styles.tripHistoryLabel}>
|
||||||
|
Item {stepIndex + 1} / {total}
|
||||||
|
</Text>
|
||||||
|
<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}` : ''}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
{mode === 'question' ? (
|
||||||
|
<View style={styles.answerRowWide}>
|
||||||
|
<Pressable style={styles.answerYesWide} onPress={onYes}>
|
||||||
|
<Text style={styles.answerText}>Yes, correct</Text>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable style={styles.answerNoWide} onPress={onNo}>
|
||||||
|
<Text style={styles.answerText}>No, update</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<View style={styles.section}>
|
||||||
|
<Field label="Status">
|
||||||
|
<ChipGroup
|
||||||
|
options={ITEM_STATUSES}
|
||||||
|
value={noForm.status}
|
||||||
|
onChange={(v) => setNoForm((prev) => ({ ...prev, status: v }))}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<Field label="Placement">
|
||||||
|
<ChipGroup
|
||||||
|
options={ITEM_PLACEMENTS}
|
||||||
|
value={noForm.placement}
|
||||||
|
onChange={(v) => setNoForm((prev) => ({ ...prev, placement: v }))}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
{noForm.status === 'lent-to' ? (
|
||||||
|
<Field label="Lent to">
|
||||||
|
<TextInput
|
||||||
|
style={styles.input}
|
||||||
|
value={noForm.lentTo}
|
||||||
|
onChangeText={(v) => setNoForm((prev) => ({ ...prev, lentTo: v }))}
|
||||||
|
placeholder="Person name"
|
||||||
|
placeholderTextColor="#6b7280"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Pressable
|
||||||
|
style={styles.inlineToggle}
|
||||||
|
onPress={() => setNoForm((prev) => ({ ...prev, updateMasterList: !prev.updateMasterList }))}
|
||||||
|
>
|
||||||
|
<Text style={styles.inlineToggleText}>
|
||||||
|
{noForm.updateMasterList ? '☑' : '☐'} Also update item in trip list
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Pressable style={styles.primaryBtn} onPress={onSaveNo}>
|
||||||
|
<Text style={styles.primaryBtnText}>Save update + next</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</ScrollView>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -11,12 +11,13 @@ export default function ItemModal({
|
|||||||
setItemModalVisible,
|
setItemModalVisible,
|
||||||
updateItemForm,
|
updateItemForm,
|
||||||
pickItemImage,
|
pickItemImage,
|
||||||
|
takeItemImage,
|
||||||
saveItemFromModal,
|
saveItemFromModal,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Modal visible={visible} animationType="slide" transparent>
|
<Modal visible={visible} animationType="slide" transparent>
|
||||||
<View style={styles.modalBackdrop}>
|
<View style={styles.modalBackdrop}>
|
||||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={styles.modalKeyboardWrap}>
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={styles.modalKeyboardWrap}>
|
||||||
<View style={styles.modalCard}>
|
<View style={styles.modalCard}>
|
||||||
<View style={styles.sectionRow}>
|
<View style={styles.sectionRow}>
|
||||||
<Text style={styles.sectionTitle}>{itemForm.id ? 'Update Item' : 'Add Item'}</Text>
|
<Text style={styles.sectionTitle}>{itemForm.id ? 'Update Item' : 'Add Item'}</Text>
|
||||||
@@ -25,7 +26,12 @@ export default function ItemModal({
|
|||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ScrollView keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>
|
<ScrollView
|
||||||
|
keyboardShouldPersistTaps="handled"
|
||||||
|
keyboardDismissMode="interactive"
|
||||||
|
contentContainerStyle={{ paddingBottom: 12 }}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
<Field label="Name">
|
<Field label="Name">
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={styles.input}
|
||||||
@@ -76,9 +82,14 @@ export default function ItemModal({
|
|||||||
</Field>
|
</Field>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<Pressable style={styles.secondaryBtn} onPress={pickItemImage}>
|
<View style={styles.actionRow}>
|
||||||
<Text style={styles.secondaryBtnText}>{itemForm.imageUri ? 'Change image' : 'Add image'}</Text>
|
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={takeItemImage}>
|
||||||
|
<Text style={styles.secondaryBtnText}>Take photo</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={pickItemImage}>
|
||||||
|
<Text style={styles.secondaryBtnText}>{itemForm.imageUri ? 'From gallery (change)' : 'From gallery'}</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
{!!itemForm.imageUri && <Image source={{ uri: itemForm.imageUri }} style={styles.previewImageSmall} />}
|
{!!itemForm.imageUri && <Image source={{ uri: itemForm.imageUri }} style={styles.previewImageSmall} />}
|
||||||
|
|
||||||
<Pressable style={styles.primaryBtn} onPress={saveItemFromModal}>
|
<Pressable style={styles.primaryBtn} onPress={saveItemFromModal}>
|
||||||
|
|||||||
141
src/styles.js
141
src/styles.js
@@ -10,10 +10,10 @@ export const styles = StyleSheet.create({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
paddingHorizontal: 14,
|
paddingHorizontal: 16,
|
||||||
paddingTop: 10,
|
paddingTop: 12,
|
||||||
paddingBottom: TAB_BAR_HEIGHT + 20,
|
paddingBottom: TAB_BAR_HEIGHT + 22,
|
||||||
gap: 12,
|
gap: 14,
|
||||||
},
|
},
|
||||||
statusSpacer: {
|
statusSpacer: {
|
||||||
height: Platform.OS === 'android' ? 8 : 0,
|
height: Platform.OS === 'android' ? 8 : 0,
|
||||||
@@ -64,7 +64,7 @@ export const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
section: {
|
section: {
|
||||||
gap: 10,
|
gap: 12,
|
||||||
},
|
},
|
||||||
sectionTitle: {
|
sectionTitle: {
|
||||||
color: '#f1f5f9',
|
color: '#f1f5f9',
|
||||||
@@ -80,7 +80,7 @@ export const styles = StyleSheet.create({
|
|||||||
|
|
||||||
card: {
|
card: {
|
||||||
backgroundColor: '#111827',
|
backgroundColor: '#111827',
|
||||||
borderRadius: 14,
|
borderRadius: 16,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: '#1f2937',
|
borderColor: '#1f2937',
|
||||||
padding: 12,
|
padding: 12,
|
||||||
@@ -91,7 +91,7 @@ export const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
cardSoft: {
|
cardSoft: {
|
||||||
backgroundColor: '#0f172a',
|
backgroundColor: '#0f172a',
|
||||||
borderRadius: 14,
|
borderRadius: 16,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: '#1e293b',
|
borderColor: '#1e293b',
|
||||||
padding: 12,
|
padding: 12,
|
||||||
@@ -117,6 +117,32 @@ export const styles = StyleSheet.create({
|
|||||||
marginTop: -2,
|
marginTop: -2,
|
||||||
marginBottom: 2,
|
marginBottom: 2,
|
||||||
},
|
},
|
||||||
|
tripHeroCard: {
|
||||||
|
backgroundColor: '#0f172a',
|
||||||
|
borderRadius: 18,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#334155',
|
||||||
|
padding: 12,
|
||||||
|
gap: 8,
|
||||||
|
},
|
||||||
|
tripHeroImage: {
|
||||||
|
width: '100%',
|
||||||
|
height: 180,
|
||||||
|
borderRadius: 12,
|
||||||
|
backgroundColor: '#111827',
|
||||||
|
},
|
||||||
|
tripHeroTitle: {
|
||||||
|
color: '#f8fafc',
|
||||||
|
fontWeight: '800',
|
||||||
|
fontSize: 22,
|
||||||
|
},
|
||||||
|
tripListTitle: {
|
||||||
|
color: '#cbd5e1',
|
||||||
|
fontWeight: '700',
|
||||||
|
fontSize: 13,
|
||||||
|
letterSpacing: 0.4,
|
||||||
|
textTransform: 'uppercase',
|
||||||
|
},
|
||||||
|
|
||||||
fieldWrap: {
|
fieldWrap: {
|
||||||
gap: 6,
|
gap: 6,
|
||||||
@@ -211,6 +237,11 @@ export const styles = StyleSheet.create({
|
|||||||
color: '#dbeafe',
|
color: '#dbeafe',
|
||||||
fontWeight: '700',
|
fontWeight: '700',
|
||||||
},
|
},
|
||||||
|
actionRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
gap: 8,
|
||||||
|
marginTop: 4,
|
||||||
|
},
|
||||||
|
|
||||||
inlineToggle: {
|
inlineToggle: {
|
||||||
marginTop: 2,
|
marginTop: 2,
|
||||||
@@ -241,7 +272,7 @@ export const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
itemCard: {
|
itemCard: {
|
||||||
borderRadius: 14,
|
borderRadius: 16,
|
||||||
backgroundColor: '#111827',
|
backgroundColor: '#111827',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: '#1f2937',
|
borderColor: '#1f2937',
|
||||||
@@ -266,6 +297,31 @@ export const styles = StyleSheet.create({
|
|||||||
marginTop: 2,
|
marginTop: 2,
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
},
|
},
|
||||||
|
quickStatusRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
gap: 8,
|
||||||
|
marginTop: 2,
|
||||||
|
},
|
||||||
|
quickStatusBtn: {
|
||||||
|
paddingVertical: 6,
|
||||||
|
paddingHorizontal: 12,
|
||||||
|
borderRadius: 999,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#334155',
|
||||||
|
backgroundColor: '#0b1220',
|
||||||
|
},
|
||||||
|
quickStatusBtnActive: {
|
||||||
|
borderColor: '#60a5fa',
|
||||||
|
backgroundColor: '#1d2a3a',
|
||||||
|
},
|
||||||
|
quickStatusBtnText: {
|
||||||
|
color: '#cbd5e1',
|
||||||
|
fontWeight: '700',
|
||||||
|
fontSize: 12,
|
||||||
|
},
|
||||||
|
quickStatusBtnTextActive: {
|
||||||
|
color: '#dbeafe',
|
||||||
|
},
|
||||||
|
|
||||||
answerRow: {
|
answerRow: {
|
||||||
marginTop: 8,
|
marginTop: 8,
|
||||||
@@ -293,6 +349,28 @@ export const styles = StyleSheet.create({
|
|||||||
color: '#f8fafc',
|
color: '#f8fafc',
|
||||||
fontWeight: '700',
|
fontWeight: '700',
|
||||||
},
|
},
|
||||||
|
answerRowWide: {
|
||||||
|
marginTop: 14,
|
||||||
|
gap: 10,
|
||||||
|
},
|
||||||
|
answerYesWide: {
|
||||||
|
backgroundColor: '#163223',
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#1f7a4e',
|
||||||
|
borderRadius: 10,
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
paddingVertical: 11,
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
answerNoWide: {
|
||||||
|
backgroundColor: '#3b1d22',
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#7f1d1d',
|
||||||
|
borderRadius: 10,
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
paddingVertical: 11,
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
answerStateDot: {
|
answerStateDot: {
|
||||||
width: 10,
|
width: 10,
|
||||||
height: 10,
|
height: 10,
|
||||||
@@ -302,6 +380,38 @@ export const styles = StyleSheet.create({
|
|||||||
answerStateDotOn: {
|
answerStateDotOn: {
|
||||||
backgroundColor: '#22c55e',
|
backgroundColor: '#22c55e',
|
||||||
},
|
},
|
||||||
|
answerStateDotBad: {
|
||||||
|
backgroundColor: '#ef4444',
|
||||||
|
},
|
||||||
|
|
||||||
|
statsRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
gap: 8,
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
},
|
||||||
|
statPill: {
|
||||||
|
borderRadius: 999,
|
||||||
|
paddingVertical: 7,
|
||||||
|
paddingHorizontal: 11,
|
||||||
|
borderWidth: 1,
|
||||||
|
},
|
||||||
|
statPillCorrect: {
|
||||||
|
backgroundColor: '#163223',
|
||||||
|
borderColor: '#1f7a4e',
|
||||||
|
},
|
||||||
|
statPillBad: {
|
||||||
|
backgroundColor: '#3b1d22',
|
||||||
|
borderColor: '#7f1d1d',
|
||||||
|
},
|
||||||
|
statPillPending: {
|
||||||
|
backgroundColor: '#1f2937',
|
||||||
|
borderColor: '#334155',
|
||||||
|
},
|
||||||
|
statPillText: {
|
||||||
|
color: '#e2e8f0',
|
||||||
|
fontWeight: '700',
|
||||||
|
fontSize: 12,
|
||||||
|
},
|
||||||
|
|
||||||
snapshotWrap: {
|
snapshotWrap: {
|
||||||
marginTop: 8,
|
marginTop: 8,
|
||||||
@@ -368,20 +478,23 @@ export const styles = StyleSheet.create({
|
|||||||
modalBackdrop: {
|
modalBackdrop: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: 'rgba(2,6,23,0.72)',
|
backgroundColor: 'rgba(2,6,23,0.72)',
|
||||||
justifyContent: 'flex-end',
|
paddingHorizontal: 12,
|
||||||
},
|
},
|
||||||
modalKeyboardWrap: {
|
modalKeyboardWrap: {
|
||||||
|
flex: 1,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
modalCard: {
|
modalCard: {
|
||||||
maxHeight: '87%',
|
width: '96%',
|
||||||
|
maxHeight: '90%',
|
||||||
backgroundColor: '#0f172a',
|
backgroundColor: '#0f172a',
|
||||||
borderTopLeftRadius: 18,
|
borderRadius: 20,
|
||||||
borderTopRightRadius: 18,
|
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: '#1e293b',
|
borderColor: '#1e293b',
|
||||||
padding: 14,
|
padding: 16,
|
||||||
gap: 8,
|
gap: 10,
|
||||||
},
|
},
|
||||||
closeText: {
|
closeText: {
|
||||||
color: '#93c5fd',
|
color: '#93c5fd',
|
||||||
|
|||||||
@@ -2,44 +2,36 @@ import React from 'react';
|
|||||||
import { Pressable, Text, View } from 'react-native';
|
import { Pressable, Text, View } from 'react-native';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
|
||||||
export default function CheckupTab({ checkupSession, answerCheckupYes, openFixModal, createFreshCheckupSession, saveCheckup }) {
|
export default function CheckupTab({ selectedTrip, selectedTripItems, checkupStats, startCheckupFlow }) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<View style={styles.sectionRow}>
|
|
||||||
<Text style={styles.sectionTitle}>Check-Up</Text>
|
<Text style={styles.sectionTitle}>Check-Up</Text>
|
||||||
<Pressable style={styles.secondaryBtnTight} onPress={createFreshCheckupSession}>
|
|
||||||
<Text style={styles.secondaryBtnText}>Restart</Text>
|
{!selectedTrip ? <Text style={styles.muted}>Select a trip first.</Text> : null}
|
||||||
</Pressable>
|
{selectedTrip && selectedTripItems.length === 0 ? <Text style={styles.muted}>No items for this trip yet.</Text> : null}
|
||||||
|
|
||||||
|
{selectedTrip && selectedTripItems.length > 0 ? (
|
||||||
|
<View style={styles.cardSoft}>
|
||||||
|
<Text style={styles.cardTitle}>Run a check-up for {selectedTrip.name}</Text>
|
||||||
|
<Text style={styles.cardMeta}>{selectedTripItems.length} items will be checked one by one.</Text>
|
||||||
|
|
||||||
|
<View style={styles.statsRow}>
|
||||||
|
<View style={[styles.statPill, styles.statPillCorrect]}>
|
||||||
|
<Text style={styles.statPillText}>Correct: {checkupStats.correct}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
<View style={[styles.statPill, styles.statPillBad]}>
|
||||||
{checkupSession.length === 0 ? <Text style={styles.muted}>No items for this trip yet.</Text> : null}
|
<Text style={styles.statPillText}>Bad: {checkupStats.bad}</Text>
|
||||||
|
</View>
|
||||||
{checkupSession.map((entry) => (
|
<View style={[styles.statPill, styles.statPillPending]}>
|
||||||
<View key={entry.itemId} style={styles.cardSoft}>
|
<Text style={styles.statPillText}>Pending: {checkupStats.pending}</Text>
|
||||||
<Text style={styles.cardTitle}>{entry.name}</Text>
|
|
||||||
<Text style={styles.cardMeta}>{entry.category || 'uncategorized'}</Text>
|
|
||||||
<Text style={styles.cardMeta}>
|
|
||||||
{entry.current.status} · {entry.current.placement}
|
|
||||||
{entry.current.status === 'lent-to' && entry.current.lentTo ? ` · ${entry.current.lentTo}` : ''}
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<View style={styles.answerRow}>
|
|
||||||
<Pressable style={styles.answerYes} onPress={() => answerCheckupYes(entry.itemId)}>
|
|
||||||
<Text style={styles.answerText}>Yes</Text>
|
|
||||||
</Pressable>
|
|
||||||
<Pressable style={styles.answerNo} onPress={() => openFixModal(entry.itemId)}>
|
|
||||||
<Text style={styles.answerText}>No</Text>
|
|
||||||
</Pressable>
|
|
||||||
<View style={[styles.answerStateDot, entry.confirmed ? styles.answerStateDotOn : null]} />
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
))}
|
|
||||||
|
|
||||||
{!!checkupSession.length && (
|
<Pressable style={styles.primaryBtn} onPress={startCheckupFlow}>
|
||||||
<Pressable style={styles.primaryBtn} onPress={saveCheckup}>
|
<Text style={styles.primaryBtnText}>Start Check-Up</Text>
|
||||||
<Text style={styles.primaryBtnText}>Save Check-Up Snapshot</Text>
|
|
||||||
</Pressable>
|
</Pressable>
|
||||||
)}
|
</View>
|
||||||
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,25 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Pressable, Text, View } from 'react-native';
|
import { Alert, Pressable, Text, View } from 'react-native';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
|
||||||
export default function HistoryTab({ selectedTrip, selectedTripCheckups, selectedCheckupId, setSelectedCheckupId }) {
|
export default function HistoryTab({
|
||||||
|
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>
|
||||||
@@ -13,10 +30,17 @@ export default function HistoryTab({ selectedTrip, selectedTripCheckups, selecte
|
|||||||
|
|
||||||
{selectedTripCheckups.map((checkup) => (
|
{selectedTripCheckups.map((checkup) => (
|
||||||
<View key={checkup.id} style={styles.cardSoft}>
|
<View key={checkup.id} style={styles.cardSoft}>
|
||||||
<Pressable onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}>
|
<Pressable
|
||||||
|
onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}
|
||||||
|
onLongPress={() => askDelete(checkup)}
|
||||||
|
delayLongPress={280}
|
||||||
|
>
|
||||||
<Text style={styles.cardTitle}>{new Date(checkup.createdAt).toLocaleString()}</Text>
|
<Text style={styles.cardTitle}>{new Date(checkup.createdAt).toLocaleString()}</Text>
|
||||||
<Text style={styles.cardMeta}>{checkup.snapshot.length} items</Text>
|
<Text style={styles.cardMeta}>
|
||||||
<Text style={styles.cardMeta}>{selectedCheckupId === checkup.id ? 'Tap to collapse' : 'Tap to open'}</Text>
|
{checkup.snapshot.length} items · correct: {checkup.stats?.correct ?? checkup.snapshot.filter((x) => x.result === 'correct').length} · bad:{' '}
|
||||||
|
{checkup.stats?.bad ?? checkup.snapshot.filter((x) => x.result === 'bad').length}
|
||||||
|
</Text>
|
||||||
|
<Text style={styles.cardMeta}>{selectedCheckupId === checkup.id ? 'Tap to collapse' : 'Tap to open'} · long hold to delete</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
|
||||||
{selectedCheckupId === checkup.id ? (
|
{selectedCheckupId === checkup.id ? (
|
||||||
|
|||||||
@@ -3,7 +3,14 @@ import { Pressable, Text, View } from 'react-native';
|
|||||||
import ItemCard from '../components/ItemCard';
|
import ItemCard from '../components/ItemCard';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
|
||||||
export default function ItemsTab({ selectedTrip, selectedTripItems, openAddItemModal, openEditItemModal, deleteItem }) {
|
export default function ItemsTab({
|
||||||
|
selectedTrip,
|
||||||
|
selectedTripItems,
|
||||||
|
openAddItemModal,
|
||||||
|
openEditItemModal,
|
||||||
|
deleteItem,
|
||||||
|
quickSetItemStatus,
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<View style={styles.sectionRow}>
|
<View style={styles.sectionRow}>
|
||||||
@@ -17,7 +24,14 @@ export default function ItemsTab({ selectedTrip, selectedTripItems, openAddItemM
|
|||||||
{selectedTripItems.length === 0 && selectedTrip ? <Text style={styles.muted}>No items yet.</Text> : null}
|
{selectedTripItems.length === 0 && selectedTrip ? <Text style={styles.muted}>No items yet.</Text> : null}
|
||||||
|
|
||||||
{selectedTripItems.map((item) => (
|
{selectedTripItems.map((item) => (
|
||||||
<ItemCard key={item.id} item={item} onEdit={openEditItemModal} onDelete={deleteItem} />
|
<ItemCard
|
||||||
|
key={item.id}
|
||||||
|
item={item}
|
||||||
|
onEdit={openEditItemModal}
|
||||||
|
onDelete={deleteItem}
|
||||||
|
onQuickPack={() => quickSetItemStatus(item.id, 'packed')}
|
||||||
|
onQuickUnpack={() => quickSetItemStatus(item.id, 'unpacked')}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
import { Image, Pressable, Text, TextInput, View } from 'react-native';
|
import { Image, KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
||||||
import Field from '../components/Field';
|
import Field from '../components/Field';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@ export default function TripsTab({
|
|||||||
tripForm,
|
tripForm,
|
||||||
updateTripForm,
|
updateTripForm,
|
||||||
pickTripImage,
|
pickTripImage,
|
||||||
|
takeTripImage,
|
||||||
templateTrip,
|
templateTrip,
|
||||||
createTrip,
|
createTrip,
|
||||||
trips,
|
trips,
|
||||||
@@ -27,12 +28,95 @@ export default function TripsTab({
|
|||||||
onInputFocus,
|
onInputFocus,
|
||||||
defaultTemplateTripId,
|
defaultTemplateTripId,
|
||||||
openDatePicker,
|
openDatePicker,
|
||||||
|
activeTripItemCount,
|
||||||
|
activeTripCheckupCount,
|
||||||
}) {
|
}) {
|
||||||
|
const [createModalVisible, setCreateModalVisible] = useState(false);
|
||||||
|
const [viewTripId, setViewTripId] = useState(null);
|
||||||
|
|
||||||
|
const activeTrip = useMemo(() => trips.find((trip) => trip.id === selectedTripId) || null, [trips, selectedTripId]);
|
||||||
|
const viewingTrip = useMemo(() => trips.find((trip) => trip.id === viewTripId) || null, [trips, viewTripId]);
|
||||||
|
|
||||||
|
function submitCreateTrip() {
|
||||||
|
const ok = createTrip();
|
||||||
|
if (ok) setCreateModalVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyTemplateFromView() {
|
||||||
|
if (!viewingTrip) return;
|
||||||
|
setTripAsTemplate(viewingTrip.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteFromView() {
|
||||||
|
if (!viewingTrip) return;
|
||||||
|
const tripId = viewingTrip.id;
|
||||||
|
setViewTripId(null);
|
||||||
|
deleteTrip(tripId);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
|
<View style={styles.sectionRow}>
|
||||||
<Text style={styles.sectionTitle}>Trips</Text>
|
<Text style={styles.sectionTitle}>Trips</Text>
|
||||||
|
<Pressable style={styles.primaryBtnTight} onPress={() => setCreateModalVisible(true)}>
|
||||||
|
<Text style={styles.primaryBtnText}>+ New Trip</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
<View style={styles.cardSoft}>
|
{activeTrip ? (
|
||||||
|
<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.cardMeta}>{activeTrip.location || 'No location'} · {activeTrip.startDate} → {activeTrip.endDate}</Text>
|
||||||
|
<Text style={styles.cardMeta}>{activeTripItemCount} items · {activeTripCheckupCount} check-ups</Text>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<Text style={styles.muted}>Create your first trip to get started.</Text>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Text style={styles.tripListTitle}>All Trips</Text>
|
||||||
|
|
||||||
|
{trips
|
||||||
|
.slice()
|
||||||
|
.sort((a, b) => b.startDate.localeCompare(a.startDate))
|
||||||
|
.map((trip) => (
|
||||||
|
<View key={trip.id} style={[styles.card, selectedTripId === trip.id && styles.cardActive]}>
|
||||||
|
<View style={styles.cardRow}>
|
||||||
|
<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>
|
||||||
|
</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={() => setViewTripId(trip.id)}>
|
||||||
|
<Text style={styles.miniBtnText}>View</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
{trip.imageUri ? <Image source={{ uri: trip.imageUri }} style={styles.previewImageSmall} /> : null}
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<Modal visible={createModalVisible} 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}>Create Trip</Text>
|
||||||
|
<Pressable onPress={() => setCreateModalVisible(false)}>
|
||||||
|
<Text style={styles.closeText}>Close</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
keyboardShouldPersistTaps="handled"
|
||||||
|
keyboardDismissMode="interactive"
|
||||||
|
contentContainerStyle={{ paddingBottom: 12 }}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
<Field label="Name">
|
<Field label="Name">
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={styles.input}
|
||||||
@@ -58,9 +142,14 @@ 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')} />
|
||||||
|
|
||||||
<Pressable style={styles.secondaryBtn} onPress={pickTripImage}>
|
<View style={styles.actionRow}>
|
||||||
<Text style={styles.secondaryBtnText}>{tripForm.imageUri ? 'Change trip image' : 'Add trip image'}</Text>
|
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={takeTripImage}>
|
||||||
|
<Text style={styles.secondaryBtnText}>Take photo</Text>
|
||||||
</Pressable>
|
</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}
|
{tripForm.imageUri ? <Image source={{ uri: tripForm.imageUri }} style={styles.previewImage} /> : null}
|
||||||
|
|
||||||
@@ -76,37 +165,52 @@ export default function TripsTab({
|
|||||||
<Text style={styles.inlineToggleText}>{tripForm.setAsDefaultTemplate ? '☑' : '☐'} Set as default template</Text>
|
<Text style={styles.inlineToggleText}>{tripForm.setAsDefaultTemplate ? '☑' : '☐'} Set as default template</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
|
||||||
<Pressable style={styles.primaryBtn} onPress={createTrip}>
|
<Pressable style={styles.primaryBtn} onPress={submitCreateTrip}>
|
||||||
<Text style={styles.primaryBtnText}>Create Trip</Text>
|
<Text style={styles.primaryBtnText}>Create Trip</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
</ScrollView>
|
||||||
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<Modal visible={!!viewingTrip} 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}>Trip View</Text>
|
||||||
|
<Pressable onPress={() => setViewTripId(null)}>
|
||||||
|
<Text style={styles.closeText}>Close</Text>
|
||||||
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{trips
|
{viewingTrip ? (
|
||||||
.slice()
|
<ScrollView
|
||||||
.sort((a, b) => b.startDate.localeCompare(a.startDate))
|
keyboardShouldPersistTaps="handled"
|
||||||
.map((trip) => (
|
keyboardDismissMode="interactive"
|
||||||
<View key={trip.id} style={[styles.card, selectedTripId === trip.id && styles.cardActive]}>
|
contentContainerStyle={{ paddingBottom: 12 }}
|
||||||
<View style={styles.cardRow}>
|
showsVerticalScrollIndicator={false}
|
||||||
<View style={styles.flex}>
|
>
|
||||||
<Text style={styles.cardTitle}>{trip.name}</Text>
|
{viewingTrip.imageUri ? <Image source={{ uri: viewingTrip.imageUri }} style={styles.previewImage} /> : null}
|
||||||
<Text style={styles.cardMeta}>{trip.location || 'No location'} · {trip.startDate} → {trip.endDate}</Text>
|
<Text style={styles.tripHeroTitle}>{viewingTrip.name}</Text>
|
||||||
<Text style={styles.cardMeta}>{defaultTemplateTripId === trip.id ? 'Default template' : ' '}</Text>
|
<Text style={styles.cardMeta}>{viewingTrip.location || 'No location'}</Text>
|
||||||
</View>
|
<Text style={styles.cardMeta}>{viewingTrip.startDate} → {viewingTrip.endDate}</Text>
|
||||||
<View style={styles.stackButtons}>
|
<Text style={styles.cardMeta}>{defaultTemplateTripId === viewingTrip.id ? 'Default template trip' : 'Not default template'}</Text>
|
||||||
<Pressable style={styles.miniBtn} onPress={() => chooseTrip(trip.id)}>
|
|
||||||
<Text style={styles.miniBtnText}>Select</Text>
|
<Pressable style={styles.secondaryBtn} onPress={applyTemplateFromView}>
|
||||||
|
<Text style={styles.secondaryBtnText}>Set as Template</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
<Pressable style={styles.miniBtn} onPress={() => setTripAsTemplate(trip.id)}>
|
|
||||||
<Text style={styles.miniBtnText}>Template</Text>
|
<Pressable style={styles.miniBtnDanger} onPress={deleteFromView}>
|
||||||
</Pressable>
|
<Text style={styles.miniBtnText}>Delete Trip</Text>
|
||||||
<Pressable style={styles.miniBtnDanger} onPress={() => deleteTrip(trip.id)}>
|
|
||||||
<Text style={styles.miniBtnText}>Delete</Text>
|
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
</ScrollView>
|
||||||
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
</View>
|
</View>
|
||||||
{trip.imageUri ? <Image source={{ uri: trip.imageUri }} style={styles.previewImageSmall} /> : null}
|
</Modal>
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,3 +23,34 @@ export function findActiveTripId(trips) {
|
|||||||
});
|
});
|
||||||
return active?.id || null;
|
return active?.id || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function findNextTripId(trips) {
|
||||||
|
const today = parseYMD(todayYMD());
|
||||||
|
if (!today) return null;
|
||||||
|
|
||||||
|
const next = trips
|
||||||
|
.map((trip) => ({ id: trip.id, start: parseYMD(trip.startDate) }))
|
||||||
|
.filter((trip) => !!trip.start && trip.start >= today)
|
||||||
|
.sort((a, b) => a.start - b.start)[0];
|
||||||
|
|
||||||
|
return next?.id || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findBestTripId(trips) {
|
||||||
|
const activeTripId = findActiveTripId(trips);
|
||||||
|
if (activeTripId) return activeTripId;
|
||||||
|
|
||||||
|
const nextTripId = findNextTripId(trips);
|
||||||
|
if (nextTripId) return nextTripId;
|
||||||
|
|
||||||
|
const latestPast = trips
|
||||||
|
.map((trip) => ({ id: trip.id, end: parseYMD(trip.endDate), start: parseYMD(trip.startDate) }))
|
||||||
|
.filter((trip) => !!trip.end || !!trip.start)
|
||||||
|
.sort((a, b) => {
|
||||||
|
const aTime = (a.end || a.start).getTime();
|
||||||
|
const bTime = (b.end || b.start).getTime();
|
||||||
|
return bTime - aTime;
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
return latestPast?.id || null;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user