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

FEATURE: Apple music style modals (DeckTransition) #4774

Closed
wants to merge 2 commits into from

Conversation

Jyrno42
Copy link

@Jyrno42 Jyrno42 commented Feb 21, 2019

Adds support for Apple music style modal animations via DeckTransition library. On IOS it also supports swipe-to-dismiss gestures. This is not fully done yet, but I opened the PR early to gather community and maintainer feedback.

Usage:

Navigation.showModal({
    component: {
        name: 'my.component.name',
        options: {
            modalPresentationStyle: Platform.OS === 'android' ? 'overCurrentContext' : undefined, // Needed for android

            animations: {
                showModal: {
                    enableDeck: true, // Default: false
                    deckPresentDuration: 0.3, // in seconds, Default: 0.3
                    deckDismissDuration: 0.3, // in seconds, Default: 0.3
                    enableDeckSwipeToDismiss: true // Default: true **Warning: IOS ONLY**
                },
                dismissModal: {
                    enable: true,
                    enableDeck: true, // Default: false
                    deckPresentDuration: 0.3, // in seconds, Default: 0.3
                    deckDismissDuration: 0.3, // in seconds, Default: 0.3
                }
            }
        }
    }
});

Note: On Android the effect looks nicer if you add a dark background color to your root view.

Usage via cocoapods:

Add the following lines to your Podfile

    pod 'ReactNativeNavigation', :path => '../node_modules/react-native-navigation'
    pod 'DeckTransition', :path => '../node_modules/react-native-navigation/lib/ios/DeckTransition'

    # see https://github.com/CocoaPods/CocoaPods/issues/7585#issuecomment-439590366
    post_install do |installer|
        installer.pods_project.targets.each do |target|
            compatibilityPhase = target.build_phases.find { |ph| ph.display_name == 'Copy generated compatibility header' }
            if compatibilityPhase
                build_phase = target.new_shell_script_build_phase('Copy Swift Header')
                build_phase.shell_script = <<-SH.strip_heredoc
                    COMPATIBILITY_HEADER_PATH="${BUILT_PRODUCTS_DIR}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h"
                    ditto "${COMPATIBILITY_HEADER_PATH}" "${PODS_ROOT}/Headers/Public/${PRODUCT_MODULE_NAME}/${PRODUCT_MODULE_NAME}-Swift.h"
                SH
            end
        end
    end

Demo

Repository: https://github.com/Jyrno42/RNNDeckTransitionDemo

example-ios

example-android


related to #4743

@Ryabchikus
Copy link

Hello. I try to start demo - it's hang on splashscreen about ~10 seconds and then crashed without any errors

@Jyrno42 Jyrno42 force-pushed the deck-transition-modals branch 5 times, most recently from 48fc622 to f0bc341 Compare March 5, 2019 11:38
@Jyrno42
Copy link
Author

Jyrno42 commented Mar 5, 2019

Ok, I now got the tests to pass as well. Also updated the Demo repository to the latest version and generated new example gifs. Detox rocks!

@Ryabchikus Can you try again with the updated Demo repository? If it still does not work, please file an issue to the Demo repository with more details.

@Ryabchikus
Copy link

@Jyrno42
updated demo works, thanks!

@Jyrno42
Copy link
Author

Jyrno42 commented Mar 13, 2019

Patch file for those who want to use this. Can be used with patch-package.

https://gist.github.com/Jyrno42/de6cbc417d3f829a49b20db3775409cc

@guyca
Copy link
Collaborator

guyca commented Mar 31, 2019

Hey @Jyrno42
Sorry I didn't reply sooner. This looks great! But I feel it adds a lot of complexity to the library in order to support a very specific use case.
What I think will be very nice, is to improve RNN so it's extensible and and have this amazing deck transition in a dedicated library. If you'd like to make the necessary changes to RNN, let me know.
It might be a lot of work, but I think we'll all benefit from it.

Once again, sorry for the late reply and thanks a lot for the PR 💪

@Jyrno42
Copy link
Author

Jyrno42 commented Apr 3, 2019

If you have any tips on where to start when making this library extensible or if you know about any existing projects that I could take a look at I would love to hear it.

@Jyrno42
Copy link
Author

Jyrno42 commented Apr 11, 2019

Hey @guyca if you find the time I would love some guidance on this:

If you have any tips on where to start when making this library extensible or if you know about any existing projects that I could take a look at I would love to hear it.

Adds support for Apple music style modal animations via [DeckTransition](https://github.com/HarshilShah/DeckTransition) library.

Usage:

```
Navigation.showModal({
    component: {
        name: 'my.component.name',
        options: {
            modalPresentationStyle: Platform.OS === 'android' ? 'overCurrentContext' : undefined, // Needed for android

            animations: {
                showModal: {
                    enableDeck: true, // Default: false
                    deckPresentDuration: 0.3, // in seconds, Default: 0.3
                    deckDismissDuration: 0.3, // in seconds, Default: 0.3
                    enableDeckSwipeToDismiss: true // Default: true **Warning: IOS ONLY**
                },
                dismissModal: {
                    enable: true,
                    enableDeck: true, // Default: false
                    deckPresentDuration: 0.3, // in seconds, Default: 0.3
                    deckDismissDuration: 0.3, // in seconds, Default: 0.3
                }
            }
        }
    }
});
```

Note: On Android the effect looks nicer if you add a dark background color to your root view.

**Usage via cocoapods:**

Add the following lines to your Podfile

```
    pod 'ReactNativeNavigation', :path => '../node_modules/react-native-navigation'
    pod 'DeckTransition', :path => '../node_modules/react-native-navigation/lib/ios/DeckTransition'

    # see CocoaPods/CocoaPods#7585 (comment)
    post_install do |installer|
        installer.pods_project.targets.each do |target|
            compatibilityPhase = target.build_phases.find { |ph| ph.display_name == 'Copy generated compatibility header' }
            if compatibilityPhase
                build_phase = target.new_shell_script_build_phase('Copy Swift Header')
                build_phase.shell_script = <<-SH.strip_heredoc
                    COMPATIBILITY_HEADER_PATH="${BUILT_PRODUCTS_DIR}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h"
                    ditto "${COMPATIBILITY_HEADER_PATH}" "${PODS_ROOT}/Headers/Public/${PRODUCT_MODULE_NAME}/${PRODUCT_MODULE_NAME}-Swift.h"
                SH
            end
        end
    end

```

Update android tests

Improve transition on android w/ nested decktransition modals

Update to new playground structure

Fix existing android tests

Add e2e tests

Ensure IOS e2e tests do not crash

s/PUSH_BUTTON/PUSH_BTN/

Add deck transition swipe-to-dismiss e2e tests and fix ios e2e test issues

- Improve android deck root detection mechanism

Improve android visuals by also fading out parent view when modal is open

IOS improvements

- Easier cocoapods support
- Fix scrollview detection
- Ensure transforms to scroll view do not glitch due to momentum
- Ensure tree gets unmounted when modal is hidden via swipe-to-dismiss
@MakhouT
Copy link
Contributor

MakhouT commented May 26, 2019

@guyca Bump.
Worth to give hime some guidance. RNN needs more people and he's willing to help :)

@kdawgwilk
Copy link
Contributor

This now supported by default in iOS 13 SDK with the automatic presentation style

@Jyrno42 Jyrno42 closed this Jun 25, 2019
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.

None yet

5 participants