33 Commits

Author SHA1 Message Date
Space-Banane
7cccc763f2 Update lock file?
All checks were successful
Luggage List Build / build-web (push) Successful in 31s
Luggage List Build / build-android (push) Successful in 6m56s
Luggage List Build / release (push) Successful in 11s
2026-04-19 10:34:24 +02:00
Space-Banane
0a8444700e Full UI 180 & Overall improvements
Some checks failed
Luggage List Build / build-web (push) Successful in 31s
Luggage List Build / build-android (push) Failing after 1m24s
Luggage List Build / release (push) Has been skipped
2026-04-19 00:12:16 +02:00
0057290055 Delete TODO.md 2026-04-18 22:27:33 +02:00
e1bfbdbf1e feat(#17,#18): add location filter and custom-location autofill
All checks were successful
Luggage List Build / build-web (push) Successful in 52s
Luggage List Build / build-android (push) Successful in 7m2s
Luggage List Build / release (push) Successful in 17s
2026-04-18 21:59:23 +02:00
063e5090ed feat(#16): support custom placement when selecting other
All checks were successful
Luggage List Build / build-web (push) Successful in 40s
Luggage List Build / build-android (push) Successful in 7m26s
Luggage List Build / release (push) Successful in 15s
2026-04-18 21:41:18 +02:00
354a13e9a9 fix(#14,#15): reduce UI clutter and rename status actions
All checks were successful
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / build-android (push) Successful in 6m27s
Luggage List Build / release (push) Successful in 18s
2026-04-18 21:32:12 +02:00
4018e97476 feat(#13): open item images in full-screen preview modal
All checks were successful
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / build-android (push) Successful in 5m42s
Luggage List Build / release (push) Successful in 11s
2026-04-18 19:45:53 +02:00
1e0eb7aee9 fix(#12): remove Select action from trips list
Some checks failed
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
Luggage List Build / build-web (push) Has been cancelled
2026-04-18 19:45:46 +02:00
a9ee91daf3 feat(#3,#4,#7): add backup/restore, polish labels, and rename bulk actions
All checks were successful
Luggage List Build / build-android (push) Successful in 5m45s
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / release (push) Successful in 14s
2026-04-18 19:30:03 +02:00
0e0ab4a059 feat(#1,#2,#5): add checkup nav/progress, image optimization controls, and raise tab bar
Some checks failed
Luggage List Build / build-web (push) Successful in 31s
Luggage List Build / build-android (push) Failing after 1m46s
Luggage List Build / release (push) Has been skipped
2026-04-18 18:45:21 +02:00
89fd4c2f44 feat(#6): add randomized fake startup loader with suitcase progress
All checks were successful
Luggage List Build / build-web (push) Successful in 41s
Luggage List Build / build-android (push) Successful in 7m54s
Luggage List Build / release (push) Successful in 13s
2026-04-18 18:32:34 +02:00
fbdae66c9b feat(#8): make item thumbnails smaller and left-aligned
All checks were successful
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / build-android (push) Successful in 6m12s
Luggage List Build / release (push) Successful in 12s
2026-04-18 18:25:54 +02:00
e8ffab355e feat(#9): remove trip image controls and displays from UI 2026-04-18 18:25:49 +02:00
2ec877362f feat: add centered quick-add item button in bottom nav
All checks were successful
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / build-android (push) Successful in 5m59s
Luggage List Build / release (push) Successful in 11s
2026-04-18 18:13:28 +02:00
fb54db0619 feat: replace native alerts with custom dialog modals
All checks were successful
Luggage List Build / build-web (push) Successful in 27s
Luggage List Build / build-android (push) Successful in 9m46s
Luggage List Build / release (push) Successful in 21s
2026-04-18 15:20:25 +02:00
a93fec97dc chore: limit CI triggers and move TODOs to Gitea issues
Some checks failed
Luggage List Build / build-android (push) Has been cancelled
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-web (push) Has been cancelled
2026-04-18 15:08:45 +02:00
86976d5c26 docs: rewrite latest requested UI polish tasks
Some checks failed
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
Luggage List Build / build-web (push) Has been cancelled
2026-04-18 15:05:46 +02:00
61b0a3d1fa feat: add trip edit/archive flow and item bulk filters
All checks were successful
Luggage List Build / build-web (push) Successful in 28s
Luggage List Build / build-android (push) Successful in 6m32s
Luggage List Build / release (push) Successful in 12s
2026-04-18 14:53:02 +02:00
3080c3affd docs: add six next improvement ideas [skip ci] 2026-04-18 14:47:59 +02:00
d33fecd657 feat: add trip view modal with template and delete actions
All checks were successful
Luggage List Build / build-web (push) Successful in 36s
Luggage List Build / build-android (push) Successful in 6m30s
Luggage List Build / release (push) Successful in 12s
2026-04-18 14:43:13 +02:00
2417d2d597 feat: auto-select active or next trip by date
Some checks failed
Luggage List Build / build-web (push) Successful in 35s
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
2026-04-18 14:41:24 +02:00
f28ff010d7 feat: move trip creation and check-up into guided modals
Some checks failed
Luggage List Build / build-web (push) Successful in 35s
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
2026-04-18 14:39:47 +02:00
d40bd6a41c feat: add history long-press delete and quick item status actions
Some checks failed
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
2026-04-18 14:34:05 +02:00
2e45261354 feat: add camera capture for trip and item images
All checks were successful
Luggage List Build / build-web (push) Successful in 31s
Luggage List Build / build-android (push) Successful in 6m24s
Luggage List Build / release (push) Successful in 14s
2026-04-18 14:19:48 +02:00
bd500674a0 fix(ui): stabilize modal keyboard behavior
All checks were successful
Luggage List Build / build-web (push) Successful in 55s
Luggage List Build / build-android (push) Successful in 6m28s
Luggage List Build / release (push) Successful in 10s
2026-04-18 14:12:34 +02:00
ef7e0ba7a1 style: center and enlarge modals to overlay navbar
All checks were successful
Luggage List Build / build-web (push) Successful in 30s
Luggage List Build / build-android (push) Successful in 6m13s
Luggage List Build / release (push) Successful in 15s
2026-04-18 13:34:42 +02:00
f34ffe39c0 feat: polish UI, fix top inset, and add check-up correctness stats
All checks were successful
Luggage List Build / build-web (push) Successful in 38s
Luggage List Build / build-android (push) Successful in 6m16s
Luggage List Build / release (push) Successful in 14s
2026-04-18 13:23:19 +02:00
30ee53fe75 feat: add calendar date picker, nav icons, and input-focused keyboard scrolling
All checks were successful
Luggage List Build / build-web (push) Successful in 28s
Luggage List Build / build-android (push) Successful in 5m59s
Luggage List Build / release (push) Successful in 11s
2026-04-18 13:12:51 +02:00
23a5f0ebae chore: remove unused docker compose and entrypoint files
All checks were successful
Luggage List Build / build-web (push) Successful in 28s
Luggage List Build / build-android (push) Successful in 5m59s
Luggage List Build / release (push) Successful in 12s
2026-04-18 12:56:30 +02:00
bdea52b7c6 refactor: split app into modular src architecture
Some checks failed
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
Luggage List Build / build-web (push) Has been cancelled
2026-04-18 12:56:12 +02:00
3323d09dda chore: remove legacy unused src template files
Some checks failed
Luggage List Build / build-web (push) Successful in 31s
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
2026-04-18 12:50:41 +02:00
4098573ea0 docs: update v2 scope and progress tracking
Some checks failed
Luggage List Build / build-web (push) Successful in 38s
Luggage List Build / build-android (push) Successful in 6m26s
Luggage List Build / release (push) Has been cancelled
2026-04-18 12:43:54 +02:00
50460a83a4 feat: redesign app UI and refactor check-up flow to yes/no modal updates
Some checks failed
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
Luggage List Build / build-web (push) Has been cancelled
2026-04-18 12:43:48 +02:00
59 changed files with 13823 additions and 2200 deletions

View File

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

View File

@@ -1,28 +0,0 @@
name: Luggage List Dev Branch Check
on:
push:
branches-ignore:
- main
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v2
- name: 🏗 Setup Node
uses: actions/setup-node@v2
with:
node-version: 22
- name: 🏗 Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: 📦 Install dependencies
run: pnpm install
- name: 🧪 Web export smoke check
run: npx expo export --platform web

View File

@@ -1,57 +0,0 @@
name: Luggage List Manual APK Build
on:
workflow_dispatch:
jobs:
build-android:
runs-on: ubuntu-latest
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v2
- name: 🏗 Setup Node
uses: actions/setup-node@v2
with:
node-version: 22
- name: 🏗 Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: 🏗 Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: 🏗 Setup Android SDK
uses: android-actions/setup-android@v3
- name: 🏗 Setup Expo and EAS
uses: expo/expo-github-action@v8
with:
token: ${{ secrets.EXPO_TOKEN }}
eas-version: latest
packager: pnpm
- name: 📦 Install dependencies
run: pnpm install
- name: 👷 Build app
run: |
eas build --local \
--non-interactive \
--output=./app-build \
--platform=android \
--profile=preview
- name: 📝 Rename build to APK
run: mv app-build luggage-list-manual.apk
- name: 📤 Upload build artifact
uses: actions/upload-artifact@v3
with:
name: luggage-list-manual-apk-build
path: luggage-list-manual.apk
if-no-files-found: error

View File

@@ -1,45 +0,0 @@
# Project Guidelines
## Code Style
- Keep components as functional React components and use hooks-based state.
- Follow existing naming and structure in `src/screens` and `src/components`:
- Screen files: `*Screen.js`
- Shared UI pieces: `src/components/*.js`
- Keep styling centralized in `src/styles.js` via `createStyles()` and use theme-driven inline color overrides in screens/components.
- Reuse `getTheme(darkMode, pinkMode)` from `src/theme.js` for color values; do not hardcode alternate palettes in individual screens.
## Architecture
- Root orchestration lives in `App.js`:
- App-level state includes current screen, focus mode, theme toggles, and timer/countdown state.
- Screen switching is controlled by the `screen` state (`home`, `timeuntil`, `timer`).
- Screen responsibilities:
- `HomeScreen`: mode selection and top controls.
- `TimeUntilScreen`: target clock-time countdown flow.
- `TimerScreen`: duration countdown flow.
- `FocusScreen`: minimal fullscreen countdown UI.
- Shared presentational components:
- `TopControls`: dark/pink/fullscreen/focus controls.
- `CountdownRow`: reusable HH:MM:SS display.
## Build And Run
- Install dependencies: `npm install`
- Start dev server: `npm start`
- Run on Android: `npm run android`
- Run on iOS: `npm run ios`
- Run on web: `npm run web`
- EAS builds use `eas.json` profiles (`development`, `preview`, `production`).
## Conventions
- Keep timer/countdown behavior in `App.js` unless intentionally refactoring architecture.
- Preserve current time behavior:
- `now` updates every second with `setInterval`.
- Time-until target is based on local device time and rolls to next day when target time has passed.
- Maintain platform guards:
- Web-only fullscreen uses `document.fullscreenElement` APIs.
- Android hardware back behavior is handled in `App.js` and should keep focus/screen fallback behavior.
- For countdown display, continue using `CountdownRow` and 2-digit padded units for consistency.
## Pitfalls
- This project has no test scripts configured; do not claim tests were run unless you add and run them.
- Be careful with web-only globals (`document`) and keep `Platform.OS` guards.
- Avoid introducing timezone assumptions without explicit product requirements; current logic is local-time based.

1125
App.js

File diff suppressed because it is too large Load Diff

View File

@@ -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
@@ -23,11 +30,3 @@ Minimal local-first luggage management app built with Expo.
npm install
npm run start
```
## Build / CI
Gitea workflows are in `.gitea/workflows`:
- `dev.yml`: smoke check via `expo export --platform web` on non-main branches
- `ci.yml`: Android APK build via `eas build --local`, web bundle export, release tag/artifacts on `main`
- `manual-build.yml`: manual Android APK build via `eas build --local`

31
TODO.md
View File

@@ -1,31 +0,0 @@
# 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
## 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)
## 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
## 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)

View File

@@ -2,12 +2,12 @@
"expo": {
"name": "Luggage List",
"slug": "luggage-list",
"version": "1.0.0",
"version": "2.0.0",
"orientation": "default",
"icon": "./assets/icon.png",
"icon": "./assets/image.png",
"userInterfaceStyle": "automatic",
"splash": {
"image": "./assets/splash-icon.png",
"image": "./assets/image.png",
"resizeMode": "contain",
"backgroundColor": "#f5f5f7"
},
@@ -19,12 +19,12 @@
"android": {
"package": "dev.reversed.luggagelist",
"adaptiveIcon": {
"foregroundImage": "./assets/icon.png",
"foregroundImage": "./assets/image.png",
"backgroundColor": "#f5f5f7"
}
},
"web": {
"favicon": "./assets/icon.png",
"favicon": "./assets/image.png",
"name": "Luggage List",
"themeColor": "#f5f5f7",
"backgroundColor": "#f5f5f7"
@@ -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

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

BIN
assets/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

View File

@@ -1,8 +0,0 @@
services:
web:
image: nginx:alpine
ports:
- "45554:80"
volumes:
- ./entrypoint.sh:/entrypoint.sh:ro
entrypoint: ["/bin/sh", "/entrypoint.sh"]

View File

@@ -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;"

2
global.css Normal file
View File

@@ -0,0 +1,2 @@
@import 'tailwindcss';
@import 'uniwind';

9
metro.config.js Normal file
View File

@@ -0,0 +1,9 @@
const { getDefaultConfig } = require('expo/metro-config');
const { withUniwindConfig } = require('uniwind/metro');
const config = getDefaultConfig(__dirname);
module.exports = withUniwindConfig(config, {
cssEntryFile: './global.css',
dtsFile: './src/uniwind-types.d.ts',
});

2359
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,19 +6,27 @@
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
"web": "expo start --web",
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"@react-native-async-storage/async-storage": "2.2.0",
"expo": "~54.0.33",
"expo-file-system": "~19.0.17",
"expo-document-picker": "~14.0.7",
"expo-file-system": "~19.0.11",
"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",
"react-native": "0.81.5",
"react-native-web": "^0.21.0"
"react-native-web": "^0.21.0",
"tailwindcss": "^4.0.0",
"uniwind": "latest"
},
"private": true
"private": true,
"devDependencies": {
"vitest": "^1.6.1"
}
}

7212
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

1186
src/AppRoot.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
import React from 'react';
import { Modal, Pressable, Text, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import { styles } from '../styles';
import { cn } from '../utils/cn';
export default function AppDialogModal({ visible, title, message, buttons = [], onClose }) {
if (!visible) return null;
const safeButtons = buttons.length ? buttons : [{ text: 'OK' }];
return (
<Modal visible={visible} transparent animationType="none" onRequestClose={onClose}>
<View className={styles.dialogBackdrop}>
<View className={styles.dialogCard}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="information-circle-outline" size={18} color="#d4d4d8" />
<Text className={styles.dialogTitle}>{title || 'Notice'}</Text>
</View>
{!!message ? <Text className={styles.dialogMessage}>{message}</Text> : null}
<View className={styles.dialogButtonsRow}>
{safeButtons.map((button, idx) => {
const tone = button.tone || (button.style === 'destructive' ? 'danger' : button.style === 'cancel' ? 'neutral' : 'primary');
const icon = tone === 'danger' ? 'warning-outline' : tone === 'neutral' ? 'close-outline' : 'checkmark-outline';
return (
<Pressable
key={`${button.text}-${idx}`}
className={cn(
styles.dialogBtn,
tone === 'primary' && styles.dialogBtnPrimary,
tone === 'danger' && styles.dialogBtnDanger,
tone === 'neutral' && styles.dialogBtnNeutral
)}
onPress={button.onPress}
>
<View className={styles.buttonContent}>
<Ionicons name={icon} size={14} color="#f8fafc" />
<Text className={styles.dialogBtnText}>{button.text || 'OK'}</Text>
</View>
</Pressable>
);
})}
</View>
</View>
</View>
</Modal>
);
}

View File

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

View File

@@ -0,0 +1,19 @@
import React from 'react';
import { Pressable, Text, View } from 'react-native';
import { styles } from '../styles';
import { cn } from '../utils/cn';
export default function ChipGroup({ options, value, onChange }) {
return (
<View className={styles.chipGroup}>
{options.map((option) => {
const active = value === option;
return (
<Pressable key={option} className={cn(styles.chip, active && styles.chipActive)} onPress={() => onChange(option)}>
<Text className={cn(styles.chipText, active && styles.chipTextActive)}>{option}</Text>
</Pressable>
);
})}
</View>
);
}

View File

@@ -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>
);
}

View File

@@ -0,0 +1,103 @@
import React, { useMemo, useState } from 'react';
import { Modal, Pressable, Text, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import { styles } from '../styles';
import { cn } from '../utils/cn';
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="none" onRequestClose={onClose}>
<View className={styles.dateModalBackdrop}>
<View className={styles.dateModalCard}>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name="calendar-outline" size={16} color="#d4d4d8" />
</View>
<Text className={styles.cardTitle}>{title}</Text>
</View>
<Pressable className={styles.secondaryBtnTight} onPress={onClose}>
<View className={styles.buttonContent}>
<Ionicons name="close" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Close</Text>
</View>
</Pressable>
</View>
<View className={styles.calendarHeader}>
<Pressable className={styles.calendarNavBtn} onPress={() => goMonth(-1)}>
<Ionicons name="chevron-back" size={18} color="#e4e4e7" />
</Pressable>
<Text className={styles.calendarMonthText}>{monthLabel(viewDate)}</Text>
<Pressable className={styles.calendarNavBtn} onPress={() => goMonth(1)}>
<Ionicons name="chevron-forward" size={18} color="#e4e4e7" />
</Pressable>
</View>
<View className={styles.calendarWeekRow}>
{WEEKDAYS.map((w) => (
<Text key={w} className={styles.calendarWeekday}>{w}</Text>
))}
</View>
<View className={styles.calendarGrid}>
{grid.map((cell, idx) => {
if (!cell) return <View key={`empty-${idx}`} className={styles.calendarCell} />;
const ymd = toYMD(cell);
const isSelected = ymd === selected;
return (
<Pressable key={ymd} className={cn(styles.calendarCell, isSelected && styles.calendarCellActive)} onPress={() => onSelect(ymd)}>
<Text className={cn(styles.calendarCellText, isSelected && styles.calendarCellTextActive)}>{cell.getDate()}</Text>
</Pressable>
);
})}
</View>
</View>
</View>
</Modal>
);
}

16
src/components/Field.js Normal file
View File

@@ -0,0 +1,16 @@
import React from 'react';
import { Text, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import { styles } from '../styles';
export default function Field({ label, icon, children }) {
return (
<View className={styles.fieldWrap}>
<View className={styles.labelRow}>
{icon ? <Ionicons name={icon} size={14} color="#d4d4d8" /> : null}
<Text className={styles.label}>{label}</Text>
</View>
{children}
</View>
);
}

View File

@@ -0,0 +1,96 @@
import React from 'react';
import { Image, Pressable, Text, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import { STATUS_COLORS } from '../constants';
import { styles } from '../styles';
import { cn } from '../utils/cn';
import { formatStatusLabel, normalizeQuantity } from '../utils/labels';
function statusAccent(status) {
return STATUS_COLORS[status] || '#64748b';
}
export default function ItemCard({ item, onEdit, onDelete, onQuickPack, onQuickUnpack, onOpenImage }) {
const isPacked = item.status === 'packed';
const isUnpacked = item.status === 'unpacked';
const quantity = normalizeQuantity(item.quantity, 1);
return (
<View className={styles.itemCard}>
<View className={styles.itemAccent} style={{ backgroundColor: statusAccent(item.status) }} />
<View className={styles.itemThumbWrap}>
{item.imageUri ? (
<Pressable onPress={() => onOpenImage?.(item.imageUri)}>
<Image source={{ uri: item.imageUri }} className={styles.itemThumbSmall} />
</Pressable>
) : (
<View className={styles.itemThumbPlaceholder}>
<Ionicons name="briefcase-outline" size={20} color="#a1a1aa" />
</View>
)}
</View>
<View className={styles.itemMain}>
<View className={styles.cardRow}>
<View className={styles.flex}>
<Text className={styles.itemTitle} numberOfLines={1}>{item.name}</Text>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="albums-outline" size={12} color="#a1a1aa" />
<Text className={styles.itemMeta}>Qty: {quantity}</Text>
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="layers-outline" size={12} color="#a1a1aa" />
<Text className={styles.itemMeta} numberOfLines={1}>{item.category || 'uncategorized'} · {formatStatusLabel(item.status, item.lentTo)}</Text>
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="pin-outline" size={12} color="#a1a1aa" />
<Text className={styles.itemMeta}>Location: {item.placement}</Text>
</View>
{item.status === 'lent-to' && !!item.lentTo ? (
<View className={styles.sectionHeaderLeft}>
<Ionicons name="person-outline" size={12} color="#a1a1aa" />
<Text className={styles.itemMeta} numberOfLines={1}>Borrower: {item.lentTo}</Text>
</View>
) : null}
{!!item.description ? (
<View className={styles.sectionHeaderLeft}>
<Ionicons name="document-text-outline" size={12} color="#a1a1aa" />
<Text className={styles.itemMeta} numberOfLines={2}>{item.description}</Text>
</View>
) : null}
</View>
<View className={styles.stackButtons}>
<Pressable className={styles.miniBtn} onPress={() => onEdit(item)}>
<View className={styles.buttonContent}>
<Ionicons name="create-outline" size={12} color="#f4f4f5" />
<Text className={styles.miniBtnText}>Edit</Text>
</View>
</Pressable>
<Pressable className={styles.miniBtnDanger} onPress={() => onDelete(item.id)}>
<View className={styles.buttonContent}>
<Ionicons name="trash-outline" size={12} color="#f4f4f5" />
<Text className={styles.miniBtnText}>Delete</Text>
</View>
</Pressable>
</View>
</View>
<View className={styles.quickStatusRow}>
<Pressable className={cn(styles.quickStatusBtn, isPacked && styles.quickStatusBtnActive)} onPress={onQuickPack}>
<View className={styles.buttonContent}>
<Ionicons name="checkmark-circle-outline" size={12} color={isPacked ? '#e0f2fe' : '#d4d4d8'} />
<Text className={cn(styles.quickStatusBtnText, isPacked && styles.quickStatusBtnTextActive)}>Packed</Text>
</View>
</Pressable>
<Pressable className={cn(styles.quickStatusBtn, isUnpacked && styles.quickStatusBtnActive)} onPress={onQuickUnpack}>
<View className={styles.buttonContent}>
<Ionicons name="remove-circle-outline" size={12} color={isUnpacked ? '#e0f2fe' : '#d4d4d8'} />
<Text className={cn(styles.quickStatusBtnText, isUnpacked && styles.quickStatusBtnTextActive)}>Unpacked</Text>
</View>
</Pressable>
</View>
</View>
</View>
);
}

View File

@@ -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>
);
}

View File

@@ -0,0 +1,91 @@
import React from 'react';
import { Pressable, ScrollView, Text, View, useWindowDimensions } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import { styles } from '../styles';
import { cn } from '../utils/cn';
export default function TripPicker({ trips, selectedTripId, onChooseTrip }) {
const { width } = useWindowDimensions();
const sortedTrips = trips.slice().sort((a, b) => b.startDate.localeCompare(a.startDate));
const useHorizontalScroll = sortedTrips.length > 2;
const extraTripCount = Math.max(0, sortedTrips.length - 2);
const scrollCardWidth = Math.max(152, Math.floor((width - 32) * 0.46));
return (
<View className={styles.tripPickerWrap}>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="map-outline" size={14} color="#d4d4d8" />
<Text className={styles.tripPickerTitle}>Choose Trip</Text>
</View>
{useHorizontalScroll ? <Text className={styles.tripPickerMoreBadge}>+{extraTripCount} more</Text> : null}
</View>
{trips.length ? (
useHorizontalScroll ? (
<>
<ScrollView
horizontal
nestedScrollEnabled
showsHorizontalScrollIndicator={false}
contentContainerStyle={styles.tripPickerScrollRow}
>
{sortedTrips.map((trip) => {
const active = selectedTripId === trip.id;
return (
<Pressable
key={trip.id}
className={cn(styles.tripChip, active && styles.tripChipActive)}
style={{ width: scrollCardWidth }}
onPress={() => onChooseTrip(trip.id)}
>
<View className={styles.sectionHeader}>
<View className={cn(styles.sectionHeaderLeft, styles.flex)}>
<Ionicons name="airplane-outline" size={14} color={active ? '#dbeafe' : '#d4d4d8'} />
<Text className={cn(styles.tripChipText, active && styles.tripChipTextActive)} numberOfLines={1}>{trip.name}</Text>
</View>
{active ? <Ionicons name="checkmark-circle" size={16} color="#bfdbfe" /> : null}
</View>
<Text className={cn(styles.tripChipSub, active && styles.tripChipSubActive)}>{trip.startDate}</Text>
</Pressable>
);
})}
</ScrollView>
<View className={styles.tripPickerMoreHintRow}>
<Ionicons name="arrow-forward-circle-outline" size={13} color="#94a3b8" />
<Text className={styles.tripPickerMoreHintText}>Swipe to see {extraTripCount} more</Text>
</View>
</>
) : (
<View style={styles.tripPickerGrid}>
{sortedTrips.map((trip) => {
const active = selectedTripId === trip.id;
return (
<Pressable
key={trip.id}
className={cn(styles.tripChip, active && styles.tripChipActive)}
style={sortedTrips.length === 1 ? styles.tripChipSingle : styles.tripChipGridItem}
onPress={() => onChooseTrip(trip.id)}
>
<View className={styles.sectionHeader}>
<View className={cn(styles.sectionHeaderLeft, styles.flex)}>
<Ionicons name="airplane-outline" size={14} color={active ? '#dbeafe' : '#d4d4d8'} />
<Text className={cn(styles.tripChipText, active && styles.tripChipTextActive)} numberOfLines={1}>{trip.name}</Text>
</View>
{active ? <Ionicons name="checkmark-circle" size={16} color="#bfdbfe" /> : null}
</View>
<Text className={cn(styles.tripChipSub, active && styles.tripChipSubActive)}>{trip.startDate}</Text>
</Pressable>
);
})}
</View>
)
) : (
<View className={styles.cardSoft}>
<Text className={styles.muted}>Create your first trip to start.</Text>
</View>
)}
</View>
);
}

20
src/constants.js Normal file
View 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,
};

163
src/modals/BackupModal.js Normal file
View File

@@ -0,0 +1,163 @@
import React, { useEffect, useRef, useState } from 'react';
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import { styles } from '../styles';
import { cn } from '../utils/cn';
export default function BackupModal({
visible,
onClose,
exportJson,
importJson,
setImportJson,
exportFile,
importFile,
applyImport,
}) {
const exportInputRef = useRef(null);
const [showExportJson, setShowExportJson] = useState(false);
const [copyState, setCopyState] = useState('idle');
useEffect(() => {
if (!visible) return;
setShowExportJson(false);
setCopyState('idle');
}, [visible]);
useEffect(() => {
if (copyState !== 'copied') return undefined;
const timeout = setTimeout(() => setCopyState('idle'), 1400);
return () => clearTimeout(timeout);
}, [copyState]);
async function handleCopyData() {
if (Platform.OS === 'web' && typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
try {
await navigator.clipboard.writeText(exportJson);
setCopyState('copied');
return;
} catch {
// fall through to manual copy fallback
}
}
setShowExportJson(true);
setCopyState('manual');
if (Platform.OS === 'android') {
return;
}
requestAnimationFrame(() => {
exportInputRef.current?.focus?.();
if (exportInputRef.current?.setNativeProps) {
exportInputRef.current.setNativeProps({
selection: { start: 0, end: exportJson.length },
});
}
});
}
return (
<Modal visible={visible} animationType="none" transparent>
<View className={styles.modalBackdrop}>
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
<View className={styles.modalCard}>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name="cloud-upload-outline" size={16} color="#d4d4d8" />
</View>
<Text className={styles.cardTitle}>Backup & Restore</Text>
</View>
<Pressable className={styles.secondaryBtnTight} onPress={onClose}>
<View className={styles.buttonContent}>
<Ionicons name="close" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Close</Text>
</View>
</Pressable>
</View>
<ScrollView keyboardShouldPersistTaps="handled" contentContainerStyle={styles.modalScrollContent} showsVerticalScrollIndicator={false}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="download-outline" size={14} color="#d4d4d8" />
<Text className={styles.cardTitle}>Export JSON</Text>
</View>
<Text className={styles.cardMeta}>Use Show JSON or Copy Data.</Text>
<View className={styles.actionRow}>
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={() => setShowExportJson((prev) => !prev)}>
<View className={styles.buttonContent}>
<Ionicons name={showExportJson ? 'eye-off-outline' : 'eye-outline'} size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>{showExportJson ? 'Hide JSON' : 'Show JSON'}</Text>
</View>
</Pressable>
<Pressable className={cn(styles.primaryBtnTight, styles.flex)} onPress={handleCopyData}>
<View className={styles.buttonContent}>
<Ionicons name={copyState === 'copied' ? 'checkmark-circle-outline' : 'copy-outline'} size={14} color="#ffffff" />
<Text className={styles.primaryBtnText}>{copyState === 'copied' ? 'Copied' : 'Copy Data'}</Text>
</View>
</Pressable>
</View>
<Pressable className={styles.secondaryBtn} onPress={exportFile}>
<View className={styles.buttonContent}>
<Ionicons name="share-social-outline" size={15} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Export File</Text>
</View>
</Pressable>
{copyState === 'manual' ? (
<Text className={styles.cardMeta}>Direct clipboard is unavailable here. JSON is shown for manual copy.</Text>
) : null}
{showExportJson ? (
Platform.OS === 'android' ? (
<View style={styles.exportJsonBlock}>
<Text style={styles.exportJsonText} selectable>{exportJson}</Text>
</View>
) : (
<TextInput
ref={exportInputRef}
style={styles.inputMultiline}
multiline
value={exportJson}
editable={false}
selectTextOnFocus
/>
)
) : null}
<View className={styles.sectionHeaderLeft}>
<Ionicons name="cloud-upload-outline" size={14} color="#d4d4d8" />
<Text className={styles.cardTitle}>Import JSON</Text>
</View>
<Text className={styles.cardMeta}>Paste a previous backup. This will replace current data.</Text>
<Pressable className={styles.secondaryBtn} onPress={importFile}>
<View className={styles.buttonContent}>
<Ionicons name="document-outline" size={15} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Pick Backup File</Text>
</View>
</Pressable>
<TextInput
style={styles.inputMultiline}
multiline
value={importJson}
onChangeText={setImportJson}
placeholder="Paste backup JSON here"
placeholderTextColor="#71717a"
/>
<Pressable className={styles.primaryBtn} onPress={applyImport}>
<View className={styles.buttonContent}>
<Ionicons name="sync-outline" size={15} color="#ffffff" />
<Text className={styles.primaryBtnText}>Import & Replace</Text>
</View>
</Pressable>
</ScrollView>
</View>
</KeyboardAvoidingView>
</View>
</Modal>
);
}

View File

@@ -0,0 +1,92 @@
import React from 'react';
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
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 className={styles.modalBackdrop}>
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
<View className={styles.modalCard}>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name="build-outline" size={16} color="#d4d4d8" />
</View>
<Text className={styles.cardTitle}>Update for this Check-Up</Text>
</View>
<Pressable className={styles.secondaryBtnTight} onPress={() => setCheckupFixModalVisible(false)}>
<View className={styles.buttonContent}>
<Ionicons name="close" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Close</Text>
</View>
</Pressable>
</View>
<ScrollView
keyboardShouldPersistTaps="handled"
keyboardDismissMode="interactive"
contentContainerStyle={styles.modalScrollContent}
showsVerticalScrollIndicator={false}
>
<Field label="Status" icon="radio-button-on-outline">
<ChipGroup
options={ITEM_STATUSES}
value={checkupFixForm.status}
onChange={(v) => setCheckupFixForm((prev) => ({ ...prev, status: v }))}
/>
</Field>
<Field label="Placement" icon="pin-outline">
<ChipGroup
options={ITEM_PLACEMENTS}
value={checkupFixForm.placement}
onChange={(v) => setCheckupFixForm((prev) => ({ ...prev, placement: v }))}
/>
</Field>
{checkupFixForm.status === 'lent-to' ? (
<Field label="Lent to" icon="person-outline">
<TextInput
className={styles.input}
value={checkupFixForm.lentTo}
onChangeText={(v) => setCheckupFixForm((prev) => ({ ...prev, lentTo: v }))}
placeholder="Person name"
placeholderTextColor="#71717a"
/>
</Field>
) : null}
<Pressable
className={styles.inlineToggle}
onPress={() => setCheckupFixForm((prev) => ({ ...prev, updateMasterList: !prev.updateMasterList }))}
>
<View className={styles.sectionHeaderLeft}>
<Ionicons name={checkupFixForm.updateMasterList ? 'checkbox-outline' : 'square-outline'} size={16} color="#d4d4d8" />
<Text className={styles.inlineToggleText}>Also update item in trip list</Text>
</View>
</Pressable>
<Pressable className={styles.primaryBtn} onPress={saveFixModal}>
<View className={styles.buttonContent}>
<Ionicons name="checkmark-circle-outline" size={15} color="#ffffff" />
<Text className={styles.primaryBtnText}>Save</Text>
</View>
</Pressable>
</ScrollView>
</View>
</KeyboardAvoidingView>
</View>
</Modal>
);
}

View File

@@ -0,0 +1,197 @@
import React from 'react';
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import { ITEM_PLACEMENTS, ITEM_STATUSES } from '../constants';
import ChipGroup from '../components/ChipGroup';
import Field from '../components/Field';
import { styles } from '../styles';
import { cn } from '../utils/cn';
import { formatItemLabel, formatStatusLabel } from '../utils/labels';
export default function CheckupFlowModal({
visible,
entry,
stepIndex,
total,
mode,
noForm,
setNoForm,
onClose,
onYes,
onNo,
onSaveNo,
onSkip,
onBack,
onFinish,
}) {
const finished = !entry;
return (
<Modal visible={visible} animationType="slide" transparent>
<View className={styles.modalBackdrop}>
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
<View className={styles.modalCard}>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name="checkmark-circle-outline" size={16} color="#d4d4d8" />
</View>
<Text className={styles.cardTitle}>Check-Up</Text>
</View>
<Pressable className={styles.secondaryBtnTight} onPress={onClose}>
<View className={styles.buttonContent}>
<Ionicons name="close" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Close</Text>
</View>
</Pressable>
</View>
{finished ? (
<View className={styles.section}>
<Text className={styles.cardTitle}>Done. Save this snapshot?</Text>
<Text className={styles.cardMeta}>All {total} items were checked.</Text>
<View className={styles.actionRow}>
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={onBack}>
<View className={styles.buttonContent}>
<Ionicons name="arrow-back-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Back</Text>
</View>
</Pressable>
<Pressable className={cn(styles.primaryBtnTight, styles.flex)} onPress={onFinish}>
<View className={styles.buttonContent}>
<Ionicons name="save-outline" size={14} color="#ffffff" />
<Text className={styles.primaryBtnText}>Save Snapshot</Text>
</View>
</Pressable>
</View>
</View>
) : (
<ScrollView
keyboardShouldPersistTaps="handled"
keyboardDismissMode="interactive"
contentContainerStyle={styles.modalScrollContent}
showsVerticalScrollIndicator={false}
>
<Text className={styles.tripHistoryLabel}>
Item {stepIndex + 1} / {total}
</Text>
<View className={styles.checkupProgressTrack}>
<View className={styles.checkupProgressFill} style={{ width: `${Math.round(((stepIndex + 1) / total) * 100)}%` }} />
</View>
<Text className={styles.cardTitle}>{formatItemLabel(entry.name, entry.quantity)}</Text>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="layers-outline" size={12} color="#a1a1aa" />
<Text className={styles.cardMeta}>{entry.category || 'uncategorized'}</Text>
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="pin-outline" size={12} color="#a1a1aa" />
<Text className={styles.cardMeta}>
Current: {formatStatusLabel(entry.current.status, entry.current.lentTo)} · {entry.current.placement}
</Text>
</View>
{mode === 'question' ? (
<View className={styles.answerRowWide}>
<View className={styles.actionRow}>
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={onBack}>
<View className={styles.buttonContent}>
<Ionicons name="arrow-back-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Back</Text>
</View>
</Pressable>
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={onSkip}>
<View className={styles.buttonContent}>
<Ionicons name="play-forward-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Skip</Text>
</View>
</Pressable>
</View>
<Pressable className={styles.answerYesWide} onPress={onYes}>
<View className={styles.buttonContent}>
<Ionicons name="checkmark-circle-outline" size={14} color="#f8fafc" />
<Text className={styles.answerText}>Yes, correct</Text>
</View>
</Pressable>
<Pressable className={styles.answerNoWide} onPress={onNo}>
<View className={styles.buttonContent}>
<Ionicons name="create-outline" size={14} color="#f8fafc" />
<Text className={styles.answerText}>No, update</Text>
</View>
</Pressable>
</View>
) : (
<View className={styles.section}>
<Field label="Status" icon="radio-button-on-outline">
<ChipGroup
options={ITEM_STATUSES}
value={noForm.status}
onChange={(v) => setNoForm((prev) => ({ ...prev, status: v }))}
/>
</Field>
<Field label="Placement" icon="pin-outline">
<ChipGroup
options={ITEM_PLACEMENTS}
value={noForm.placement}
onChange={(v) => setNoForm((prev) => ({ ...prev, placement: v }))}
/>
</Field>
{noForm.placement === 'other' ? (
<Field label="Custom location" icon="navigate-outline">
<TextInput
className={styles.input}
value={noForm.placementCustom}
onChangeText={(v) => setNoForm((prev) => ({ ...prev, placementCustom: v }))}
placeholder="bath-kit"
placeholderTextColor="#71717a"
/>
</Field>
) : null}
{noForm.status === 'lent-to' ? (
<Field label="Lent to" icon="person-outline">
<TextInput
className={styles.input}
value={noForm.lentTo}
onChangeText={(v) => setNoForm((prev) => ({ ...prev, lentTo: v }))}
placeholder="Person name"
placeholderTextColor="#71717a"
/>
</Field>
) : null}
<Pressable
className={styles.inlineToggle}
onPress={() => setNoForm((prev) => ({ ...prev, updateMasterList: !prev.updateMasterList }))}
>
<View className={styles.sectionHeaderLeft}>
<Ionicons name={noForm.updateMasterList ? 'checkbox-outline' : 'square-outline'} size={16} color="#d4d4d8" />
<Text className={styles.inlineToggleText}>Also update item in trip list</Text>
</View>
</Pressable>
<View className={styles.actionRow}>
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={onBack}>
<View className={styles.buttonContent}>
<Ionicons name="arrow-back-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Back</Text>
</View>
</Pressable>
<Pressable className={cn(styles.primaryBtnTight, styles.flex)} onPress={onSaveNo}>
<View className={styles.buttonContent}>
<Ionicons name="arrow-forward-circle-outline" size={14} color="#ffffff" />
<Text className={styles.primaryBtnText}>Save + Next</Text>
</View>
</Pressable>
</View>
</View>
)}
</ScrollView>
)}
</View>
</KeyboardAvoidingView>
</View>
</Modal>
);
}

429
src/modals/ItemModal.js Normal file
View File

@@ -0,0 +1,429 @@
import React, { useEffect, useRef, useState } from 'react';
import { Image, KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import { ITEM_PLACEMENTS, ITEM_STATUSES } from '../constants';
import Field from '../components/Field';
import { styles } from '../styles';
import { cn } from '../utils/cn';
const CATEGORY_OPTIONS = ['toiletries', 'electronics', 'documents', 'outfits', 'accessories', 'other'];
const PRESET_CATEGORIES = CATEGORY_OPTIONS.filter((option) => option !== 'other');
const IMAGE_QUALITY_OPTIONS = ['low', 'balanced', 'high'];
function normalizeValue(value) {
return (value || '').trim().toLowerCase();
}
function optionLabel(value) {
return (value || '').replace(/-/g, ' ');
}
function SelectField({ value, placeholder, onPress }) {
return (
<Pressable className={styles.selectTrigger} onPress={onPress}>
<Text className={cn(styles.selectTriggerText, !value && styles.selectTriggerPlaceholder)}>{value ? optionLabel(value) : placeholder}</Text>
<Ionicons name="chevron-down" size={16} color="#a1a1aa" />
</Pressable>
);
}
function SelectPopupModal({ visible, title, options, value, onSelect, onClose }) {
if (!visible) return null;
return (
<Modal visible={visible} transparent animationType="none" onRequestClose={onClose}>
<View className={styles.selectModalBackdrop}>
<Pressable className={styles.selectModalBackdropHit} onPress={onClose} />
<View className={styles.selectModalCard}>
<View className={styles.sectionHeader}>
<Text className={styles.cardTitle}>{title}</Text>
<Pressable className={styles.secondaryBtnTight} onPress={onClose}>
<View className={styles.buttonContent}>
<Ionicons name="close" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Close</Text>
</View>
</Pressable>
</View>
<View className={styles.selectMenu}>
{options.map((option, index) => {
const active = value === option;
const isLast = index === options.length - 1;
return (
<Pressable
key={option}
className={cn(styles.selectMenuItem, active && styles.selectMenuItemActive, isLast && styles.selectMenuItemLast)}
onPress={() => onSelect(option)}
>
<Text className={cn(styles.selectMenuItemText, active && styles.selectMenuItemTextActive)}>{optionLabel(option)}</Text>
<Ionicons name={active ? 'checkmark-circle' : 'ellipse-outline'} size={16} color={active ? '#93c5fd' : '#71717a'} />
</Pressable>
);
})}
</View>
</View>
</View>
</Modal>
);
}
function qualityValue(level) {
if (level === 'high') return 0.95;
if (level === 'low') return 0.45;
return 0.75;
}
export default function ItemModal({
visible,
itemForm,
previousCustomPlacements,
setItemModalVisible,
updateItemForm,
pickItemImage,
takeItemImage,
saveItemFromModal,
}) {
const [categoryCustomMode, setCategoryCustomMode] = useState(false);
const [placementCustomMode, setPlacementCustomMode] = useState(false);
const [openPicker, setOpenPicker] = useState(null);
const nameInputRef = useRef(null);
const quantityInputRef = useRef(null);
const descriptionInputRef = useRef(null);
const lentToInputRef = useRef(null);
useEffect(() => {
if (!visible) {
setOpenPicker(null);
return;
}
const normalizedCategory = normalizeValue(itemForm.category);
const customCategory = !!normalizedCategory && !PRESET_CATEGORIES.includes(normalizedCategory);
setCategoryCustomMode(customCategory);
setPlacementCustomMode(itemForm.placement === 'other');
setOpenPicker(null);
}, [visible, itemForm.id]);
useEffect(() => {
if (!visible || itemForm.id) return undefined;
const timeout = setTimeout(() => {
nameInputRef.current?.focus?.();
}, 80);
return () => clearTimeout(timeout);
}, [visible, itemForm.id]);
const mediaOptions = {
quality: qualityValue(itemForm.imageQuality),
allowCrop: !!itemForm.imageAllowCrop,
};
const normalizedCategory = normalizeValue(itemForm.category);
const categorySelectValue = PRESET_CATEGORIES.includes(normalizedCategory) ? normalizedCategory : '';
const savedPlacementOptions = (previousCustomPlacements || []).slice(0, 6);
const savedPlacementValue = savedPlacementOptions.includes(itemForm.placementCustom) ? itemForm.placementCustom : '';
const pickerConfig = {
category: {
title: 'Select category',
options: CATEGORY_OPTIONS,
value: categorySelectValue,
onSelect: chooseCategory,
},
status: {
title: 'Select status',
options: ITEM_STATUSES,
value: itemForm.status,
onSelect: chooseStatus,
},
placement: {
title: 'Select placement',
options: ITEM_PLACEMENTS,
value: itemForm.placement,
onSelect: choosePlacement,
},
savedPlacement: {
title: 'Saved custom locations',
options: savedPlacementOptions,
value: savedPlacementValue,
onSelect: chooseSavedPlacement,
},
imageQuality: {
title: 'Image quality',
options: IMAGE_QUALITY_OPTIONS,
value: itemForm.imageQuality,
onSelect: chooseImageQuality,
},
};
const activePicker = openPicker ? pickerConfig[openPicker] : null;
function chooseCategory(value) {
if (value === 'other') {
setCategoryCustomMode(true);
if (PRESET_CATEGORIES.includes(normalizedCategory)) {
updateItemForm('category', '');
}
setOpenPicker(null);
return;
}
setCategoryCustomMode(false);
updateItemForm('category', value);
setOpenPicker(null);
}
function chooseStatus(value) {
updateItemForm('status', value);
setOpenPicker(null);
}
function choosePlacement(value) {
if (value === 'other') {
setPlacementCustomMode(true);
updateItemForm('placement', 'other');
setOpenPicker(null);
return;
}
setPlacementCustomMode(false);
updateItemForm('placement', value);
setOpenPicker(null);
}
function chooseSavedPlacement(value) {
updateItemForm('placementCustom', value);
setOpenPicker(null);
}
function chooseImageQuality(value) {
updateItemForm('imageQuality', value);
setOpenPicker(null);
}
function resetCategorySelector() {
setCategoryCustomMode(false);
updateItemForm('category', '');
setOpenPicker(null);
}
function resetPlacementSelector() {
setPlacementCustomMode(false);
updateItemForm('placement', ITEM_PLACEMENTS[0] || 'suitcase');
setOpenPicker(null);
}
return (
<Modal visible={visible} animationType="none" transparent>
<View className={styles.modalBackdrop}>
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
<View className={styles.modalCard}>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name={itemForm.id ? 'create-outline' : 'add-circle-outline'} size={16} color="#d4d4d8" />
</View>
<Text className={styles.cardTitle}>{itemForm.id ? 'Update Item' : 'Add Item'}</Text>
</View>
<Pressable className={styles.secondaryBtnTight} onPress={() => setItemModalVisible(false)}>
<View className={styles.buttonContent}>
<Ionicons name="close" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Close</Text>
</View>
</Pressable>
</View>
<ScrollView
keyboardShouldPersistTaps="handled"
keyboardDismissMode="interactive"
contentContainerStyle={styles.modalScrollContent}
showsVerticalScrollIndicator={false}
>
<Field label="Name" icon="text-outline">
<TextInput
ref={nameInputRef}
className={styles.input}
value={itemForm.name}
onChangeText={(v) => updateItemForm('name', v)}
placeholder="Toothbrush"
placeholderTextColor="#71717a"
returnKeyType="next"
blurOnSubmit={false}
onSubmitEditing={() => quantityInputRef.current?.focus?.()}
/>
</Field>
<Field label="Quantity" icon="albums-outline">
<TextInput
ref={quantityInputRef}
className={styles.input}
value={`${itemForm.quantity || 1}`}
onChangeText={(v) => {
const numeric = (v || '').replace(/[^0-9]/g, '');
updateItemForm('quantity', numeric ? Math.max(1, Number.parseInt(numeric, 10)) : 1);
}}
placeholder="1"
placeholderTextColor="#71717a"
keyboardType="number-pad"
returnKeyType="next"
blurOnSubmit={false}
onSubmitEditing={() => descriptionInputRef.current?.focus?.()}
/>
</Field>
<Field label="Description" icon="document-text-outline">
<TextInput
ref={descriptionInputRef}
className={styles.input}
value={itemForm.description}
onChangeText={(v) => updateItemForm('description', v)}
placeholder="Optional"
placeholderTextColor="#71717a"
returnKeyType={itemForm.status === 'lent-to' ? 'next' : 'done'}
onSubmitEditing={() => {
if (itemForm.status === 'lent-to') {
lentToInputRef.current?.focus?.();
}
}}
/>
</Field>
<Field label="Category" icon="layers-outline">
{categoryCustomMode ? (
<View className={styles.selectCustomRow}>
<TextInput
className={cn(styles.input, styles.flex)}
value={itemForm.category}
onChangeText={(v) => updateItemForm('category', v)}
placeholder="Custom category"
placeholderTextColor="#71717a"
/>
<Pressable className={styles.selectCustomResetBtn} onPress={resetCategorySelector}>
<Ionicons name="refresh-outline" size={16} color="#d4d4d8" />
</Pressable>
</View>
) : (
<SelectField
value={categorySelectValue}
placeholder="Select category"
onPress={() => setOpenPicker('category')}
/>
)}
</Field>
<Field label="Status" icon="radio-button-on-outline">
<SelectField
value={itemForm.status}
placeholder="Select status"
onPress={() => setOpenPicker('status')}
/>
</Field>
<Field label="Placement" icon="pin-outline">
{placementCustomMode ? (
<View className={styles.fieldWrap}>
<View className={styles.selectCustomRow}>
<TextInput
className={cn(styles.input, styles.flex)}
value={itemForm.placementCustom}
onChangeText={(v) => updateItemForm('placementCustom', v)}
placeholder="bath-kit"
placeholderTextColor="#71717a"
/>
<Pressable className={styles.selectCustomResetBtn} onPress={resetPlacementSelector}>
<Ionicons name="refresh-outline" size={16} color="#d4d4d8" />
</Pressable>
</View>
<Text className={styles.cardMeta}>Custom location</Text>
{savedPlacementOptions.length ? (
<SelectField
value={savedPlacementValue}
placeholder="Use saved custom location"
onPress={() => setOpenPicker('savedPlacement')}
/>
) : null}
</View>
) : (
<SelectField
value={itemForm.placement}
placeholder="Select placement"
onPress={() => setOpenPicker('placement')}
/>
)}
</Field>
{itemForm.status === 'lent-to' ? (
<Field label="Lent to" icon="person-outline">
<TextInput
ref={lentToInputRef}
className={styles.input}
value={itemForm.lentTo}
onChangeText={(v) => updateItemForm('lentTo', v)}
placeholder="Person name"
placeholderTextColor="#71717a"
returnKeyType="done"
/>
</Field>
) : null}
<View className={styles.actionRow}>
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={() => takeItemImage(mediaOptions)}>
<View className={styles.buttonContent}>
<Ionicons name="camera-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Take photo</Text>
</View>
</Pressable>
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={() => pickItemImage(mediaOptions)}>
<View className={styles.buttonContent}>
<Ionicons name="images-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>{itemForm.imageUri ? 'From gallery (change)' : 'From gallery'}</Text>
</View>
</Pressable>
</View>
{!!itemForm.imageUri ? (
<>
<Image source={{ uri: itemForm.imageUri }} className={styles.previewImageSmall} />
<Field label="Image optimization" icon="image-outline">
<SelectField
value={itemForm.imageQuality}
placeholder="Select quality"
onPress={() => setOpenPicker('imageQuality')}
/>
</Field>
<Pressable className={styles.inlineToggle} onPress={() => updateItemForm('imageAllowCrop', !itemForm.imageAllowCrop)}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name={itemForm.imageAllowCrop ? 'checkbox-outline' : 'square-outline'} size={16} color="#d4d4d8" />
<Text className={styles.inlineToggleText}>Enable optional crop before save</Text>
</View>
</Pressable>
</>
) : null}
<Pressable className={styles.primaryBtn} onPress={saveItemFromModal}>
<View className={styles.buttonContent}>
<Ionicons name="checkmark-circle-outline" size={15} color="#ffffff" />
<Text className={styles.primaryBtnText}>{itemForm.id ? 'Save Changes' : 'Add Item'}</Text>
</View>
</Pressable>
</ScrollView>
<SelectPopupModal
visible={!!activePicker}
title={activePicker?.title || 'Select option'}
options={activePicker?.options || []}
value={activePicker?.value || ''}
onSelect={(value) => activePicker?.onSelect?.(value)}
onClose={() => setOpenPicker(null)}
/>
</View>
</KeyboardAvoidingView>
</View>
</Modal>
);
}

View File

@@ -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>
);
}

View File

@@ -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>
);
}

View File

@@ -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>
);
}

View File

@@ -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>
);
}

View File

@@ -1,167 +1,244 @@
import { StyleSheet } from 'react-native';
import { Platform } from 'react-native';
import { TAB_BAR_HEIGHT } from './constants';
export function createStyles() {
return StyleSheet.create({
root: { flex: 1 },
scroll: {
flexGrow: 1,
alignItems: 'center',
justifyContent: 'center',
padding: 24,
paddingVertical: 48,
},
title: {
fontSize: 44,
fontWeight: '900',
marginBottom: 20,
letterSpacing: 1,
},
logo: {
width: 100,
height: 100,
marginBottom: 20,
borderRadius: 22,
},
topRow: {
width: '100%',
maxWidth: 640,
alignItems: 'center',
gap: 10,
marginBottom: 20,
},
backMenuBtn: {
paddingHorizontal: 18,
paddingVertical: 10,
borderRadius: 14,
borderWidth: 1.5,
},
toggleRow: {
flexDirection: 'row',
flexWrap: 'wrap',
gap: 10,
justifyContent: 'center',
},
toggleBtn: {
paddingHorizontal: 16,
paddingVertical: 8,
borderRadius: 20,
borderWidth: 1.5,
},
toggleText: { fontSize: 14, fontWeight: '600' },
modeSelectLabel: {
fontSize: 12,
letterSpacing: 2,
textTransform: 'uppercase',
marginBottom: 20,
},
modeCard: {
width: '100%',
maxWidth: 440,
borderRadius: 22,
padding: 28,
borderWidth: 2,
alignItems: 'center',
marginBottom: 16,
shadowColor: '#000',
shadowOffset: { width: 0, height: 6 },
shadowOpacity: 0.18,
shadowRadius: 14,
elevation: 7,
},
modeTitle: {
fontSize: 26,
fontWeight: '800',
marginBottom: 8,
letterSpacing: 0.5,
},
modeDesc: {
fontSize: 14,
textAlign: 'center',
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,
},
inputLabel: {
fontSize: 12,
letterSpacing: 1,
textTransform: 'uppercase',
marginBottom: 10,
},
inputRow: {
flexDirection: 'row',
alignItems: 'center',
gap: 10,
marginBottom: 16,
},
timerInputGroup: { alignItems: 'center', gap: 4 },
inputUnit: { fontSize: 11, fontWeight: '600', letterSpacing: 1.5 },
timeInput: {
width: 72,
height: 58,
borderRadius: 12,
borderWidth: 2,
textAlign: 'center',
fontSize: 28,
fontWeight: '800',
},
colon: { fontSize: 34, fontWeight: '900' },
btnRow: {
flexDirection: 'row',
gap: 12,
marginTop: 20,
alignItems: 'center',
},
setBtn: {
paddingHorizontal: 32,
paddingVertical: 14,
borderRadius: 14,
},
setBtnText: { color: '#fff', fontSize: 16, fontWeight: '700', letterSpacing: 0.5 },
resetBtn: {
paddingHorizontal: 20,
paddingVertical: 13,
borderRadius: 14,
borderWidth: 1.5,
},
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,
},
focusExitText: { fontSize: 14, fontWeight: '600' },
});
}
export const styles = {
safe: 'flex-1 bg-[#09090b]',
flex: 'flex-1',
content: {
paddingHorizontal: 16,
paddingTop: 14,
paddingBottom: TAB_BAR_HEIGHT + 24,
gap: 18,
},
statusSpacer: Platform.OS === 'android' ? 'h-2' : 'h-0',
center: 'flex-1 items-center justify-center',
muted: 'text-[#a1a1aa] text-sm leading-5',
loadingEmoji: 'text-[56px] mb-3',
loadingTitle: 'text-[#fafafa] font-black text-[22px] mb-3',
loadingBarTrack: 'w-[178px] h-[8px] rounded-full bg-[#1f1f23] border border-[#2f2f35] overflow-hidden mb-2',
loadingBarFill: 'h-full rounded-full bg-[#3b82f6]',
loadingPercent: 'text-[#a1a1aa] text-xs font-semibold tracking-[0.4px]',
screenHero: 'rounded-xl bg-[#18181b] border border-[#27272a] p-5 gap-2 shadow-md',
screenHeroTop: 'flex-row items-center justify-between gap-3',
screenHeroTitle: 'text-[#fafafa] text-[26px] leading-[30px] font-black tracking-tight',
screenHeroSubtitle: 'text-[#a1a1aa] text-[13px] leading-[18px]',
screenHeroBadge: 'px-3 py-1.5 rounded-lg bg-[#27272a]',
screenHeroBadgeText: 'text-[#d4d4d8] text-xs font-semibold',
sectionHeader: 'flex-row items-center justify-between gap-3',
sectionHeaderLeft: 'flex-row items-center gap-2',
sectionHeaderIconWrap: 'w-7 h-7 rounded-lg bg-[#27272a] items-center justify-center',
sectionSubtle: 'text-[#a1a1aa] text-sm leading-5',
tripPickerWrap: 'gap-2',
tripPickerTitle: 'text-[#d4d4d8] text-sm font-semibold',
tripPickerMoreBadge: 'text-[#93c5fd] text-xs font-semibold px-2 py-1 rounded-lg bg-[#172338] border border-[#1e3a5f]',
tripPickerGrid: {
flexDirection: 'row',
flexWrap: 'wrap',
gap: 10,
},
tripPickerScrollRow: {
gap: 10,
paddingRight: 4,
},
tripPickerMoreHintRow: 'flex-row items-center gap-1.5 px-1',
tripPickerMoreHintText: 'text-[#94a3b8] text-xs font-medium',
tripChipGridItem: {
width: '48.5%',
},
tripChipSingle: {
width: '100%',
},
tripChip: 'px-3.5 py-3.5 rounded-xl bg-[#18181b] border border-[#27272a] gap-1 shadow-md',
tripChipActive: 'bg-[#1e293b] border-[#60a5fa]',
tripChipText: 'text-[#f4f4f5] font-semibold text-base',
tripChipTextActive: 'text-[#f8fafc]',
tripChipSub: 'text-[#a1a1aa] text-xs',
tripChipSubActive: 'text-[#cbd5e1]',
section: 'gap-5',
sectionTitle: 'text-[#f4f4f5] text-[22px] leading-7 font-black tracking-tight',
sectionRow: 'flex-row justify-between items-center gap-3',
card: 'bg-[#18181b] rounded-xl border border-[#27272a] p-4 gap-3 shadow-md',
cardActive: 'border-[#60a5fa]',
cardArchived: 'opacity-[0.7] border-[#3f3f46]',
cardSoft: 'bg-[#111114] rounded-xl border border-[#27272a] p-4 gap-3 shadow-md',
cardRow: 'flex-row gap-3 items-start',
cardTitle: 'text-[#fafafa] font-bold text-[17px] leading-6',
cardMeta: 'text-[#a1a1aa] text-[13px] leading-[18px]',
tripHistoryLabel: 'text-[#93c5fd] text-sm font-medium',
tripHeroCard: 'bg-[#18181b] rounded-xl border border-[#27272a] p-5 gap-2 shadow-md',
tripHeroImage: 'w-full h-[180px] rounded-xl bg-[#111114]',
tripHeroTitle: 'text-[#fafafa] font-black text-[22px] leading-7',
tripListTitle: 'text-[#d4d4d8] font-semibold text-sm tracking-[0.5px] uppercase',
fieldWrap: 'gap-1.5',
labelRow: 'flex-row items-center gap-2',
label: 'text-[#d4d4d8] font-medium text-sm',
input: 'border border-[#3f3f46] rounded-xl bg-[#111114] text-[#f4f4f5] px-3.5 py-3',
selectCustomRow: 'flex-row items-center gap-2',
selectCustomResetBtn: 'w-11 h-11 rounded-xl bg-[#27272a] border border-[#3f3f46] items-center justify-center',
inputMultiline: {
borderWidth: 1,
borderColor: '#3f3f46',
borderRadius: 12,
backgroundColor: '#111114',
color: '#f4f4f5',
paddingHorizontal: 12,
paddingVertical: 10,
minHeight: 150,
textAlignVertical: 'top',
fontSize: 13,
fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
},
exportJsonBlock: {
borderWidth: 1,
borderColor: '#3f3f46',
borderRadius: 12,
backgroundColor: '#111114',
paddingHorizontal: 12,
paddingVertical: 10,
minHeight: 150,
},
exportJsonText: {
color: '#f4f4f5',
fontSize: 13,
lineHeight: 18,
fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
},
dateInput: 'border border-[#3f3f46] rounded-xl bg-[#111114] px-3.5 py-3',
dateInputText: 'text-[#e4e4e7] font-medium',
chipGroup: 'flex-row flex-wrap gap-2',
chip: 'rounded-xl px-3 py-2 border border-[#3f3f46] bg-[#111114]',
chipActive: 'border-[#60a5fa] bg-[#172338]',
chipText: 'text-[#d4d4d8] font-medium text-xs',
chipTextActive: 'text-[#e0f2fe]',
selectTrigger: 'rounded-xl border border-[#3f3f46] bg-[#111114] px-3.5 py-3 flex-row items-center justify-between',
selectTriggerText: 'text-[#e4e4e7] text-sm font-medium',
selectTriggerPlaceholder: 'text-[#71717a] font-normal',
selectModalBackdrop: 'absolute inset-0 justify-center px-5',
selectModalBackdropHit: 'absolute inset-0 bg-[rgba(9,9,11,0.76)]',
selectModalCard: 'bg-[#18181b] rounded-xl border border-[#27272a] p-4 gap-3 shadow-md',
selectMenu: 'rounded-xl border border-[#3f3f46] bg-[#111114] overflow-hidden',
selectMenuItem: 'px-3.5 py-3 flex-row items-center justify-between border-b border-[#27272a]',
selectMenuItemLast: 'border-b-0',
selectMenuItemActive: 'bg-[#172338]',
selectMenuItemText: 'text-[#d4d4d8] text-sm font-medium',
selectMenuItemTextActive: 'text-[#e0f2fe]',
primaryBtn: 'mt-2 rounded-xl bg-[#2563eb] items-center justify-center py-3 px-3.5 w-full',
primaryBtnTight: 'rounded-xl bg-[#2563eb] items-center justify-center py-2.5 px-3.5',
primaryBtnText: 'text-white font-semibold text-sm',
secondaryBtn: 'mt-2 rounded-xl bg-[#27272a] border border-[#3f3f46] items-center justify-center py-3 px-3.5 w-full',
secondaryBtnTight: 'rounded-xl bg-[#27272a] border border-[#3f3f46] items-center justify-center py-2.5 px-3.5',
secondaryBtnText: 'text-[#f4f4f5] font-semibold text-sm',
actionRow: 'flex-row gap-2 mt-2',
actionRowInline: 'flex-row gap-2',
buttonContent: 'flex-row items-center justify-center gap-2',
inlineToggle: 'mt-1 rounded-xl bg-[#111114] border border-[#3f3f46] px-3.5 py-2.5',
inlineToggleText: 'text-[#d4d4d8] text-sm',
stackButtons: 'gap-2',
miniBtn: 'bg-[#27272a] border border-[#3f3f46] rounded-xl py-2 px-2.5',
miniBtnDanger: 'bg-[#3f1d1d] border border-[#7f1d1d] rounded-xl py-2 px-2.5',
miniBtnText: 'text-[#f4f4f5] font-semibold text-xs',
itemCard: 'rounded-xl bg-[#18181b] border border-[#27272a] overflow-hidden flex-row items-start shadow-md',
itemAccent: 'w-[4px] self-stretch',
itemThumbWrap: 'pt-4 pl-3.5',
itemThumbSmall: 'w-[46px] h-[46px] rounded-xl bg-[#111114]',
itemThumbPlaceholder: 'w-[46px] h-[46px] rounded-xl bg-[#111114] items-center justify-center border border-[#3f3f46]',
itemThumbPlaceholderText: 'text-xl',
itemMain: 'flex-1 p-4 gap-2',
itemTitle: 'text-[#fafafa] font-semibold text-base',
itemMeta: 'text-[#a1a1aa] text-[13px] leading-[18px]',
quickStatusRow: 'flex-row gap-2 mt-1',
quickStatusBtn: 'py-1.5 px-2.5 rounded-xl border border-[#3f3f46] bg-[#111114]',
quickStatusBtnActive: 'border-[#60a5fa] bg-[#1e293b]',
quickStatusBtnText: 'text-[#d4d4d8] font-semibold text-xs',
quickStatusBtnTextActive: 'text-[#e0f2fe]',
answerRow: 'mt-3 flex-row items-center gap-3',
answerYes: 'bg-[#14532d] border border-[#166534] rounded-xl px-4 py-3',
answerNo: 'bg-[#3f1d1d] border border-[#7f1d1d] rounded-xl px-4 py-3',
answerText: 'text-[#f8fafc] font-semibold',
answerRowWide: 'mt-4 gap-3',
checkupProgressTrack: 'w-full h-2 rounded-full bg-[#27272a] overflow-hidden mt-2 mb-3',
checkupProgressFill: 'h-full bg-[#2563eb]',
answerYesWide: 'bg-[#14532d] border border-[#166534] rounded-xl px-4 py-3.5 items-center',
answerNoWide: 'bg-[#3f1d1d] border border-[#7f1d1d] rounded-xl px-4 py-3.5 items-center',
answerStateDot: 'w-[10px] h-[10px] rounded-full bg-[#475569]',
answerStateDotOn: 'bg-[#22c55e]',
answerStateDotBad: 'bg-[#ef4444]',
statsRow: 'flex-row gap-2 flex-wrap mt-1',
statPill: 'rounded-xl py-1.5 px-2.5 border',
statPillCorrect: 'bg-[#14532d] border-[#166534]',
statPillBad: 'bg-[#3f1d1d] border-[#7f1d1d]',
statPillPending: 'bg-[#27272a] border-[#3f3f46]',
statPillText: 'text-[#f4f4f5] font-semibold text-xs',
packProgressLabel: 'text-[#d4d4d8] text-sm font-medium',
packProgressMeta: 'text-[#a1a1aa] text-xs font-semibold',
packProgressTrack: 'w-full h-2 rounded-full bg-[#27272a] overflow-hidden',
packProgressFill: 'h-full bg-[#22c55e]',
snapshotWrap: 'mt-3 border-t border-t-[#27272a] pt-3 gap-2',
snapshotRow: 'py-1.5',
snapshotTitle: 'text-[#f4f4f5] font-medium text-sm',
previewImage: 'w-full h-[160px] rounded-xl bg-[#111114]',
previewImageSmall: 'w-full h-[132px] rounded-xl bg-[#111114]',
imagePreviewBackdrop: 'flex-1 bg-[rgba(9,9,11,0.88)] items-center justify-center px-5',
imagePreviewCard: 'w-full max-w-[460px] rounded-xl border border-[#3f3f46] bg-[#18181b] p-5 gap-3 shadow-md',
imagePreviewImage: 'w-full h-[360px] rounded-xl bg-[#111114]',
imagePreviewHint: 'text-[#a1a1aa] text-center text-xs font-medium',
tabBarWrap: Platform.OS === 'ios'
? 'absolute bottom-[6px] left-0 right-0 px-[10px] pb-[14px]'
: 'absolute bottom-[6px] left-0 right-0 px-[10px] pb-2',
tabBar: 'h-[72px] rounded-2xl bg-[#0b1220] border border-[#1f2937] flex-row items-center justify-between px-2',
tabGroupSide: 'flex-row w-[42%] justify-around items-center',
tabItem: 'items-center justify-center gap-[3px] min-w-[56px]',
tabAddBtn: 'w-[54px] h-[54px] rounded-full items-center justify-center bg-[#2563eb] -mt-6 border-2 border-[#0b1220]',
tabAddBtnDisabled: 'opacity-[0.45]',
tabLabel: 'text-[#94a3b8] text-[11px] font-semibold',
tabLabelActive: 'text-[#dbeafe]',
modalBackdrop: 'flex-1 bg-[rgba(9,9,11,0.8)] px-5',
dialogBackdrop: 'flex-1 bg-[rgba(9,9,11,0.8)] items-center justify-center px-6',
dialogCard: 'w-full bg-[#18181b] rounded-xl border border-[#27272a] p-6 gap-5 shadow-md',
dialogTitle: 'text-[#fafafa] font-bold text-lg',
dialogMessage: 'text-[#d4d4d8] leading-6 text-sm',
dialogButtonsRow: 'flex-row gap-3 justify-end flex-wrap',
dialogBtn: 'rounded-xl py-2.5 px-3.5 border min-w-[92px] items-center',
dialogBtnPrimary: 'bg-[#2563eb] border-[#2563eb]',
dialogBtnDanger: 'bg-[#7f1d1d] border-[#991b1b]',
dialogBtnNeutral: 'bg-[#27272a] border-[#3f3f46]',
dialogBtnText: 'text-[#f8fafc] font-semibold text-sm',
modalKeyboardWrap: 'flex-1 w-full items-center justify-center',
modalCard: 'w-[96%] max-h-[92%] bg-[#18181b] rounded-xl border border-[#27272a] p-6 gap-4 shadow-md',
modalScrollContent: {
paddingBottom: 20,
gap: 12,
},
closeText: 'text-[#d4d4d8] font-semibold text-sm',
dateModalBackdrop: 'flex-1 bg-[rgba(9,9,11,0.82)] justify-center px-5',
dateModalCard: 'bg-[#18181b] rounded-xl border border-[#27272a] p-6 gap-4 shadow-md',
calendarHeader: 'flex-row items-center justify-between',
calendarNavBtn: 'w-9 h-9 items-center justify-center rounded-xl bg-[#27272a]',
calendarNavText: 'text-[#e4e4e7] text-[20px] font-bold leading-[22px]',
calendarMonthText: 'text-[#fafafa] font-bold text-base',
calendarWeekRow: 'flex-row justify-between',
calendarWeekday: 'text-[#a1a1aa] w-[14.2%] text-center text-xs',
calendarGrid: 'flex-row flex-wrap',
calendarCell: 'w-[14.2%] h-[38px] items-center justify-center rounded-xl my-0.5',
calendarCellActive: 'bg-[#2563eb]',
calendarCellText: 'text-[#d4d4d8] font-medium',
calendarCellTextActive: 'text-white font-semibold',
};

64
src/tabs/CheckupTab.js Normal file
View File

@@ -0,0 +1,64 @@
import React from 'react';
import { Pressable, Text, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import { styles } from '../styles';
import { cn } from '../utils/cn';
export default function CheckupTab({ selectedTrip, selectedTripItems, checkupStats, startCheckupFlow }) {
return (
<View className={styles.section}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name="checkmark-circle-outline" size={16} color="#d4d4d8" />
</View>
<Text className={styles.sectionTitle}>Check-Up Session</Text>
</View>
{!selectedTrip ? (
<View className={styles.cardSoft}>
<Text className={styles.muted}>Select a trip first.</Text>
</View>
) : null}
{selectedTrip && selectedTripItems.length === 0 ? (
<View className={styles.cardSoft}>
<Text className={styles.muted}>No items for this trip yet.</Text>
</View>
) : null}
{selectedTrip && selectedTripItems.length > 0 ? (
<View className={styles.cardSoft}>
<Text className={styles.cardTitle}>Run a check-up for {selectedTrip.name}</Text>
<Text className={styles.cardMeta}>{selectedTripItems.length} items will be checked one by one.</Text>
<View className={styles.statsRow}>
<View className={cn(styles.statPill, styles.statPillCorrect)}>
<View className={styles.buttonContent}>
<Ionicons name="checkmark-circle-outline" size={12} color="#f4f4f5" />
<Text className={styles.statPillText}>Correct: {checkupStats.correct}</Text>
</View>
</View>
<View className={cn(styles.statPill, styles.statPillBad)}>
<View className={styles.buttonContent}>
<Ionicons name="close-circle-outline" size={12} color="#f4f4f5" />
<Text className={styles.statPillText}>Bad: {checkupStats.bad}</Text>
</View>
</View>
<View className={cn(styles.statPill, styles.statPillPending)}>
<View className={styles.buttonContent}>
<Ionicons name="pause-circle-outline" size={12} color="#f4f4f5" />
<Text className={styles.statPillText}>Pending: {checkupStats.pending}</Text>
</View>
</View>
</View>
<Pressable className={styles.primaryBtn} onPress={startCheckupFlow}>
<View className={styles.buttonContent}>
<Ionicons name="play-circle-outline" size={15} color="#ffffff" />
<Text className={styles.primaryBtnText}>Start Check-Up</Text>
</View>
</Pressable>
</View>
) : null}
</View>
);
}

80
src/tabs/HistoryTab.js Normal file
View File

@@ -0,0 +1,80 @@
import React from 'react';
import { Pressable, Text, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import { styles } from '../styles';
import { formatItemLabel, formatStatusLabel } from '../utils/labels';
export default function HistoryTab({ selectedTrip, selectedTripCheckups, selectedCheckupId, setSelectedCheckupId, onDeleteCheckup }) {
return (
<View className={styles.section}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name="time-outline" size={16} color="#d4d4d8" />
</View>
<Text className={styles.sectionTitle}>Check-Up History</Text>
</View>
{!selectedTrip ? (
<View className={styles.cardSoft}>
<Text className={styles.muted}>Select a trip first.</Text>
</View>
) : null}
{selectedTrip ? (
<View className={styles.sectionHeaderLeft}>
<Ionicons name="briefcase-outline" size={13} color="#93c5fd" />
<Text className={styles.tripHistoryLabel}>Check-ups for: {selectedTrip.name}</Text>
</View>
) : null}
{selectedTrip && selectedTripCheckups.length === 0 ? (
<View className={styles.cardSoft}>
<Text className={styles.muted}>No check-ups saved yet.</Text>
</View>
) : null}
{selectedTripCheckups.map((checkup) => (
<View key={checkup.id} className={styles.cardSoft}>
<Pressable
onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}
onLongPress={() => onDeleteCheckup(checkup.id)}
delayLongPress={280}
>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="calendar-outline" size={14} color="#a1a1aa" />
<Text className={styles.cardTitle}>{new Date(checkup.createdAt).toLocaleString()}</Text>
</View>
<Ionicons name={selectedCheckupId === checkup.id ? 'chevron-up' : 'chevron-down'} size={16} color="#a1a1aa" />
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="analytics-outline" size={13} color="#a1a1aa" />
<Text className={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>
</View>
<Text className={styles.cardMeta}>{selectedCheckupId === checkup.id ? 'Tap to collapse' : 'Tap to open'} · long hold to delete</Text>
</Pressable>
{selectedCheckupId === checkup.id ? (
<View className={styles.snapshotWrap}>
{checkup.snapshot.map((entry) => (
<View key={entry.itemId} className={styles.snapshotRow}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="cube-outline" size={12} color="#a1a1aa" />
<Text className={styles.snapshotTitle}>{formatItemLabel(entry.name, entry.quantity)}</Text>
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="pin-outline" size={12} color="#a1a1aa" />
<Text className={styles.cardMeta}>
{formatStatusLabel(entry.status, entry.lentTo)} · {entry.placement}
</Text>
</View>
</View>
))}
</View>
) : null}
</View>
))}
</View>
);
}

206
src/tabs/ItemsTab.js Normal file
View File

@@ -0,0 +1,206 @@
import React, { useMemo, useState } from 'react';
import { Image, Modal, Pressable, Text, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import ItemCard from '../components/ItemCard';
import { ITEM_STATUSES } from '../constants';
import { styles } from '../styles';
import { cn } from '../utils/cn';
import { formatFilterLabel, formatStatusLabel } from '../utils/labels';
export default function ItemsTab({
selectedTrip,
selectedTripItems,
openAddItemModal,
openEditItemModal,
deleteItem,
quickSetItemStatus,
bulkSetItemStatus,
}) {
const [statusFilter, setStatusFilter] = useState('all');
const [categoryFilter, setCategoryFilter] = useState('all');
const [locationFilter, setLocationFilter] = useState('all');
const [imagePreviewUri, setImagePreviewUri] = useState('');
const categories = useMemo(
() => Array.from(new Set(selectedTripItems.map((item) => item.category?.trim()).filter(Boolean))).sort((a, b) => a.localeCompare(b)),
[selectedTripItems]
);
const locations = useMemo(
() => Array.from(new Set(selectedTripItems.map((item) => item.placement?.trim()).filter(Boolean))).sort((a, b) => a.localeCompare(b)),
[selectedTripItems]
);
const filteredItems = useMemo(
() =>
selectedTripItems.filter((item) => {
const matchStatus = statusFilter === 'all' || item.status === statusFilter;
const itemCategory = item.category?.trim() || '';
const itemLocation = item.placement?.trim() || '';
const matchCategory = categoryFilter === 'all' || itemCategory === categoryFilter;
const matchLocation = locationFilter === 'all' || itemLocation === locationFilter;
return matchStatus && matchCategory && matchLocation;
}),
[selectedTripItems, statusFilter, categoryFilter, locationFilter]
);
const packedItemCount = useMemo(
() => selectedTripItems.filter((item) => item.status === 'packed').length,
[selectedTripItems]
);
const packProgress = selectedTripItems.length ? packedItemCount / selectedTripItems.length : 0;
const filterStatusOptions = ['all', ...ITEM_STATUSES];
const filterCategoryOptions = ['all', ...categories];
const filterLocationOptions = ['all', ...locations];
return (
<View className={styles.section}>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name="briefcase-outline" size={16} color="#d4d4d8" />
</View>
<Text className={styles.sectionTitle}>Packing List</Text>
</View>
<Pressable className={styles.primaryBtnTight} onPress={openAddItemModal}>
<View className={styles.buttonContent}>
<Ionicons name="add-circle-outline" size={14} color="#ffffff" />
<Text className={styles.primaryBtnText}>Add</Text>
</View>
</Pressable>
</View>
{!selectedTrip ? (
<View className={styles.cardSoft}>
<Text className={styles.muted}>Select a trip first.</Text>
</View>
) : null}
{selectedTripItems.length === 0 && selectedTrip ? (
<View className={styles.cardSoft}>
<Text className={styles.muted}>No items yet.</Text>
</View>
) : null}
{selectedTrip && selectedTripItems.length > 0 ? (
<View className={styles.cardSoft}>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="checkmark-done-outline" size={16} color="#86efac" />
<Text className={styles.cardTitle}>Progress</Text>
</View>
<Text className={styles.packProgressMeta}>{Math.round(packProgress * 100)}%</Text>
</View>
<Text className={styles.packProgressLabel}>{packedItemCount}/{selectedTripItems.length} items packed</Text>
<View className={styles.packProgressTrack}>
<View className={styles.packProgressFill} style={{ width: `${Math.round(packProgress * 100)}%` }} />
</View>
</View>
) : null}
{selectedTrip ? (
<View className={styles.cardSoft}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="flash-outline" size={16} color="#d4d4d8" />
<Text className={styles.cardTitle}>Quick Actions</Text>
</View>
<View className={styles.actionRow}>
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={() => bulkSetItemStatus(filteredItems.map((x) => x.id), 'packed')}>
<View className={styles.buttonContent}>
<Ionicons name="checkmark-circle-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Pack All ({filteredItems.length})</Text>
</View>
</Pressable>
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={() => bulkSetItemStatus(filteredItems.map((x) => x.id), 'unpacked')}>
<View className={styles.buttonContent}>
<Ionicons name="remove-circle-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Unpack All ({filteredItems.length})</Text>
</View>
</Pressable>
</View>
</View>
) : null}
{selectedTripItems.length > 0 ? (
<View className={styles.cardSoft}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="funnel-outline" size={16} color="#d4d4d8" />
<Text className={styles.cardTitle}>Filters</Text>
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="radio-button-on-outline" size={12} color="#a1a1aa" />
<Text className={styles.cardMeta}>Status</Text>
</View>
<View className={styles.chipGroup}>
{filterStatusOptions.map((status) => {
const active = statusFilter === status;
return (
<Pressable key={status} className={cn(styles.chip, active && styles.chipActive)} onPress={() => setStatusFilter(status)}>
<Text className={cn(styles.chipText, active && styles.chipTextActive)}>{status === 'all' ? formatFilterLabel(status) : formatStatusLabel(status)}</Text>
</Pressable>
);
})}
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="layers-outline" size={12} color="#a1a1aa" />
<Text className={styles.cardMeta}>Category</Text>
</View>
<View className={styles.chipGroup}>
{filterCategoryOptions.map((category) => {
const active = categoryFilter === category;
return (
<Pressable key={category} className={cn(styles.chip, active && styles.chipActive)} onPress={() => setCategoryFilter(category)}>
<Text className={cn(styles.chipText, active && styles.chipTextActive)}>{formatFilterLabel(category)}</Text>
</Pressable>
);
})}
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="pin-outline" size={12} color="#a1a1aa" />
<Text className={styles.cardMeta}>Location</Text>
</View>
<View className={styles.chipGroup}>
{filterLocationOptions.map((location) => {
const active = locationFilter === location;
return (
<Pressable key={location} className={cn(styles.chip, active && styles.chipActive)} onPress={() => setLocationFilter(location)}>
<Text className={cn(styles.chipText, active && styles.chipTextActive)}>{formatFilterLabel(location)}</Text>
</Pressable>
);
})}
</View>
</View>
) : null}
{filteredItems.map((item) => (
<ItemCard
key={item.id}
item={item}
onEdit={openEditItemModal}
onDelete={deleteItem}
onQuickPack={() => quickSetItemStatus(item.id, 'packed')}
onQuickUnpack={() => quickSetItemStatus(item.id, 'unpacked')}
onOpenImage={(uri) => setImagePreviewUri(uri)}
/>
))}
{selectedTripItems.length > 0 && filteredItems.length === 0 ? (
<View className={styles.cardSoft}>
<Text className={styles.muted}>No items match the current filters.</Text>
</View>
) : null}
<Modal visible={!!imagePreviewUri} transparent animationType="fade">
<Pressable className={styles.imagePreviewBackdrop} onPress={() => setImagePreviewUri('')}>
<Pressable className={styles.imagePreviewCard} onPress={() => {}}>
{imagePreviewUri ? <Image source={{ uri: imagePreviewUri }} className={styles.imagePreviewImage} resizeMode="contain" /> : null}
<Text className={styles.imagePreviewHint}>Tap outside to close</Text>
</Pressable>
</Pressable>
</Modal>
</View>
);
}

444
src/tabs/TripsTab.js Normal file
View File

@@ -0,0 +1,444 @@
import React, { useMemo, useState } from 'react';
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import DatePickerModal from '../components/DatePickerModal';
import Field from '../components/Field';
import { styles } from '../styles';
import { cn } from '../utils/cn';
function DateField({ label, value, onPress }) {
return (
<Field label={label} icon="calendar-outline">
<Pressable className={styles.dateInput} onPress={onPress}>
<View className={styles.sectionHeader}>
<Text className={styles.dateInputText}>{value}</Text>
<Ionicons name="chevron-forward" size={14} color="#a1a1aa" />
</View>
</Pressable>
</Field>
);
}
const emptyEditForm = {
name: '',
location: '',
startDate: '',
endDate: '',
};
export default function TripsTab({
tripForm,
updateTripForm,
templateTrip,
createTrip,
trips,
selectedTripId,
setTripAsTemplate,
saveTripEdits,
setTripArchived,
deleteTrip,
onInputFocus,
defaultTemplateTripId,
openDatePicker,
activeTripItemCount,
activeTripPackedCount,
activeTripCheckupCount,
openBackupModal,
}) {
const [createModalVisible, setCreateModalVisible] = useState(false);
const [viewTripId, setViewTripId] = useState(null);
const [editMode, setEditMode] = useState(false);
const [editForm, setEditForm] = useState(emptyEditForm);
const [viewDatePicker, setViewDatePicker] = useState({ visible: false, field: 'startDate' });
const activeTrip = useMemo(() => trips.find((trip) => trip.id === selectedTripId) || null, [trips, selectedTripId]);
const viewingTrip = useMemo(() => trips.find((trip) => trip.id === viewTripId) || null, [trips, viewTripId]);
const activeTrips = useMemo(() => trips.filter((trip) => !trip.archived), [trips]);
const archivedTrips = useMemo(() => trips.filter((trip) => trip.archived), [trips]);
function submitCreateTrip() {
const ok = createTrip();
if (ok) setCreateModalVisible(false);
}
function openView(tripId) {
const trip = trips.find((x) => x.id === tripId);
if (!trip) return;
setViewTripId(tripId);
setEditMode(false);
setEditForm({
name: trip.name || '',
location: trip.location || '',
startDate: trip.startDate || '',
endDate: trip.endDate || '',
});
}
function updateEditForm(field, value) {
setEditForm((prev) => ({ ...prev, [field]: value }));
}
function saveEditFromView() {
if (!viewingTrip) return;
const ok = saveTripEdits(viewingTrip.id, editForm);
if (!ok) return;
setEditMode(false);
}
function applyTemplateFromView() {
if (!viewingTrip) return;
setTripAsTemplate(viewingTrip.id);
}
function toggleArchiveFromView() {
if (!viewingTrip) return;
setTripArchived(viewingTrip.id, !viewingTrip.archived);
if (!viewingTrip.archived) {
setViewTripId(null);
setEditMode(false);
}
}
function deleteFromView() {
if (!viewingTrip) return;
const tripId = viewingTrip.id;
setViewTripId(null);
setEditMode(false);
deleteTrip(tripId);
}
return (
<View className={styles.section}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name="airplane-outline" size={16} color="#d4d4d8" />
</View>
<Text className={styles.sectionTitle}>Trip Planner</Text>
</View>
<View className={styles.actionRow}>
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={openBackupModal}>
<View className={styles.buttonContent}>
<Ionicons name="save-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Backup</Text>
</View>
</Pressable>
<Pressable className={cn(styles.primaryBtnTight, styles.flex)} onPress={() => setCreateModalVisible(true)}>
<View className={styles.buttonContent}>
<Ionicons name="add-circle-outline" size={14} color="#ffffff" />
<Text className={styles.primaryBtnText}>New Trip</Text>
</View>
</Pressable>
</View>
{activeTrip ? (
<View className={styles.tripHeroCard}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="location-outline" size={16} color="#d4d4d8" />
<Text className={styles.tripHeroTitle}>{activeTrip.name}</Text>
</View>
<Text className={styles.cardMeta}>{activeTrip.location || 'No location'} · {activeTrip.startDate} {activeTrip.endDate}</Text>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="layers-outline" size={13} color="#a1a1aa" />
<Text className={styles.cardMeta}>{activeTripItemCount} items · {activeTripCheckupCount} check-ups</Text>
</View>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="checkmark-done-outline" size={13} color="#86efac" />
<Text className={styles.packProgressLabel}>{activeTripPackedCount}/{activeTripItemCount} items packed</Text>
</View>
<Text className={styles.packProgressMeta}>{activeTripItemCount ? Math.round((activeTripPackedCount / activeTripItemCount) * 100) : 0}%</Text>
</View>
<View className={styles.packProgressTrack}>
<View
className={styles.packProgressFill}
style={{ width: `${activeTripItemCount ? (activeTripPackedCount / activeTripItemCount) * 100 : 0}%` }}
/>
</View>
</View>
) : (
<View className={styles.cardSoft}>
<Text className={styles.muted}>No active trips. Unarchive one or create a new trip.</Text>
</View>
)}
<Text className={styles.tripListTitle}>Active Trips</Text>
{activeTrips
.slice()
.sort((a, b) => b.startDate.localeCompare(a.startDate))
.map((trip) => (
<View key={trip.id} className={cn(styles.card, selectedTripId === trip.id && styles.cardActive)}>
<View className={styles.cardRow}>
<View className={styles.flex}>
<Text className={styles.cardTitle}>{trip.name}</Text>
<Text className={styles.cardMeta}>{trip.location || 'No location'} · {trip.startDate} {trip.endDate}</Text>
{defaultTemplateTripId === trip.id ? (
<View className={styles.sectionHeaderLeft}>
<Ionicons name="bookmark-outline" size={12} color="#a1a1aa" />
<Text className={styles.cardMeta}>Default template</Text>
</View>
) : null}
</View>
<View className={styles.stackButtons}>
<Pressable className={styles.miniBtn} onPress={() => openView(trip.id)}>
<View className={styles.buttonContent}>
<Ionicons name="eye-outline" size={12} color="#f4f4f5" />
<Text className={styles.miniBtnText}>View</Text>
</View>
</Pressable>
</View>
</View>
</View>
))}
{archivedTrips.length > 0 ? (
<>
<Text className={styles.tripListTitle}>Archived Trips</Text>
{archivedTrips
.slice()
.sort((a, b) => b.startDate.localeCompare(a.startDate))
.map((trip) => (
<View key={trip.id} className={cn(styles.card, styles.cardArchived)}>
<View className={styles.cardRow}>
<View className={styles.flex}>
<Text className={styles.cardTitle}>{trip.name}</Text>
<Text className={styles.cardMeta}>{trip.location || 'No location'} · {trip.startDate} {trip.endDate}</Text>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="archive-outline" size={12} color="#a1a1aa" />
<Text className={styles.cardMeta}>Archived</Text>
</View>
</View>
<View className={styles.stackButtons}>
<Pressable className={styles.miniBtn} onPress={() => openView(trip.id)}>
<View className={styles.buttonContent}>
<Ionicons name="eye-outline" size={12} color="#f4f4f5" />
<Text className={styles.miniBtnText}>View</Text>
</View>
</Pressable>
</View>
</View>
</View>
))}
</>
) : null}
<Modal visible={createModalVisible} animationType="slide" transparent>
<View className={styles.modalBackdrop}>
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
<View className={styles.modalCard}>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name="add-circle-outline" size={16} color="#d4d4d8" />
</View>
<Text className={styles.cardTitle}>Create Trip</Text>
</View>
<Pressable className={styles.secondaryBtnTight} onPress={() => setCreateModalVisible(false)}>
<View className={styles.buttonContent}>
<Ionicons name="close" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Close</Text>
</View>
</Pressable>
</View>
<ScrollView
keyboardShouldPersistTaps="handled"
keyboardDismissMode="interactive"
contentContainerStyle={styles.modalScrollContent}
showsVerticalScrollIndicator={false}
>
<Field label="Name" icon="text-outline">
<TextInput
className={styles.input}
value={tripForm.name}
onChangeText={(v) => updateTripForm('name', v)}
placeholder="Summer Weekend"
placeholderTextColor="#71717a"
onFocus={onInputFocus}
/>
</Field>
<Field label="Location" icon="location-outline">
<TextInput
className={styles.input}
value={tripForm.location}
onChangeText={(v) => updateTripForm('location', v)}
placeholder="Berlin"
placeholderTextColor="#71717a"
onFocus={onInputFocus}
/>
</Field>
<DateField label="Start Date" value={tripForm.startDate} onPress={() => openDatePicker('startDate')} />
<DateField label="End Date" value={tripForm.endDate} onPress={() => openDatePicker('endDate')} />
{templateTrip ? (
<Pressable className={styles.inlineToggle} onPress={() => updateTripForm('copyDefaultTemplate', !tripForm.copyDefaultTemplate)}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name={tripForm.copyDefaultTemplate ? 'checkbox-outline' : 'square-outline'} size={16} color="#d4d4d8" />
<Text className={styles.inlineToggleText}>Copy items from template ({templateTrip.name})</Text>
</View>
</Pressable>
) : null}
<Pressable className={styles.inlineToggle} onPress={() => updateTripForm('setAsDefaultTemplate', !tripForm.setAsDefaultTemplate)}>
<View className={styles.sectionHeaderLeft}>
<Ionicons name={tripForm.setAsDefaultTemplate ? 'checkbox-outline' : 'square-outline'} size={16} color="#d4d4d8" />
<Text className={styles.inlineToggleText}>Set as default template</Text>
</View>
</Pressable>
<Pressable className={styles.primaryBtn} onPress={submitCreateTrip}>
<View className={styles.buttonContent}>
<Ionicons name="checkmark-circle-outline" size={15} color="#ffffff" />
<Text className={styles.primaryBtnText}>Create Trip</Text>
</View>
</Pressable>
</ScrollView>
</View>
</KeyboardAvoidingView>
</View>
</Modal>
<Modal visible={!!viewingTrip} animationType="slide" transparent>
<View className={styles.modalBackdrop}>
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
<View className={styles.modalCard}>
<View className={styles.sectionHeader}>
<View className={styles.sectionHeaderLeft}>
<View className={styles.sectionHeaderIconWrap}>
<Ionicons name="compass-outline" size={16} color="#d4d4d8" />
</View>
<Text className={styles.cardTitle}>Trip Details</Text>
</View>
<Pressable
className={styles.secondaryBtnTight}
onPress={() => {
setViewTripId(null);
setEditMode(false);
}}
>
<View className={styles.buttonContent}>
<Ionicons name="close" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Close</Text>
</View>
</Pressable>
</View>
{viewingTrip ? (
<ScrollView
keyboardShouldPersistTaps="handled"
keyboardDismissMode="interactive"
contentContainerStyle={styles.modalScrollContent}
showsVerticalScrollIndicator={false}
>
{!editMode ? (
<>
<Text className={styles.tripHeroTitle}>{viewingTrip.name}</Text>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="location-outline" size={13} color="#a1a1aa" />
<Text className={styles.cardMeta}>{viewingTrip.location || 'No location'}</Text>
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="calendar-outline" size={13} color="#a1a1aa" />
<Text className={styles.cardMeta}>{viewingTrip.startDate} {viewingTrip.endDate}</Text>
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="bookmark-outline" size={13} color="#a1a1aa" />
<Text className={styles.cardMeta}>{defaultTemplateTripId === viewingTrip.id ? 'Default template trip' : 'Not default template'}</Text>
</View>
<View className={styles.sectionHeaderLeft}>
<Ionicons name="archive-outline" size={13} color="#a1a1aa" />
<Text className={styles.cardMeta}>{viewingTrip.archived ? 'Archived' : 'Active'}</Text>
</View>
<Pressable className={styles.secondaryBtn} onPress={() => setEditMode(true)}>
<View className={styles.buttonContent}>
<Ionicons name="create-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Edit Trip</Text>
</View>
</Pressable>
<Pressable className={styles.secondaryBtn} onPress={applyTemplateFromView}>
<View className={styles.buttonContent}>
<Ionicons name="bookmark-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Set as Template</Text>
</View>
</Pressable>
<Pressable className={styles.secondaryBtn} onPress={toggleArchiveFromView}>
<View className={styles.buttonContent}>
<Ionicons name={viewingTrip.archived ? 'refresh-outline' : 'archive-outline'} size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>{viewingTrip.archived ? 'Unarchive Trip' : 'Archive Trip'}</Text>
</View>
</Pressable>
<Pressable className={styles.secondaryBtn} onPress={deleteFromView}>
<View className={styles.buttonContent}>
<Ionicons name="trash-outline" size={14} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Delete Trip</Text>
</View>
</Pressable>
</>
) : (
<>
<Field label="Name" icon="text-outline">
<TextInput
className={styles.input}
value={editForm.name}
onChangeText={(v) => updateEditForm('name', v)}
placeholder="Trip name"
placeholderTextColor="#71717a"
onFocus={onInputFocus}
/>
</Field>
<Field label="Location" icon="location-outline">
<TextInput
className={styles.input}
value={editForm.location}
onChangeText={(v) => updateEditForm('location', v)}
placeholder="Location"
placeholderTextColor="#71717a"
onFocus={onInputFocus}
/>
</Field>
<DateField label="Start Date" value={editForm.startDate} onPress={() => setViewDatePicker({ visible: true, field: 'startDate' })} />
<DateField label="End Date" value={editForm.endDate} onPress={() => setViewDatePicker({ visible: true, field: 'endDate' })} />
<Pressable className={styles.primaryBtn} onPress={saveEditFromView}>
<View className={styles.buttonContent}>
<Ionicons name="checkmark-circle-outline" size={15} color="#ffffff" />
<Text className={styles.primaryBtnText}>Save Trip</Text>
</View>
</Pressable>
<Pressable className={styles.secondaryBtn} onPress={() => setEditMode(false)}>
<View className={styles.buttonContent}>
<Ionicons name="close-circle-outline" size={15} color="#f4f4f5" />
<Text className={styles.secondaryBtnText}>Cancel Edit</Text>
</View>
</Pressable>
</>
)}
</ScrollView>
) : null}
</View>
</KeyboardAvoidingView>
</View>
</Modal>
<DatePickerModal
visible={viewDatePicker.visible}
title={viewDatePicker.field === 'startDate' ? 'Pick start date' : 'Pick end date'}
value={editForm[viewDatePicker.field]}
onClose={() => setViewDatePicker((prev) => ({ ...prev, visible: false }))}
onSelect={(ymd) => {
updateEditForm(viewDatePicker.field, ymd);
setViewDatePicker((prev) => ({ ...prev, visible: false }));
}}
/>
</View>
);
}

View File

@@ -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',
};
}

10
src/uniwind-types.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
// NOTE: This file is generated by uniwind and it should not be edited manually.
/// <reference types="uniwind/types" />
declare module 'uniwind' {
export interface UniwindConfig {
themes: readonly ['light', 'dark']
}
}
export {}

76
src/utils/backup.js Normal file
View File

@@ -0,0 +1,76 @@
import { normalizeNameAndQuantity } from './labels';
export function normalizeItemRecord(item = {}) {
const normalized = normalizeNameAndQuantity(item.name, item.quantity);
return {
...item,
name: normalized.name,
quantity: normalized.quantity,
};
}
export function normalizeSnapshotRecord(entry = {}) {
const normalized = normalizeNameAndQuantity(entry.name, entry.quantity);
return {
...entry,
name: normalized.name,
quantity: normalized.quantity,
};
}
export function normalizePayloadShape(payload = {}) {
const itemsByTrip = {};
Object.entries(payload.itemsByTrip || {}).forEach(([tripId, items]) => {
itemsByTrip[tripId] = (Array.isArray(items) ? items : []).map(normalizeItemRecord);
});
const checkupsByTrip = {};
Object.entries(payload.checkupsByTrip || {}).forEach(([tripId, checkups]) => {
checkupsByTrip[tripId] = (Array.isArray(checkups) ? checkups : []).map((checkup) => ({
...checkup,
snapshot: (Array.isArray(checkup?.snapshot) ? checkup.snapshot : []).map(normalizeSnapshotRecord),
}));
});
return {
...payload,
itemsByTrip,
checkupsByTrip,
};
}
export function stringifyBackupData(data) {
return JSON.stringify(
{
version: 2,
exportedAt: new Date().toISOString(),
data,
},
null,
2
);
}
export function parseBackupText(rawText = '') {
if (!`${rawText || ''}`.trim()) {
return { ok: false, error: 'missing-backup' };
}
let parsed;
try {
parsed = JSON.parse(rawText);
} catch {
return { ok: false, error: 'invalid-json' };
}
const payload = parsed?.data && typeof parsed.data === 'object' ? parsed.data : parsed;
if (!payload || typeof payload !== 'object' || !Array.isArray(payload.trips) || !payload.itemsByTrip || !payload.checkupsByTrip) {
return { ok: false, error: 'invalid-backup' };
}
return {
ok: true,
payload: normalizePayloadShape(payload),
};
}

90
src/utils/backup.test.js Normal file
View File

@@ -0,0 +1,90 @@
import {
normalizeItemRecord,
normalizePayloadShape,
parseBackupText,
stringifyBackupData,
} from './backup';
describe('backup helpers', () => {
test('normalizeItemRecord migrates legacy quantity from item name', () => {
expect(
normalizeItemRecord({
id: 'item_1',
name: '3x socks',
quantity: 1,
})
).toEqual({
id: 'item_1',
name: 'socks',
quantity: 3,
});
});
test('normalizePayloadShape normalizes nested items and snapshots', () => {
const normalized = normalizePayloadShape({
trips: [],
itemsByTrip: {
trip_1: [{ id: 'item_1', name: '2x cables', quantity: 1 }],
},
checkupsByTrip: {
trip_1: [
{
id: 'checkup_1',
snapshot: [{ itemId: 'item_1', name: '4x batteries', quantity: 1 }],
},
],
},
});
expect(normalized.itemsByTrip.trip_1[0]).toEqual({
id: 'item_1',
name: 'cables',
quantity: 2,
});
expect(normalized.checkupsByTrip.trip_1[0].snapshot[0]).toEqual({
itemId: 'item_1',
name: 'batteries',
quantity: 4,
});
});
test('stringifyBackupData returns versioned backup payload', () => {
const json = stringifyBackupData({ trips: [] });
const parsed = JSON.parse(json);
expect(parsed.version).toBe(2);
expect(parsed.data).toEqual({ trips: [] });
expect(typeof parsed.exportedAt).toBe('string');
});
test('parseBackupText rejects missing and malformed payloads', () => {
expect(parseBackupText('')).toEqual({ ok: false, error: 'missing-backup' });
expect(parseBackupText('{bad')).toEqual({ ok: false, error: 'invalid-json' });
expect(parseBackupText('{"foo":1}')).toEqual({ ok: false, error: 'invalid-backup' });
});
test('parseBackupText accepts wrapped backup payloads and normalizes data', () => {
const wrapped = JSON.stringify({
version: 2,
data: {
trips: [{ id: 'trip_1' }],
itemsByTrip: {
trip_1: [{ id: 'item_1', name: '2x socks', quantity: 1 }],
},
checkupsByTrip: {
trip_1: [],
},
},
});
const result = parseBackupText(wrapped);
expect(result.ok).toBe(true);
expect(result.payload.itemsByTrip.trip_1[0]).toEqual({
id: 'item_1',
name: 'socks',
quantity: 2,
});
});
});

3
src/utils/cn.js Normal file
View File

@@ -0,0 +1,3 @@
export function cn(...parts) {
return parts.filter(Boolean).join(' ');
}

15
src/utils/cn.test.js Normal file
View File

@@ -0,0 +1,15 @@
import { cn } from './cn';
describe('cn', () => {
test('joins truthy class parts', () => {
expect(cn('a', 'b', 'c')).toBe('a b c');
});
test('skips falsy parts', () => {
expect(cn('a', '', null, undefined, false, 'b')).toBe('a b');
});
test('returns empty string when nothing is provided', () => {
expect(cn()).toBe('');
});
});

56
src/utils/date.js Normal file
View File

@@ -0,0 +1,56 @@
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;
}
export function findNextTripId(trips) {
const today = parseYMD(todayYMD());
if (!today) return null;
const next = trips
.map((trip) => ({ id: trip.id, start: parseYMD(trip.startDate) }))
.filter((trip) => !!trip.start && trip.start >= today)
.sort((a, b) => a.start - b.start)[0];
return next?.id || null;
}
export function findBestTripId(trips) {
const activeTripId = findActiveTripId(trips);
if (activeTripId) return activeTripId;
const nextTripId = findNextTripId(trips);
if (nextTripId) return nextTripId;
const latestPast = trips
.map((trip) => ({ id: trip.id, end: parseYMD(trip.endDate), start: parseYMD(trip.startDate) }))
.filter((trip) => !!trip.end || !!trip.start)
.sort((a, b) => {
const aTime = (a.end || a.start).getTime();
const bTime = (b.end || b.start).getTime();
return bTime - aTime;
})[0];
return latestPast?.id || null;
}

78
src/utils/date.test.js Normal file
View File

@@ -0,0 +1,78 @@
import { findActiveTripId, findBestTripId, findNextTripId, makeId, parseYMD, todayYMD } from './date';
import { vi } from 'vitest';
describe('date helpers', () => {
beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date(2026, 3, 18, 12, 0, 0));
});
afterEach(() => {
vi.useRealTimers();
vi.restoreAllMocks();
});
test('makeId returns a prefixed id with timestamp and random suffix', () => {
vi.spyOn(Math, 'random').mockReturnValue(0.123456);
const id = makeId('item');
expect(id).toMatch(/^item_\d+_[a-z0-9]{6}$/);
});
test('todayYMD returns yyyy-mm-dd', () => {
expect(todayYMD()).toBe('2026-04-18');
});
test('parseYMD returns null for invalid format', () => {
expect(parseYMD('2026/04/18')).toBeNull();
expect(parseYMD('')).toBeNull();
expect(parseYMD(null)).toBeNull();
});
test('parseYMD returns date for valid format', () => {
const parsed = parseYMD('2026-04-18');
expect(parsed).toBeInstanceOf(Date);
expect(parsed?.getFullYear()).toBe(2026);
});
test('findActiveTripId picks a currently active trip', () => {
const trips = [
{ id: 'past', startDate: '2026-04-01', endDate: '2026-04-10' },
{ id: 'active', startDate: '2026-04-15', endDate: '2026-04-20' },
{ id: 'future', startDate: '2026-05-01', endDate: '2026-05-05' },
];
expect(findActiveTripId(trips)).toBe('active');
});
test('findNextTripId picks nearest upcoming trip', () => {
const trips = [
{ id: 'next-later', startDate: '2026-05-10', endDate: '2026-05-12' },
{ id: 'next-soon', startDate: '2026-04-20', endDate: '2026-04-22' },
{ id: 'past', startDate: '2026-03-01', endDate: '2026-03-02' },
];
expect(findNextTripId(trips)).toBe('next-soon');
});
test('findBestTripId prefers active trip, then next trip, then latest past trip', () => {
const activeTrips = [
{ id: 'active', startDate: '2026-04-10', endDate: '2026-04-20' },
{ id: 'future', startDate: '2026-04-25', endDate: '2026-04-27' },
];
expect(findBestTripId(activeTrips)).toBe('active');
const nextTrips = [
{ id: 'future-1', startDate: '2026-04-30', endDate: '2026-05-02' },
{ id: 'future-2', startDate: '2026-04-22', endDate: '2026-04-23' },
];
expect(findBestTripId(nextTrips)).toBe('future-2');
const pastTrips = [
{ id: 'old', startDate: '2026-02-01', endDate: '2026-02-05' },
{ id: 'recent', startDate: '2026-04-01', endDate: '2026-04-10' },
];
expect(findBestTripId(pastTrips)).toBe('recent');
});
});

27
src/utils/items.js Normal file
View File

@@ -0,0 +1,27 @@
import { ITEM_PLACEMENTS } from '../constants';
export function toPlacementFormState(rawPlacement = 'suitcase') {
const placement = `${rawPlacement || ''}`.trim() || 'suitcase';
const hasPresetPlacement = ITEM_PLACEMENTS.includes(placement);
return {
placement: hasPresetPlacement ? placement : 'other',
placementCustom: hasPresetPlacement || placement === 'other' ? '' : placement,
};
}
export function resolvePlacementValue(placement = '', placementCustom = '') {
const normalizedPlacement = `${placement || ''}`.trim();
if (!normalizedPlacement) return '';
if (normalizedPlacement === 'other') {
return `${placementCustom || ''}`.trim();
}
return normalizedPlacement;
}
export function withPlacementCustomFallback(currentCustom = '', fallback = '') {
const custom = `${currentCustom || ''}`.trim();
return custom || `${fallback || ''}`.trim();
}

33
src/utils/items.test.js Normal file
View File

@@ -0,0 +1,33 @@
import { resolvePlacementValue, toPlacementFormState, withPlacementCustomFallback } from './items';
describe('items helpers', () => {
test('toPlacementFormState keeps known placements as-is', () => {
expect(toPlacementFormState('suitcase')).toEqual({
placement: 'suitcase',
placementCustom: '',
});
});
test('toPlacementFormState converts custom placements to other with value', () => {
expect(toPlacementFormState('hotel safe')).toEqual({
placement: 'other',
placementCustom: 'hotel safe',
});
});
test('resolvePlacementValue returns custom value when placement is other', () => {
expect(resolvePlacementValue('other', ' hotel safe ')).toBe('hotel safe');
});
test('resolvePlacementValue returns direct placement when not other', () => {
expect(resolvePlacementValue('backpack', 'ignored')).toBe('backpack');
});
test('withPlacementCustomFallback prefers existing custom value', () => {
expect(withPlacementCustomFallback('closet shelf', 'hotel safe')).toBe('closet shelf');
});
test('withPlacementCustomFallback uses fallback when custom is empty', () => {
expect(withPlacementCustomFallback(' ', 'hotel safe')).toBe('hotel safe');
});
});

83
src/utils/labels.js Normal file
View File

@@ -0,0 +1,83 @@
export function toTitleWords(value) {
if (!value) return '';
return value
.toString()
.split('-')
.map((part) => (part ? part[0].toUpperCase() + part.slice(1) : part))
.join(' ');
}
export function formatStatusLabel(status, lentTo = '') {
if (!status) return '';
if (status === 'lent-to') {
const name = lentTo?.trim();
return name ? `Lent To ${name}` : 'Lent To';
}
return toTitleWords(status);
}
export function formatFilterLabel(value) {
if (!value) return '';
if (value === 'all') return 'All';
return toTitleWords(value);
}
export function normalizeQuantity(value, fallback = 1) {
const parsed = Number.parseInt(`${value ?? ''}`, 10);
if (Number.isFinite(parsed) && parsed > 0) return parsed;
return fallback;
}
export function extractLegacyQuantityFromName(rawName = '') {
const name = `${rawName || ''}`.trim();
if (!name) {
return { matched: false, name: '', quantity: 1 };
}
let matched = name.match(/^(\d+)\s*[xX×]\s*(.+)$/);
if (matched) {
const quantity = normalizeQuantity(matched[1], 1);
const cleanName = (matched[2] || '').trim() || name;
return { matched: true, name: cleanName, quantity };
}
matched = name.match(/^(.+?)\s+(\d+)\s*[xX×]$/);
if (matched) {
const quantity = normalizeQuantity(matched[2], 1);
const cleanName = (matched[1] || '').trim() || name;
return { matched: true, name: cleanName, quantity };
}
return { matched: false, name, quantity: 1 };
}
export function normalizeNameAndQuantity(rawName = '', rawQuantity = null) {
const explicitQuantity = normalizeQuantity(rawQuantity, 0);
const legacy = extractLegacyQuantityFromName(rawName);
if (legacy.matched && explicitQuantity <= 1) {
return {
name: legacy.name,
quantity: normalizeQuantity(legacy.quantity, 1),
};
}
const quantity = explicitQuantity > 0 ? explicitQuantity : legacy.quantity;
const cleanName = `${rawName || ''}`.trim() || legacy.name;
return {
name: cleanName,
quantity: normalizeQuantity(quantity, 1),
};
}
export function formatItemLabel(name = '', quantity = 1) {
const cleanName = `${name || ''}`.trim();
const normalizedQuantity = normalizeQuantity(quantity, 1);
if (!cleanName) {
return normalizedQuantity > 1 ? `${normalizedQuantity}x item` : 'item';
}
return normalizedQuantity > 1 ? `${normalizedQuantity}x ${cleanName}` : cleanName;
}

72
src/utils/labels.test.js Normal file
View File

@@ -0,0 +1,72 @@
import {
extractLegacyQuantityFromName,
formatFilterLabel,
formatItemLabel,
formatStatusLabel,
normalizeNameAndQuantity,
normalizeQuantity,
toTitleWords,
} from './labels';
describe('labels helpers', () => {
test('toTitleWords title-cases dashed words', () => {
expect(toTitleWords('left-behind')).toBe('Left Behind');
});
test('formatStatusLabel formats lent-to with optional person', () => {
expect(formatStatusLabel('lent-to', 'Alex')).toBe('Lent To Alex');
expect(formatStatusLabel('lent-to', ' ')).toBe('Lent To');
expect(formatStatusLabel('packed')).toBe('Packed');
});
test('formatFilterLabel handles all and regular values', () => {
expect(formatFilterLabel('all')).toBe('All');
expect(formatFilterLabel('with-user')).toBe('With User');
});
test('normalizeQuantity uses positive integers and fallback for invalid values', () => {
expect(normalizeQuantity(3)).toBe(3);
expect(normalizeQuantity('7')).toBe(7);
expect(normalizeQuantity('0')).toBe(1);
expect(normalizeQuantity('', 5)).toBe(5);
});
test('extractLegacyQuantityFromName parses leading and trailing quantity formats', () => {
expect(extractLegacyQuantityFromName('3x socks')).toEqual({
matched: true,
name: 'socks',
quantity: 3,
});
expect(extractLegacyQuantityFromName('socks 4x')).toEqual({
matched: true,
name: 'socks',
quantity: 4,
});
expect(extractLegacyQuantityFromName('2× chargers')).toEqual({
matched: true,
name: 'chargers',
quantity: 2,
});
expect(extractLegacyQuantityFromName('passport')).toEqual({
matched: false,
name: 'passport',
quantity: 1,
});
});
test('normalizeNameAndQuantity prioritizes explicit quantity but migrates legacy names', () => {
expect(normalizeNameAndQuantity('3x socks', null)).toEqual({ name: 'socks', quantity: 3 });
expect(normalizeNameAndQuantity('3x socks', 1)).toEqual({ name: 'socks', quantity: 3 });
expect(normalizeNameAndQuantity('3x socks', 5)).toEqual({ name: '3x socks', quantity: 5 });
expect(normalizeNameAndQuantity('socks', 2)).toEqual({ name: 'socks', quantity: 2 });
});
test('formatItemLabel includes quantity prefix when quantity > 1', () => {
expect(formatItemLabel('socks', 3)).toBe('3x socks');
expect(formatItemLabel('passport', 1)).toBe('passport');
expect(formatItemLabel('', 2)).toBe('2x item');
});
});

34
src/utils/trips.js Normal file
View File

@@ -0,0 +1,34 @@
import { parseYMD } from './date';
export function validateTripDraft({ name = '', startDate = '', endDate = '' }) {
if (!`${name || ''}`.trim()) {
return {
valid: false,
title: 'Missing name',
message: 'Trip name is required.',
};
}
const start = parseYMD(startDate);
const end = parseYMD(endDate);
if (!start || !end) {
return {
valid: false,
title: 'Invalid dates',
message: 'Please select valid trip dates.',
};
}
if (start > end) {
return {
valid: false,
title: 'Invalid dates',
message: 'Start date cannot be after end date.',
};
}
return {
valid: true,
};
}

57
src/utils/trips.test.js Normal file
View File

@@ -0,0 +1,57 @@
import { validateTripDraft } from './trips';
describe('trips helpers', () => {
test('returns missing-name validation error', () => {
expect(
validateTripDraft({
name: ' ',
startDate: '2026-04-20',
endDate: '2026-04-22',
})
).toEqual({
valid: false,
title: 'Missing name',
message: 'Trip name is required.',
});
});
test('returns invalid-dates validation error for malformed dates', () => {
expect(
validateTripDraft({
name: 'Paris',
startDate: '2026/04/20',
endDate: '2026-04-22',
})
).toEqual({
valid: false,
title: 'Invalid dates',
message: 'Please select valid trip dates.',
});
});
test('returns invalid-dates validation error when start is after end', () => {
expect(
validateTripDraft({
name: 'Paris',
startDate: '2026-05-01',
endDate: '2026-04-22',
})
).toEqual({
valid: false,
title: 'Invalid dates',
message: 'Start date cannot be after end date.',
});
});
test('returns valid for a good trip draft', () => {
expect(
validateTripDraft({
name: 'Paris',
startDate: '2026-04-20',
endDate: '2026-04-22',
})
).toEqual({
valid: true,
});
});
});

9
vitest.config.js Normal file
View File

@@ -0,0 +1,9 @@
const { defineConfig } = require('vitest/config');
module.exports = defineConfig({
test: {
environment: 'node',
globals: true,
include: ['src/utils/**/*.test.js'],
},
});