mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 05:21:15 +00:00
feat(native): swipe rows, long-press menus, placeholders while loading, fading pictures, iOS bounce and app icon quick actions
Packing items, tasks and expenses swipe sideways to their actions, as in Mail or Reminders: done or open one way, delete and edit the other, the first one run by a full swipe. They are second ways to what each row already offers; an expense still asks before it goes. A long press on a trip card lifts it and opens its menu with the card's own actions. Plain confirmations in MConfirmSheet now also ask through the system where the app can. Lists, the atlas and a journey show grey placeholders in their shape while loading instead of a spinner in an empty screen (MSkeleton); buttons keep theirs. A picture still loading fades in once it is there; one from the cache shows at once. In the iOS app the page bounces at its ends again, except on screens with pull-to-refresh, whose pull it would race; Android keeps its stretch off. On iOS a long press on the app icon offers "New trip" and the trip coming up by its name, set by the UI in its language (TrekShell.setQuickActions, feature quickActions), and a tap opens it, also from a cold start. The app's own CSS moves out of index.css into native/nativeApp.css, which had outgrown its size budget.
This commit is contained in:
@@ -23,6 +23,20 @@ function refreshFailed(): void {}
|
||||
* Writes the content's transform directly during the drag, so a pull costs no
|
||||
* React render per frame; `state` only changes at the edges (armed, refreshing).
|
||||
*/
|
||||
/*
|
||||
* The iOS app lets the page bounce at its ends (mobile.css). A pull is only told
|
||||
* from a scroll after 8 px, and by then WebKit's own bounce has started and can no
|
||||
* longer be stopped, so the two would pull at once. While a screen offers
|
||||
* pull-to-refresh, <html> carries data-pull-refresh and the page does not bounce.
|
||||
*/
|
||||
let bounceHolds = 0;
|
||||
function holdBounce(): void {
|
||||
if (bounceHolds++ === 0) document.documentElement.setAttribute('data-pull-refresh', '');
|
||||
}
|
||||
function releaseBounce(): void {
|
||||
if (--bounceHolds === 0) document.documentElement.removeAttribute('data-pull-refresh');
|
||||
}
|
||||
|
||||
export function usePullToRefresh(
|
||||
contentRef: RefObject<HTMLElement | null>,
|
||||
onRefresh: () => Promise<unknown>,
|
||||
@@ -113,6 +127,7 @@ export function usePullToRefresh(
|
||||
});
|
||||
};
|
||||
|
||||
holdBounce();
|
||||
window.addEventListener('touchstart', onStart, { passive: true });
|
||||
// Not passive: once a pull has started, the page must not also scroll or bounce.
|
||||
window.addEventListener('touchmove', onMove, { passive: false });
|
||||
@@ -124,6 +139,7 @@ export function usePullToRefresh(
|
||||
window.removeEventListener('touchend', onEnd);
|
||||
window.removeEventListener('touchcancel', onEnd);
|
||||
place(0, false);
|
||||
releaseBounce();
|
||||
};
|
||||
}, [contentRef, enabled, scrollerRef]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user