From 89fd4c2f44fad3b9f3b1a1b6f77cb20b77992ff0 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 18 Apr 2026 18:32:34 +0200 Subject: [PATCH] feat(#6): add randomized fake startup loader with suitcase progress --- src/AppRoot.js | 33 +++++++++++++++++++++++++++++++-- src/styles.js | 22 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/AppRoot.js b/src/AppRoot.js index 1888ab5..90456ba 100644 --- a/src/AppRoot.js +++ b/src/AppRoot.js @@ -63,6 +63,8 @@ export default function AppRoot() { const scrollRef = useRef(null); const [loaded, setLoaded] = useState(false); + const [fakeLoadDone, setFakeLoadDone] = useState(false); + const [fakeLoadProgress, setFakeLoadProgress] = useState(0); const [tab, setTab] = useState('trips'); const [data, setData] = useState(emptyData); @@ -83,6 +85,8 @@ export default function AppRoot() { const [dialogState, setDialogState] = useState({ visible: false, title: '', message: '', buttons: [] }); const topInset = Platform.OS === 'android' ? (RNStatusBar.currentHeight || 0) + 10 : 0; + const fakeLoadTotalMs = useMemo(() => 1200 + Math.floor(Math.random() * 2801), []); + const appReady = loaded && fakeLoadDone; const visibleTrips = useMemo(() => data.trips.filter((trip) => !trip.archived), [data.trips]); @@ -165,6 +169,26 @@ export default function AppRoot() { })(); }, []); + useEffect(() => { + const startedAt = Date.now(); + + const interval = setInterval(() => { + const elapsed = Date.now() - startedAt; + setFakeLoadProgress(Math.min(1, elapsed / fakeLoadTotalMs)); + }, 60); + + const timeout = setTimeout(() => { + setFakeLoadProgress(1); + setFakeLoadDone(true); + clearInterval(interval); + }, fakeLoadTotalMs); + + return () => { + clearInterval(interval); + clearTimeout(timeout); + }; + }, [fakeLoadTotalMs]); + useEffect(() => { if (!loaded) return; AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(data)).catch(() => { @@ -733,12 +757,17 @@ export default function AppRoot() { openAddItemModal(); } - if (!loaded) { + if (!appReady) { return ( - Loading local data... + 🧳 + Packing your list... + + + + {Math.round(fakeLoadProgress * 100)}% ); diff --git a/src/styles.js b/src/styles.js index 56ec972..a4f4e42 100644 --- a/src/styles.js +++ b/src/styles.js @@ -26,6 +26,28 @@ export const styles = StyleSheet.create({ muted: { color: '#8793a5', }, + loadingEmoji: { + fontSize: 52, + marginBottom: 8, + }, + loadingTitle: { + color: '#f8fafc', + fontWeight: '700', + fontSize: 17, + marginBottom: 10, + }, + loadingBarTrack: { + width: 220, + height: 10, + borderRadius: 999, + backgroundColor: '#1e293b', + overflow: 'hidden', + marginBottom: 8, + }, + loadingBarFill: { + height: '100%', + backgroundColor: '#2563eb', + }, tripPickerWrap: { marginBottom: 6,