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

Add ability to config onEndReachedThreshold and rowHasChanged props #76

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open

Conversation

lughino
Copy link
Contributor

@lughino lughino commented Oct 30, 2016

No description provided.

@lughino lughino changed the title Add ability to config onEndReachedThreshold prop Add ability to config onEndReachedThreshold and rowHasChanged props Nov 1, 2016
@@ -67,8 +67,10 @@ class ListView extends React.Component {
static propTypes = {
autoHideHeader: React.PropTypes.bool,
style: React.PropTypes.object,
data: React.PropTypes.array,
data: React.PropTypes.oneOfType([
React.PropTypes.object, React.PropTypes.array]),
Copy link
Contributor

Choose a reason for hiding this comment

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

When would you use object over array? Could you write an example of passed data as object and what would you expect to be rendered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Certainly, the component ListViewDataSource allows you to use the structure as an array or as an object (map). This means that you can pass a map structured in this way:

{
  "postId1": {
     "id": "postId1",
     "title": "lorem ipsum",
     ....
  },
  "postId2": {
     "id": "postId2",
     "title": "lorem ipsum",
     ....
  },
  ...
}

Having the data in store with that structure, this means that you should not change them.
Actually it would also be given the option of passing the getRowData method (dataBlob, sectionID, rowID); which allows you to instruct the ListView to own structure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool! Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

If data is object it won't work when grouping data into sections because data is grouped with reduce and object doesn't have reduce #L41. Update groupItemsIntoSections to use lodash reduce (it support both object and array).

@@ -67,8 +67,10 @@ class ListView extends React.Component {
static propTypes = {
autoHideHeader: React.PropTypes.bool,
style: React.PropTypes.object,
data: React.PropTypes.array,
data: React.PropTypes.oneOfType([
React.PropTypes.object, React.PropTypes.array]),
Copy link
Contributor

Choose a reason for hiding this comment

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

If data is object it won't work when grouping data into sections because data is grouped with reduce and object doesn't have reduce #L41. Update groupItemsIntoSections to use lodash reduce (it support both object and array).

@SoHotSoup
Copy link
Contributor

@MrBr could you take another look at it?

Copy link
Contributor

@MrBr MrBr left a comment

Choose a reason for hiding this comment

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

You are doing good job.

I just want to make sure we keep code at highest level.

package.json Outdated
"@shoutem/animation": "^0.9.0",
"@shoutem/theme": "^0.8.8",
"@shoutem/animation": "^0.8.10",
"@shoutem/theme": "git+https://github.com/Lughino/theme.git#0.9.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

We can not depend on a fork for the theme module. Can you please make PR there as well.

After your PR is merged we can release new version.

What are the changes in the theme anyway?

@@ -204,6 +216,7 @@ class DropDownMenu extends Component {
<ZoomOut driver={this.timingDriver} maxFactor={1.1} style={{ flex: 1 }}>
<FadeIn driver={this.timingDriver} style={{ flex: 1 }}>
<View style={style.modal} styleName="vertical">
{header && <Title style={style.header}>{header}</Title>}
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if we had new method renderHeader and this expression there.

static defaultProps = {
selectedIndex: 0,
showNextPage: false,
renderPlaceholder: () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

One line would be nicer () => <LoadingIndicator/>.

const { onIndexSelected } = this.props;
this.setState({
selectedIndex: newIndex,
}, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nicer if we had selectedIndexUpdated method and if you would name argument selectedIndex then you could use object literals shorthand.

this.setState({ selectedIndex }, this.selectedIndexUpdated)

import { connectStyle } from '@shoutem/theme';
import { TimingDriver } from '@shoutem/animation';

import Image from 'react-native-transformable-image';
Copy link
Contributor

Choose a reason for hiding this comment

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

@zrumenjak & @SoHotSoup does it make sense maybe to include this in the toolkit? Maybe we could have prop on our image which would enable or disable such transformations (or change rendered component).

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't include it in the toolkit for now. We are currently using this component only in some situations (iOS gallery, and lightbox), but we are also using a different, completely native, component in the gallery on Android.

}
}

updateImageSwitchingStatus() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Update prefix doesn't seems correct when we have no argument to which we update. There is certain logic in this function it does more then one thing so I would name itrefreshImageSwitchingStatus or resolveImageSwitchingStatus. That indicates that there is something going on.

You could easily have 3 methods from this one.

);
}

getImageTransformer(page) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you keep render methods grouped together, it is much cleaner.

You can also group, update methods, get methods and other.

Copy link
Contributor

Choose a reason for hiding this comment

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

You always pass here selectedIndex, better name then for the argument would be index.

const description = _.get(page, 'description');

if (!image) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Return null? How does this affect gallery? Should we maybe have fallback image?

}
}

onSingleTapConfirmed() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you document when will this be called.


resetSurroundingImageTransformations() {
const { selectedIndex } = this.state;
let transformer = this.getImageTransformer(selectedIndex - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

This repeated code should be handled differently.

For example, you can implement getImageTransformers(indexes) and then

// Surrounding indexes
const indexes = [selectedIndex + 1, selectedIndex - 1]; 
const transformers = this.getImageTransformers(indexes);

transformers.forEach(this.resetImageTransformer);

Or you can have resetImageTransformer work with index and have condition in there (does transformer exists). But I like more the way it is now, it is clean.

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.

4 participants