Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(navigation): loading screen improvements #1016

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hgray-instawork
Copy link
Collaborator

…1014)

Resolving a bug where a delay in the behavior is applied to both the
triggering of the behavior and the subsequent document injection.

Example:
```
<behavior action="new" delay="1000" href="/hyperview/public/navigation/behaviors/actions/modal/index.xml" show-during-load="loading-screen" />
```

| Before | After |
| -- | -- |
|
![before](https://github.com/user-attachments/assets/2788818b-78d6-4c94-991e-b7aa7ec2b82e)
|
![after](https://github.com/user-attachments/assets/574ae86b-c4a7-451c-b87c-c7a5a8219ddf)


[Asana](https://app.asana.com/0/1204008699308084/1209072402643062/f)
…d nav-routes (#1007)

As an update to Hyperview's loading screen functionality, this update
allows us to pass a dynamic loading screen into Hyperview. The loading
screen optionally receives the `<behavior>` or `<nav-route>` which
caused it to appear, allowing the loading screen to retrieve
attributes/children from the element and modify the component
accordingly.

Example:
```
const LoadingScreen = (props: Props) => {
  const showDuringLoad = props.element?.getAttribute('show-during-load');
  const color = (showDuringLoad === 'green-loader') ? 'green' : '#8d9494';
  return (
    <View>
      <ActivityIndicator color={color} size="large" />
    </View>
  );
};
```

- [fix: use only first
indicator](7cab73c)
- [the
documentation](https://hyperview.org/docs/reference_behavior_attributes#navigation-actions-1)
states `show-during-load` should only contain a single screen id. This
enforces this and also cleans up the naming/typing
- [fix:
typo](b667b2a)
- [chore: pass the
behaviorElement](56a2700)
- ensure the behavior element which triggered the navigation action is
passed so it can be cached
- [chore: pass the behavior element id or route id in route
params](4dd745f)
- allow the routeId to be passed in params. Also, if no preloadScreen is
found, attempt to inject a behavior element into the cache.
- [chore: simplify cache
location](976c83d)
- the element cache can be simplified by only having it at the top-level
rather than in every navigator.
- [chore: support cache
removal](118083d)
- add support for clearing items from cache
- [chore: loadingScreen component receives optional
element](764ae7f)
- the loading screen passed into Hyperview can now accept an optional
element which represents the trigger of this loading event. This will
either be the behavior which caused the navigation, or the `<nav-route>`
which is being loaded.
- [chore: update Loading component and
instantiation](f78602a)
- updating the internal `loading` component to support retrieval of
cached elements, instantiation of any passed loading screen, and cache
cleanup during unmount. Default spinner implementation remains as a
backup.
- [chore: purge
cache](a2d0543)
- loading screens should purge the cache on unmount


Notes: some additional testing will be necessary in general with these
changes but some smoke tests have shown positive results. Also, we
should not have to worry about memory leaks as the containers which hold
the cached screens (preload or behavior) are part of the route/screen
hierarchy and they would get removed when the screen is removed.


TODO:
- [ ] - documentation updates
- [ ] - update demo. This must be done post-release as demo points to
released version of Hyperview. See
#1011


[TAD](https://instawork.atlassian.net/wiki/spaces/EN/pages/3671949446/TAD+-+Hyperview+Loading+Screens)

[Asana](https://app.asana.com/0/1204008699308084/1208750137800484/f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant