Comments (11)
@aeirola
I merged, So I'm going to release it to npm as 0.1.7
soon.
from react-native-custom-tabs.
@aeirola
Thank you for PR.
I understand, and thought that proposal of the custom animation option is as follows.
- Only
animations
. - Animation name is as short as possible.
CustomTabs.openURL(url, {
...
// For value, specify only full qualifier or only resource name.
// In the case of the resource name, the module complements the application package in java side.
animations: {
startEnter: 'slide_in_bottom',
startExit: 'slide_out_bottom',
endEnter: 'slide_in_bottom',
endExit: 'slide_out_bottom',
},
// or
animations: ANIMATIONS_SLIDE, // or ANIMATIONS_FADE
})
// in TabOption.js
// Change definition of ANIMATIONS_SLIDE/ANIMATIONS_FADE to `object` as follows.
export ANIMATIONS_SLIDE: Animations = {
startEnter: 'com.github.droibit.android.reactnative.customtabs:anim/slide_in_right',
...
}
export type Animations = {
startEnter: string,
...
}
What do you think about proposal?
from react-native-custom-tabs.
Hi @droibit. Yeah, that actually makes more sense. With only one option for configuring animations it is explicit that only one animation is configurable. I'll update the PR to reflect this.
from react-native-custom-tabs.
I updated the PR with a more streamlined configuration. Unfortunately during testing I noticed that the custom animations provided by this package are not accessible as we expected. It looks like all resources provided by dependent native modules are packaged under the application package name, meaning that I'm not able to access the animations through com.github.droibit.android.reactnative.customtabs:anim/slide_in_right
, but instead only through my.application.package.name:anim/slide_in_right
.
Maybe it is better to then just export ANIMATIONS_SLIDE
and ANIMATIONS_FADE
as unique strings, which are handled as special cases in the Java code so that we are able to access the correct animations through R.anim
. The interface to the user of the package will still remain the same, with only one animations
property.
from react-native-custom-tabs.
@aeirola Thank you for updating.
Oh, I mistook the full qualifier of slide animation...
Consider the resource access problem and write my proposal again.
- Only
animations
.
And,
- For consistency, only
object
type. - And specify short resource name(In many cases, can omit the package name).
CustomTabs.openURL(url, {
...
// For value, specify only full qualifier or only resource name.
// Note: For resources bundled with application, complement the application package name on Java side.
animations: {
startEnter: 'slide_in_bottom',
startExit: 'slide_out_bottom',
endEnter: 'slide_in_bottom',
endExit: 'slide_out_bottom',
},
// or
animations: ANIMATIONS_SLIDE, // or ANIMATIONS_FADE
})
// Change definition of ANIMATIONS_SLIDE/ANIMATIONS_FADE to `object` as follows.
export ANIMATIONS_SLIDE: Animations = {
// Note: For resources bundled with library, complement the application package name on Java side.
startEnter: 'slide_in_right',
...
}
export ANIMATIONS_FADE: Animatios = {
// Note: Full qualifier does not complete package name.
startEnter: 'android:anim/fade_in',
...
}
In Java side:
// Note: The full resource qualifier is "package:type/entry".
// https://developer.android.com/reference/android/content/res/Resources.html#getIdentifier(java.lang.String, java.lang.String, java.lang.String)
private static final Pattern animationIdentifierPattern = Pattern.compile("^.+:anim/");
/* package */ void applyAnimation(Context context, CustomTabsIntent.Builder builder, ReadableMap animations) {
final int startEnterAnimationId = animations.hasKey("startEnter")
? context.getResources().getIdentifier(resolveAnimationIdentifierIfNeed(animations.getString("startEnter")), null, null)
: 0;
...
}
// Complement the application name of the resource qualifier as necessary.
private String resolveAnimationIdentifierIfNeed(Context context, String identifier) {
if (animationIdentifierPattern.matcher(identifier).find()) {
return identifier;
}
return String.format("%s:anim/%s", context.getPackageName(), identifier);
}
I think that snipet probably works.
Could you consider the above contents?
from react-native-custom-tabs.
@droibit Yeah, that actually makes more sense. This way we would have a general interface for both custom and predefined animations. And it has the benefit for allowing shorthand custom animation names as well.
Only change I'd make to your proposal would be to have a slightly more common regex which wouldn't enforce the resource directory to be anim/
, but instead have something like ^.+:.+/
.
from react-native-custom-tabs.
@aeirola Thank you for review!
Could you change regular expression(^.+:.+/
) and update PR?
from react-native-custom-tabs.
@droibit Yes, just updated the PR. Just performing final testing on my app to verify that it works. If the PR looks good, I could go ahead and squash the commits to a single one for cleaner history.
from react-native-custom-tabs.
@aeirola LGTM 👍
from react-native-custom-tabs.
@droibit Squashed and ready for merge.
from react-native-custom-tabs.
@aeirola
I just released 0.1.7.
Thank you!
from react-native-custom-tabs.
Related Issues (20)
- Pre-starting / Pre - feching in react native chrome custom tab
- Not working in React Native 0.56 HOT 1
- Bump version and publish on npm
- React Native 0.56+ android build failure
- package com.github.droibit.android.reactnative.customtabs does not exist HOT 2
- Is there a way to know that user got back to the app? HOT 1
- Is there a way to add a custom menu item?
- Adding support for SafariView for iOS HOT 1
- Is there any way to create a callback function on attempt to close the custom tab?
- Typescript support
- Podspec needed for RN0.60 HOT 2
- Path or configuration is wrong when compiling project to ios HOT 2
- React custom tabs component crashing Xcode
- Navigation is blocked
- Cannot find symbol CustomTabsIntent HOT 1
- Still maintained? HOT 3
- Build failing on `import android.support.customtabs.CustomTabsIntent`
- openURL fails on ios HOT 3
- Support new React Native new architecture
- upgrade reac-native to 0.71.6,an error occurred HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-custom-tabs.