feat: add history long-press delete and quick item status actions
This commit is contained in:
@@ -15,7 +15,7 @@ export default function CheckupTab({
|
||||
<View style={styles.sectionRow}>
|
||||
<Text style={styles.sectionTitle}>Check-Up</Text>
|
||||
<Pressable style={styles.secondaryBtnTight} onPress={createFreshCheckupSession}>
|
||||
<Text style={styles.secondaryBtnText}>Restart</Text>
|
||||
<Text style={styles.secondaryBtnText}>Check-up</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
import React from 'react';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
import { Alert, Pressable, Text, View } from 'react-native';
|
||||
import { styles } from '../styles';
|
||||
|
||||
export default function HistoryTab({ selectedTrip, selectedTripCheckups, selectedCheckupId, setSelectedCheckupId }) {
|
||||
export default function HistoryTab({
|
||||
selectedTrip,
|
||||
selectedTripCheckups,
|
||||
selectedCheckupId,
|
||||
setSelectedCheckupId,
|
||||
onDeleteCheckup,
|
||||
}) {
|
||||
function askDelete(checkup) {
|
||||
Alert.alert('Delete check-up?', 'This snapshot will be removed from history.', [
|
||||
{ text: 'Cancel', style: 'cancel' },
|
||||
{
|
||||
text: 'Delete',
|
||||
style: 'destructive',
|
||||
onPress: () => onDeleteCheckup(checkup.id),
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.section}>
|
||||
<Text style={styles.sectionTitle}>History</Text>
|
||||
@@ -13,13 +30,17 @@ export default function HistoryTab({ selectedTrip, selectedTripCheckups, selecte
|
||||
|
||||
{selectedTripCheckups.map((checkup) => (
|
||||
<View key={checkup.id} style={styles.cardSoft}>
|
||||
<Pressable onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}>
|
||||
<Pressable
|
||||
onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}
|
||||
onLongPress={() => askDelete(checkup)}
|
||||
delayLongPress={280}
|
||||
>
|
||||
<Text style={styles.cardTitle}>{new Date(checkup.createdAt).toLocaleString()}</Text>
|
||||
<Text style={styles.cardMeta}>
|
||||
{checkup.snapshot.length} items · correct: {checkup.stats?.correct ?? checkup.snapshot.filter((x) => x.result === 'correct').length} · bad:{' '}
|
||||
{checkup.stats?.bad ?? checkup.snapshot.filter((x) => x.result === 'bad').length}
|
||||
</Text>
|
||||
<Text style={styles.cardMeta}>{selectedCheckupId === checkup.id ? 'Tap to collapse' : 'Tap to open'}</Text>
|
||||
<Text style={styles.cardMeta}>{selectedCheckupId === checkup.id ? 'Tap to collapse' : 'Tap to open'} · long hold to delete</Text>
|
||||
</Pressable>
|
||||
|
||||
{selectedCheckupId === checkup.id ? (
|
||||
|
||||
@@ -3,7 +3,14 @@ import { Pressable, Text, View } from 'react-native';
|
||||
import ItemCard from '../components/ItemCard';
|
||||
import { styles } from '../styles';
|
||||
|
||||
export default function ItemsTab({ selectedTrip, selectedTripItems, openAddItemModal, openEditItemModal, deleteItem }) {
|
||||
export default function ItemsTab({
|
||||
selectedTrip,
|
||||
selectedTripItems,
|
||||
openAddItemModal,
|
||||
openEditItemModal,
|
||||
deleteItem,
|
||||
quickSetItemStatus,
|
||||
}) {
|
||||
return (
|
||||
<View style={styles.section}>
|
||||
<View style={styles.sectionRow}>
|
||||
@@ -17,7 +24,14 @@ export default function ItemsTab({ selectedTrip, selectedTripItems, openAddItemM
|
||||
{selectedTripItems.length === 0 && selectedTrip ? <Text style={styles.muted}>No items yet.</Text> : null}
|
||||
|
||||
{selectedTripItems.map((item) => (
|
||||
<ItemCard key={item.id} item={item} onEdit={openEditItemModal} onDelete={deleteItem} />
|
||||
<ItemCard
|
||||
key={item.id}
|
||||
item={item}
|
||||
onEdit={openEditItemModal}
|
||||
onDelete={deleteItem}
|
||||
onQuickPack={() => quickSetItemStatus(item.id, 'packed')}
|
||||
onQuickUnpack={() => quickSetItemStatus(item.id, 'unpacked')}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user