Coder Social home page Coder Social logo

Comments (9)

gitaaron avatar gitaaron commented on May 11, 2024 1

Also related - #107

from fx-fotos.

amanforindia avatar amanforindia commented on May 11, 2024

Hi team, @ghorbani-m:

  1. The pinch shown in the video (actual behavior) doesn't work in the latest master branch. I can get the number of columns to change by clicking on the button at the top though. Was the pinch done in an earlier commit that I can checkout to?
  2. Currently, each asset is a separate section for recyclerlistview. Instead my idea is to have the day's images which are all combined in 1 section into a common section. Now, we make numCols an animated.value (or useSharedValue of reanimated but I haven't worked with reanimated too much yet), give canChangeSize={true} to recyclerlistview and in recyclerlistview's height/width computation for the section, we only calculate the combined section's height (width being 100%). For achieving this we may need to use externalScrollView or onSizeChanged callback or forceNonDeterministicRendering but I need to investigate more about that. Inside the specific day's section, we can implement a custom grid which is in sync with the numCols animated variable.

Let me know if this approach sounds good!

@ehsan6sha to answer your question about "Are we still using one recyclerlistview for 2,3,4 and 5 column modes?", yes we would still use that but the column number becomes an animated value with possible floating point values rather than integers.

from fx-fotos.

ghorbani-m avatar ghorbani-m commented on May 11, 2024

@amanforindia Thanks for your proposal,

  1. I have checked it out one more time, and it works for me, I have tested it on the android platform (samsung phone), could you please make sure you got the latest changes from the Master branch.
  2. The drawback which I could see is using a bunch of images in a section, the recyclelistview's idea is recycling the components (section) instead of creating them to prevent performance issue on scrolling, but in your approach you need to recreate a list of images inside each section when the section is recycling, I believe it causes performance issue.

from fx-fotos.

skydevht avatar skydevht commented on May 11, 2024

A solution would be to precalculate the image dimensions for k columns, k ranging from 1 to n. Then, we implement a custom grid layout manager, rearranging the views around when k changes. The difference with the actual behavior, is to control the animation part directly with our animation control value. I guess the current layout manager calculates the new layout when k changes and does the animation. The trick is to precalculate all the possible layouts, then let it evolve based on the current control value.

from fx-fotos.

amanforindia avatar amanforindia commented on May 11, 2024

Hi @skydevht, @ghorbani-m for a smooth experience I think the height of the container which has the current day's images needs to scale linearly and gradually as the pinch goes from 1 column to 2 columns (accounting for fractional values). Also, the images themselves have to scale fractionally and not just get rearranged. Maybe I'm missing something here but I'm not exactly clear yet how I would achieve this without any tradeoff in performance.

from fx-fotos.

ghorbani-m avatar ghorbani-m commented on May 11, 2024

@skydevht Thanks for your description
You are right, the solution is to control the transition's animation while pinching the screen, but the question is how can we accomplish that? at the Layout Manager, you just define the section's dimensions, and there is no way to determine the section's position. somehow if you can manage the image's position from the outside of "Recyclelistview" the task is almost done.

@amanforindia You know, the matter is not the type of section's animation, the matter is how we can control the animation will pinching the screen,

A workaround that I am thinking of is if each section (image) knows about the next position and dimension based on the pinch type (Pinch in/out) then we might manage the next transition's animation based on pinch value.

Another way is to change the animation's type which was implemented before by @ehsan-git-dev , like this:

https://github.com/functionland/photos/blob/main/assets/demo/BOX_Photos_pinchzoom_to_switch_between_modes.gif)

The above animation was implemented by 3 Recycleviewlist with different colNums at the same time, Also it is acceptable if we could manage it only with one Recycleviewlist.

from fx-fotos.

skydevht avatar skydevht commented on May 11, 2024

A possible implementation would be to use the pinch-zoom event value as our control. The possible state would be the current number of columns and the next amount (lower or greater) of columns. When the interaction end, we can select the closest state to do a finishing animation. As the layout of the items will change the number of rows, we need to control the position of the additional elements that are presents (date header). If we need one interaction to switch between a greater number of columns, we can add states in between.

This solution requires direct access to the position of the items. This will likely require us to write a custom manager instead of relying on the one provided by the recycler list view library. The photos sections are the only one that need their scale to be animated. I don't know yet if we can hijack that part of the layout calculation. The library has a VirtualRenderer that manage the visible views, but I hope we only need to provide their position, and not manage the creation and destruction too.

from fx-fotos.

skydevht avatar skydevht commented on May 11, 2024

@ghorbani-m you need to overwrite whatever is controlling the section position. If it can automatically adjust that based on the section's dimension, you need to redefine what is a section and go from there.

from fx-fotos.

ghorbani-m avatar ghorbani-m commented on May 11, 2024

@skydevht The current implementation uses the pinch-zoom value and column number state (numCols) and then decides based on pinch scale value to increase or decrease the numCols' value and finally in the Layout Provider calculates the section dimension based on numCols' value.

Regarding your solution "This solution requires direct access to the position of the items", actually we have access to each section's position by "onItemLayout" event, and we are able to animate the sections but finally, somehow we need to tell the RecyclerListView that the sections positions are changed and recalculate the sections or recreate the new sections that now they are in the ViewPort.

As you mentioned we need to controll the section position but there is not any interface in the recycleviewlist to force reclaculate the layouy smoothly.

It seems if we want to use RecycleViewList with layout animation we need to add some features in the Recycleviewlist repo.

from fx-fotos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.