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

refactor: onboarding mechanics and navigation #1464

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

jleach
Copy link
Contributor

@jleach jleach commented Mar 10, 2025

Summary of Changes

Improving Onboarding Flexibility

Currently, adding or reorganizing onboarding screens is cumbersome due to hardcoded navigation logic. This PR simplifies the process by relying more on application state and less on manual navigation rules.

Key Changes:

  • Onboarding screens are now managed as an array, making it easier to modify the order of screens.
  • The OnboardingStack automatically displays the first incomplete screen.
  • Once all screens are completed, an event is emitted to signal that onboarding is finished, prompting the root stack to transition to MainStack.
  • The only required screens in this process are CreatePIN and/or EnterPIN.

Screenshots, videos, or gifs

Replace this text with embedded media for UI changes if they are included in this PR. If there are none, simply enter N/A

Breaking change guide

Replace this text with any breaking changes included in this PR along with how to address them in downstream projects. If there are none, simply enter N/A

Related Issues

Replace this text with issue #'s that are relevant to this PR. If there are none, simply enter N/A

Pull Request Checklist

Tick all boxes below to demonstrate that you have completed the respective task. If the item does not apply to your this PR check it anyway to make it apparent that there's nothing to do.

  • All commits contain a DCO Signed-off-by line (we use the DCO GitHub app to enforce this)
  • If applicable, screenshots, gifs, or video are included for UI changes
  • If applicable, breaking changes are described above along with how to address them
  • Updated documentation as needed for changed code and new or modified features
  • Added sufficient tests so that overall code coverage is not reduced

If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!

Pro Tip 🤓

  • Read our contribution guide at least once; it will save you a few review cycles!
  • Your PR will likely not be reviewed until all the above boxes are checked and all automated checks have passed

@jleach jleach force-pushed the feat/refactor-onboarding-nav branch from 9d17b8b to db9bc97 Compare March 12, 2025 17:59
@jleach jleach marked this pull request as ready for review March 12, 2025 18:00
@jleach jleach requested a review from a team as a code owner March 12, 2025 18:00
@jleach jleach requested a review from fc-santos March 12, 2025 18:07
@@ -15,36 +15,37 @@ import { createCarouselStyle } from '../screens/OnboardingPages'
import PINCreate from '../screens/PINCreate'
import PINEnter from '../screens/PINEnter'
import PushNotification from '../screens/PushNotification'
// import UpdateAvailable from '../screens/UpdateAvailable'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to keep this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

fc-santos
fc-santos previously approved these changes Mar 13, 2025
@@ -105,6 +105,6 @@ describe('Splash Screen', () => {
jest.runAllTimers()
})

expect(navigation.dispatch).toHaveBeenCalledTimes(1)
expect(navigation.dispatch).toHaveBeenCalledTimes(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: what are we testing for if we don't expect this to be called?

Copy link
Contributor

@bryce-mcmath bryce-mcmath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few small non-blocking suggestions and some questions

PushNotification: React.FC<StackScreenProps<ParamListBase, Screens.UsePushNotifications>>
Developer: React.FC<StackScreenProps<ParamListBase>>
AttemptLockout: React.FC<StackScreenProps<ParamListBase>>
OnBoardingScreen: React.FC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we take the opportunity to change this while we're touching this code, so it's the same casing as it is everywhere else?

Suggested change
OnBoardingScreen: React.FC
OnboardingScreen: React.FC

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -73,7 +81,7 @@ const OnboardingStack: React.FC = () => {
[dispatch]
)

const OnBoardingScreen = () => {
const OnBoardingScreen = useCallback(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const OnBoardingScreen = useCallback(() => {
const OnboardingScreen = useCallback(() => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

() => store.authentication.didAuthenticate && store.onboarding.postAuthScreens.length === 0,
[store.authentication.didAuthenticate, store.onboarding.postAuthScreens]
)
const isOnboardingComplete = useMemo(() => onboardingComplete, [onboardingComplete])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this useMemo will have any effect. I think primitive values already only cause re-renders when they change. If they are reassigned to the same value they don't cause re-renders (afaik)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

const { t } = useTranslation()
const Stack = createStackNavigator()
const theme = useTheme()
const OnboardingTheme = theme.OnboardingTheme
const carousel = createCarouselStyle(OnboardingTheme)
const [
splash,
config,
Splash,
pages,
useBiometry,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a screen (JSX) and not a hook it should probably be capitalized. Not something we have to do in this PR, just at some point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean "useBiometry" if so I created a ticket with some issues I noticed along the way and this was one. I think it should be renamed to not use use in the name for clarity.

Comment on lines -94 to -96
if (store.onboarding.didCompleteOnboarding) {
navigation.goBack()
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this screen can be accessed from the settings menu, not just onboarding. So that call to navigation.goBack() might still be needed in that case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

setMounted(true)
}, [])

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, what does the user see while state is being loaded for the first time on a cold start?

Copy link
Contributor Author

@jleach jleach Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I may need to add this back then. It's a bit confusing but we have a splash screen imported from a NPM package and our Splash screen. I assumed there was a bug in the NPM version that is meant to show the app logo screen until the "state" is loaded at which point the app can then continue. Maybe I need to update Splash to show in two different ways, or fix the npm package to work.

jleach added 12 commits March 17, 2025 14:36
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
jleach added 9 commits March 17, 2025 14:36
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
@jleach jleach force-pushed the feat/refactor-onboarding-nav branch from 992421f to ad95120 Compare March 17, 2025 21:36
jleach added 3 commits March 17, 2025 14:39
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
Signed-off-by: Jason C. Leach <[email protected]>
@jleach jleach enabled auto-merge (squash) March 17, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants