App : plus de « tirer pour actualiser » (accueil, statistiques, historique)
Les données se rechargent à l'ouverture de chaque écran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a510efc496
commit
68a81ddbf3
3 changed files with 10 additions and 27 deletions
|
|
@ -84,10 +84,10 @@ export default function History() {
|
||||||
contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 32 }}
|
contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 32 }}
|
||||||
onEndReached={() => cursor && !loading && load(false)}
|
onEndReached={() => cursor && !loading && load(false)}
|
||||||
onEndReachedThreshold={0.5}
|
onEndReachedThreshold={0.5}
|
||||||
refreshing={loading && items.length === 0}
|
bounces={false}
|
||||||
onRefresh={() => load(true)}
|
overScrollMode="never"
|
||||||
ListEmptyComponent={!loading ? <T v="muted" style={{ textAlign: 'center', marginTop: 40 }}>Aucune opération sur la période.</T> : null}
|
ListEmptyComponent={!loading ? <T v="muted" style={{ textAlign: 'center', marginTop: 40 }}>Aucune opération sur la période.</T> : null}
|
||||||
ListFooterComponent={loading && items.length > 0 ? <ActivityIndicator style={{ margin: 16 }} /> : null}
|
ListFooterComponent={loading ? <ActivityIndicator style={{ margin: 16 }} /> : null}
|
||||||
ItemSeparatorComponent={() => <View style={{ height: 1, backgroundColor: c.border }} />}
|
ItemSeparatorComponent={() => <View style={{ height: 1, backgroundColor: c.border }} />}
|
||||||
renderItem={({ item: o }) => {
|
renderItem={({ item: o }) => {
|
||||||
const rejected = o.type === 'REJECTED';
|
const rejected = o.type === 'REJECTED';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import { Alert, Linking, Pressable, RefreshControl, ScrollView, View } from 'react-native';
|
import { Alert, Linking, Pressable, ScrollView, View } from 'react-native';
|
||||||
import { router, useFocusEffect } from 'expo-router';
|
import { router, useFocusEffect } from 'expo-router';
|
||||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||||
import Svg, { Path } from 'react-native-svg';
|
import Svg, { Path } from 'react-native-svg';
|
||||||
|
|
@ -58,7 +58,6 @@ function Counter() {
|
||||||
const { me, logout } = useSession();
|
const { me, logout } = useSession();
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const [summary, setSummary] = useState<Summary | null>(null);
|
const [summary, setSummary] = useState<Summary | null>(null);
|
||||||
const [refreshing, setRefreshing] = useState(false);
|
|
||||||
const [tab, setTab] = useState<'scan' | 'config'>('scan');
|
const [tab, setTab] = useState<'scan' | 'config'>('scan');
|
||||||
|
|
||||||
const load = useCallback(async () => {
|
const load = useCallback(async () => {
|
||||||
|
|
@ -81,16 +80,9 @@ function Counter() {
|
||||||
<SafeAreaView style={{ flex: 1, backgroundColor: c.bg }}>
|
<SafeAreaView style={{ flex: 1, backgroundColor: c.bg }}>
|
||||||
<ScrollView
|
<ScrollView
|
||||||
contentContainerStyle={{ padding: 20, gap: 20, flexGrow: 1 }}
|
contentContainerStyle={{ padding: 20, gap: 20, flexGrow: 1 }}
|
||||||
refreshControl={
|
// Pas de « tirer pour actualiser » : les chiffres se rechargent à chaque retour sur l'écran.
|
||||||
<RefreshControl
|
bounces={false}
|
||||||
refreshing={refreshing}
|
overScrollMode="never"
|
||||||
onRefresh={async () => {
|
|
||||||
setRefreshing(true);
|
|
||||||
await load();
|
|
||||||
setRefreshing(false);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
|
||||||
<BrandSymbol size={36} />
|
<BrandSymbol size={36} />
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import { Alert, Pressable, RefreshControl, ScrollView, View } from 'react-native';
|
import { Alert, Pressable, ScrollView, View } from 'react-native';
|
||||||
import { useFocusEffect } from 'expo-router';
|
import { useFocusEffect } from 'expo-router';
|
||||||
import { api, ApiError } from '../src/api';
|
import { api, ApiError } from '../src/api';
|
||||||
import { describe } from '../src/errors';
|
import { describe } from '../src/errors';
|
||||||
|
|
@ -37,7 +37,6 @@ export default function StatsScreen() {
|
||||||
const [data, setData] = useState<Stats | null>(null);
|
const [data, setData] = useState<Stats | null>(null);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [locked, setLocked] = useState(false);
|
const [locked, setLocked] = useState(false);
|
||||||
const [refreshing, setRefreshing] = useState(false);
|
|
||||||
const [sending, setSending] = useState<string | null>(null);
|
const [sending, setSending] = useState<string | null>(null);
|
||||||
|
|
||||||
const load = useCallback(async (d: number) => {
|
const load = useCallback(async (d: number) => {
|
||||||
|
|
@ -94,16 +93,8 @@ export default function StatsScreen() {
|
||||||
return (
|
return (
|
||||||
<ScrollView
|
<ScrollView
|
||||||
contentContainerStyle={{ padding: 20, gap: 16 }}
|
contentContainerStyle={{ padding: 20, gap: 16 }}
|
||||||
refreshControl={
|
bounces={false}
|
||||||
<RefreshControl
|
overScrollMode="never"
|
||||||
refreshing={refreshing}
|
|
||||||
onRefresh={async () => {
|
|
||||||
setRefreshing(true);
|
|
||||||
await load(days);
|
|
||||||
setRefreshing(false);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<View style={{ flexDirection: 'row', gap: 8 }}>
|
<View style={{ flexDirection: 'row', gap: 8 }}>
|
||||||
{PERIODS.map(([d, label]) => (
|
{PERIODS.map(([d, label]) => (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue