-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Activity indicator: add size prop #8935
Conversation
By analyzing the blame information on this pull request, we identified @janicduplessis and @sebmarkbage to be potential reviewers. |
f82158b
to
369e201
Compare
} | ||
}, | ||
{ | ||
title: 'Custom size (size: 31, scale transform: 1.5)', |
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.
Let's remove the scale example.
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.
Will do @janicduplessis
Have you tested this change on both iOS and Android? Also does changing the size like this actually scales up the indicator (as far as I remember it didn't on iOS and it is why we had use a scale transform). |
@@ -0,0 +1,15 @@ | |||
--- |
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.
Do we need a separate docs page just for indicator size? Can we not include it in the same documentation as ActivityIndicator
?
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 think the case is because we use custom propType checker instead. Since I'm gonna revert it, this doc is will be better left out. Thanks!
369e201
to
594eded
Compare
594eded
to
b0b27cd
Compare
render() { | ||
return ( | ||
<ActivityIndicator | ||
style={styles.centering} |
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.
number This type is incompatible with string
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.
number This type is incompatible with string
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.
@satya164 This is what I was talking about that flow keeps complaining, and thus I decided to create a custom propType checker instead.
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.
@fadils Seems Flow is confused regarding the types. Can you add annotation to getDefaultProps
so that flow doesn't try to infer the type and see if it fixes the issue?
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.
type IndicatorSize = number | 'small' | 'large';
type DefaultProps = {
animating: boolean;
color: any;
hidesWhenStopped: boolean;
size: IndicatorSize;
}
@janicduplessis, @satya164 not yet working on iOS. Should we create an Android specific prop for now? Maybe like |
Let's add a comment that says that passing a number to the size prop is only supported on Android in the prop documentation. |
Alright. Any idea to make flow happy with this and consequently pass the CI? |
Will check the Flow thing in a while. |
Previously, size can only accept either 'small' or 'large'. And to obtain a custom size, scale transformation is used. This is to let users to possibly pass number value to define ActivityIndicator's size. Not yet supported on iOS.
b0b27cd
to
168666b
Compare
@satya164 the annotation works. Awesome! |
]; | ||
|
||
if (Platform.OS === 'android') { |
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.
You can use the platform prop in the example object to avoid having to do this.
{
platform: 'android',
title: '',
...
}
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.
Thanks! Didn't know about it.
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.
@janicduplessis Previously, you suggested that we erase example that uses transformation.
I was thinking that if we put
{
platform: 'ios',
...
}
then it would be a bit misleading as actually transformation can be done in Android as well.
If we didn't use platform
, then the example will still be shown in Android, along with the custom size (with number) examples.
Any input?
Should we just keep it with something like this:
{
title: 'Custom size (transform scale: 1.5)',
}
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.
Let's keep the scale example and just add one with a custom size that is android only.
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.
OK. Thanks!
168666b
to
384f654
Compare
@@ -24,6 +24,7 @@ | |||
|
|||
const React = require('react'); | |||
const ReactNative = require('react-native'); | |||
const Platform = require('Platform'); |
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.
no-unused-vars: 'Platform' is defined but never used
384f654
to
a86576d
Compare
@satya164 @janicduplessis is there anything else to ship this PR? I would be more than happy to add/change anything. |
@fadils Thanks for the ping. @facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review internal test results. |
63d15af
Summary: **motivation** Previously, size can only accept either 'small' or 'large'. And to obtain a custom size, scale transformation is used. This is to let users to possibly pass number value directly to define ActivityIndicator's size. **Test plan** I have also modified the current example to reflect the new size prop in action. Closes facebook#8935 Differential Revision: D3637910 fbshipit-source-id: 6b8e1d4504964916df327b2d3eaaef1bb8cd5112
Summary: **motivation** Previously, size can only accept either 'small' or 'large'. And to obtain a custom size, scale transformation is used. This is to let users to possibly pass number value directly to define ActivityIndicator's size. **Test plan** I have also modified the current example to reflect the new size prop in action. Closes facebook/react-native#8935 Differential Revision: D3637910 fbshipit-source-id: 6b8e1d4504964916df327b2d3eaaef1bb8cd5112
Summary: **motivation** Previously, size can only accept either 'small' or 'large'. And to obtain a custom size, scale transformation is used. This is to let users to possibly pass number value directly to define ActivityIndicator's size. **Test plan** I have also modified the current example to reflect the new size prop in action. Closes facebook#8935 Differential Revision: D3637910 fbshipit-source-id: 6b8e1d4504964916df327b2d3eaaef1bb8cd5112
motivation
Previously, size can only accept either 'small' or 'large'. And to obtain a custom size, scale transformation is used. This is to let users to possibly pass number value directly to define ActivityIndicator's size.
Test plan
I have also modified the current example to reflect the new size prop in action.