-
Notifications
You must be signed in to change notification settings - Fork 14
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
UI redesign part3 #858
UI redesign part3 #858
Conversation
|
74af13d
to
c45fe76
Compare
Contact screen will be refactored later
Needs optimization to avoid visual artefacts
…with onContentSizeChange
Maybe it's time to break this PR in smaller chunks again? :/ It seems to be growing a lot. Maybe I can start reviewing and you can work on part 4? |
Supports the same functionalities as the original one. TODO: I couldn't use animated scroll utility function anymore, and I feel like the drag gesture is less smooth. Test it.
This will make reusibility way easier (cf. next commit)
8c3597f
to
95b5449
Compare
a1f4546
to
42a630f
Compare
UX needs to be tested (should we close the first modal manually?)
Note: The huge diff is due to reorganizing callbacks, not actual changes
// Using sin allows to smoothen movements (espacially when phon is upside down) | ||
const sinRoll = useDerivedValue(() => Math.sin(gyroscope.sensor.value.roll)) | ||
const sinPitch = useDerivedValue(() => Math.sin(gyroscope.sensor.value.pitch)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents the weird movements we've seen before
</ButtonsRow> | ||
</ScreenSection> | ||
</ModalContent> | ||
<BottomModal modalId={id}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment about the whole PR: every time I've wrapped a modal in BottomModal
, the whole component is marked as changed, but it's not.
What you should take a look at it how I extracted the callbacks, like handleConsolidate
above. The main difference is that the modals are now responsible for closing themselves once the callbacks are executed. Before, it was the parents which were handling this.
} | ||
|
||
const Screen = ({ children, headerOptions, ...props }: ScreenProps) => { | ||
const Screen = ({ children, headerOptions, safeAreaPadding, usesKeyboard, ...props }: ScreenProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the same functionalities as ScrollScreen
. We used to use scroll screens when not actually needed. I've replaced some of them with simple non-scrollable screens.
}, [allConfirmedTransactionsLoaded, dispatch, isLoading]) | ||
|
||
return ( | ||
<FlashList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was using a FlatList before.
handleClose, | ||
contentScrollHandlers, | ||
isScrollable | ||
} = useBottomModalState({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted the animation and gesture logic in a hook, allowing reusability in BottomModalFlashList
.
|
||
export default BottomModalFlashList | ||
|
||
const KeyboardAvoidingViewStyled = styled(KeyboardAvoidingView)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Styles are the same as in BottomModal
for now. But it may change in the future - I want to refactor the modals header & title. The implementation will probably not be the same in both BottomModal variants.
@@ -38,6 +38,8 @@ export interface ModalFlatListContentProps<T> extends ModalContentBaseProps, Fla | |||
|
|||
const scrollDefaultProps = { bounces: false, scrollEventThrottle: 16 } | |||
|
|||
// TODO: DELETE THIS COMPONENT ONCE BOTTOM MODAL IS REFACTORED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will actually keep ModalContent probably, but the file can be cleaned up a lot.
const contentScrollHandlers: ContentScrollHandlers = { | ||
onScroll: (e) => { | ||
contentScrollY.value = e.nativeEvent.contentOffset.y | ||
|
||
if (!isContentDragged.value) return | ||
|
||
if (contentScrollY.value <= 0) { | ||
// Move the modal | ||
if (contentScrollY.value < previousContentScrollY.value) { | ||
const newModalHeightValue = modalHeight.value - contentScrollY.value | ||
modalHeightDelta.value = modalHeight.value - newModalHeightValue | ||
modalHeight.value = newModalHeightValue | ||
} | ||
} else if (-modalHeight.value < maxHeight) { | ||
handleMaximize() | ||
} | ||
previousContentScrollY.value = contentScrollY.value | ||
}, | ||
onScrollBeginDrag: () => { | ||
isContentDragged.value = true | ||
}, | ||
onScrollEndDrag: () => { | ||
isContentDragged.value = false | ||
|
||
if (modalHeightDelta.value < -1) { | ||
handleClose() | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, that was a pain in the 🍑
It's not perfect yet, there are some glitches when the use scrolls down the content a bit, then go back up again. But for closing modals quickly it works well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff highlight the main limitation with the new way to open modals. Because we need to pass callbacks in openModal
, we need to take into account where openModal
is called. All needed callbacks must be declared before the function is used, which can be a little tricky. Also, more useCallback
hooks are now required.
@@ -31,13 +35,17 @@ type NFTListScreenProps = StackScreenProps<InWalletTabsParamList, 'NFTListScreen | |||
const NFTListScreen = ({ navigation }: NFTListScreenProps) => { | |||
const { t } = useTranslation() | |||
const { screenScrollY, screenScrollHandler } = useScreenScrollHandler() | |||
const listRef = useRef<FlashList<NFT>>(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason this ref is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through all files. The GH UI is very laggy due to the amount of them 😆
I will do some more functional tests once I get some feedback on the review 👍
apps/mobile-wallet/src/features/walletconnect/WalletConnectPairingsModal.tsx
Show resolved
Hide resolved
<View style={{ backgroundColor: 'black', flex: 1 }}> | ||
<AnimatedCirclesBackground isAnimated /> | ||
</View> | ||
<Modal visible={!!lastUsedWalletId && biometricsRequiredForAppAccess && !isWalletUnlocked} animationType="fade"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I remember that changing it to fade
creates a weird artefact but I don't remember exactly how. I need to do a functional test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any artefact in the next PR 🤞
In this PR: