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

feat: add slide animations on Android #648

Merged
merged 14 commits into from
Nov 23, 2020

Conversation

jiong-shen-cb
Copy link
Contributor

No description provided.

}
}

// remove all screens previously on stack
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This portion is moved from the top because the animations need to be set first before any screens are added/removed

@hirbod
Copy link
Contributor

hirbod commented Sep 23, 2020

Awesome.

@Jalson1982
Copy link

Hope this will be in master soon. Great job @jiong-shen-cb

@hirbod
Copy link
Contributor

hirbod commented Sep 29, 2020

What do you think about this approach @WoLewicki
It is the XML way but looks nice and clean.

@WoLewicki
Copy link
Member

If only it works, I think using XMLs will be a good option 🎉.
I think we should prefix them somehow, like rns_close_slide_in to avoid any name clashes. Will test this PR in free time and please do so too, especially with nested navigators and popToTop options etc. so we can spot the problems quickly if there are any

@jiong-shen-cb
Copy link
Contributor Author

I will update the xml names, btw since I only added support for android (not an ios developer), if necessary I could use some help extend it for ios

@itsjgf
Copy link
Contributor

itsjgf commented Oct 12, 2020

I have opened a PR on top of this one that adds support for stackAnimation: 'slide' on iOS & tweaks the modal animation on Android -> #662

@WoLewicki
Copy link
Member

I think it would also be nice to have the option for rtl transition, from what I tested, only thing needed for the new transition is to swap close with open transition specs. Maybe it would be better to change the naming of these specs to something like rns_slide_in_from_right, rns_slide_out_from_right, rns_slide_in_from_left, rns_slide_out_from_left. It would require adding another animation option, probably SLIDE_RTL would be the best name. Can you do it @jiong-shen-cb?

@jiong-shen-cb
Copy link
Contributor Author

sure I can add it this week,

@jiong-shen-cb
Copy link
Contributor Author

@WoLewicki I added slide_rtl, please check
@itsjgf please merge my changes into your branch and add slide_rtl in iOS if you could. Thanks!

@jiong-shen-cb
Copy link
Contributor Author

@WoLewicki Added and rebased to master, please check if they are good enough.

@WoLewicki
Copy link
Member

Looks perfect! The last (hopefully) change that is required is to add new animation options to iOS in order for it to be able to work correctly with those changes. Please change the method in https://github.com/software-mansion/react-native-screens/blob/master/ios/RNSScreen.m#L502 to:

RCT_ENUM_CONVERTER(RNSScreenStackAnimation, (@{
                                                  @"default": @(RNSScreenStackAnimationDefault),
                                                  @"none": @(RNSScreenStackAnimationNone),
                                                  @"fade": @(RNSScreenStackAnimationFade),
                                                  @"flip": @(RNSScreenStackAnimationFlip),
                                                  @"slide": @(RNSScreenStackAnimationDefault),
                                                  @"slide_rtl": @(RNSScreenStackAnimationDefault),
                                                  }), RNSScreenStackAnimationDefault, integerValue)

It will just add resolving the new options to the default animation.

@jiong-shen-cb
Copy link
Contributor Author

Thanks, updated

@WoLewicki
Copy link
Member

After consultations with @kmagiera, we decided that it would be very good to have some clips/gifs in this thread that show the transitions, especially going forward and back with using:

  1. header back button
  2. normal goBack() with e.g. a button
  3. hw back button (the one at the bottom of the phone's screen)

It looks like now the 3. option is giving different results in animation due to using Android Fragment's back stack.

Another thing is the name of the transitions. slide_rtl can be thought of as something that changes the direction of the content, while in this case it is not directly connected to it and can be used with ltr and rtl. So maybe it would be good to change the names to e.g. slide_from_right and slide_from_left, or something even more adequate. What do you think?

@jiong-shen-cb
Copy link
Contributor Author

Yes I see the issue and will look into that this week.

@jiong-shen-cb
Copy link
Contributor Author

@WoLewicki Sorry I got delayed from other stuff last week. I think name changes are good (since rtl was actually slide from left). After comparing the build from master and this branch, I see same behavior on the hw back button from the Example app. Could you provide some clips to show the difference?

@WoLewicki
Copy link
Member

I tested it again and I cannot reproduce it now, and I am not sure why. Could you update the PR according to the instructions? I also added a TestsExample project: https://github.com/software-mansion/react-native-screens/tree/master/TestsExample, (after rebasing to newest master you should be able to use it) could you add a Test648 file in there which shows the application of the PR? Some basic and maybe nested stack that shows that it works how it should and compiles on both platforms. It will be easier for everyone to test it then.

@jiong-shen-cb
Copy link
Contributor Author

Great, will look at those tomorrow.

@jiong-shen-cb
Copy link
Contributor Author

Updated, please check.

@WoLewicki
Copy link
Member

Thanks for your contribution! It looks like it is ready to be merged 🎉

@WoLewicki WoLewicki changed the title Adding slide animation to the list of available transition animations feat: add slide animations on Android Nov 23, 2020
@WoLewicki WoLewicki merged commit 6d110d6 into software-mansion:master Nov 23, 2020
@jiong-shen-cb
Copy link
Contributor Author

Thank you! Is there a potential release date for the changes?

@WoLewicki
Copy link
Member

It depends on some factors, but next week most probably.

@hadnet
Copy link

hadnet commented Dec 2, 2020

I've been waiting for this for a long time. Just to be sure cause I'm not up to date with this guys but this will add the possibility to use slide animations (like iOS) on Android, right? When this release will be available?

@WoLewicki
Copy link
Member

Yes, this PR adds slide animations on transitions on Android. This should be released alongside with #662, and @itsjgf is still working on it, but you can always apply these changes and test them by using patch-package.

@hadnet
Copy link

hadnet commented Feb 2, 2021

Ok, guys, I tried everything and this slide animation is not working on Android. I installed version 2.16.0/1 2.17.X and no slide animation. These are the packages I'm using along with Expo SDK40. I tested using Android 11 and tested on an older Android 6.x but does not work either. The other options like flip, fade working good. Can anyone help me understand what is wrong here?

    "@react-navigation/bottom-tabs": "^5.11.7",
    "@react-navigation/native": "^5.9.2",
    "@react-navigation/stack": "^5.14.2",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-reanimated": "~1.13.0",
    "react-native-screens": "2.16.1",

@WoLewicki
Copy link
Member

If you use Expo managed workflow, the native code is included in the client and cannot be changed. react-native-screens package version in SDK 40 is 2.15.0, so this commit is not available there yet, which means you cannot use it unfortunately.

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.

6 participants