Skip to content

feat: add AnimatedFAB improvements - #2907

Merged
lukewalczak merged 52 commits into
callstack:mainfrom
Drakeoon:feat/animated-extended-fab-improvements
Nov 3, 2021
Merged

lukewalczak merged 52 commits into
callstack:mainfrom
Drakeoon:feat/animated-extended-fab-improvements

Conversation

@Drakeoon

@Drakeoon Drakeoon commented Sep 20, 2021

Copy link
Copy Markdown
Contributor

Summary

This PR introduces fixes and improvements to original AnimatedFAB pull request

  • Add support for animateFor: "left" property
  • Add snapshot tests for AnimatedFAB component
  • Add integration tests for AnimatedFAB component (new properties)

Test plan

iOS

AnimatedFAB.iOS.mp4

Android

AnimatedFAB.Android.mp4

@callstack-bot

callstack-bot commented Sep 20, 2021

Copy link
Copy Markdown

Hey @Drakeoon, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

@Drakeoon

Copy link
Copy Markdown
Contributor Author

@lukewalczak I noticed two things:

  1. The AnimatedFAB behavior is different depending on the platform. On iOS it expands when we scroll up and collapses when we scroll down. On Android it does the opposite - expands when we scroll down and collapses when we scroll up. Is this an intended behavior?
  2. Pressing on the button does not show the ripple effect as on your video. It could be a small bug introduced at some point during development, I'll try to investigate futher

@lukewalczak

Copy link
Copy Markdown
Member
  1. The AnimatedFAB behavior is different depending on the platform. On iOS it expands when we scroll up and collapses when we scroll down. On Android it does the opposite - expands when we scroll down and collapses when we scroll up. Is this an intended behavior?
  2. Pressing on the button does not show the ripple effect as on your video. It could be a small bug introduced at some point during development, I'll try to investigate futher
  1. On both platforms behavior should be the same. According to the documentation:

The FAB should not return to an extended FAB until the user scrolls back to the top of the page.

like on the video from MD

  1. There should be a ripple effect on the whole button.

Comment thread src/components/FAB/AnimatedFAB.tsx Outdated
@Drakeoon
Drakeoon force-pushed the feat/animated-extended-fab-improvements branch from 0d96eb4 to 184ce29 Compare September 23, 2021 14:23
@lukewalczak
lukewalczak force-pushed the feat/animated-extended-fab branch from 80fa1f5 to a573c04 Compare October 11, 2021 09:36
@lukewalczak
lukewalczak force-pushed the feat/animated-extended-fab branch from a637f14 to fcaefef Compare October 13, 2021 14:46

@p-syche p-syche left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great job improving this component!
I left you a few comments to consider, and a few nitpicks ;)
One important note is that you have a FlatList without keys which definitely needs to be fixed. I also don't love the hardcoded SIZE.
Other than that this is solid work, nice usage of types 👍

Comment thread example/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx
Comment thread example/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx Outdated
Comment thread example/src/Examples/AnimatedFABExample/CustomFABControls.tsx
Comment thread example/src/Examples/AnimatedFABExample/CustomFABControls.tsx Outdated
Comment thread src/components/FAB/AnimatedFAB.tsx
Comment thread src/components/FAB/AnimatedFAB.tsx Outdated
/**
* Label for extended `FAB`.
*/
label: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be preferable to add some string length constraints to your label.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea, however we didn't yet choose what the allowed label size is. I think for now we'll allow any size and in future iterations we can improve on that. WDYT @lukewalczak ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, I think we should leave that responsibility to the user.

testID?: string;
};

const SIZE = 56;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hardcoded size may become a real headache when Apple comes up with a new super small or super-duper large display 😂 Consider using something more future-proof, for example check screen size and calculate a percentage of it.

@Drakeoon Drakeoon Oct 21, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree with you. The size comes from the Material Design Guidelines, but I'm also aware that we use many hacks to just make it "look good". While I think we shouldn't make the Icon responsive (nor derive it from screen), I think we still could do a better job and avoid hacks. I'll leave it as it is, but for sure this could be improved in the future

Comment thread src/components/FAB/AnimatedFAB.tsx Outdated
...defaultPositionStyles,
},
absoluteFill: {},
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure I see the point of creating CombinedStyles, it adds a bit of complexity. Can you tell me why you decided to create this const this way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My main goal was to move dynamic styles logic to a function, that I can later move to a separate file to clean up the JSX and component logic. Thanks for pointing this out, as I forgot to do it before requesting code review 😄 Please take a look at my recent changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks much cleaner now 👍

Comment thread src/components/FAB/AnimatedFAB.tsx Outdated
}),
},
];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This whole block may be more readable as a switch statement instead of multiple ifs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've tried implementing it with switch statement, but I think it's kind of the same. Ideally I would use something like Immer here to mutate the objects, but that's what we're left with for now

…ct-native-paper into feat/animated-extended-fab-improvements
@lukewalczak
lukewalczak deleted the branch callstack:main October 19, 2021 07:46
@lukewalczak lukewalczak reopened this Oct 19, 2021
@lukewalczak
lukewalczak changed the base branch from feat/animated-extended-fab to main October 19, 2021 07:53
@Drakeoon

Copy link
Copy Markdown
Contributor Author

@p-syche Thank you so much for your feedback! I really appreciate it 👍🏻

I answered your questions and implemented requested changes. There are also some small refactor commits to improve code readability. I think the PR is ready for your final review @p-syche @lukewalczak

@Drakeoon
Drakeoon requested a review from p-syche October 21, 2021 11:12
@p-syche

p-syche commented Oct 21, 2021

Copy link
Copy Markdown
Contributor

@Drakeoon thank you for following up on my notes.
@lukewalczak I think this is good to go, but I don't want to pull the trigger without your blessing. Also a maintainer's approval is necessary so I can't pull the trigger 😅

@lukewalczak

Copy link
Copy Markdown
Member

@Drakeoon could you please also:

to unblock that component in prod?

@Drakeoon Drakeoon changed the title AnimatedFAB improvements feat: add AnimatedFAB improvements Oct 29, 2021

@lukewalczak lukewalczak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome work 🎉 !

@lukewalczak
lukewalczak merged commit 50ccce0 into callstack:main Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants