feat(mobile): refine TREK navigation and interfaces

This commit is contained in:
Maurice
2026-12-03 23:06:17 +01:00
parent 995e9c435f
commit 00955f0ac5
553 changed files with 17703 additions and 13101 deletions
@@ -57,13 +57,18 @@ export function usePackingItemActions({
const [addingCategory, setAddingCategory] = useState(false);
const [newCategoryName, setNewCategoryName] = useState('');
const addItemToCategory = async (category: string, name: string) => {
const addItemToCategory = async (category: string | null, name: string) => {
try {
// Reuse the '...' placeholder slot when the category already has one, so a
// freshly-emptied category keeps its position (and therefore its colour)
// instead of the new item being appended to the end of the list.
const pool = placeholderFrom === 'store' ? useTripStore.getState().packingItems : items;
const placeholder = pool.find((i) => i.category === category && isPackingPlaceholder(i));
const placeholder = packingViewItems(pool, view).find(
(i) =>
(i.category || null) === category &&
isPackingPlaceholder(i) &&
(view === 'common' || i.owner_id == null || i.owner_id === currentUserId)
);
if (placeholder) {
await updatePackingItem(tripId, placeholder.id, { name });
} else {
@@ -71,12 +76,13 @@ export function usePackingItemActions({
// category's own items agree on (#2241).
await addPackingItem(tripId, {
name,
category,
...newItemSharing(items, category, view, currentUserId),
...(category ? { category, ...newItemSharing(items, category, view, currentUserId) } : { visibility: view }),
} as Parameters<typeof addPackingItem>[1]);
}
return true;
} catch {
toast.error(t('packing.toast.addError'));
return false;
}
};
@@ -88,7 +94,7 @@ export function usePackingItemActions({
// removing the placeholder is how an empty category is dismissed.
const deleteItem = async (item: PackingItem) => {
try {
if (isLastCustomItemInCategory(item, items)) {
if (isLastCustomItemInCategory(item, packingViewItems(items, item.is_private ? 'personal' : 'common'))) {
if (item.checked) await togglePackingItem(tripId, item.id, false);
await updatePackingItem(tripId, item.id, {
name: PACKING_PLACEHOLDER_NAME,
@@ -106,7 +112,7 @@ export function usePackingItemActions({
/** Moves every item of a category to the new name, one write each; a failure stops it and is thrown. */
const renameCategory = async (oldName: string, newName: string) => {
const toUpdate = items.filter((i) => (i.category || defaultCategory) === oldName);
const toUpdate = packingViewItems(items, view).filter((i) => (i.category || defaultCategory) === oldName);
for (const item of toUpdate) {
await updatePackingItem(tripId, item.id, { category: newName });
}
@@ -136,7 +142,7 @@ export function usePackingItemActions({
/** Removes the checked items of the open view only, the ones the button's count names. */
const clearChecked = async () => {
let failed = false;
for (const item of packingViewItems(items, view).filter((i) => i.checked)) {
for (const item of packingViewItems(items, view).filter((i) => i.checked && !isPackingPlaceholder(i))) {
try {
await deletePackingItem(tripId, item.id);
} catch {