Compare commits
10 Commits
luggage-li
...
luggage-li
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e45261354 | |||
| bd500674a0 | |||
| ef7e0ba7a1 | |||
| f34ffe39c0 | |||
| 30ee53fe75 | |||
| 23a5f0ebae | |||
| bdea52b7c6 | |||
| 3323d09dda | |||
| 4098573ea0 | |||
| 50460a83a4 |
21
README.md
21
README.md
@@ -2,20 +2,27 @@
|
||||
|
||||
Minimal local-first luggage management app built with Expo.
|
||||
|
||||
## MVP Implemented
|
||||
## Current Features (V2)
|
||||
|
||||
- No auth, no server, local storage only (AsyncStorage)
|
||||
- Trips with name, location, dates, optional image from gallery
|
||||
- Active trip auto-select when today is inside trip date range
|
||||
- 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
|
||||
- Default trip template (copied into new trip, not linked)
|
||||
- Luggage items with:
|
||||
- name, description, category
|
||||
- status: packed, unpacked, lost, left-behind, lent-to (+ person name)
|
||||
- placement: suitcase, backpack, with-user, other
|
||||
- optional image from gallery
|
||||
- Check-up snapshots per trip
|
||||
- Check-up history view with per-item state at that time
|
||||
- JSON export (shareable file)
|
||||
- Default trip template (copied into new trip, not linked)
|
||||
- Item create/edit via modal
|
||||
- Check-up flow as yes/no checklist with live stats (correct/bad/pending):
|
||||
- “No” opens update modal
|
||||
- fixes can be check-up-only or optionally synced to trip item list
|
||||
- Check-up history per selected trip with saved snapshots + stats
|
||||
|
||||
## Notes
|
||||
|
||||
- JSON export is removed for now.
|
||||
- Dark-mode-first minimalist UI.
|
||||
|
||||
## Run
|
||||
|
||||
|
||||
60
TODO.md
60
TODO.md
@@ -1,31 +1,41 @@
|
||||
# TODO - Luggage List
|
||||
|
||||
## In Progress
|
||||
- [x] Bootstrap project from `/root/projects/time-until`
|
||||
- [x] Set app metadata to Luggage List
|
||||
- [x] Add first MVP implementation shell
|
||||
## Stage
|
||||
Improving & Fixing Bugs (V3)
|
||||
|
||||
## MVP Feature Checklist
|
||||
- [x] Local-only storage (no auth/no backend)
|
||||
- [x] Trip creation/selection with active trip auto-selection
|
||||
- [x] Trip image support
|
||||
- [x] Luggage items CRUD with category
|
||||
- [x] Item statuses: packed, unpacked, lost, left-behind, lent-to (+ person name)
|
||||
- [x] Item placement tracking: suitcase, backpack, with-user, other
|
||||
- [x] Item image support
|
||||
- [x] Create check-up snapshots
|
||||
- [x] Check-up history per trip
|
||||
- [x] JSON export
|
||||
- [x] Default luggage list template (copy into new trip)
|
||||
## V2 Changes Requested
|
||||
- [x] Trip can be selected from everywhere (global trip picker)
|
||||
- [x] Fixed trip switching behavior for web by removing aggressive auto-reselect
|
||||
- [x] Removed trip image crop (gallery pick without editing)
|
||||
- [x] Item updates now happen in a modal
|
||||
- [x] Redesigned item cards
|
||||
- [x] Moved top nav to bottom and made it mobile-friendly
|
||||
- [x] Removed top title block
|
||||
- [x] Reworked check-up flow to yes/no checklist
|
||||
- [x] “No” now opens update modal for check-up-only changes
|
||||
- [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`
|
||||
|
||||
## Remaining
|
||||
- [x] Adjust CI/CD workflow naming and artifact naming for this project
|
||||
- [x] Validate app builds (web export smoke check)
|
||||
- [x] Polish README and commit final notes
|
||||
## Validation
|
||||
- [x] `npm install`
|
||||
- [x] `npx expo export --platform web`
|
||||
|
||||
## Progress Log
|
||||
- [x] Initial MVP scaffold and all requested core features implemented
|
||||
- [x] Added trip deletion flow and confirmation
|
||||
- [x] Updated Gitea workflows/artifacts naming for Luggage List
|
||||
- [x] Ran local web export smoke checks successfully
|
||||
- [x] Removed `eas init` from CI/manual workflows (run once locally instead)
|
||||
- [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)
|
||||
|
||||
11
app.json
11
app.json
@@ -34,6 +34,15 @@
|
||||
"eas": {
|
||||
"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."
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 32 KiB |
BIN
assets/icon.png
BIN
assets/icon.png
Binary file not shown.
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 32 KiB |
@@ -1,8 +0,0 @@
|
||||
services:
|
||||
web:
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- "45554:80"
|
||||
volumes:
|
||||
- ./entrypoint.sh:/entrypoint.sh:ro
|
||||
entrypoint: ["/bin/sh", "/entrypoint.sh"]
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
WEBROOT="/usr/share/nginx/html"
|
||||
GITEA_URL="https://gitea.reversed.dev"
|
||||
GITEA_REPO="space/time-until"
|
||||
|
||||
echo "Fetching latest release"
|
||||
|
||||
RELEASE_JSON=$(wget -qO- \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_REPO/releases/latest")
|
||||
|
||||
ASSET_URL=$(echo "$RELEASE_JSON" | sed -n 's/.*"browser_download_url" *: *"\([^"]*dist\.zip[^"]*\)".*/\1/p' | head -1)
|
||||
|
||||
if [ -z "$ASSET_URL" ]; then
|
||||
echo "ERROR: No dist.zip found in latest release"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Downloading $ASSET_URL ..."
|
||||
wget -qO /tmp/dist.zip --header="$AUTH_HEADER" "$ASSET_URL"
|
||||
|
||||
echo "Extracting to $WEBROOT ..."
|
||||
rm -rf "${WEBROOT:?}"/*
|
||||
unzip -o /tmp/dist.zip -d "$WEBROOT"
|
||||
rm /tmp/dist.zip
|
||||
|
||||
echo "Starting nginx ..."
|
||||
exec nginx -g "daemon off;"
|
||||
11
package-lock.json
generated
11
package-lock.json
generated
@@ -10,9 +10,7 @@
|
||||
"dependencies": {
|
||||
"@react-native-async-storage/async-storage": "2.2.0",
|
||||
"expo": "~54.0.33",
|
||||
"expo-file-system": "~19.0.17",
|
||||
"expo-image-picker": "~17.0.8",
|
||||
"expo-sharing": "~14.0.7",
|
||||
"expo-status-bar": "~3.0.9",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
@@ -4441,15 +4439,6 @@
|
||||
"node": ">=20.16.0"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-sharing": {
|
||||
"version": "14.0.8",
|
||||
"resolved": "https://registry.npmjs.org/expo-sharing/-/expo-sharing-14.0.8.tgz",
|
||||
"integrity": "sha512-A1pPr2iBrxypFDCWVAESk532HK+db7MFXbvO2sCV9ienaFXAk7lIBm6bkqgE6vzRd9O3RGdEGzYx80cYlc089Q==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-status-bar": {
|
||||
"version": "3.0.9",
|
||||
"resolved": "https://registry.npmjs.org/expo-status-bar/-/expo-status-bar-3.0.9.tgz",
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
"dependencies": {
|
||||
"@react-native-async-storage/async-storage": "2.2.0",
|
||||
"expo": "~54.0.33",
|
||||
"expo-file-system": "~19.0.17",
|
||||
"expo-image-picker": "~17.0.8",
|
||||
"expo-sharing": "~14.0.7",
|
||||
"expo-status-bar": "~3.0.9",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
|
||||
621
src/AppRoot.js
Normal file
621
src/AppRoot.js
Normal file
@@ -0,0 +1,621 @@
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Alert, KeyboardAvoidingView, Platform, SafeAreaView, ScrollView, StatusBar as RNStatusBar, Text, View } from 'react-native';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import * as ImagePicker from 'expo-image-picker';
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import BottomTab from './components/BottomTab';
|
||||
import TripPicker from './components/TripPicker';
|
||||
import DatePickerModal from './components/DatePickerModal';
|
||||
import ItemModal from './modals/ItemModal';
|
||||
import CheckupFixModal from './modals/CheckupFixModal';
|
||||
import TripsTab from './tabs/TripsTab';
|
||||
import ItemsTab from './tabs/ItemsTab';
|
||||
import CheckupTab from './tabs/CheckupTab';
|
||||
import HistoryTab from './tabs/HistoryTab';
|
||||
import { emptyData, STORAGE_KEY } from './constants';
|
||||
import { findActiveTripId, makeId, parseYMD, todayYMD } from './utils/date';
|
||||
import { styles } from './styles';
|
||||
|
||||
const emptyTripForm = () => ({
|
||||
name: '',
|
||||
location: '',
|
||||
startDate: todayYMD(),
|
||||
endDate: todayYMD(),
|
||||
imageUri: '',
|
||||
copyDefaultTemplate: true,
|
||||
setAsDefaultTemplate: false,
|
||||
});
|
||||
|
||||
const emptyItemForm = () => ({
|
||||
id: null,
|
||||
name: '',
|
||||
description: '',
|
||||
category: '',
|
||||
status: 'unpacked',
|
||||
placement: 'suitcase',
|
||||
lentTo: '',
|
||||
imageUri: '',
|
||||
});
|
||||
|
||||
export default function AppRoot() {
|
||||
const scrollRef = useRef(null);
|
||||
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [tab, setTab] = useState('trips');
|
||||
const [data, setData] = useState(emptyData);
|
||||
|
||||
const [selectedTripId, setSelectedTripId] = useState(null);
|
||||
const [tripForm, setTripForm] = useState(emptyTripForm());
|
||||
const [datePicker, setDatePicker] = useState({ visible: false, field: 'startDate' });
|
||||
|
||||
const [itemModalVisible, setItemModalVisible] = useState(false);
|
||||
const [itemForm, setItemForm] = useState(emptyItemForm());
|
||||
|
||||
const [checkupSession, setCheckupSession] = useState([]);
|
||||
const [checkupFixModalVisible, setCheckupFixModalVisible] = useState(false);
|
||||
const [checkupFixTargetId, setCheckupFixTargetId] = useState(null);
|
||||
const [checkupFixForm, setCheckupFixForm] = useState({
|
||||
status: 'unpacked',
|
||||
placement: 'suitcase',
|
||||
lentTo: '',
|
||||
updateMasterList: false,
|
||||
});
|
||||
|
||||
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 selectedTripItems = useMemo(() => {
|
||||
if (!selectedTripId) return [];
|
||||
return data.itemsByTrip[selectedTripId] || [];
|
||||
}, [data.itemsByTrip, selectedTripId]);
|
||||
|
||||
const selectedTripCheckups = useMemo(() => {
|
||||
if (!selectedTripId) return [];
|
||||
return (data.checkupsByTrip[selectedTripId] || []).slice().sort((a, b) => b.createdAt - a.createdAt);
|
||||
}, [data.checkupsByTrip, selectedTripId]);
|
||||
|
||||
const templateTrip = useMemo(
|
||||
() => data.trips.find((trip) => trip.id === data.defaultTemplateTripId) || null,
|
||||
[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]);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const raw = await AsyncStorage.getItem(STORAGE_KEY);
|
||||
if (raw) {
|
||||
const parsed = JSON.parse(raw);
|
||||
setData({ ...emptyData, ...parsed });
|
||||
}
|
||||
} catch {
|
||||
Alert.alert('Error', 'Could not load local data.');
|
||||
} finally {
|
||||
setLoaded(true);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!loaded) return;
|
||||
AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(data)).catch(() => {
|
||||
Alert.alert('Error', 'Could not save local data.');
|
||||
});
|
||||
}, [data, loaded]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!loaded) return;
|
||||
if (!data.trips.length) {
|
||||
setSelectedTripId(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedTripId && data.trips.some((trip) => trip.id === selectedTripId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const activeTripId = findActiveTripId(data.trips);
|
||||
setSelectedTripId(activeTripId || data.trips[0].id);
|
||||
}, [data.trips, selectedTripId, loaded]);
|
||||
|
||||
useEffect(() => {
|
||||
if (tab !== 'checkup') return;
|
||||
createFreshCheckupSession();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [selectedTripId, selectedTripItems.length]);
|
||||
|
||||
function updateTripForm(field, value) {
|
||||
setTripForm((prev) => ({ ...prev, [field]: value }));
|
||||
}
|
||||
|
||||
function updateItemForm(field, value) {
|
||||
setItemForm((prev) => ({ ...prev, [field]: value }));
|
||||
}
|
||||
|
||||
function openDatePicker(field) {
|
||||
setDatePicker({ visible: true, field });
|
||||
}
|
||||
|
||||
function onSelectDate(ymd) {
|
||||
updateTripForm(datePicker.field, ymd);
|
||||
setDatePicker((prev) => ({ ...prev, visible: false }));
|
||||
}
|
||||
|
||||
async function pickImage(onPicked) {
|
||||
const perm = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||
if (!perm.granted) {
|
||||
Alert.alert('Permission needed', 'Allow gallery access to select images.');
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await ImagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||
allowsEditing: false,
|
||||
quality: 0.85,
|
||||
});
|
||||
|
||||
if (!result.canceled && result.assets?.[0]?.uri) {
|
||||
onPicked(result.assets[0].uri);
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
if (!tripForm.name.trim()) {
|
||||
Alert.alert('Missing name', 'Trip name is required.');
|
||||
return;
|
||||
}
|
||||
|
||||
const start = parseYMD(tripForm.startDate);
|
||||
const end = parseYMD(tripForm.endDate);
|
||||
|
||||
if (!start || !end) {
|
||||
Alert.alert('Invalid dates', 'Please select valid trip dates.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (start > end) {
|
||||
Alert.alert('Invalid dates', 'Start date cannot be after end date.');
|
||||
return;
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
const tripId = makeId('trip');
|
||||
|
||||
setData((prev) => {
|
||||
const next = {
|
||||
...prev,
|
||||
trips: [
|
||||
...prev.trips,
|
||||
{
|
||||
id: tripId,
|
||||
name: tripForm.name.trim(),
|
||||
location: tripForm.location.trim(),
|
||||
startDate: tripForm.startDate,
|
||||
endDate: tripForm.endDate,
|
||||
imageUri: tripForm.imageUri,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
],
|
||||
itemsByTrip: { ...prev.itemsByTrip, [tripId]: [] },
|
||||
checkupsByTrip: { ...prev.checkupsByTrip, [tripId]: [] },
|
||||
};
|
||||
|
||||
if (tripForm.copyDefaultTemplate && prev.defaultTemplateTripId) {
|
||||
const templateItems = prev.itemsByTrip[prev.defaultTemplateTripId] || [];
|
||||
next.itemsByTrip[tripId] = templateItems.map((item) => ({
|
||||
...item,
|
||||
id: makeId('item'),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
}));
|
||||
}
|
||||
|
||||
if (tripForm.setAsDefaultTemplate) {
|
||||
next.defaultTemplateTripId = tripId;
|
||||
}
|
||||
|
||||
return next;
|
||||
});
|
||||
|
||||
setSelectedTripId(tripId);
|
||||
setTripForm(emptyTripForm());
|
||||
}
|
||||
|
||||
function setTripAsTemplate(tripId) {
|
||||
setData((prev) => ({ ...prev, defaultTemplateTripId: tripId }));
|
||||
}
|
||||
|
||||
function deleteTrip(tripId) {
|
||||
Alert.alert('Delete trip?', 'Trip items and check-up history will also be deleted.', [
|
||||
{ text: 'Cancel', style: 'cancel' },
|
||||
{
|
||||
text: 'Delete',
|
||||
style: 'destructive',
|
||||
onPress: () => {
|
||||
setData((prev) => {
|
||||
const trips = prev.trips.filter((trip) => trip.id !== tripId);
|
||||
const itemsByTrip = { ...prev.itemsByTrip };
|
||||
const checkupsByTrip = { ...prev.checkupsByTrip };
|
||||
delete itemsByTrip[tripId];
|
||||
delete checkupsByTrip[tripId];
|
||||
|
||||
return {
|
||||
...prev,
|
||||
trips,
|
||||
itemsByTrip,
|
||||
checkupsByTrip,
|
||||
defaultTemplateTripId: prev.defaultTemplateTripId === tripId ? null : prev.defaultTemplateTripId,
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
function openAddItemModal() {
|
||||
setItemForm(emptyItemForm());
|
||||
setItemModalVisible(true);
|
||||
}
|
||||
|
||||
function openEditItemModal(item) {
|
||||
setItemForm({
|
||||
id: item.id,
|
||||
name: item.name || '',
|
||||
description: item.description || '',
|
||||
category: item.category || '',
|
||||
status: item.status || 'unpacked',
|
||||
placement: item.placement || 'suitcase',
|
||||
lentTo: item.lentTo || '',
|
||||
imageUri: item.imageUri || '',
|
||||
});
|
||||
setItemModalVisible(true);
|
||||
}
|
||||
|
||||
function saveItemFromModal() {
|
||||
if (!selectedTripId) {
|
||||
Alert.alert('No trip selected', 'Please select or create a trip first.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemForm.name.trim()) {
|
||||
Alert.alert('Missing name', 'Item name is required.');
|
||||
return;
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
setData((prev) => {
|
||||
const items = prev.itemsByTrip[selectedTripId] || [];
|
||||
const existingCreatedAt = items.find((item) => item.id === itemForm.id)?.createdAt || now;
|
||||
const nextItem = {
|
||||
id: itemForm.id || makeId('item'),
|
||||
name: itemForm.name.trim(),
|
||||
description: itemForm.description.trim(),
|
||||
category: itemForm.category.trim(),
|
||||
status: itemForm.status,
|
||||
placement: itemForm.placement,
|
||||
lentTo: itemForm.status === 'lent-to' ? itemForm.lentTo.trim() : '',
|
||||
imageUri: itemForm.imageUri,
|
||||
createdAt: existingCreatedAt,
|
||||
updatedAt: now,
|
||||
};
|
||||
|
||||
const nextItems = itemForm.id
|
||||
? items.map((item) => (item.id === itemForm.id ? nextItem : item))
|
||||
: [...items, nextItem];
|
||||
|
||||
return {
|
||||
...prev,
|
||||
itemsByTrip: {
|
||||
...prev.itemsByTrip,
|
||||
[selectedTripId]: nextItems,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
setItemModalVisible(false);
|
||||
setItemForm(emptyItemForm());
|
||||
}
|
||||
|
||||
function deleteItem(itemId) {
|
||||
setData((prev) => {
|
||||
const items = prev.itemsByTrip[selectedTripId] || [];
|
||||
return {
|
||||
...prev,
|
||||
itemsByTrip: {
|
||||
...prev.itemsByTrip,
|
||||
[selectedTripId]: items.filter((item) => item.id !== itemId),
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createFreshCheckupSession() {
|
||||
if (!selectedTripItems.length) {
|
||||
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,
|
||||
result: 'pending',
|
||||
}));
|
||||
|
||||
setCheckupSession(fresh);
|
||||
}
|
||||
|
||||
function answerCheckupYes(itemId) {
|
||||
setCheckupSession((prev) =>
|
||||
prev.map((entry) => (entry.itemId === itemId ? { ...entry, confirmed: true, result: 'correct' } : 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,
|
||||
result: 'bad',
|
||||
}
|
||||
: entry
|
||||
)
|
||||
);
|
||||
|
||||
if (checkupFixForm.updateMasterList && selectedTripId) {
|
||||
setData((prev) => {
|
||||
const items = prev.itemsByTrip[selectedTripId] || [];
|
||||
return {
|
||||
...prev,
|
||||
itemsByTrip: {
|
||||
...prev.itemsByTrip,
|
||||
[selectedTripId]: items.map((item) =>
|
||||
item.id === targetId
|
||||
? {
|
||||
...item,
|
||||
status: patch.status,
|
||||
placement: patch.placement,
|
||||
lentTo: patch.lentTo,
|
||||
updatedAt: Date.now(),
|
||||
}
|
||||
: item
|
||||
),
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
setCheckupFixModalVisible(false);
|
||||
setCheckupFixTargetId(null);
|
||||
}
|
||||
|
||||
function saveCheckup() {
|
||||
if (!selectedTripId) {
|
||||
Alert.alert('No trip selected', 'Please select a trip first.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkupSession.length) {
|
||||
Alert.alert('No items', 'Add items before creating a check-up.');
|
||||
return;
|
||||
}
|
||||
|
||||
const pending = checkupSession.filter((entry) => !entry.confirmed).length;
|
||||
if (pending > 0) {
|
||||
Alert.alert('Incomplete', `Please confirm all items first (${pending} remaining).`);
|
||||
return;
|
||||
}
|
||||
|
||||
const snapshot = checkupSession.map((entry) => ({
|
||||
itemId: entry.itemId,
|
||||
name: entry.name,
|
||||
category: entry.category,
|
||||
status: entry.current.status,
|
||||
placement: entry.current.placement,
|
||||
lentTo: entry.current.status === 'lent-to' ? entry.current.lentTo : '',
|
||||
result: entry.result || 'pending',
|
||||
}));
|
||||
|
||||
setData((prev) => {
|
||||
const existing = prev.checkupsByTrip[selectedTripId] || [];
|
||||
return {
|
||||
...prev,
|
||||
checkupsByTrip: {
|
||||
...prev.checkupsByTrip,
|
||||
[selectedTripId]: [
|
||||
...existing,
|
||||
{
|
||||
id: makeId('checkup'),
|
||||
createdAt: Date.now(),
|
||||
snapshot,
|
||||
stats: {
|
||||
correct: snapshot.filter((entry) => entry.result === 'correct').length,
|
||||
bad: snapshot.filter((entry) => entry.result === 'bad').length,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Alert.alert('Saved', 'Check-up snapshot saved.');
|
||||
createFreshCheckupSession();
|
||||
}
|
||||
|
||||
function onInputFocus(event) {
|
||||
const target = event?.target;
|
||||
if (!target) return;
|
||||
setTimeout(() => {
|
||||
const scrollFn = scrollRef.current?.scrollResponderScrollNativeHandleToKeyboard;
|
||||
if (typeof scrollFn === 'function') {
|
||||
scrollFn(target, 90, true);
|
||||
}
|
||||
}, 80);
|
||||
}
|
||||
|
||||
if (!loaded) {
|
||||
return (
|
||||
<SafeAreaView style={[styles.safe, { paddingTop: topInset }]}>
|
||||
<StatusBar style="light" translucent={false} />
|
||||
<View style={styles.center}>
|
||||
<Text style={styles.muted}>Loading local data...</Text>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView style={[styles.safe, { paddingTop: topInset }]}>
|
||||
<StatusBar style="light" translucent={false} />
|
||||
|
||||
<KeyboardAvoidingView style={styles.flex} behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
|
||||
<ScrollView
|
||||
ref={scrollRef}
|
||||
contentContainerStyle={styles.content}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<TripPicker trips={data.trips} selectedTripId={selectedTripId} onChooseTrip={setSelectedTripId} />
|
||||
|
||||
{tab === 'trips' && (
|
||||
<TripsTab
|
||||
tripForm={tripForm}
|
||||
updateTripForm={updateTripForm}
|
||||
pickTripImage={() => pickImage((uri) => updateTripForm('imageUri', uri))}
|
||||
takeTripImage={() => takeImage((uri) => updateTripForm('imageUri', uri))}
|
||||
templateTrip={templateTrip}
|
||||
createTrip={createTrip}
|
||||
trips={data.trips}
|
||||
selectedTripId={selectedTripId}
|
||||
chooseTrip={setSelectedTripId}
|
||||
setTripAsTemplate={setTripAsTemplate}
|
||||
deleteTrip={deleteTrip}
|
||||
onInputFocus={onInputFocus}
|
||||
defaultTemplateTripId={data.defaultTemplateTripId}
|
||||
openDatePicker={openDatePicker}
|
||||
/>
|
||||
)}
|
||||
|
||||
{tab === 'items' && (
|
||||
<ItemsTab
|
||||
selectedTrip={selectedTrip}
|
||||
selectedTripItems={selectedTripItems}
|
||||
openAddItemModal={openAddItemModal}
|
||||
openEditItemModal={openEditItemModal}
|
||||
deleteItem={deleteItem}
|
||||
/>
|
||||
)}
|
||||
|
||||
{tab === 'checkup' && (
|
||||
<CheckupTab
|
||||
checkupSession={checkupSession}
|
||||
checkupStats={checkupStats}
|
||||
answerCheckupYes={answerCheckupYes}
|
||||
openFixModal={openFixModal}
|
||||
createFreshCheckupSession={createFreshCheckupSession}
|
||||
saveCheckup={saveCheckup}
|
||||
/>
|
||||
)}
|
||||
|
||||
{tab === 'history' && (
|
||||
<HistoryTab
|
||||
selectedTrip={selectedTrip}
|
||||
selectedTripCheckups={selectedTripCheckups}
|
||||
selectedCheckupId={selectedCheckupId}
|
||||
setSelectedCheckupId={setSelectedCheckupId}
|
||||
/>
|
||||
)}
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
|
||||
<BottomTab current={tab} onChange={setTab} />
|
||||
|
||||
<DatePickerModal
|
||||
visible={datePicker.visible}
|
||||
title={datePicker.field === 'startDate' ? 'Pick start date' : 'Pick end date'}
|
||||
value={tripForm[datePicker.field]}
|
||||
onClose={() => setDatePicker((prev) => ({ ...prev, visible: false }))}
|
||||
onSelect={onSelectDate}
|
||||
/>
|
||||
|
||||
<ItemModal
|
||||
visible={itemModalVisible}
|
||||
itemForm={itemForm}
|
||||
setItemModalVisible={setItemModalVisible}
|
||||
updateItemForm={updateItemForm}
|
||||
pickItemImage={() => pickImage((uri) => updateItemForm('imageUri', uri))}
|
||||
takeItemImage={() => takeImage((uri) => updateItemForm('imageUri', uri))}
|
||||
saveItemFromModal={saveItemFromModal}
|
||||
/>
|
||||
|
||||
<CheckupFixModal
|
||||
visible={checkupFixModalVisible}
|
||||
checkupFixForm={checkupFixForm}
|
||||
setCheckupFixForm={setCheckupFixForm}
|
||||
setCheckupFixModalVisible={setCheckupFixModalVisible}
|
||||
saveFixModal={saveFixModal}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
33
src/components/BottomTab.js
Normal file
33
src/components/BottomTab.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import React from 'react';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||
import { styles } from '../styles';
|
||||
|
||||
export default function BottomTab({ current, onChange }) {
|
||||
const tabs = [
|
||||
{ key: 'trips', label: 'Trips', icon: 'airplane-outline', iconActive: 'airplane' },
|
||||
{ key: 'items', label: 'Items', icon: 'briefcase-outline', iconActive: 'briefcase' },
|
||||
{ key: 'checkup', label: 'Check-Up', icon: 'checkmark-circle-outline', iconActive: 'checkmark-circle' },
|
||||
{ key: 'history', label: 'History', icon: 'time-outline', iconActive: 'time' },
|
||||
];
|
||||
|
||||
return (
|
||||
<View style={styles.tabBarWrap}>
|
||||
<View style={styles.tabBar}>
|
||||
{tabs.map((tab) => {
|
||||
const active = current === tab.key;
|
||||
return (
|
||||
<Pressable key={tab.key} 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>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
18
src/components/ChipGroup.js
Normal file
18
src/components/ChipGroup.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
import { styles } from '../styles';
|
||||
|
||||
export default function ChipGroup({ options, value, onChange }) {
|
||||
return (
|
||||
<View style={styles.chipGroup}>
|
||||
{options.map((option) => {
|
||||
const active = value === option;
|
||||
return (
|
||||
<Pressable key={option} style={[styles.chip, active && styles.chipActive]} onPress={() => onChange(option)}>
|
||||
<Text style={[styles.chipText, active && styles.chipTextActive]}>{option}</Text>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Text, View } from 'react-native';
|
||||
|
||||
function pad(n) {
|
||||
return String(n).padStart(2, '0');
|
||||
}
|
||||
|
||||
export default function CountdownRow({ styles, cd, accent, subText, pinkMode, numStyle, sepStyle }) {
|
||||
const outline = pinkMode
|
||||
? {
|
||||
borderColor: '#ff4fa3',
|
||||
borderWidth: 1.5,
|
||||
borderRadius: 10,
|
||||
paddingHorizontal: 8,
|
||||
}
|
||||
: {};
|
||||
|
||||
return (
|
||||
<View style={styles.countdownRow}>
|
||||
{cd.hours > 0 && (
|
||||
<>
|
||||
<View style={styles.timeBlock}>
|
||||
<Text style={[numStyle, { color: accent }, outline]}>{pad(cd.hours)}</Text>
|
||||
<Text style={[styles.countdownUnit, { color: subText }]}>HRS</Text>
|
||||
</View>
|
||||
<Text style={[sepStyle, { color: accent }]}>:</Text>
|
||||
</>
|
||||
)}
|
||||
<View style={styles.timeBlock}>
|
||||
<Text style={[numStyle, { color: accent }, outline]}>{pad(cd.minutes)}</Text>
|
||||
<Text style={[styles.countdownUnit, { color: subText }]}>MIN</Text>
|
||||
</View>
|
||||
<Text style={[sepStyle, { color: accent }]}>:</Text>
|
||||
<View style={styles.timeBlock}>
|
||||
<Text style={[numStyle, { color: accent }, outline]}>{pad(cd.seconds)}</Text>
|
||||
<Text style={[styles.countdownUnit, { color: subText }]}>SEC</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
93
src/components/DatePickerModal.js
Normal file
93
src/components/DatePickerModal.js
Normal file
@@ -0,0 +1,93 @@
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { Modal, Pressable, Text, View } from 'react-native';
|
||||
import { styles } from '../styles';
|
||||
import { todayYMD } from '../utils/date';
|
||||
|
||||
const WEEKDAYS = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
|
||||
|
||||
function toYMD(date) {
|
||||
const y = date.getFullYear();
|
||||
const m = `${date.getMonth() + 1}`.padStart(2, '0');
|
||||
const d = `${date.getDate()}`.padStart(2, '0');
|
||||
return `${y}-${m}-${d}`;
|
||||
}
|
||||
|
||||
function parseFromYMD(value) {
|
||||
if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return new Date();
|
||||
const date = new Date(`${value}T00:00:00`);
|
||||
return Number.isNaN(date.getTime()) ? new Date() : date;
|
||||
}
|
||||
|
||||
function monthLabel(date) {
|
||||
return date.toLocaleDateString(undefined, { month: 'long', year: 'numeric' });
|
||||
}
|
||||
|
||||
function buildMonthGrid(viewDate) {
|
||||
const first = new Date(viewDate.getFullYear(), viewDate.getMonth(), 1);
|
||||
const startWeekday = (first.getDay() + 6) % 7;
|
||||
const daysInMonth = new Date(viewDate.getFullYear(), viewDate.getMonth() + 1, 0).getDate();
|
||||
|
||||
const cells = [];
|
||||
for (let i = 0; i < startWeekday; i += 1) cells.push(null);
|
||||
for (let day = 1; day <= daysInMonth; day += 1) {
|
||||
cells.push(new Date(viewDate.getFullYear(), viewDate.getMonth(), day));
|
||||
}
|
||||
|
||||
while (cells.length % 7 !== 0) cells.push(null);
|
||||
return cells;
|
||||
}
|
||||
|
||||
export default function DatePickerModal({ visible, value, onClose, onSelect, title = 'Pick date' }) {
|
||||
const [viewDate, setViewDate] = useState(parseFromYMD(value || todayYMD()));
|
||||
|
||||
const grid = useMemo(() => buildMonthGrid(viewDate), [viewDate]);
|
||||
const selected = value || todayYMD();
|
||||
|
||||
const goMonth = (diff) => {
|
||||
setViewDate((prev) => new Date(prev.getFullYear(), prev.getMonth() + diff, 1));
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal visible={visible} transparent animationType="fade" onRequestClose={onClose}>
|
||||
<View style={styles.dateModalBackdrop}>
|
||||
<View style={styles.dateModalCard}>
|
||||
<View style={styles.sectionRow}>
|
||||
<Text style={styles.sectionTitle}>{title}</Text>
|
||||
<Pressable onPress={onClose}>
|
||||
<Text style={styles.closeText}>Close</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
<View style={styles.calendarHeader}>
|
||||
<Pressable style={styles.calendarNavBtn} onPress={() => goMonth(-1)}>
|
||||
<Text style={styles.calendarNavText}>‹</Text>
|
||||
</Pressable>
|
||||
<Text style={styles.calendarMonthText}>{monthLabel(viewDate)}</Text>
|
||||
<Pressable style={styles.calendarNavBtn} onPress={() => goMonth(1)}>
|
||||
<Text style={styles.calendarNavText}>›</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
<View style={styles.calendarWeekRow}>
|
||||
{WEEKDAYS.map((w) => (
|
||||
<Text key={w} style={styles.calendarWeekday}>{w}</Text>
|
||||
))}
|
||||
</View>
|
||||
|
||||
<View style={styles.calendarGrid}>
|
||||
{grid.map((cell, idx) => {
|
||||
if (!cell) return <View key={`empty-${idx}`} style={styles.calendarCell} />;
|
||||
const ymd = toYMD(cell);
|
||||
const isSelected = ymd === selected;
|
||||
return (
|
||||
<Pressable key={ymd} style={[styles.calendarCell, isSelected && styles.calendarCellActive]} onPress={() => onSelect(ymd)}>
|
||||
<Text style={[styles.calendarCellText, isSelected && styles.calendarCellTextActive]}>{cell.getDate()}</Text>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
12
src/components/Field.js
Normal file
12
src/components/Field.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import { Text, View } from 'react-native';
|
||||
import { styles } from '../styles';
|
||||
|
||||
export default function Field({ label, children }) {
|
||||
return (
|
||||
<View style={styles.fieldWrap}>
|
||||
<Text style={styles.label}>{label}</Text>
|
||||
{children}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
36
src/components/ItemCard.js
Normal file
36
src/components/ItemCard.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import { Image, Pressable, Text, View } from 'react-native';
|
||||
import { STATUS_COLORS } from '../constants';
|
||||
import { styles } from '../styles';
|
||||
|
||||
function statusAccent(status) {
|
||||
return STATUS_COLORS[status] || '#64748b';
|
||||
}
|
||||
|
||||
export default function ItemCard({ item, onEdit, onDelete }) {
|
||||
return (
|
||||
<View style={styles.itemCard}>
|
||||
<View style={[styles.itemAccent, { backgroundColor: statusAccent(item.status) }]} />
|
||||
<View style={styles.itemMain}>
|
||||
<View style={styles.cardRow}>
|
||||
<View style={styles.flex}>
|
||||
<Text style={styles.itemTitle}>{item.name}</Text>
|
||||
<Text style={styles.itemMeta}>{item.category || 'uncategorized'} · {item.status}</Text>
|
||||
<Text style={styles.itemMeta}>Location: {item.placement}</Text>
|
||||
{item.status === 'lent-to' && !!item.lentTo ? <Text style={styles.itemMeta}>Lent to: {item.lentTo}</Text> : null}
|
||||
{!!item.description ? <Text style={styles.itemMeta}>{item.description}</Text> : null}
|
||||
</View>
|
||||
<View style={styles.stackButtons}>
|
||||
<Pressable style={styles.miniBtn} onPress={() => onEdit(item)}>
|
||||
<Text style={styles.miniBtnText}>Edit</Text>
|
||||
</Pressable>
|
||||
<Pressable style={styles.miniBtnDanger} onPress={() => onDelete(item.id)}>
|
||||
<Text style={styles.miniBtnText}>Delete</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
{item.imageUri ? <Image source={{ uri: item.imageUri }} style={styles.previewImageSmall} /> : null}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Platform, Text, TouchableOpacity, View } from 'react-native';
|
||||
|
||||
export default function TopControls({
|
||||
styles,
|
||||
accent,
|
||||
pink,
|
||||
darkMode,
|
||||
pinkMode,
|
||||
isFullscreen,
|
||||
showBackToMenu,
|
||||
showFocus,
|
||||
onBackToMenu,
|
||||
onToggleDark,
|
||||
onTogglePink,
|
||||
onToggleFullscreen,
|
||||
onFocus,
|
||||
}) {
|
||||
return (
|
||||
<View style={styles.topRow}>
|
||||
{showBackToMenu && (
|
||||
<TouchableOpacity
|
||||
style={[styles.backMenuBtn, { borderColor: accent, backgroundColor: `${accent}1f` }]}
|
||||
onPress={onBackToMenu}
|
||||
>
|
||||
<Text style={[styles.toggleText, { color: accent }]}>Back To Menu</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
|
||||
<View style={styles.toggleRow}>
|
||||
<TouchableOpacity
|
||||
style={[styles.toggleBtn, { borderColor: accent, backgroundColor: `${accent}1f` }]}
|
||||
onPress={onToggleDark}
|
||||
>
|
||||
<Text style={[styles.toggleText, { color: accent }]}>{darkMode ? 'Light' : 'Dark'}</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
styles.toggleBtn,
|
||||
{ borderColor: pink, backgroundColor: pinkMode ? `${pink}33` : 'transparent' },
|
||||
]}
|
||||
onPress={onTogglePink}
|
||||
>
|
||||
<Text style={[styles.toggleText, { color: pink }]}>Pink</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
{Platform.OS === 'web' && (
|
||||
<TouchableOpacity
|
||||
style={[styles.toggleBtn, { borderColor: accent, backgroundColor: `${accent}14` }]}
|
||||
onPress={onToggleFullscreen}
|
||||
>
|
||||
<Text style={[styles.toggleText, { color: accent }]}>
|
||||
{isFullscreen ? 'Exit Full' : 'Fullscreen'}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
|
||||
{showFocus && (
|
||||
<TouchableOpacity
|
||||
style={[styles.toggleBtn, { borderColor: accent, backgroundColor: `${accent}1f` }]}
|
||||
onPress={onFocus}
|
||||
>
|
||||
<Text style={[styles.toggleText, { color: accent }]}>Focus</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
28
src/components/TripPicker.js
Normal file
28
src/components/TripPicker.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
import { Pressable, ScrollView, Text, View } from 'react-native';
|
||||
import { styles } from '../styles';
|
||||
|
||||
export default function TripPicker({ trips, selectedTripId, onChooseTrip }) {
|
||||
return (
|
||||
<View style={styles.tripPickerWrap}>
|
||||
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.tripChipScroll}>
|
||||
{trips.length ? (
|
||||
trips
|
||||
.slice()
|
||||
.sort((a, b) => b.startDate.localeCompare(a.startDate))
|
||||
.map((trip) => {
|
||||
const active = selectedTripId === trip.id;
|
||||
return (
|
||||
<Pressable key={trip.id} style={[styles.tripChip, active && styles.tripChipActive]} onPress={() => onChooseTrip(trip.id)}>
|
||||
<Text style={[styles.tripChipText, active && styles.tripChipTextActive]}>{trip.name}</Text>
|
||||
<Text style={[styles.tripChipSub, active && styles.tripChipSubActive]}>{trip.startDate}</Text>
|
||||
</Pressable>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<Text style={styles.muted}>Create your first trip to start.</Text>
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
20
src/constants.js
Normal file
20
src/constants.js
Normal file
@@ -0,0 +1,20 @@
|
||||
export const STORAGE_KEY = 'luggage-list:v2';
|
||||
export const TAB_BAR_HEIGHT = 72;
|
||||
|
||||
export const ITEM_STATUSES = ['packed', 'unpacked', 'lost', 'left-behind', 'lent-to'];
|
||||
export const ITEM_PLACEMENTS = ['suitcase', 'backpack', 'with-user', 'other'];
|
||||
|
||||
export const STATUS_COLORS = {
|
||||
packed: '#22c55e',
|
||||
unpacked: '#64748b',
|
||||
lost: '#ef4444',
|
||||
'left-behind': '#f59e0b',
|
||||
'lent-to': '#8b5cf6',
|
||||
};
|
||||
|
||||
export const emptyData = {
|
||||
trips: [],
|
||||
itemsByTrip: {},
|
||||
checkupsByTrip: {},
|
||||
defaultTemplateTripId: null,
|
||||
};
|
||||
79
src/modals/CheckupFixModal.js
Normal file
79
src/modals/CheckupFixModal.js
Normal file
@@ -0,0 +1,79 @@
|
||||
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 CheckupFixModal({
|
||||
visible,
|
||||
checkupFixForm,
|
||||
setCheckupFixForm,
|
||||
setCheckupFixModalVisible,
|
||||
saveFixModal,
|
||||
}) {
|
||||
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}>Update for this Check-Up</Text>
|
||||
<Pressable onPress={() => setCheckupFixModalVisible(false)}>
|
||||
<Text style={styles.closeText}>Close</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
<ScrollView
|
||||
keyboardShouldPersistTaps="handled"
|
||||
keyboardDismissMode="interactive"
|
||||
contentContainerStyle={{ paddingBottom: 12 }}
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<Field label="Status">
|
||||
<ChipGroup
|
||||
options={ITEM_STATUSES}
|
||||
value={checkupFixForm.status}
|
||||
onChange={(v) => setCheckupFixForm((prev) => ({ ...prev, status: v }))}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field label="Placement">
|
||||
<ChipGroup
|
||||
options={ITEM_PLACEMENTS}
|
||||
value={checkupFixForm.placement}
|
||||
onChange={(v) => setCheckupFixForm((prev) => ({ ...prev, placement: v }))}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
{checkupFixForm.status === 'lent-to' ? (
|
||||
<Field label="Lent to">
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
value={checkupFixForm.lentTo}
|
||||
onChangeText={(v) => setCheckupFixForm((prev) => ({ ...prev, lentTo: v }))}
|
||||
placeholder="Person name"
|
||||
placeholderTextColor="#6b7280"
|
||||
/>
|
||||
</Field>
|
||||
) : null}
|
||||
|
||||
<Pressable
|
||||
style={styles.inlineToggle}
|
||||
onPress={() => setCheckupFixForm((prev) => ({ ...prev, updateMasterList: !prev.updateMasterList }))}
|
||||
>
|
||||
<Text style={styles.inlineToggleText}>
|
||||
{checkupFixForm.updateMasterList ? '☑' : '☐'} Also update item in trip list
|
||||
</Text>
|
||||
</Pressable>
|
||||
|
||||
<Pressable style={styles.primaryBtn} onPress={saveFixModal}>
|
||||
<Text style={styles.primaryBtnText}>Save</Text>
|
||||
</Pressable>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</View>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
104
src/modals/ItemModal.js
Normal file
104
src/modals/ItemModal.js
Normal file
@@ -0,0 +1,104 @@
|
||||
import React from 'react';
|
||||
import { Image, 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 ItemModal({
|
||||
visible,
|
||||
itemForm,
|
||||
setItemModalVisible,
|
||||
updateItemForm,
|
||||
pickItemImage,
|
||||
takeItemImage,
|
||||
saveItemFromModal,
|
||||
}) {
|
||||
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}>{itemForm.id ? 'Update Item' : 'Add Item'}</Text>
|
||||
<Pressable onPress={() => setItemModalVisible(false)}>
|
||||
<Text style={styles.closeText}>Close</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
<ScrollView
|
||||
keyboardShouldPersistTaps="handled"
|
||||
keyboardDismissMode="interactive"
|
||||
contentContainerStyle={{ paddingBottom: 12 }}
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<Field label="Name">
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
value={itemForm.name}
|
||||
onChangeText={(v) => updateItemForm('name', v)}
|
||||
placeholder="Toothbrush"
|
||||
placeholderTextColor="#6b7280"
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field label="Description">
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
value={itemForm.description}
|
||||
onChangeText={(v) => updateItemForm('description', v)}
|
||||
placeholder="Optional"
|
||||
placeholderTextColor="#6b7280"
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field label="Category">
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
value={itemForm.category}
|
||||
onChangeText={(v) => updateItemForm('category', v)}
|
||||
placeholder="toiletries"
|
||||
placeholderTextColor="#6b7280"
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field label="Status">
|
||||
<ChipGroup options={ITEM_STATUSES} value={itemForm.status} onChange={(v) => updateItemForm('status', v)} />
|
||||
</Field>
|
||||
|
||||
<Field label="Placement">
|
||||
<ChipGroup options={ITEM_PLACEMENTS} value={itemForm.placement} onChange={(v) => updateItemForm('placement', v)} />
|
||||
</Field>
|
||||
|
||||
{itemForm.status === 'lent-to' ? (
|
||||
<Field label="Lent to">
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
value={itemForm.lentTo}
|
||||
onChangeText={(v) => updateItemForm('lentTo', v)}
|
||||
placeholder="Person name"
|
||||
placeholderTextColor="#6b7280"
|
||||
/>
|
||||
</Field>
|
||||
) : null}
|
||||
|
||||
<View style={styles.actionRow}>
|
||||
<Pressable style={[styles.secondaryBtnTight, styles.flex]} onPress={takeItemImage}>
|
||||
<Text style={styles.secondaryBtnText}>Take photo</Text>
|
||||
</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} />}
|
||||
|
||||
<Pressable style={styles.primaryBtn} onPress={saveItemFromModal}>
|
||||
<Text style={styles.primaryBtnText}>{itemForm.id ? 'Save Changes' : 'Add Item'}</Text>
|
||||
</Pressable>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</View>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
import React from 'react';
|
||||
import { StatusBar, Text, TouchableOpacity, View } from 'react-native';
|
||||
import CountdownRow from '../components/CountdownRow';
|
||||
|
||||
export default function FocusScreen({
|
||||
styles,
|
||||
theme,
|
||||
screen,
|
||||
pinkMode,
|
||||
tuIsOver,
|
||||
tuCountdown,
|
||||
targetTime,
|
||||
timerDone,
|
||||
timerHr,
|
||||
timerMin,
|
||||
timerSec,
|
||||
onShowUI,
|
||||
}) {
|
||||
const pinkOutlineText = pinkMode
|
||||
? {
|
||||
borderColor: theme.pink,
|
||||
borderWidth: 2,
|
||||
borderRadius: 12,
|
||||
paddingHorizontal: 20,
|
||||
paddingVertical: 8,
|
||||
}
|
||||
: {};
|
||||
|
||||
let focusContent = null;
|
||||
|
||||
if (screen === 'timeuntil') {
|
||||
focusContent = tuIsOver ? (
|
||||
<Text style={[styles.overText, styles.focusOverText, { color: pinkMode ? theme.pink : theme.danger }, pinkOutlineText]}>
|
||||
Time's Up!
|
||||
</Text>
|
||||
) : tuCountdown ? (
|
||||
<View style={styles.focusCountdown}>
|
||||
<Text style={[styles.focusLabel, { color: theme.subText }]}>
|
||||
until {targetTime?.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
|
||||
</Text>
|
||||
<CountdownRow
|
||||
styles={styles}
|
||||
cd={tuCountdown}
|
||||
accent={theme.accent}
|
||||
subText={theme.subText}
|
||||
pinkMode={pinkMode}
|
||||
numStyle={styles.focusNum}
|
||||
sepStyle={styles.focusSep}
|
||||
/>
|
||||
</View>
|
||||
) : (
|
||||
<Text style={[styles.placeholder, { color: theme.subText }]}>No timer set</Text>
|
||||
);
|
||||
}
|
||||
|
||||
if (screen === 'timer') {
|
||||
focusContent = timerDone ? (
|
||||
<Text style={[styles.overText, styles.focusOverText, { color: pinkMode ? theme.pink : theme.danger }, pinkOutlineText]}>
|
||||
Done!
|
||||
</Text>
|
||||
) : (
|
||||
<View style={styles.focusCountdown}>
|
||||
<Text style={[styles.focusLabel, { color: theme.subText }]}>TIMER</Text>
|
||||
<CountdownRow
|
||||
styles={styles}
|
||||
cd={{ hours: timerHr, minutes: timerMin, seconds: timerSec }}
|
||||
accent={theme.accent}
|
||||
subText={theme.subText}
|
||||
pinkMode={pinkMode}
|
||||
numStyle={styles.focusNum}
|
||||
sepStyle={styles.focusSep}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={[styles.root, styles.focusRoot, { backgroundColor: theme.bg }]}>
|
||||
<StatusBar hidden />
|
||||
{focusContent}
|
||||
<TouchableOpacity style={[styles.focusExitBtn, { borderColor: theme.accent }]} onPress={onShowUI}>
|
||||
<Text style={[styles.focusExitText, { color: theme.accent }]}>Show UI</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ScrollView, Text, TouchableOpacity, View, Image } from 'react-native';
|
||||
import TopControls from '../components/TopControls';
|
||||
|
||||
export default function HomeScreen({
|
||||
styles,
|
||||
theme,
|
||||
now,
|
||||
pinkMode,
|
||||
darkMode,
|
||||
isFullscreen,
|
||||
onToggleDark,
|
||||
onTogglePink,
|
||||
onToggleFullscreen,
|
||||
onSelectTimeUntil,
|
||||
onSelectTimer,
|
||||
}) {
|
||||
return (
|
||||
<View style={[styles.root, { backgroundColor: theme.bg }]}>
|
||||
<ScrollView contentContainerStyle={styles.scroll} keyboardShouldPersistTaps="handled">
|
||||
<Image
|
||||
source={require('../../assets/icon.png')}
|
||||
style={[styles.logo, pinkMode && { borderColor: theme.accent, borderWidth: 2 }]}
|
||||
/>
|
||||
<Text
|
||||
style={[
|
||||
styles.title,
|
||||
{ color: theme.accent },
|
||||
pinkMode && {
|
||||
borderColor: theme.accent,
|
||||
borderWidth: 2,
|
||||
borderRadius: 10,
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 4,
|
||||
},
|
||||
]}
|
||||
>
|
||||
Time Until
|
||||
</Text>
|
||||
|
||||
<TopControls
|
||||
styles={styles}
|
||||
accent={theme.accent}
|
||||
pink={theme.pink}
|
||||
darkMode={darkMode}
|
||||
pinkMode={pinkMode}
|
||||
isFullscreen={isFullscreen}
|
||||
showBackToMenu={false}
|
||||
showFocus={false}
|
||||
onBackToMenu={() => {}}
|
||||
onToggleDark={onToggleDark}
|
||||
onTogglePink={onTogglePink}
|
||||
onToggleFullscreen={onToggleFullscreen}
|
||||
onFocus={() => {}}
|
||||
/>
|
||||
|
||||
<Text style={[styles.modeSelectLabel, { color: theme.subText }]}>SELECT MODE</Text>
|
||||
|
||||
<TouchableOpacity
|
||||
style={[styles.modeCard, { backgroundColor: theme.cardBg, borderColor: theme.accent }]}
|
||||
onPress={onSelectTimeUntil}
|
||||
activeOpacity={0.75}
|
||||
>
|
||||
<Text style={[styles.modeTitle, { color: theme.accent }]}>Mode 1: Time Until</Text>
|
||||
<Text style={[styles.modeDesc, { color: theme.subText }]}>
|
||||
Set a target clock time and count down to it
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity
|
||||
style={[styles.modeCard, { backgroundColor: theme.cardBg, borderColor: theme.border }]}
|
||||
onPress={onSelectTimer}
|
||||
activeOpacity={0.75}
|
||||
>
|
||||
<Text style={[styles.modeTitle, { color: theme.accent }]}>Mode 2: Timer</Text>
|
||||
<Text style={[styles.modeDesc, { color: theme.subText }]}>
|
||||
Set duration in hours, minutes, and seconds
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<Text style={[styles.clock, { color: theme.subText, marginTop: 32 }]}>
|
||||
{now.toLocaleTimeString([], {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
})}
|
||||
</Text>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import CountdownRow from '../components/CountdownRow';
|
||||
import TopControls from '../components/TopControls';
|
||||
|
||||
export default function TimeUntilScreen({
|
||||
styles,
|
||||
theme,
|
||||
now,
|
||||
darkMode,
|
||||
pinkMode,
|
||||
isFullscreen,
|
||||
targetTime,
|
||||
tuHour,
|
||||
tuMinute,
|
||||
tuIsOver,
|
||||
tuCountdown,
|
||||
onChangeHour,
|
||||
onChangeMinute,
|
||||
onSetTimer,
|
||||
onResetTimer,
|
||||
onBackToMenu,
|
||||
onToggleDark,
|
||||
onTogglePink,
|
||||
onToggleFullscreen,
|
||||
onFocus,
|
||||
}) {
|
||||
const isCountingDown = Boolean(tuCountdown) && !tuIsOver;
|
||||
|
||||
const pinkOutlineText = pinkMode
|
||||
? {
|
||||
borderColor: theme.pink,
|
||||
borderWidth: 2,
|
||||
borderRadius: 12,
|
||||
paddingHorizontal: 20,
|
||||
paddingVertical: 8,
|
||||
}
|
||||
: {};
|
||||
|
||||
return (
|
||||
<View style={[styles.root, { backgroundColor: theme.bg }]}>
|
||||
<ScrollView contentContainerStyle={styles.scroll} keyboardShouldPersistTaps="handled">
|
||||
<Text
|
||||
style={[
|
||||
styles.title,
|
||||
{ color: theme.accent },
|
||||
pinkMode && {
|
||||
borderColor: theme.accent,
|
||||
borderWidth: 2,
|
||||
borderRadius: 10,
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 4,
|
||||
},
|
||||
]}
|
||||
>
|
||||
Time Until
|
||||
</Text>
|
||||
|
||||
<TopControls
|
||||
styles={styles}
|
||||
accent={theme.accent}
|
||||
pink={theme.pink}
|
||||
darkMode={darkMode}
|
||||
pinkMode={pinkMode}
|
||||
isFullscreen={isFullscreen}
|
||||
showBackToMenu
|
||||
showFocus={targetTime !== null || tuIsOver}
|
||||
onBackToMenu={onBackToMenu}
|
||||
onToggleDark={onToggleDark}
|
||||
onTogglePink={onTogglePink}
|
||||
onToggleFullscreen={onToggleFullscreen}
|
||||
onFocus={onFocus}
|
||||
/>
|
||||
|
||||
<View style={[styles.card, { backgroundColor: theme.cardBg, borderColor: theme.border }]}>
|
||||
{!isCountingDown && (
|
||||
<>
|
||||
<Text style={[styles.inputLabel, { color: theme.subText }]}>Set target time (24h)</Text>
|
||||
<View style={styles.inputRow}>
|
||||
<TextInput
|
||||
style={[
|
||||
styles.timeInput,
|
||||
{ color: theme.text, borderColor: theme.accent, backgroundColor: theme.inputBg },
|
||||
]}
|
||||
placeholder="HH"
|
||||
placeholderTextColor={darkMode ? '#5a6886' : '#98a1ba'}
|
||||
value={tuHour}
|
||||
onChangeText={onChangeHour}
|
||||
keyboardType="numeric"
|
||||
maxLength={2}
|
||||
/>
|
||||
<Text style={[styles.colon, { color: theme.accent }]}>:</Text>
|
||||
<TextInput
|
||||
style={[
|
||||
styles.timeInput,
|
||||
{ color: theme.text, borderColor: theme.accent, backgroundColor: theme.inputBg },
|
||||
]}
|
||||
placeholder="MM"
|
||||
placeholderTextColor={darkMode ? '#5a6886' : '#98a1ba'}
|
||||
value={tuMinute}
|
||||
onChangeText={onChangeMinute}
|
||||
keyboardType="numeric"
|
||||
maxLength={2}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.btnRow}>
|
||||
<TouchableOpacity style={[styles.setBtn, { backgroundColor: theme.accent }]} onPress={onSetTimer}>
|
||||
<Text style={styles.setBtnText}>Set Timer</Text>
|
||||
</TouchableOpacity>
|
||||
{targetTime && (
|
||||
<TouchableOpacity
|
||||
style={[styles.resetBtn, { borderColor: theme.accent }]}
|
||||
onPress={onResetTimer}
|
||||
>
|
||||
<Text style={[styles.resetBtnText, { color: theme.accent }]}>Reset</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
|
||||
{isCountingDown && targetTime && (
|
||||
<View style={styles.btnRow}>
|
||||
<TouchableOpacity
|
||||
style={[styles.resetBtn, { borderColor: theme.accent }]}
|
||||
onPress={onResetTimer}
|
||||
>
|
||||
<Text style={[styles.resetBtnText, { color: theme.accent }]}>Reset</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{tuIsOver ? (
|
||||
<View style={styles.overContainer}>
|
||||
<Text style={[styles.overText, { color: pinkMode ? theme.pink : theme.danger }, pinkOutlineText]}>
|
||||
Time's Up!
|
||||
</Text>
|
||||
<Text style={[styles.overSub, { color: theme.subText }]}>
|
||||
{targetTime?.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} has been reached
|
||||
</Text>
|
||||
</View>
|
||||
) : tuCountdown ? (
|
||||
<View style={styles.countdownContainer}>
|
||||
<Text style={[styles.countdownLabel, { color: theme.subText }]}>
|
||||
until {targetTime?.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
|
||||
</Text>
|
||||
<CountdownRow
|
||||
styles={styles}
|
||||
cd={tuCountdown}
|
||||
accent={theme.accent}
|
||||
subText={theme.subText}
|
||||
pinkMode={pinkMode}
|
||||
numStyle={styles.countdownNum}
|
||||
sepStyle={styles.sep}
|
||||
/>
|
||||
</View>
|
||||
) : (
|
||||
<Text style={[styles.placeholder, { color: theme.subText }]}>Enter a time above to start counting down</Text>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<Text style={[styles.clock, { color: theme.subText }]}>
|
||||
{now.toLocaleTimeString([], {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
})}
|
||||
</Text>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import CountdownRow from '../components/CountdownRow';
|
||||
import TopControls from '../components/TopControls';
|
||||
|
||||
export default function TimerScreen({
|
||||
styles,
|
||||
theme,
|
||||
now,
|
||||
darkMode,
|
||||
pinkMode,
|
||||
isFullscreen,
|
||||
timerRunning,
|
||||
timerDone,
|
||||
timerRemaining,
|
||||
timerHInput,
|
||||
timerMInput,
|
||||
timerSInput,
|
||||
timerHr,
|
||||
timerMin,
|
||||
timerSec,
|
||||
onChangeH,
|
||||
onChangeM,
|
||||
onChangeS,
|
||||
onStart,
|
||||
onPause,
|
||||
onResume,
|
||||
onReset,
|
||||
onBackToMenu,
|
||||
onToggleDark,
|
||||
onTogglePink,
|
||||
onToggleFullscreen,
|
||||
onFocus,
|
||||
}) {
|
||||
const timerActive = timerRunning || timerRemaining > 0 || timerDone;
|
||||
const isCountingDown = timerRemaining > 0;
|
||||
const pinkOutlineText = pinkMode
|
||||
? {
|
||||
borderColor: theme.pink,
|
||||
borderWidth: 2,
|
||||
borderRadius: 12,
|
||||
paddingHorizontal: 20,
|
||||
paddingVertical: 8,
|
||||
}
|
||||
: {};
|
||||
|
||||
return (
|
||||
<View style={[styles.root, { backgroundColor: theme.bg }]}>
|
||||
<ScrollView contentContainerStyle={styles.scroll} keyboardShouldPersistTaps="handled">
|
||||
<Text
|
||||
style={[
|
||||
styles.title,
|
||||
{ color: theme.accent },
|
||||
pinkMode && {
|
||||
borderColor: theme.accent,
|
||||
borderWidth: 2,
|
||||
borderRadius: 10,
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 4,
|
||||
},
|
||||
]}
|
||||
>
|
||||
Timer
|
||||
</Text>
|
||||
|
||||
<TopControls
|
||||
styles={styles}
|
||||
accent={theme.accent}
|
||||
pink={theme.pink}
|
||||
darkMode={darkMode}
|
||||
pinkMode={pinkMode}
|
||||
isFullscreen={isFullscreen}
|
||||
showBackToMenu
|
||||
showFocus={timerActive}
|
||||
onBackToMenu={onBackToMenu}
|
||||
onToggleDark={onToggleDark}
|
||||
onTogglePink={onTogglePink}
|
||||
onToggleFullscreen={onToggleFullscreen}
|
||||
onFocus={onFocus}
|
||||
/>
|
||||
|
||||
<View style={[styles.card, { backgroundColor: theme.cardBg, borderColor: theme.border }]}>
|
||||
{!isCountingDown && !timerDone ? (
|
||||
<>
|
||||
<Text style={[styles.inputLabel, { color: theme.subText }]}>Set duration</Text>
|
||||
<View style={styles.inputRow}>
|
||||
<View style={styles.timerInputGroup}>
|
||||
<TextInput
|
||||
style={[
|
||||
styles.timeInput,
|
||||
{ color: theme.text, borderColor: theme.accent, backgroundColor: theme.inputBg },
|
||||
]}
|
||||
placeholder="00"
|
||||
placeholderTextColor={darkMode ? '#5a6886' : '#98a1ba'}
|
||||
value={timerHInput}
|
||||
onChangeText={onChangeH}
|
||||
keyboardType="numeric"
|
||||
maxLength={2}
|
||||
/>
|
||||
<Text style={[styles.inputUnit, { color: theme.subText }]}>HRS</Text>
|
||||
</View>
|
||||
<Text style={[styles.colon, { color: theme.accent }]}>:</Text>
|
||||
<View style={styles.timerInputGroup}>
|
||||
<TextInput
|
||||
style={[
|
||||
styles.timeInput,
|
||||
{ color: theme.text, borderColor: theme.accent, backgroundColor: theme.inputBg },
|
||||
]}
|
||||
placeholder="00"
|
||||
placeholderTextColor={darkMode ? '#5a6886' : '#98a1ba'}
|
||||
value={timerMInput}
|
||||
onChangeText={onChangeM}
|
||||
keyboardType="numeric"
|
||||
maxLength={2}
|
||||
/>
|
||||
<Text style={[styles.inputUnit, { color: theme.subText }]}>MIN</Text>
|
||||
</View>
|
||||
<Text style={[styles.colon, { color: theme.accent }]}>:</Text>
|
||||
<View style={styles.timerInputGroup}>
|
||||
<TextInput
|
||||
style={[
|
||||
styles.timeInput,
|
||||
{ color: theme.text, borderColor: theme.accent, backgroundColor: theme.inputBg },
|
||||
]}
|
||||
placeholder="00"
|
||||
placeholderTextColor={darkMode ? '#5a6886' : '#98a1ba'}
|
||||
value={timerSInput}
|
||||
onChangeText={onChangeS}
|
||||
keyboardType="numeric"
|
||||
maxLength={2}
|
||||
/>
|
||||
<Text style={[styles.inputUnit, { color: theme.subText }]}>SEC</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<TouchableOpacity style={[styles.setBtn, { backgroundColor: theme.accent }]} onPress={onStart}>
|
||||
<Text style={styles.setBtnText}>Start</Text>
|
||||
</TouchableOpacity>
|
||||
</>
|
||||
) : timerDone ? (
|
||||
<View style={styles.overContainer}>
|
||||
<Text style={[styles.overText, { color: pinkMode ? theme.pink : theme.danger }, pinkOutlineText]}>
|
||||
Done!
|
||||
</Text>
|
||||
<TouchableOpacity
|
||||
style={[styles.setBtn, { backgroundColor: theme.accent, marginTop: 20 }]}
|
||||
onPress={onReset}
|
||||
>
|
||||
<Text style={styles.setBtnText}>New Timer</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
) : (
|
||||
<View style={styles.countdownContainer}>
|
||||
<View>
|
||||
<CountdownRow
|
||||
styles={styles}
|
||||
cd={{ hours: timerHr, minutes: timerMin, seconds: timerSec }}
|
||||
accent={theme.accent}
|
||||
subText={theme.subText}
|
||||
pinkMode={pinkMode}
|
||||
numStyle={styles.countdownNum}
|
||||
sepStyle={styles.sep}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.btnRow}>
|
||||
{timerRunning ? (
|
||||
<TouchableOpacity style={[styles.resetBtn, { borderColor: theme.accent }]} onPress={onPause}>
|
||||
<Text style={[styles.resetBtnText, { color: theme.accent }]}>Pause</Text>
|
||||
</TouchableOpacity>
|
||||
) : (
|
||||
<TouchableOpacity style={[styles.setBtn, { backgroundColor: theme.accent }]} onPress={onResume}>
|
||||
<Text style={styles.setBtnText}>Resume</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
|
||||
<TouchableOpacity style={[styles.resetBtn, { borderColor: theme.danger }]} onPress={onReset}>
|
||||
<Text style={[styles.resetBtnText, { color: theme.danger }]}>Reset</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<Text style={[styles.clock, { color: theme.subText }]}>
|
||||
{now.toLocaleTimeString([], {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
})}
|
||||
</Text>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
597
src/styles.js
597
src/styles.js
@@ -1,167 +1,502 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
import { Platform, StyleSheet } from 'react-native';
|
||||
import { TAB_BAR_HEIGHT } from './constants';
|
||||
|
||||
export function createStyles() {
|
||||
return StyleSheet.create({
|
||||
root: { flex: 1 },
|
||||
scroll: {
|
||||
flexGrow: 1,
|
||||
export const styles = StyleSheet.create({
|
||||
safe: {
|
||||
flex: 1,
|
||||
backgroundColor: '#090d12',
|
||||
},
|
||||
flex: {
|
||||
flex: 1,
|
||||
},
|
||||
content: {
|
||||
paddingHorizontal: 16,
|
||||
paddingTop: 12,
|
||||
paddingBottom: TAB_BAR_HEIGHT + 22,
|
||||
gap: 14,
|
||||
},
|
||||
statusSpacer: {
|
||||
height: Platform.OS === 'android' ? 8 : 0,
|
||||
},
|
||||
center: {
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
padding: 24,
|
||||
paddingVertical: 48,
|
||||
},
|
||||
title: {
|
||||
fontSize: 44,
|
||||
fontWeight: '900',
|
||||
marginBottom: 20,
|
||||
letterSpacing: 1,
|
||||
muted: {
|
||||
color: '#8793a5',
|
||||
},
|
||||
logo: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
marginBottom: 20,
|
||||
borderRadius: 22,
|
||||
|
||||
tripPickerWrap: {
|
||||
marginBottom: 6,
|
||||
},
|
||||
topRow: {
|
||||
width: '100%',
|
||||
maxWidth: 640,
|
||||
tripChipScroll: {
|
||||
gap: 8,
|
||||
paddingRight: 12,
|
||||
},
|
||||
tripChip: {
|
||||
paddingHorizontal: 12,
|
||||
paddingVertical: 9,
|
||||
borderRadius: 12,
|
||||
backgroundColor: '#121923',
|
||||
borderWidth: 1,
|
||||
borderColor: '#1f2937',
|
||||
minWidth: 120,
|
||||
},
|
||||
tripChipActive: {
|
||||
backgroundColor: '#1d2a3a',
|
||||
borderColor: '#60a5fa',
|
||||
},
|
||||
tripChipText: {
|
||||
color: '#e2e8f0',
|
||||
fontWeight: '700',
|
||||
},
|
||||
tripChipTextActive: {
|
||||
color: '#bfdbfe',
|
||||
},
|
||||
tripChipSub: {
|
||||
color: '#64748b',
|
||||
fontSize: 12,
|
||||
marginTop: 2,
|
||||
},
|
||||
tripChipSubActive: {
|
||||
color: '#93c5fd',
|
||||
},
|
||||
|
||||
section: {
|
||||
gap: 12,
|
||||
},
|
||||
sectionTitle: {
|
||||
color: '#f1f5f9',
|
||||
fontSize: 18,
|
||||
fontWeight: '700',
|
||||
},
|
||||
sectionRow: {
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
gap: 10,
|
||||
marginBottom: 20,
|
||||
},
|
||||
backMenuBtn: {
|
||||
paddingHorizontal: 18,
|
||||
paddingVertical: 10,
|
||||
borderRadius: 14,
|
||||
borderWidth: 1.5,
|
||||
|
||||
card: {
|
||||
backgroundColor: '#111827',
|
||||
borderRadius: 16,
|
||||
borderWidth: 1,
|
||||
borderColor: '#1f2937',
|
||||
padding: 12,
|
||||
gap: 8,
|
||||
},
|
||||
toggleRow: {
|
||||
cardActive: {
|
||||
borderColor: '#60a5fa',
|
||||
},
|
||||
cardSoft: {
|
||||
backgroundColor: '#0f172a',
|
||||
borderRadius: 16,
|
||||
borderWidth: 1,
|
||||
borderColor: '#1e293b',
|
||||
padding: 12,
|
||||
gap: 10,
|
||||
},
|
||||
cardRow: {
|
||||
flexDirection: 'row',
|
||||
gap: 10,
|
||||
},
|
||||
cardTitle: {
|
||||
color: '#f8fafc',
|
||||
fontWeight: '700',
|
||||
fontSize: 15,
|
||||
},
|
||||
cardMeta: {
|
||||
color: '#94a3b8',
|
||||
marginTop: 3,
|
||||
fontSize: 13,
|
||||
},
|
||||
tripHistoryLabel: {
|
||||
color: '#93c5fd',
|
||||
fontSize: 13,
|
||||
marginTop: -2,
|
||||
marginBottom: 2,
|
||||
},
|
||||
|
||||
fieldWrap: {
|
||||
gap: 6,
|
||||
},
|
||||
label: {
|
||||
color: '#cbd5e1',
|
||||
fontWeight: '600',
|
||||
},
|
||||
input: {
|
||||
borderWidth: 1,
|
||||
borderColor: '#243244',
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#0b1220',
|
||||
color: '#e5e7eb',
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 11,
|
||||
},
|
||||
dateInput: {
|
||||
borderWidth: 1,
|
||||
borderColor: '#29415e',
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#0b1220',
|
||||
paddingHorizontal: 12,
|
||||
paddingVertical: 12,
|
||||
},
|
||||
dateInputText: {
|
||||
color: '#dbeafe',
|
||||
fontWeight: '600',
|
||||
},
|
||||
|
||||
chipGroup: {
|
||||
flexDirection: 'row',
|
||||
flexWrap: 'wrap',
|
||||
gap: 10,
|
||||
justifyContent: 'center',
|
||||
gap: 7,
|
||||
},
|
||||
toggleBtn: {
|
||||
chip: {
|
||||
borderRadius: 999,
|
||||
paddingHorizontal: 11,
|
||||
paddingVertical: 7,
|
||||
borderWidth: 1,
|
||||
borderColor: '#273449',
|
||||
backgroundColor: '#0b1220',
|
||||
},
|
||||
chipActive: {
|
||||
borderColor: '#60a5fa',
|
||||
backgroundColor: '#172338',
|
||||
},
|
||||
chipText: {
|
||||
color: '#cbd5e1',
|
||||
fontWeight: '600',
|
||||
fontSize: 12,
|
||||
},
|
||||
chipTextActive: {
|
||||
color: '#bfdbfe',
|
||||
},
|
||||
|
||||
primaryBtn: {
|
||||
marginTop: 4,
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#2563eb',
|
||||
alignItems: 'center',
|
||||
paddingVertical: 11,
|
||||
paddingHorizontal: 12,
|
||||
},
|
||||
primaryBtnTight: {
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#2563eb',
|
||||
alignItems: 'center',
|
||||
paddingVertical: 8,
|
||||
paddingHorizontal: 12,
|
||||
},
|
||||
primaryBtnText: {
|
||||
color: '#fff',
|
||||
fontWeight: '700',
|
||||
},
|
||||
secondaryBtn: {
|
||||
marginTop: 4,
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#1f2937',
|
||||
alignItems: 'center',
|
||||
paddingVertical: 11,
|
||||
paddingHorizontal: 12,
|
||||
},
|
||||
secondaryBtnTight: {
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#1f2937',
|
||||
alignItems: 'center',
|
||||
paddingVertical: 8,
|
||||
paddingHorizontal: 12,
|
||||
},
|
||||
secondaryBtnText: {
|
||||
color: '#dbeafe',
|
||||
fontWeight: '700',
|
||||
},
|
||||
actionRow: {
|
||||
flexDirection: 'row',
|
||||
gap: 8,
|
||||
marginTop: 4,
|
||||
},
|
||||
|
||||
inlineToggle: {
|
||||
marginTop: 2,
|
||||
},
|
||||
inlineToggleText: {
|
||||
color: '#cbd5e1',
|
||||
},
|
||||
|
||||
stackButtons: {
|
||||
gap: 7,
|
||||
},
|
||||
miniBtn: {
|
||||
backgroundColor: '#1e293b',
|
||||
borderRadius: 8,
|
||||
paddingVertical: 7,
|
||||
paddingHorizontal: 10,
|
||||
},
|
||||
miniBtnDanger: {
|
||||
backgroundColor: '#3b1d22',
|
||||
borderRadius: 8,
|
||||
paddingVertical: 7,
|
||||
paddingHorizontal: 10,
|
||||
},
|
||||
miniBtnText: {
|
||||
color: '#e2e8f0',
|
||||
fontWeight: '700',
|
||||
fontSize: 12,
|
||||
},
|
||||
|
||||
itemCard: {
|
||||
borderRadius: 16,
|
||||
backgroundColor: '#111827',
|
||||
borderWidth: 1,
|
||||
borderColor: '#1f2937',
|
||||
overflow: 'hidden',
|
||||
flexDirection: 'row',
|
||||
},
|
||||
itemAccent: {
|
||||
width: 5,
|
||||
},
|
||||
itemMain: {
|
||||
flex: 1,
|
||||
padding: 12,
|
||||
gap: 8,
|
||||
},
|
||||
itemTitle: {
|
||||
color: '#f8fafc',
|
||||
fontWeight: '700',
|
||||
fontSize: 15,
|
||||
},
|
||||
itemMeta: {
|
||||
color: '#94a3b8',
|
||||
marginTop: 2,
|
||||
fontSize: 13,
|
||||
},
|
||||
|
||||
answerRow: {
|
||||
marginTop: 8,
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
gap: 8,
|
||||
},
|
||||
answerYes: {
|
||||
backgroundColor: '#163223',
|
||||
borderWidth: 1,
|
||||
borderColor: '#1f7a4e',
|
||||
borderRadius: 9,
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 8,
|
||||
borderRadius: 20,
|
||||
borderWidth: 1.5,
|
||||
},
|
||||
toggleText: { fontSize: 14, fontWeight: '600' },
|
||||
modeSelectLabel: {
|
||||
answerNo: {
|
||||
backgroundColor: '#3b1d22',
|
||||
borderWidth: 1,
|
||||
borderColor: '#7f1d1d',
|
||||
borderRadius: 9,
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 8,
|
||||
},
|
||||
answerText: {
|
||||
color: '#f8fafc',
|
||||
fontWeight: '700',
|
||||
},
|
||||
answerStateDot: {
|
||||
width: 10,
|
||||
height: 10,
|
||||
borderRadius: 99,
|
||||
backgroundColor: '#475569',
|
||||
},
|
||||
answerStateDotOn: {
|
||||
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,
|
||||
letterSpacing: 2,
|
||||
textTransform: 'uppercase',
|
||||
marginBottom: 20,
|
||||
},
|
||||
modeCard: {
|
||||
|
||||
snapshotWrap: {
|
||||
marginTop: 8,
|
||||
borderTopWidth: 1,
|
||||
borderTopColor: '#1e293b',
|
||||
paddingTop: 8,
|
||||
gap: 7,
|
||||
},
|
||||
snapshotRow: {
|
||||
paddingVertical: 3,
|
||||
},
|
||||
snapshotTitle: {
|
||||
color: '#e2e8f0',
|
||||
fontWeight: '600',
|
||||
},
|
||||
|
||||
previewImage: {
|
||||
width: '100%',
|
||||
maxWidth: 440,
|
||||
borderRadius: 22,
|
||||
padding: 28,
|
||||
borderWidth: 2,
|
||||
height: 150,
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#111827',
|
||||
},
|
||||
previewImageSmall: {
|
||||
width: '100%',
|
||||
height: 120,
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#111827',
|
||||
},
|
||||
|
||||
tabBarWrap: {
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
paddingHorizontal: 10,
|
||||
paddingBottom: Platform.OS === 'ios' ? 14 : 8,
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
tabBar: {
|
||||
height: TAB_BAR_HEIGHT,
|
||||
borderRadius: 16,
|
||||
backgroundColor: '#0b1220',
|
||||
borderWidth: 1,
|
||||
borderColor: '#1f2937',
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
marginBottom: 16,
|
||||
shadowColor: '#000',
|
||||
shadowOffset: { width: 0, height: 6 },
|
||||
shadowOpacity: 0.18,
|
||||
shadowRadius: 14,
|
||||
elevation: 7,
|
||||
justifyContent: 'space-around',
|
||||
},
|
||||
modeTitle: {
|
||||
fontSize: 26,
|
||||
fontWeight: '800',
|
||||
marginBottom: 8,
|
||||
letterSpacing: 0.5,
|
||||
tabItem: {
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
gap: 4,
|
||||
minWidth: 62,
|
||||
},
|
||||
modeDesc: {
|
||||
fontSize: 14,
|
||||
textAlign: 'center',
|
||||
tabLabel: {
|
||||
color: '#94a3b8',
|
||||
fontSize: 12,
|
||||
fontWeight: '600',
|
||||
},
|
||||
tabLabelActive: {
|
||||
color: '#dbeafe',
|
||||
},
|
||||
|
||||
modalBackdrop: {
|
||||
flex: 1,
|
||||
backgroundColor: 'rgba(2,6,23,0.72)',
|
||||
paddingHorizontal: 12,
|
||||
},
|
||||
modalKeyboardWrap: {
|
||||
flex: 1,
|
||||
width: '100%',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
modalCard: {
|
||||
width: '96%',
|
||||
maxHeight: '90%',
|
||||
backgroundColor: '#0f172a',
|
||||
borderRadius: 20,
|
||||
borderWidth: 1,
|
||||
borderColor: '#1e293b',
|
||||
padding: 16,
|
||||
gap: 10,
|
||||
},
|
||||
closeText: {
|
||||
color: '#93c5fd',
|
||||
fontWeight: '700',
|
||||
},
|
||||
|
||||
dateModalBackdrop: {
|
||||
flex: 1,
|
||||
backgroundColor: 'rgba(2,6,23,0.75)',
|
||||
justifyContent: 'center',
|
||||
paddingHorizontal: 16,
|
||||
},
|
||||
dateModalCard: {
|
||||
backgroundColor: '#0f172a',
|
||||
borderRadius: 16,
|
||||
borderWidth: 1,
|
||||
borderColor: '#1e293b',
|
||||
padding: 14,
|
||||
gap: 10,
|
||||
},
|
||||
calendarHeader: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
calendarNavBtn: {
|
||||
width: 34,
|
||||
height: 34,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#1e293b',
|
||||
},
|
||||
calendarNavText: {
|
||||
color: '#dbeafe',
|
||||
fontSize: 20,
|
||||
fontWeight: '700',
|
||||
lineHeight: 22,
|
||||
},
|
||||
card: {
|
||||
width: '100%',
|
||||
maxWidth: 440,
|
||||
borderRadius: 22,
|
||||
padding: 28,
|
||||
borderWidth: 1.5,
|
||||
alignItems: 'center',
|
||||
shadowColor: '#000',
|
||||
shadowOffset: { width: 0, height: 6 },
|
||||
shadowOpacity: 0.2,
|
||||
shadowRadius: 16,
|
||||
elevation: 8,
|
||||
calendarMonthText: {
|
||||
color: '#f8fafc',
|
||||
fontWeight: '700',
|
||||
fontSize: 15,
|
||||
},
|
||||
inputLabel: {
|
||||
fontSize: 12,
|
||||
letterSpacing: 1,
|
||||
textTransform: 'uppercase',
|
||||
marginBottom: 10,
|
||||
},
|
||||
inputRow: {
|
||||
calendarWeekRow: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
gap: 10,
|
||||
marginBottom: 16,
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
timerInputGroup: { alignItems: 'center', gap: 4 },
|
||||
inputUnit: { fontSize: 11, fontWeight: '600', letterSpacing: 1.5 },
|
||||
timeInput: {
|
||||
width: 72,
|
||||
height: 58,
|
||||
borderRadius: 12,
|
||||
borderWidth: 2,
|
||||
calendarWeekday: {
|
||||
color: '#94a3b8',
|
||||
width: '14.2%',
|
||||
textAlign: 'center',
|
||||
fontSize: 28,
|
||||
fontWeight: '800',
|
||||
fontSize: 12,
|
||||
},
|
||||
colon: { fontSize: 34, fontWeight: '900' },
|
||||
btnRow: {
|
||||
calendarGrid: {
|
||||
flexDirection: 'row',
|
||||
gap: 12,
|
||||
marginTop: 20,
|
||||
flexWrap: 'wrap',
|
||||
},
|
||||
calendarCell: {
|
||||
width: '14.2%',
|
||||
height: 38,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
borderRadius: 10,
|
||||
marginVertical: 2,
|
||||
},
|
||||
setBtn: {
|
||||
paddingHorizontal: 32,
|
||||
paddingVertical: 14,
|
||||
borderRadius: 14,
|
||||
calendarCellActive: {
|
||||
backgroundColor: '#2563eb',
|
||||
},
|
||||
setBtnText: { color: '#fff', fontSize: 16, fontWeight: '700', letterSpacing: 0.5 },
|
||||
resetBtn: {
|
||||
paddingHorizontal: 20,
|
||||
paddingVertical: 13,
|
||||
borderRadius: 14,
|
||||
borderWidth: 1.5,
|
||||
calendarCellText: {
|
||||
color: '#cbd5e1',
|
||||
fontWeight: '600',
|
||||
},
|
||||
resetBtnText: { fontSize: 15, fontWeight: '600' },
|
||||
overContainer: { alignItems: 'center', paddingVertical: 12, gap: 10 },
|
||||
overText: { fontSize: 52, fontWeight: '900', letterSpacing: 2 },
|
||||
overSub: { fontSize: 15 },
|
||||
countdownContainer: { alignItems: 'center', gap: 12 },
|
||||
countdownLabel: { fontSize: 13, letterSpacing: 0.5, textTransform: 'uppercase' },
|
||||
countdownRow: { flexDirection: 'row', alignItems: 'flex-start', gap: 6, justifyContent: 'center' },
|
||||
timeBlock: { alignItems: 'center', gap: 4 },
|
||||
countdownNum: { fontSize: 58, fontWeight: '800', lineHeight: 66 },
|
||||
countdownUnit: { fontSize: 11, fontWeight: '600', letterSpacing: 1.5 },
|
||||
sep: { fontSize: 50, fontWeight: '800', marginTop: 4 },
|
||||
placeholder: { fontSize: 15, textAlign: 'center', paddingVertical: 24, lineHeight: 24 },
|
||||
clock: { marginTop: 24, fontSize: 13, letterSpacing: 1.5 },
|
||||
focusRoot: { alignItems: 'center', justifyContent: 'center', paddingHorizontal: 10 },
|
||||
focusCountdown: { alignItems: 'center', gap: 16, width: '100%' },
|
||||
focusLabel: { fontSize: 16, letterSpacing: 0.5, textTransform: 'uppercase' },
|
||||
focusNum: { fontSize: 72, fontWeight: '800', lineHeight: 80 },
|
||||
focusSep: { fontSize: 56, fontWeight: '800', marginTop: 8 },
|
||||
focusOverText: { fontSize: 72 },
|
||||
focusExitBtn: {
|
||||
position: 'absolute',
|
||||
bottom: 40,
|
||||
right: 32,
|
||||
paddingHorizontal: 18,
|
||||
paddingVertical: 10,
|
||||
borderRadius: 20,
|
||||
borderWidth: 1.5,
|
||||
calendarCellTextActive: {
|
||||
color: '#fff',
|
||||
fontWeight: '700',
|
||||
},
|
||||
focusExitText: { fontSize: 14, fontWeight: '600' },
|
||||
});
|
||||
}
|
||||
|
||||
72
src/tabs/CheckupTab.js
Normal file
72
src/tabs/CheckupTab.js
Normal file
@@ -0,0 +1,72 @@
|
||||
import React from 'react';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
import { styles } from '../styles';
|
||||
|
||||
export default function CheckupTab({
|
||||
checkupSession,
|
||||
checkupStats,
|
||||
answerCheckupYes,
|
||||
openFixModal,
|
||||
createFreshCheckupSession,
|
||||
saveCheckup,
|
||||
}) {
|
||||
return (
|
||||
<View style={styles.section}>
|
||||
<View style={styles.sectionRow}>
|
||||
<Text style={styles.sectionTitle}>Check-Up</Text>
|
||||
<Pressable style={styles.secondaryBtnTight} onPress={createFreshCheckupSession}>
|
||||
<Text style={styles.secondaryBtnText}>Restart</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
{!!checkupSession.length && (
|
||||
<View style={styles.statsRow}>
|
||||
<View style={[styles.statPill, styles.statPillCorrect]}>
|
||||
<Text style={styles.statPillText}>Correct: {checkupStats.correct}</Text>
|
||||
</View>
|
||||
<View style={[styles.statPill, styles.statPillBad]}>
|
||||
<Text style={styles.statPillText}>Bad: {checkupStats.bad}</Text>
|
||||
</View>
|
||||
<View style={[styles.statPill, styles.statPillPending]}>
|
||||
<Text style={styles.statPillText}>Pending: {checkupStats.pending}</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{checkupSession.length === 0 ? <Text style={styles.muted}>No items for this trip yet.</Text> : null}
|
||||
|
||||
{checkupSession.map((entry) => (
|
||||
<View key={entry.itemId} style={styles.cardSoft}>
|
||||
<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.result === 'correct' ? styles.answerStateDotOn : null,
|
||||
entry.result === 'bad' ? styles.answerStateDotBad : null,
|
||||
]}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
|
||||
{!!checkupSession.length && (
|
||||
<Pressable style={styles.primaryBtn} onPress={saveCheckup}>
|
||||
<Text style={styles.primaryBtnText}>Save Check-Up Snapshot</Text>
|
||||
</Pressable>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
42
src/tabs/HistoryTab.js
Normal file
42
src/tabs/HistoryTab.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import React from 'react';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
import { styles } from '../styles';
|
||||
|
||||
export default function HistoryTab({ selectedTrip, selectedTripCheckups, selectedCheckupId, setSelectedCheckupId }) {
|
||||
return (
|
||||
<View style={styles.section}>
|
||||
<Text style={styles.sectionTitle}>History</Text>
|
||||
|
||||
{!selectedTrip ? <Text style={styles.muted}>Select a trip first.</Text> : null}
|
||||
{selectedTrip ? <Text style={styles.tripHistoryLabel}>Check-ups for: {selectedTrip.name}</Text> : null}
|
||||
{selectedTrip && selectedTripCheckups.length === 0 ? <Text style={styles.muted}>No check-ups saved yet.</Text> : null}
|
||||
|
||||
{selectedTripCheckups.map((checkup) => (
|
||||
<View key={checkup.id} style={styles.cardSoft}>
|
||||
<Pressable onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}>
|
||||
<Text style={styles.cardTitle}>{new Date(checkup.createdAt).toLocaleString()}</Text>
|
||||
<Text style={styles.cardMeta}>
|
||||
{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'}</Text>
|
||||
</Pressable>
|
||||
|
||||
{selectedCheckupId === checkup.id ? (
|
||||
<View style={styles.snapshotWrap}>
|
||||
{checkup.snapshot.map((entry) => (
|
||||
<View key={entry.itemId} style={styles.snapshotRow}>
|
||||
<Text style={styles.snapshotTitle}>{entry.name}</Text>
|
||||
<Text style={styles.cardMeta}>
|
||||
{entry.status} · {entry.placement}
|
||||
{entry.status === 'lent-to' && entry.lentTo ? ` · ${entry.lentTo}` : ''}
|
||||
</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
24
src/tabs/ItemsTab.js
Normal file
24
src/tabs/ItemsTab.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
import ItemCard from '../components/ItemCard';
|
||||
import { styles } from '../styles';
|
||||
|
||||
export default function ItemsTab({ selectedTrip, selectedTripItems, openAddItemModal, openEditItemModal, deleteItem }) {
|
||||
return (
|
||||
<View style={styles.section}>
|
||||
<View style={styles.sectionRow}>
|
||||
<Text style={styles.sectionTitle}>Luggage Items</Text>
|
||||
<Pressable style={styles.primaryBtnTight} onPress={openAddItemModal}>
|
||||
<Text style={styles.primaryBtnText}>+ Add</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
{!selectedTrip ? <Text style={styles.muted}>Select a trip first.</Text> : null}
|
||||
{selectedTripItems.length === 0 && selectedTrip ? <Text style={styles.muted}>No items yet.</Text> : null}
|
||||
|
||||
{selectedTripItems.map((item) => (
|
||||
<ItemCard key={item.id} item={item} onEdit={openEditItemModal} onDelete={deleteItem} />
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
118
src/tabs/TripsTab.js
Normal file
118
src/tabs/TripsTab.js
Normal file
@@ -0,0 +1,118 @@
|
||||
import React from 'react';
|
||||
import { Image, Pressable, Text, TextInput, View } from 'react-native';
|
||||
import Field from '../components/Field';
|
||||
import { styles } from '../styles';
|
||||
|
||||
function DateField({ label, value, onPress }) {
|
||||
return (
|
||||
<Field label={label}>
|
||||
<Pressable style={styles.dateInput} onPress={onPress}>
|
||||
<Text style={styles.dateInputText}>{value}</Text>
|
||||
</Pressable>
|
||||
</Field>
|
||||
);
|
||||
}
|
||||
|
||||
export default function TripsTab({
|
||||
tripForm,
|
||||
updateTripForm,
|
||||
pickTripImage,
|
||||
takeTripImage,
|
||||
templateTrip,
|
||||
createTrip,
|
||||
trips,
|
||||
selectedTripId,
|
||||
chooseTrip,
|
||||
setTripAsTemplate,
|
||||
deleteTrip,
|
||||
onInputFocus,
|
||||
defaultTemplateTripId,
|
||||
openDatePicker,
|
||||
}) {
|
||||
return (
|
||||
<View style={styles.section}>
|
||||
<Text style={styles.sectionTitle}>Trips</Text>
|
||||
|
||||
<View style={styles.cardSoft}>
|
||||
<Field label="Name">
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
value={tripForm.name}
|
||||
onChangeText={(v) => updateTripForm('name', v)}
|
||||
placeholder="Summer Weekend"
|
||||
placeholderTextColor="#6b7280"
|
||||
onFocus={onInputFocus}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field label="Location">
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
value={tripForm.location}
|
||||
onChangeText={(v) => updateTripForm('location', v)}
|
||||
placeholder="Berlin"
|
||||
placeholderTextColor="#6b7280"
|
||||
onFocus={onInputFocus}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<DateField label="Start Date" value={tripForm.startDate} onPress={() => openDatePicker('startDate')} />
|
||||
<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 ? (
|
||||
<Pressable style={styles.inlineToggle} onPress={() => updateTripForm('copyDefaultTemplate', !tripForm.copyDefaultTemplate)}>
|
||||
<Text style={styles.inlineToggleText}>
|
||||
{tripForm.copyDefaultTemplate ? '☑' : '☐'} Copy items from template ({templateTrip.name})
|
||||
</Text>
|
||||
</Pressable>
|
||||
) : null}
|
||||
|
||||
<Pressable style={styles.inlineToggle} onPress={() => updateTripForm('setAsDefaultTemplate', !tripForm.setAsDefaultTemplate)}>
|
||||
<Text style={styles.inlineToggleText}>{tripForm.setAsDefaultTemplate ? '☑' : '☐'} Set as default template</Text>
|
||||
</Pressable>
|
||||
|
||||
<Pressable style={styles.primaryBtn} onPress={createTrip}>
|
||||
<Text style={styles.primaryBtnText}>Create Trip</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
{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={() => setTripAsTemplate(trip.id)}>
|
||||
<Text style={styles.miniBtnText}>Template</Text>
|
||||
</Pressable>
|
||||
<Pressable style={styles.miniBtnDanger} onPress={() => deleteTrip(trip.id)}>
|
||||
<Text style={styles.miniBtnText}>Delete</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
{trip.imageUri ? <Image source={{ uri: trip.imageUri }} style={styles.previewImageSmall} /> : null}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
31
src/theme.js
31
src/theme.js
@@ -1,31 +0,0 @@
|
||||
export function getTheme(darkMode, pinkMode) {
|
||||
const dark = {
|
||||
bg: '#0b1020',
|
||||
cardBg: '#131a2a',
|
||||
text: '#e6ecff',
|
||||
subText: '#93a0bf',
|
||||
accent: '#5fb0ff',
|
||||
border: '#24304a',
|
||||
inputBg: '#0f1727',
|
||||
};
|
||||
|
||||
const light = {
|
||||
bg: '#f7f8fc',
|
||||
cardBg: '#ffffff',
|
||||
text: '#1d2433',
|
||||
subText: '#5f6b85',
|
||||
accent: '#1f67ff',
|
||||
border: '#d5def2',
|
||||
inputBg: '#eef3ff',
|
||||
};
|
||||
|
||||
const base = darkMode ? dark : light;
|
||||
const accent = pinkMode ? '#ff4fa3' : base.accent;
|
||||
|
||||
return {
|
||||
...base,
|
||||
accent,
|
||||
danger: '#ef4444',
|
||||
pink: '#ff4fa3',
|
||||
};
|
||||
}
|
||||
25
src/utils/date.js
Normal file
25
src/utils/date.js
Normal file
@@ -0,0 +1,25 @@
|
||||
export function makeId(prefix) {
|
||||
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
||||
}
|
||||
|
||||
export function todayYMD() {
|
||||
const now = new Date();
|
||||
return `${now.getFullYear()}-${`${now.getMonth() + 1}`.padStart(2, '0')}-${`${now.getDate()}`.padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
export function parseYMD(value) {
|
||||
if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return null;
|
||||
const d = new Date(`${value}T00:00:00`);
|
||||
return Number.isNaN(d.getTime()) ? null : d;
|
||||
}
|
||||
|
||||
export function findActiveTripId(trips) {
|
||||
const today = parseYMD(todayYMD());
|
||||
if (!today) return null;
|
||||
const active = trips.find((trip) => {
|
||||
const start = parseYMD(trip.startDate);
|
||||
const end = parseYMD(trip.endDate);
|
||||
return !!start && !!end && today >= start && today <= end;
|
||||
});
|
||||
return active?.id || null;
|
||||
}
|
||||
Reference in New Issue
Block a user